fix:历史记录界面后端对接
This commit is contained in:
@@ -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
|
||||
};
|
||||
});
|
||||
|
||||
@@ -162,6 +162,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||
if (!error) {
|
||||
const {authRoutes: staticAuthRoutes} = createStaticRoutes();
|
||||
const filteredAuthRoutes = filterAuthRoutesByRoles(staticAuthRoutes, authStore.userInfo.roles ?? []);
|
||||
console.log (filteredAuthRoutes.concat(routes))
|
||||
addAuthRoutes(filteredAuthRoutes.concat(routes));
|
||||
|
||||
handleAuthRoutes();
|
||||
@@ -184,7 +185,6 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||
const vueRoutes = getAuthVueRoutes(sortRoutes);
|
||||
|
||||
resetVueRoutes();
|
||||
|
||||
addRoutesToVueRouter(vueRoutes);
|
||||
|
||||
getGlobalMenus(sortRoutes);
|
||||
|
||||
Reference in New Issue
Block a user