add:增加一个全局的loading

This commit is contained in:
chenpingsen
2024-08-21 17:54:27 +08:00
parent c09ca418b3
commit 05bb62752b
3 changed files with 31 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { ref } from 'vue';
export const items = defineStore({ export const items = defineStore({
id: 'items', id: 'items',
@@ -10,10 +11,32 @@ export const items = defineStore({
projectId: 'HLlmTZp8', projectId: 'HLlmTZp8',
// 站点ID // 站点ID
siteId: undefined, siteId: undefined,
// 全局loading状态
isLoading: ref(false),
}; };
}, },
getters: { getters: {
double: (state: any) => state.count * 2, // 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);
},
}, },
actions: {},
}); });

View File

@@ -60,7 +60,7 @@
v-if="runMode.value == 2 || runMode.value == 4" v-if="runMode.value == 2 || runMode.value == 4"
src="../../image/liftState/wind-hot.svg" src="../../image/liftState/wind-hot.svg"
alt="" /> alt="" />
<img v-if="runMode.value == 0" src="../../image/liftState/switch-on.svg" alt="" /> <img v-if="runMode.value == 0" src="../../image/liftState/switch-off.svg" alt="" />
</div> </div>
</div> </div>
<!-- 冷风 热风 --> <!-- 冷风 热风 -->
@@ -93,9 +93,7 @@
const switchStatus = computed(() => { const switchStatus = computed(() => {
return props.dataSource.record.switchStatus; return props.dataSource.record.switchStatus;
}); });
onMounted(() => { onMounted(() => {});
console.log(props.dataSource, 'pppppppppppp');
});
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.box-model { .box-model {

View File

@@ -443,13 +443,13 @@
}); });
}; };
// 温度数组 // 温度数组
const sensorData = ref([]); const sensorData = ref<any>([]);
// 湿度数组 // 湿度数组
const humidityData = ref([]); const humidityData = ref<any>([]);
// PM2.5数组 // PM2.5数组
const pmData = ref([]); const pmData = ref<any>([]);
// 二氧化碳 浓度 // 二氧化碳 浓度
const CO2Data = ref([]); const CO2Data = ref<any>([]);
// 排风扇 // 排风扇
const fanData = ref([]); const fanData = ref([]);
// 风幕机 // 风幕机