Skip to content

Commit f7b97d3

Browse files
committed
【代码评审】IoT:设备配置的评审
1 parent 107ee7b commit f7b97d3

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed
Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
<!-- 设备配置 -->
12
<template>
23
<div>
34
<el-alert
4-
title="IoT平台支持远程更新设备的配置文件(SON格式),您可以在下方编辑配置模板,对设备的系统参数、网络参数等进行远程配置,通过批量更新对设备进行批量远程维护和管理"
5+
title="支持远程更新设备的配置文件(JSON 格式),可以在下方编辑配置模板,对设备的系统参数、网络参数等进行远程配置。配置完成后,需点击「下发」按钮,设备即可进行远程配置"
56
type="info"
67
show-icon
78
class="my-4"
89
description="如需编辑文件,请点击下方编辑按钮"
910
/>
10-
11+
12+
<!-- JSON 编辑器:读模式 -->
1113
<Vue3Jsoneditor
1214
ref="editor"
1315
v-if="isEditing"
@@ -17,6 +19,7 @@
1719
currentMode="code"
1820
@error="onError"
1921
/>
22+
<!-- JSON 编辑器:写模式 -->
2023
<Vue3Jsoneditor
2124
ref="editor"
2225
v-else
@@ -35,53 +38,49 @@
3538
</template>
3639

3740
<script lang="ts" setup>
38-
import { ref, computed } from 'vue';
39-
import Vue3Jsoneditor from 'v3-jsoneditor/src/Vue3Jsoneditor.vue';
41+
import { ref, computed } from 'vue'
42+
import Vue3Jsoneditor from 'v3-jsoneditor/src/Vue3Jsoneditor.vue'
4043
41-
// 定义设备配置的状态
4244
const deviceConfig = ref({
43-
"name": "dyla1n"
44-
});
45-
46-
// 编辑状态
47-
const isEditing = ref(false);
48-
49-
// JSON 编辑器的选项
45+
name: 'dyla1n'
46+
}) // 定义设备配置 TODO @dylan:从后端读取
47+
const isEditing = ref(false) // 编辑状态
5048
const editorOptions = computed(() => ({
5149
mainMenuBar: false,
5250
navigationBar: false,
53-
statusBar: false,
54-
}));
51+
statusBar: false
52+
})) // JSON 编辑器的选项
5553
56-
// 启用编辑模式的函数
54+
/** 启用编辑模式的函数 */
5755
const enableEdit = () => {
58-
isEditing.value = true;
59-
};
56+
isEditing.value = true
57+
}
6058
61-
// 取消编辑的函数
59+
/** 取消编辑的函数 */
6260
const cancelEdit = () => {
63-
isEditing.value = false;
61+
isEditing.value = false
6462
// 逻辑代码
65-
console.log('取消编辑');
66-
};
63+
console.log('取消编辑')
64+
}
6765
68-
// 保存配置的函数
66+
/** 保存配置的函数 */
6967
const saveConfig = () => {
70-
isEditing.value = false;
68+
isEditing.value = false
7169
// 逻辑代码
72-
console.log('保存配置');
73-
};
70+
console.log('保存配置')
71+
}
7472
75-
// 处理 JSON 编辑器错误的函数
73+
/** 处理 JSON 编辑器错误的函数 */
7674
const onError = (e: any) => {
77-
console.log('onError', e);
78-
};
75+
console.log('onError', e)
76+
}
7977
</script>
8078

79+
<!-- TODO dylan:建议使用 unocss 替代哈,AI 模型友好 -->
8180
<style scoped>
8281
.button-group {
8382
display: flex;
8483
justify-content: center;
8584
margin-top: 20px;
8685
}
87-
</style>
86+
</style>

0 commit comments

Comments
 (0)