From d1ed96b8fc197ce395d458e160c649a772b8bfbc Mon Sep 17 00:00:00 2001 From: Ironsp <1522278303@qq.com> Date: Fri, 29 May 2026 11:47:50 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=85=A8=E5=B1=80=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=90=8D=E7=A7=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot --- src/layout/components/notice/index.vue | 2 +- src/store/modules/equipmentList.ts | 30 ++++++++++++++++++++++++++ src/views/WarningList/list.vue | 7 ++++++ src/views/systemList/base/base.vue | 3 +++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/store/modules/equipmentList.ts diff --git a/src/layout/components/notice/index.vue b/src/layout/components/notice/index.vue index bab0cf7..a7d2c6e 100644 --- a/src/layout/components/notice/index.vue +++ b/src/layout/components/notice/index.vue @@ -15,7 +15,7 @@ - + diff --git a/src/store/modules/equipmentList.ts b/src/store/modules/equipmentList.ts new file mode 100644 index 0000000..91c6e96 --- /dev/null +++ b/src/store/modules/equipmentList.ts @@ -0,0 +1,30 @@ +import { defineStore } from 'pinia'; +import { ref, computed } from 'vue'; +import { getDevicetList } from '@/api/equipmentList/index'; + +export const useDeviceStore = defineStore('devices', () => { + // --- State (状态) --- + // 相当于 Vuex 中的 state,用 ref 或 reactive 定义 + const deviceList = ref(); + + // --- Getters (计算属性) --- + // 相当于 Vuex 中的 getters,直接用 computed 定义 + + // --- Actions (动作) --- + // 相当于 Vuex 中的 actions/mutations,直接写同步或异步函数 + async function getdeviceList(query?: any) { + try { + const response = await getDevicetList(query); + console.log('获取设备列表:', response); + deviceList.value = response.data; + } catch (error) { + console.error('获取设备列表失败', error); + } + } + + // ⚠️ 核心点:必须把需要暴露出去的变量和方法 return 出去! + return { + deviceList, + getdeviceList + }; +}); diff --git a/src/views/WarningList/list.vue b/src/views/WarningList/list.vue index 2d00aea..a6e71dd 100644 --- a/src/views/WarningList/list.vue +++ b/src/views/WarningList/list.vue @@ -118,6 +118,12 @@ diff --git a/src/views/systemList/base/base.vue b/src/views/systemList/base/base.vue index 51d3c88..08d43e9 100644 --- a/src/views/systemList/base/base.vue +++ b/src/views/systemList/base/base.vue @@ -48,6 +48,7 @@ import type { UploadProps, UploadUserFile } from 'element-plus'; import { uploadDemo, getDemo, updateDemo } from '@/api/systemList/index'; import { ElMessage } from 'element-plus'; import { Plus } from '@element-plus/icons-vue'; +import router from '@/router'; const uploadUrl = import.meta.env.VITE_BASE_API + '/system/logo/upload'; @@ -84,6 +85,8 @@ const save = async () => { .then((res) => { console.log('保存成功', res); ElMessage.success('保存成功'); + // 刷新当前路由 + router.go(0); }) .catch((err) => { console.error('保存失败', err);