Skip to content

Commit 5d32cc3

Browse files
committed
【代码评审】IoT:plugin 相关的实现
1 parent 7be9c3e commit 5d32cc3

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/views/iot/plugin/detail/index.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,19 @@
3333
</el-descriptions-item>
3434
</el-descriptions>
3535
</ContentWrap>
36+
<!-- TODO @haohao:如果是独立部署,也是通过上传插件包哇? -->
3637
<ContentWrap class="mt-10px">
3738
<el-button type="warning" plain @click="handleImport" v-hasPermi="['system:user:import']">
3839
<Icon icon="ep:upload" /> 上传插件包
3940
</el-button>
4041
</ContentWrap>
4142
</div>
43+
<!-- TODO @haohao:待完成:配置管理 -->
44+
<!-- TODO @haohao:待完成:script 管理 -->
45+
<!-- TODO @haohao:插件实例的前端展示:底部要不要加个分页,展示运行中的实力?默认勾选,只展示 state 为在线的 -->
46+
4247
<!-- 插件导入对话框 -->
48+
<!-- TODO @haohao:Number 尽量不用。因为有用户会使用 snowflake、或者 string 的时候,会有问题 -->
4349
<PluginImportForm
4450
ref="importFormRef"
4551
:id="Number(pluginInfo.id)"
@@ -50,7 +56,7 @@
5056
<script lang="ts" setup>
5157
import { PluginInfoApi, PluginInfoVO } from '@/api/iot/plugininfo'
5258
import { useRoute } from 'vue-router'
53-
import { ref, onMounted } from 'vue'
59+
import { onMounted, ref } from 'vue'
5460
import PluginImportForm from './PluginImportForm.vue'
5561
5662
const message = useMessage()
@@ -70,6 +76,7 @@ const pluginInfo = ref<PluginInfoVO>({
7076
config: '',
7177
script: ''
7278
})
79+
// TODO @haohao:这里可以改成 pluginInfo.id > 0 去判断,然后 handleStatusChange disable 按钮
7380
const isInitialLoad = ref(true) // 初始化标志位
7481
7582
onMounted(() => {
@@ -81,9 +88,9 @@ onMounted(() => {
8188
}
8289
})
8390
91+
/** 获取插件详情 */
8492
const getPluginInfo = async (id: number) => {
85-
const data = await PluginInfoApi.getPluginInfo(id)
86-
pluginInfo.value = data
93+
pluginInfo.value = await PluginInfoApi.getPluginInfo(id)
8794
}
8895
8996
/** 处理状态变更 */
@@ -100,7 +107,8 @@ const handleStatusChange = async (status: number) => {
100107
status
101108
})
102109
message.success('更新状态成功')
103-
getPluginInfo(Number(pluginInfo.value.id))
110+
// 获取详情
111+
await getPluginInfo(pluginInfo.value.id)
104112
} catch (error) {
105113
pluginInfo.value.status = status === 1 ? 0 : 1
106114
message.error('更新状态失败')

src/views/iot/plugin/index.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- TODO @芋艿:增加一个【运维管理】,然后把插件放过去? -->
12
<template>
23
<ContentWrap>
34
<!-- 搜索工作栏 -->
@@ -64,7 +65,7 @@
6465
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
6566
<el-table-column label="插件名称" align="center" prop="name" />
6667
<el-table-column label="插件标识" align="center" prop="pluginKey" />
67-
<el-table-column label="jar包" align="center" prop="file" />
68+
<el-table-column label="jar 包" align="center" prop="file" />
6869
<el-table-column label="版本号" align="center" prop="version" />
6970
<el-table-column label="部署方式" align="center" prop="deployType">
7071
<template #default="scope">
@@ -144,7 +145,7 @@
144145
</span>
145146
</div>
146147
<div class="mb-2.5 last:mb-0">
147-
<span class="text-[#717c8e] mr-2.5">jar包</span>
148+
<span class="text-[#717c8e] mr-2.5">jar 包</span>
148149
<span class="text-[#0b1d30]">{{ item.fileName }}</span>
149150
</div>
150151
<div class="mb-2.5 last:mb-0">
@@ -155,6 +156,7 @@
155156
<span class="text-[#717c8e] mr-2.5">部署方式</span>
156157
<dict-tag :type="DICT_TYPE.IOT_PLUGIN_DEPLOY_TYPE" :value="item.deployType" />
157158
</div>
159+
<!-- TODO @haohao:这里【状态】要不去掉,变成:1)通过颜色,区分开启、禁用,类似 device 上线状态;2)开启、禁用操作,放到下面的“按钮”,3 个一排,好看电 -->
158160
<div class="mb-2.5 last:mb-0">
159161
<span class="text-[#717c8e] mr-2.5">状态</span>
160162
<el-switch

0 commit comments

Comments
 (0)