update 优化代码 统一store用法
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { createPinia } from "pinia";
|
||||
|
||||
const store = createPinia();
|
||||
|
||||
export default store;
|
||||
|
@ -1,5 +1,8 @@
|
||||
import zhCN from 'element-plus/es/locale/lang/zh-cn';
|
||||
import enUS from 'element-plus/es/locale/lang/en';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { ref, reactive, computed } from 'vue';
|
||||
|
||||
export const useAppStore = defineStore('app', () => {
|
||||
const sidebarStatus = useStorage('sidebarStatus', '1');
|
||||
@ -68,5 +71,3 @@ export const useAppStore = defineStore('app', () => {
|
||||
toggleSideBarHide
|
||||
};
|
||||
});
|
||||
|
||||
export default useAppStore;
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useDictStore = defineStore('dict', () => {
|
||||
const dict = ref<Map<string, DictDataOption[]>>(new Map());
|
||||
|
||||
@ -61,5 +63,3 @@ export const useDictStore = defineStore('dict', () => {
|
||||
cleanDict
|
||||
};
|
||||
});
|
||||
|
||||
export default useDictStore;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { reactive } from 'vue';
|
||||
|
||||
interface NoticeItem {
|
||||
title?: string;
|
||||
@ -38,5 +39,3 @@ export const useNoticeStore = defineStore('notice', () => {
|
||||
clearNotice
|
||||
};
|
||||
});
|
||||
|
||||
export default useNoticeStore;
|
||||
|
@ -4,11 +4,10 @@ import store from '@/store';
|
||||
import { getRouters } from '@/api/menu';
|
||||
import auth from '@/plugins/auth';
|
||||
import { RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import Layout from '@/layout/index.vue';
|
||||
import ParentView from '@/components/ParentView/index.vue';
|
||||
import InnerLink from '@/layout/components/InnerLink/index.vue';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { createCustomNameComponent } from '@/utils/createCustomNameComponent';
|
||||
|
||||
// 匹配views里面所有的.vue文件
|
||||
@ -206,5 +205,3 @@ function duplicateRouteChecker(localRoutes: Route[], routes: Route[]) {
|
||||
nameList.push(route.name.toString());
|
||||
});
|
||||
}
|
||||
|
||||
export default usePermissionStore;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import defaultSettings from '@/settings';
|
||||
import { useDynamicTitle } from '@/utils/dynamicTitle';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useSettingsStore = defineStore('setting', () => {
|
||||
const storageSetting = useStorage<LayoutSetting>('layout-setting', {
|
||||
@ -43,5 +45,3 @@ export const useSettingsStore = defineStore('setting', () => {
|
||||
setTitle
|
||||
};
|
||||
});
|
||||
|
||||
export default useSettingsStore;
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { RouteLocationNormalized } from 'vue-router';
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useTagsViewStore = defineStore('tagsView', () => {
|
||||
const visitedViews = ref<RouteLocationNormalized[]>([]);
|
||||
@ -230,4 +232,3 @@ export const useTagsViewStore = defineStore('tagsView', () => {
|
||||
delIframeView
|
||||
};
|
||||
});
|
||||
export default useTagsViewStore;
|
||||
|
@ -3,7 +3,7 @@ import { getToken, removeToken, setToken } from '@/utils/auth';
|
||||
import { login as loginApi, logout as logoutApi, getInfo as getUserInfo } from '@/api/login';
|
||||
import { LoginData } from '@/api/types';
|
||||
import defAva from '@/assets/images/profile.jpg';
|
||||
import store from '@/store';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const token = ref(getToken());
|
||||
@ -83,5 +83,3 @@ export const useUserStore = defineStore('user', () => {
|
||||
setAvatar
|
||||
};
|
||||
});
|
||||
|
||||
export default useUserStore;
|
||||
|
Reference in New Issue
Block a user