From 18eabfb04267be896fa05aa3a33ec14c8a3b3281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Thu, 10 Oct 2024 21:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91IOT=EF=BC=9A=E6=9E=9A=E4=B8=BE=E5=92=8C=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=88=B0=E5=89=AA=E8=B4=B4=E6=9D=BF=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/product/index.ts | 6 ++++++ src/api/iot/thinkmodelfunction/index.ts | 13 ++++++++++++ .../iot/device/detail/DeviceDetailsHeader.vue | 16 +++++++------- .../iot/device/detail/DeviceDetailsInfo.vue | 9 +++++--- src/views/iot/product/ProductForm.vue | 16 +++++++++----- .../product/detail/ProductDetailsHeader.vue | 11 ++++++---- .../product/detail/ThinkModelFunctionForm.vue | 21 ++++++++++++------- 7 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/api/iot/product/index.ts b/src/api/iot/product/index.ts index 1ffa490d..19c827cf 100644 --- a/src/api/iot/product/index.ts +++ b/src/api/iot/product/index.ts @@ -18,6 +18,12 @@ export interface ProductVO { createTime: Date // 创建时间 } +// IOT 数据校验级别枚举类 +export enum ValidateTypeEnum { + WEAK = 0, // 弱校验 + NONE = 1 // 免校验 +} + // IoT 产品 API export const ProductApi = { // 查询产品分页 diff --git a/src/api/iot/thinkmodelfunction/index.ts b/src/api/iot/thinkmodelfunction/index.ts index bd2e2d0f..1fce8137 100644 --- a/src/api/iot/thinkmodelfunction/index.ts +++ b/src/api/iot/thinkmodelfunction/index.ts @@ -14,6 +14,19 @@ export interface ThinkModelFunctionVO { service: string // 服务 } +// IOT 产品功能(物模型)类型枚举类 +export enum ProductFunctionTypeEnum { + PROPERTY = 1, // 属性 + SERVICE = 2, // 服务 + EVENT = 3 // 事件 +} + +// IOT 产品功能(物模型)访问模式枚举类 +export enum ProductFunctionAccessModeEnum { + READ_WRITE = 'rw', // 读写 + READ_ONLY = 'r' // 只读 +} + // IoT 产品物模型 API export const ThinkModelFunctionApi = { // 查询产品物模型分页 diff --git a/src/views/iot/device/detail/DeviceDetailsHeader.vue b/src/views/iot/device/detail/DeviceDetailsHeader.vue index 62960529..f051bd87 100644 --- a/src/views/iot/device/detail/DeviceDetailsHeader.vue +++ b/src/views/iot/device/detail/DeviceDetailsHeader.vue @@ -53,16 +53,14 @@ const openForm = (type: string, id?: number) => { const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>() const emit = defineEmits(['refresh']) -/** - * 将文本复制到剪贴板 - * - * @param text 需要复制的文本 - */ -const copyToClipboard = (text: string) => { - // TODO @haohao:可以考虑用 await 异步转同步哈 - navigator.clipboard.writeText(text).then(() => { +/** 复制到剪贴板方法 */ +const copyToClipboard = async (text: string) => { + try { + await navigator.clipboard.writeText(text) message.success('复制成功') - }) + } catch (error) { + message.error('复制失败') + } } /** diff --git a/src/views/iot/device/detail/DeviceDetailsInfo.vue b/src/views/iot/device/detail/DeviceDetailsInfo.vue index 59b9d254..968fc8d5 100644 --- a/src/views/iot/device/detail/DeviceDetailsInfo.vue +++ b/src/views/iot/device/detail/DeviceDetailsInfo.vue @@ -100,10 +100,13 @@ const mqttParams = ref({ }) // 定义 MQTT 参数对象 /** 复制到剪贴板方法 */ -const copyToClipboard = (text: string) => { - navigator.clipboard.writeText(text).then(() => { +const copyToClipboard = async (text: string) => { + try { + await navigator.clipboard.writeText(text) message.success('复制成功') - }) + } catch (error) { + message.error('复制失败') + } } /** 打开 MQTT 参数弹框的方法 */ diff --git a/src/views/iot/product/ProductForm.vue b/src/views/iot/product/ProductForm.vue index 75d6efcc..ed522e8d 100644 --- a/src/views/iot/product/ProductForm.vue +++ b/src/views/iot/product/ProductForm.vue @@ -100,7 +100,7 @@