2
0

fix:历史记录界面后端对接

This commit is contained in:
zhongzm
2024-12-18 17:24:26 +08:00
parent 7cf6249fd8
commit a6342d7036
8 changed files with 327 additions and 216 deletions

View File

@@ -7,7 +7,7 @@ import { localStg } from '@/utils/storage';
import { $t } from '@/locales';
import { useRouteStore } from '../route';
import { clearAuthStorage, emptyInfo, getToken } from './shared';
import { doCheckUserRepeat, sendCaptcha } from '@/service/api/auth';
import { doCheckUserRepeat, sendCaptcha, fetchDashboardData } from '@/service/api/auth';
export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
const routeStore = useRouteStore();
@@ -18,6 +18,8 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
const userInfo: Api.Auth.UserInfo = reactive(emptyInfo);
const permissions = computed(() => userInfo.permissions);
/** Dashboard data */
const dashboardData = ref<Api.Dashboard.GaugeData | null>(null);
watch(
() => token.value,
@@ -159,6 +161,16 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
const { data, error } = await sendCaptcha({ email }); // 这里调用后端接口发送验证码
return { data, error };
}
/** Fetch dashboard data */
async function getDashboardData() {
const { data, error } = await fetchDashboardData();
if (!error) {
dashboardData.value = data;
return data;
}
return null;
}
return {
token,
@@ -172,6 +184,8 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
register,
captcha,
checkUserRepeat,
updateUserProfile
updateUserProfile,
dashboardData,
getDashboardData
};
});