mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
Merge remote-tracking branch 'soybeanjs/main' into ruoyi
# Conflicts: # CHANGELOG.md # README.md # package.json # pnpm-lock.yaml # src/plugins/loading.ts # src/store/modules/auth/index.ts
This commit is contained in:
@ -79,17 +79,13 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
||||
const pass = await loginByToken(loginToken);
|
||||
|
||||
if (pass) {
|
||||
await routeStore.initAuthRoute();
|
||||
|
||||
await redirectFromLogin(redirect);
|
||||
|
||||
if (routeStore.isInitAuthRoute) {
|
||||
// window.$notification?.success({
|
||||
// title: $t('page.login.common.loginSuccess'),
|
||||
// content: $t('page.login.common.welcomeBack', { userName: userInfo.userName }),
|
||||
// duration: 4500
|
||||
// });
|
||||
}
|
||||
window.$notification?.success({
|
||||
title: $t('page.login.common.loginSuccess'),
|
||||
content: $t('page.login.common.welcomeBack', { userName: userInfo.userName }),
|
||||
duration: 4500
|
||||
});
|
||||
}
|
||||
} else {
|
||||
resetStore();
|
||||
|
@ -232,10 +232,17 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||
handleConstantAndAuthRoutes();
|
||||
|
||||
setIsInitConstantRoute(true);
|
||||
|
||||
tabStore.initHomeTab();
|
||||
}
|
||||
|
||||
/** Init auth route */
|
||||
async function initAuthRoute() {
|
||||
// check if user info is initialized
|
||||
if (!authStore.userInfo.userId) {
|
||||
await authStore.initUserInfo();
|
||||
}
|
||||
|
||||
if (authRouteMode.value === 'static') {
|
||||
initStaticAuthRoute();
|
||||
} else {
|
||||
@ -364,6 +371,14 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||
return getSelectedMenuKeyPathByKey(selectedKey, menus.value);
|
||||
}
|
||||
|
||||
async function onRouteSwitchWhenLoggedIn() {
|
||||
await authStore.initUserInfo();
|
||||
}
|
||||
|
||||
async function onRouteSwitchWhenNotLoggedIn() {
|
||||
// some global init logic if it does not need to be logged in
|
||||
}
|
||||
|
||||
return {
|
||||
resetStore,
|
||||
routeHome,
|
||||
@ -380,6 +395,8 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
||||
isInitAuthRoute,
|
||||
setIsInitAuthRoute,
|
||||
getIsAuthRouteExist,
|
||||
getSelectedMenuKeyPath
|
||||
getSelectedMenuKeyPath,
|
||||
onRouteSwitchWhenLoggedIn,
|
||||
onRouteSwitchWhenNotLoggedIn
|
||||
};
|
||||
});
|
||||
|
@ -174,6 +174,7 @@ export const useThemeStore = defineStore(SetupStoreId.Theme, () => {
|
||||
darkMode,
|
||||
val => {
|
||||
toggleCssDarkMode(val);
|
||||
localStg.set('darkMode', val);
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
@ -1,11 +1,11 @@
|
||||
import type { GlobalThemeOverrides } from 'naive-ui';
|
||||
import { defu } from 'defu';
|
||||
import { addColorAlpha, getColorPalette, getPaletteColorByNumber, getRgb } from '@sa/color';
|
||||
import { overrideThemeSettings, themeSettings } from '@/theme/settings';
|
||||
import { themeVars } from '@/theme/vars';
|
||||
import { toggleHtmlClass } from '@/utils/common';
|
||||
import { localStg } from '@/utils/storage';
|
||||
|
||||
const DARK_CLASS = 'dark';
|
||||
import { DARK_CLASS } from '@/constants/app';
|
||||
|
||||
/** Init theme settings */
|
||||
export function initThemeSettings() {
|
||||
@ -17,12 +17,15 @@ export function initThemeSettings() {
|
||||
// if it is production mode, the theme settings will be cached in localStorage
|
||||
// if want to update theme settings when publish new version, please update `overrideThemeSettings` in `src/theme/settings.ts`
|
||||
|
||||
const settings = localStg.get('themeSettings') || themeSettings;
|
||||
const localSettings = localStg.get('themeSettings');
|
||||
|
||||
let settings = defu(localSettings, themeSettings);
|
||||
|
||||
const isOverride = localStg.get('overrideThemeFlag') === BUILD_TIME;
|
||||
|
||||
if (!isOverride) {
|
||||
Object.assign(settings, overrideThemeSettings);
|
||||
settings = defu(overrideThemeSettings, settings);
|
||||
|
||||
localStg.set('overrideThemeFlag', BUILD_TIME);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user