| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import type { GlobalState } from "./pinia.types";
- import { defineStore } from "pinia";
- import { toRefs, reactive } from "vue";
- const useStore = defineStore("globalStore", () => {
- const state: GlobalState = reactive({
- globalLoading: false,
- routerLoading: false,
- requestLoading: false,
- fullScreenLoading: false,
- isPageSwitching: false,
- statusBarHeight: 0,
- theme: "light"
- });
- const setGlobalTheme = (payload: string) => {
- state.theme = payload;
- };
- const setBarHeight = (payload: number) => {
- state.statusBarHeight = payload;
- };
- const setGlobalLoading = (payload: boolean) => {
- state.globalLoading = payload;
- };
- const setRouterLoading = (payload: boolean) => {
- state.routerLoading = payload;
- };
- const setRequestLoading = (payload: boolean) => {
- state.requestLoading = payload;
- };
- const setFullScreenLoading = (payload: boolean) => {
- state.fullScreenLoading = payload;
- };
- return {
- ...toRefs(state),
- setGlobalLoading,
- setBarHeight,
- setGlobalTheme,
- setRouterLoading,
- setRequestLoading,
- setFullScreenLoading,
- };
- });
- export default useStore; // 导出
|