refactor(project): re-adjust the overall folder

This commit is contained in:
vince
2024-07-23 00:03:59 +08:00
parent a1a566cb2f
commit 14538f7ed5
281 changed files with 1365 additions and 1659 deletions

View File

@@ -1,8 +1,8 @@
import type { InitStoreOptions } from '@vben-core/stores';
import type { InitStoreOptions } from '@vben/stores';
import type { App } from 'vue';
import { initStore, storeToRefs } from '@vben-core/stores';
import { initStore, resetAllStores, storeToRefs } from '@vben/stores';
/**
* @zh_CN 初始化pinia
@@ -13,7 +13,6 @@ async function setupStore(app: App, options: InitStoreOptions) {
app.use(pinia);
}
export { setupStore, storeToRefs };
export { resetAllStores, setupStore, storeToRefs };
export { useAccessStore } from './modules/access';
export { useAppStore } from './modules/app';

View File

@@ -6,7 +6,7 @@ import { computed, ref } from 'vue';
import { useRouter } from 'vue-router';
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
import { useCoreAccessStore } from '@vben-core/stores';
import { resetAllStores, useCoreAccessStore } from '@vben/stores';
import { notification } from 'ant-design-vue';
import { defineStore } from 'pinia';
@@ -50,7 +50,7 @@ export const useAccessStore = defineStore('access', () => {
onSuccess?: () => Promise<void> | void,
) {
// 异步处理用户登录操作并获取 accessToken
let userInfo: UserInfo | null = null;
let userInfo: null | UserInfo = null;
try {
loading.value = true;
const { accessToken, refreshToken } = await login(params);
@@ -102,7 +102,7 @@ export const useAccessStore = defineStore('access', () => {
}
async function logout() {
coreStoreAccess.$reset();
resetAllStores();
openLoginExpiredModal.value = false;
// 回登陆页带上当前路由地址
@@ -115,17 +115,19 @@ export const useAccessStore = defineStore('access', () => {
}
async function fetchUserInfo() {
let userInfo: UserInfo | null = null;
let userInfo: null | UserInfo = null;
userInfo = await getUserInfo();
coreStoreAccess.setUserInfo(userInfo);
return userInfo;
}
function reset() {
coreStoreAccess.$reset();
function $reset() {
loading.value = false;
openLoginExpiredModal.value = false;
}
return {
$reset,
accessRoutes,
accessToken,
authLogin,
@@ -134,7 +136,6 @@ export const useAccessStore = defineStore('access', () => {
logout,
openLoginExpiredModal,
refreshToken,
reset,
setAccessMenus,
setAccessRoutes,
setAccessToken,

View File

@@ -1,38 +0,0 @@
import { useCoreTabbarStore } from '@vben-core/stores';
import { defineStore } from 'pinia';
import { useAccessStore } from './access';
interface AppState {
isLockScreen: boolean;
lockScreenPassword?: string;
}
export const useAppStore = defineStore('app', {
actions: {
lockScreen(password: string) {
this.isLockScreen = true;
this.lockScreenPassword = password;
},
resetAppState() {
const accessStore = useAccessStore();
const coreTabbarStore = useCoreTabbarStore();
accessStore.reset();
coreTabbarStore.$reset();
},
unlockScreen() {
this.isLockScreen = false;
this.lockScreenPassword = undefined;
},
},
persist: {
paths: ['isLockScreen', 'lockScreenPassword'],
},
state: (): AppState => ({
isLockScreen: false,
lockScreenPassword: undefined,
}),
});