智慧园区前端大屏
linwe
2025-05-23 d2e2df7c4805cc9c5e4e915202f304e0e9a53758
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 11:35:36
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-10-28 18:22:32
 * @FilePath: \bigScreen\src\store\modules\appStore.js
 * @Description: 
 * 
 * Copyright (c) 2024 by shuishen, All Rights Reserved. 
 */
import { defineStore } from 'pinia'
import { ref } from 'vue'
const useAppStore = defineStore(
  'appStore',
  () => {
    let loadNum = ref(0)
    let loadMap = false
 
 
    const hideLoading = () => {
      loadNum.value--
    }
    const showLoading = () => {
      loadNum.value++
    }
    const isLoading = () => {
      return loadNum.value > 0
    }
 
    const setLoadMap = (flag) => {
      loadMap = flag
    }
 
    const getLoadMap = () => {
      return loadMap == true
    }
 
    return {
      hideLoading,
      showLoading,
      isLoading,
      setLoadMap,
      getLoadMap
      // loadNum要持久化保存到本地一定要加,当然不加数据响应是没问题的,isLoading也会重新计算,就是不会保存
    }
  }
  //作为第三个参数配置
  // {
  //   persist: {
  //     enabled: true,
  //     strategies: [{storage: localStorage, paths: ['loadNum']}]
  //   }
  // }
)
 
export default useAppStore