diff --git a/apps/web-antd/package.json b/apps/web-antd/package.json index e5e9941..ddbbe8b 100644 --- a/apps/web-antd/package.json +++ b/apps/web-antd/package.json @@ -50,9 +50,11 @@ "echarts": "^5.5.1", "jsencrypt": "^3.3.2", "lodash-es": "^4.17.21", + "monaco-editor": "^0.52.2", "pinia": "catalog:", "tinymce": "^7.3.0", "unplugin-vue-components": "^0.27.3", + "vite-plugin-monaco-editor": "^1.1.0", "vue": "catalog:", "vue-router": "catalog:", "vue3-colorpicker": "^2.3.0" diff --git a/apps/web-antd/src/components/MonacoEditor/index.vue b/apps/web-antd/src/components/MonacoEditor/index.vue new file mode 100644 index 0000000..6ab485e --- /dev/null +++ b/apps/web-antd/src/components/MonacoEditor/index.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/apps/web-antd/src/views/device/product/detail/components/BasicInfo.vue b/apps/web-antd/src/views/device/product/detail/components/BasicInfo.vue index a931625..069b81d 100644 --- a/apps/web-antd/src/views/device/product/detail/components/BasicInfo.vue +++ b/apps/web-antd/src/views/device/product/detail/components/BasicInfo.vue @@ -114,13 +114,13 @@ const productParams = computed(() => )?.label }} - + diff --git a/apps/web-antd/src/views/device/product/detail/components/DeviceAccess.vue b/apps/web-antd/src/views/device/product/detail/components/DeviceAccess.vue index 2fc741f..dc24c41 100644 --- a/apps/web-antd/src/views/device/product/detail/components/DeviceAccess.vue +++ b/apps/web-antd/src/views/device/product/detail/components/DeviceAccess.vue @@ -86,10 +86,10 @@ const tableColumns = computed(() => { }); // Markdown转HTML -const markdownToHtml = computed(() => { - // 这里可以使用markdown-it等库转换markdown为HTML - return accessInfo.value.document || ''; -}); +// const markdownToHtml = computed(() => { +// // 这里可以使用markdown-it等库转换markdown为HTML +// return accessInfo.value.document || ''; +// }); // 选择接入方式 const handleSelectAccess = () => { @@ -141,7 +141,8 @@ const handleSave = async () => { saveLoading.value = true; await productUpdateById(props.productInfo.id, { id: props.productInfo.id, - provider: accessInfo.value.id, + provider: accessInfo.value.provider, + gatewayId: accessInfo.value.id, storePolicy: selectedStorePolicy.value, protocolConf: JSON.stringify(formData), }); @@ -165,9 +166,9 @@ const loadStorePolicy = async () => { // 加载接入信息 const loadAccessInfo = async () => { - if (props.productInfo.provider) { + if (props.productInfo.gatewayId) { // 这里调用API加载接入信息 - const res = await gatewayInfo(props.productInfo.provider); + const res = await gatewayInfo(props.productInfo.gatewayId); accessInfo.value = res; // 模拟数据 @@ -214,7 +215,7 @@ onMounted(() => { 选择 设备接入网关,用以提供设备接入能力 - 请联系管理员配置产品接入方式 + 请联系管理员配置产品接入网关 @@ -226,7 +227,7 @@ onMounted(() => {
-

接入方式

+

接入网关

{

消息协议

- +

{{ accessInfo.protocolName }}

-
+ +
{{markdownToHtml}}
@@ -311,7 +313,7 @@ onMounted(() => { >

{{ config.name }}

- +
@@ -453,7 +455,7 @@ onMounted(() => { diff --git a/apps/web-antd/src/views/device/product/detail/components/Metadata.vue b/apps/web-antd/src/views/device/product/detail/components/Metadata.vue index 55ffc73..ee21b49 100644 --- a/apps/web-antd/src/views/device/product/detail/components/Metadata.vue +++ b/apps/web-antd/src/views/device/product/detail/components/Metadata.vue @@ -26,9 +26,17 @@ const emit = defineEmits<{ refresh: []; }>(); +const defaultMetadata = { + properties: [], + functions: [], + events: [], + propertyGroups: [], // 新增属性分组 +}; + const activeTab = ref('properties'); const importVisible = ref(false); const tslVisible = ref(false); +const tslMetadata = ref(); const showReset = ref(false); // 物模型编辑状态 @@ -71,6 +79,7 @@ const handleImport = () => { // 查看TSL const handleViewTSL = () => { + tslMetadata.value = JSON.parse(JSON.stringify(currentMetadata.value)); tslVisible.value = true; }; @@ -88,6 +97,7 @@ const handleImportClose = () => { // 关闭TSL抽屉 const handleTSLClose = () => { + tslMetadata.value = JSON.parse(JSON.stringify(defaultMetadata)); tslVisible.value = false; }; @@ -220,7 +230,7 @@ const handleSave = async () => { metadata: JSON.stringify(metadata), }); - message.success('保存成功'); + // message.success('保存成功'); // 更新原始数据 originalMetadata.value = JSON.parse(JSON.stringify(metadata)); metadataChanged.value = false; @@ -320,7 +330,7 @@ loadMetadata(); @click="handleViewTSL" v-access:code="['device:product:edit']" > - 物模型TSL + 物模型
@@ -379,11 +389,15 @@ loadMetadata(); - +
diff --git a/apps/web-antd/src/views/device/product/detail/components/MetadataTable.vue b/apps/web-antd/src/views/device/product/detail/components/MetadataTable.vue index 15c0c15..6da29f3 100644 --- a/apps/web-antd/src/views/device/product/detail/components/MetadataTable.vue +++ b/apps/web-antd/src/views/device/product/detail/components/MetadataTable.vue @@ -91,7 +91,7 @@ const columns = computed(() => { dataIndex: 'dataType', key: 'dataType', align: 'center', - width: 100, + width: 150, }, { title: '读写类型', diff --git a/apps/web-antd/src/views/device/product/detail/components/PropertyDrawer.vue b/apps/web-antd/src/views/device/product/detail/components/PropertyDrawer.vue index 8233532..3b5f9e3 100644 --- a/apps/web-antd/src/views/device/product/detail/components/PropertyDrawer.vue +++ b/apps/web-antd/src/views/device/product/detail/components/PropertyDrawer.vue @@ -431,7 +431,7 @@ watch( diff --git a/apps/web-antd/src/views/device/product/detail/components/PropertyGroupDrawer.vue b/apps/web-antd/src/views/device/product/detail/components/PropertyGroupDrawer.vue index 8bc0e85..3e1dd85 100644 --- a/apps/web-antd/src/views/device/product/detail/components/PropertyGroupDrawer.vue +++ b/apps/web-antd/src/views/device/product/detail/components/PropertyGroupDrawer.vue @@ -257,7 +257,7 @@ const handleClose = () => { diff --git a/apps/web-antd/src/views/device/product/detail/components/TSLViewer.vue b/apps/web-antd/src/views/device/product/detail/components/TSLViewer.vue new file mode 100644 index 0000000..61c375b --- /dev/null +++ b/apps/web-antd/src/views/device/product/detail/components/TSLViewer.vue @@ -0,0 +1,205 @@ + + + + + diff --git a/apps/web-antd/vite.config.mts b/apps/web-antd/vite.config.mts index ff1ad95..49ed448 100644 --- a/apps/web-antd/vite.config.mts +++ b/apps/web-antd/vite.config.mts @@ -3,12 +3,14 @@ import { defineConfig } from '@vben/vite-config'; // 自行取消注释来启用按需导入功能 // import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; // import Components from 'unplugin-vue-components/vite'; +import monacoEditorPlugin from 'vite-plugin-monaco-editor'; export default defineConfig(async () => { return { application: {}, vite: { plugins: [ + (monacoEditorPlugin as any).default({}), // Components({ // dirs: [], // 默认会导入src/components目录下所有组件 不需要 // dts: './types/components.d.ts', // 输出类型文件