style: 优化个人中心和偏好设置弹窗样式,重构工作入口为精致分屏布局并移除首字徽标
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { getLoginKey, login as apiLogin, devLogin, fetchMe } from "../api/auth";
|
||||
import type { ApiRequestConfig } from "../api/axios";
|
||||
import { setToken, clearToken, getToken } from "../utils/auth";
|
||||
import { encryptLoginPayload } from "../utils/loginCrypto";
|
||||
import type { UserInfo } from "../types/api";
|
||||
@@ -17,7 +18,7 @@ export const useAuthStore = defineStore("auth", () => {
|
||||
const loading = ref(false);
|
||||
const forceLogin = ref(false);
|
||||
|
||||
const login = async (email: string, password: string) => {
|
||||
const login = async (email: string, password: string, options: { restoreStudy?: boolean } = {}) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } =
|
||||
@@ -29,10 +30,12 @@ export const useAuthStore = defineStore("auth", () => {
|
||||
useSessionStore().resetActivity();
|
||||
localStorage.setItem(LAST_LOGIN_EMAIL_KEY, email);
|
||||
const me = await fetchMeAction();
|
||||
const studyStore = useStudyStore();
|
||||
const userKey = me?.email || email;
|
||||
await studyStore.restoreStudyForUser(userKey, { preferActive: me?.is_admin });
|
||||
await studyStore.loadCurrentStudyPermissions().catch(() => {});
|
||||
if (options.restoreStudy !== false) {
|
||||
const studyStore = useStudyStore();
|
||||
const userKey = me?.email || email;
|
||||
await studyStore.restoreStudyForUser(userKey, { preferActive: me?.is_admin });
|
||||
await studyStore.loadCurrentStudyPermissions().catch(() => {});
|
||||
}
|
||||
forceLogin.value = false;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
@@ -53,8 +56,8 @@ export const useAuthStore = defineStore("auth", () => {
|
||||
});
|
||||
};
|
||||
|
||||
const fetchMeAction = async () => {
|
||||
const { data } = await fetchMe();
|
||||
const fetchMeAction = async (config?: ApiRequestConfig) => {
|
||||
const { data } = await fetchMe(config);
|
||||
user.value = data;
|
||||
if (data?.email) {
|
||||
localStorage.setItem(LAST_LOGIN_EMAIL_KEY, data.email);
|
||||
|
||||
Reference in New Issue
Block a user