2024-05-21 16:42:16 +08:00
|
|
|
|
import { defineStore } from 'pinia';
|
2024-08-21 17:54:27 +08:00
|
|
|
|
import { ref } from 'vue';
|
2024-05-21 16:42:16 +08:00
|
|
|
|
|
|
|
|
|
export const items = defineStore({
|
|
|
|
|
id: 'items',
|
|
|
|
|
state() {
|
2024-07-29 17:03:10 +08:00
|
|
|
|
return {
|
|
|
|
|
list: [],
|
|
|
|
|
count: 10,
|
|
|
|
|
// 当前项目ID
|
|
|
|
|
projectId: 'HLlmTZp8',
|
|
|
|
|
// 站点ID
|
|
|
|
|
siteId: undefined,
|
2024-08-21 17:54:27 +08:00
|
|
|
|
// 全局loading状态
|
|
|
|
|
isLoading: ref(false),
|
2024-07-29 17:03:10 +08:00
|
|
|
|
};
|
2024-05-21 16:42:16 +08:00
|
|
|
|
},
|
|
|
|
|
getters: {
|
2024-08-21 17:54:27 +08:00
|
|
|
|
// double: (state: any) => state.count * 2,
|
|
|
|
|
},
|
|
|
|
|
actions: {
|
|
|
|
|
// 设置全局loading
|
|
|
|
|
setLoading(bool: boolean) {
|
|
|
|
|
if (bool == this.isLoading) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// loading在此框架的设定内,无法高于drawer(抽屉)
|
|
|
|
|
// 但操作逻辑又集中在drawer中,此处只能操作DOM
|
|
|
|
|
const dom: any = document.querySelector('.ant-spin-nested-loading');
|
|
|
|
|
if (bool) {
|
|
|
|
|
// 抽屉的高度为 999
|
|
|
|
|
dom.style.zIndex = '1111';
|
|
|
|
|
} else {
|
|
|
|
|
dom.style.zIndex = '';
|
|
|
|
|
}
|
|
|
|
|
this.isLoading = bool;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.setLoading(false);
|
|
|
|
|
}, 5000);
|
|
|
|
|
},
|
2024-05-21 16:42:16 +08:00
|
|
|
|
},
|
|
|
|
|
});
|