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 @@