【代码评审】IoT:设备配置的评审

This commit is contained in:
YunaiV 2025-02-11 09:54:18 +08:00
parent 107ee7bebf
commit f7b97d344e

View File

@ -1,13 +1,15 @@
<!-- 设备配置 -->
<template> <template>
<div> <div>
<el-alert <el-alert
title="IoT平台支持远程更新设备的配置文件(SON格式)可以在下方编辑配置模板,对设备的系统参数、网络参数等进行远程配置,通过批量更新对设备进行批量远程维护和管理。" title="支持远程更新设备的配置文件(JSON 格式),可以在下方编辑配置模板,对设备的系统参数、网络参数等进行远程配置。配置完成后,需点击「下发」按钮,设备即可进行远程配置。"
type="info" type="info"
show-icon show-icon
class="my-4" class="my-4"
description="如需编辑文件,请点击下方编辑按钮" description="如需编辑文件,请点击下方编辑按钮"
/> />
<!-- JSON 编辑器读模式 -->
<Vue3Jsoneditor <Vue3Jsoneditor
ref="editor" ref="editor"
v-if="isEditing" v-if="isEditing"
@ -17,6 +19,7 @@
currentMode="code" currentMode="code"
@error="onError" @error="onError"
/> />
<!-- JSON 编辑器写模式 -->
<Vue3Jsoneditor <Vue3Jsoneditor
ref="editor" ref="editor"
v-else v-else
@ -35,53 +38,49 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed } from 'vue'; import { ref, computed } from 'vue'
import Vue3Jsoneditor from 'v3-jsoneditor/src/Vue3Jsoneditor.vue'; import Vue3Jsoneditor from 'v3-jsoneditor/src/Vue3Jsoneditor.vue'
//
const deviceConfig = ref({ const deviceConfig = ref({
"name": "dyla1n" name: 'dyla1n'
}); }) // TODO @dylan
const isEditing = ref(false) //
//
const isEditing = ref(false);
// JSON
const editorOptions = computed(() => ({ const editorOptions = computed(() => ({
mainMenuBar: false, mainMenuBar: false,
navigationBar: false, navigationBar: false,
statusBar: false, statusBar: false
})); })) // JSON
// /** 启用编辑模式的函数 */
const enableEdit = () => { const enableEdit = () => {
isEditing.value = true; isEditing.value = true
}; }
// /** 取消编辑的函数 */
const cancelEdit = () => { const cancelEdit = () => {
isEditing.value = false; isEditing.value = false
// //
console.log('取消编辑'); console.log('取消编辑')
}; }
// /** 保存配置的函数 */
const saveConfig = () => { const saveConfig = () => {
isEditing.value = false; isEditing.value = false
// //
console.log('保存配置'); console.log('保存配置')
}; }
// JSON /** 处理 JSON 编辑器错误的函数 */
const onError = (e: any) => { const onError = (e: any) => {
console.log('onError', e); console.log('onError', e)
}; }
</script> </script>
<!-- TODO dylan建议使用 unocss 替代哈AI 模型友好 -->
<style scoped> <style scoped>
.button-group { .button-group {
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-top: 20px; margin-top: 20px;
} }
</style> </style>