feat(projects): 主题配置抽屉: 迁移其他功能

This commit is contained in:
Soybean
2022-01-09 13:25:42 +08:00
parent 912bfdf439
commit 6d132c5977
10 changed files with 269 additions and 6 deletions

View File

@ -32,7 +32,6 @@ interface AuthStore {
export const useAuthStore = defineStore('auth-store', () => {
const { toLogin, toLoginRedirect } = useRouterPush(false);
const { loading: loginLoding, startLoading: startLoginLoading, endLoading: endLoginLoading } = useLoading();
const userInfo: Auth.UserInfo = reactive(getUserInfo());
function handleSetUserInfo(data: Auth.UserInfo) {
@ -46,12 +45,18 @@ export const useAuthStore = defineStore('auth-store', () => {
const isLogin = computed(() => Boolean(token.value));
const { loading: loginLoding, startLoading: startLoginLoading, endLoading: endLoginLoading } = useLoading();
function resetStore() {
handleSetUserInfo(getUserInfo());
handleSetToken(getToken());
}
function resetAuthStore(pushRoute: boolean = true) {
const auth = useAuthStore();
const route = unref(globalRouter.currentRoute);
clearAuthStorage();
auth.$reset();
resetStore();
if (pushRoute && route.meta.requiresAuth) {
toLogin();