fix 优化报警消息
This commit is contained in:
36
src/store/modules/warnningList.ts
Normal file
36
src/store/modules/warnningList.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { listDemo, updateDemo } from '@/api/WarningList/index';
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export const useWarningListStore = defineStore('warningListStore', () => {
|
||||
// --- State (状态) ---
|
||||
// 相当于 Vuex 中的 state,用 ref 或 reactive 定义
|
||||
const warningList = ref([]);
|
||||
const warningListTotal = ref(0);
|
||||
// --- Getters (计算属性) ---
|
||||
// 相当于 Vuex 中的 getters,直接用 computed 定义
|
||||
|
||||
// --- Actions (动作) ---
|
||||
// 相当于 Vuex 中的 actions/mutations,直接写同步或异步函数
|
||||
async function getWarningList(deviceId?: string | number) {
|
||||
try {
|
||||
const response = await listDemo({
|
||||
deviceId,
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
// console.log('6666666666666666666', response);
|
||||
warningList.value = response.data || [];
|
||||
warningListTotal.value = response.data.total || 0;
|
||||
} catch (error) {
|
||||
console.error('获取消息列表失败', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 核心点:必须把需要暴露出去的变量和方法 return 出去!
|
||||
return {
|
||||
warningList,
|
||||
warningListTotal,
|
||||
getWarningList
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user