Merge pull request '修复后台登录进入后,刷新网站图标未正常加载的问题。' (#321) from TowCents/Admin.NET.Pro:v2 into v2
Reviewed-on: https://code.adminnet.top/Admin.NET/Admin.NET.Pro/pulls/321
This commit is contained in:
commit
6df37f0659
@ -22,7 +22,7 @@ import mittBus from '/@/utils/mitt';
|
|||||||
import setIntroduction from '/@/utils/setIconfont';
|
import setIntroduction from '/@/utils/setIconfont';
|
||||||
// import Watermark from '/@/utils/watermark';
|
// import Watermark from '/@/utils/watermark';
|
||||||
import { initIdleTimeout } from '/@/utils/idleTimeout';
|
import { initIdleTimeout } from '/@/utils/idleTimeout';
|
||||||
|
import { updateFavicon } from '/@/utils/sysInfo'
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
||||||
const Settings = defineAsyncComponent(() => import('/@/layout/navBars/topBar/settings.vue'));
|
const Settings = defineAsyncComponent(() => import('/@/layout/navBars/topBar/settings.vue'));
|
||||||
@ -74,6 +74,12 @@ onMounted(() => {
|
|||||||
if (Local.get('themeConfig')) {
|
if (Local.get('themeConfig')) {
|
||||||
storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') });
|
storesThemeConfig.setThemeConfig({ themeConfig: Local.get('themeConfig') });
|
||||||
document.documentElement.style.cssText = Local.get('themeConfigStyle');
|
document.documentElement.style.cssText = Local.get('themeConfigStyle');
|
||||||
|
|
||||||
|
// 从本地存储恢复favicon
|
||||||
|
const storedConfig = Local.get('themeConfig');
|
||||||
|
if (storedConfig && storedConfig.logoUrl) {
|
||||||
|
updateFavicon(storedConfig.logoUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 获取缓存中的全屏配置
|
// 获取缓存中的全屏配置
|
||||||
if (Session.get('isTagsViewCurrenFull')) {
|
if (Session.get('isTagsViewCurrenFull')) {
|
||||||
|
|||||||
@ -1,81 +1,81 @@
|
|||||||
import { Local } from '/@/utils/storage';
|
import { Local } from '/@/utils/storage';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||||
import logoImg from '/@/assets/logo.png';
|
import logoImg from '/@/assets/logo.png';
|
||||||
|
|
||||||
import { SysTenantApi } from '/@/api-services';
|
import { SysTenantApi } from '/@/api-services';
|
||||||
import { feature, getAPI } from '/@/utils/axios-utils';
|
import { feature, getAPI } from '/@/utils/axios-utils';
|
||||||
import { updateIdleTimeout } from '/@/utils/idleTimeout';
|
import { updateIdleTimeout } from '/@/utils/idleTimeout';
|
||||||
|
|
||||||
const storesThemeConfig = useThemeConfig();
|
const storesThemeConfig = useThemeConfig();
|
||||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||||
|
|
||||||
// 加载系统信息
|
// 加载系统信息
|
||||||
export async function loadSysInfo(tenantid: number) {
|
export async function loadSysInfo(tenantid: number) {
|
||||||
const [err, res] = await feature(getAPI(SysTenantApi).apiSysTenantSysInfoTenantIdGet(Number(tenantid)));
|
const [err, res] = await feature(getAPI(SysTenantApi).apiSysTenantSysInfoTenantIdGet(Number(tenantid)));
|
||||||
if (err) {
|
if (err) {
|
||||||
// 默认 logo 地址
|
// 默认 logo 地址
|
||||||
themeConfig.value.logoUrl = logoImg;
|
themeConfig.value.logoUrl = logoImg;
|
||||||
// 保存配置
|
// 保存配置
|
||||||
Local.remove('themeConfig');
|
Local.remove('themeConfig');
|
||||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (res.data.type != 'success' || res.data.result == null) return;
|
if (res.data.type != 'success' || res.data.result == null) return;
|
||||||
|
|
||||||
const data = res.data.result;
|
const data = res.data.result;
|
||||||
// 系统logo
|
// 系统logo
|
||||||
themeConfig.value.logoUrl = data.logo;
|
themeConfig.value.logoUrl = data.logo;
|
||||||
// 主标题
|
// 主标题
|
||||||
themeConfig.value.globalTitle = data.title;
|
themeConfig.value.globalTitle = data.title;
|
||||||
// 副标题
|
// 副标题
|
||||||
themeConfig.value.globalViceTitle = data.viceTitle;
|
themeConfig.value.globalViceTitle = data.viceTitle;
|
||||||
// 系统说明
|
// 系统说明
|
||||||
themeConfig.value.globalViceTitleMsg = data.viceDesc;
|
themeConfig.value.globalViceTitleMsg = data.viceDesc;
|
||||||
// Icp备案信息
|
// Icp备案信息
|
||||||
themeConfig.value.icp = data.icp;
|
themeConfig.value.icp = data.icp;
|
||||||
themeConfig.value.icpUrl = data.icpUrl;
|
themeConfig.value.icpUrl = data.icpUrl;
|
||||||
// 水印
|
// 水印
|
||||||
themeConfig.value.isWatermark = data.watermark != null;
|
themeConfig.value.isWatermark = data.watermark != null;
|
||||||
themeConfig.value.watermarkText = data.watermark;
|
themeConfig.value.watermarkText = data.watermark;
|
||||||
// 版权说明
|
// 版权说明
|
||||||
themeConfig.value.copyright = data.copyright;
|
themeConfig.value.copyright = data.copyright;
|
||||||
// 版本号
|
// 版本号
|
||||||
themeConfig.value.version = data.version;
|
themeConfig.value.version = data.version;
|
||||||
// 全局主题
|
// 全局主题
|
||||||
themeConfig.value.primary = data.themeColor;
|
themeConfig.value.primary = data.themeColor;
|
||||||
// 布局切换
|
// 布局切换
|
||||||
themeConfig.value.layout = data.layout;
|
themeConfig.value.layout = data.layout;
|
||||||
// 面切动画
|
// 面切动画
|
||||||
themeConfig.value.animation = data.animation;
|
themeConfig.value.animation = data.animation;
|
||||||
// 登录验证
|
// 登录验证
|
||||||
themeConfig.value.secondVer = data.secondVer;
|
themeConfig.value.secondVer = data.secondVer;
|
||||||
themeConfig.value.captcha = data.captcha;
|
themeConfig.value.captcha = data.captcha;
|
||||||
// 开启强制修改密码
|
// 开启强制修改密码
|
||||||
themeConfig.value.forceChangePassword = data.forceChangePassword;
|
themeConfig.value.forceChangePassword = data.forceChangePassword;
|
||||||
// 是否验证密码有效期
|
// 是否验证密码有效期
|
||||||
themeConfig.value.passwordExpirationTime = data.passwordExpirationTime;
|
themeConfig.value.passwordExpirationTime = data.passwordExpirationTime;
|
||||||
// 开启多语言切换
|
// 开启多语言切换
|
||||||
themeConfig.value.i18NSwitch = data.i18NSwitch;
|
themeConfig.value.i18NSwitch = data.i18NSwitch;
|
||||||
// 闲置超时时间
|
// 闲置超时时间
|
||||||
themeConfig.value.idleTimeout = data.idleTimeout;
|
themeConfig.value.idleTimeout = data.idleTimeout;
|
||||||
// 密码加解密公匙
|
// 密码加解密公匙
|
||||||
window.__env__.VITE_SM_PUBLIC_KEY = data.publicKey;
|
window.__env__.VITE_SM_PUBLIC_KEY = data.publicKey;
|
||||||
|
|
||||||
// 更新 favicon
|
// 更新 favicon
|
||||||
updateFavicon(data.logo);
|
updateFavicon(data.logo);
|
||||||
|
|
||||||
// 更新空闲超时时间
|
// 更新空闲超时时间
|
||||||
updateIdleTimeout(themeConfig.value.idleTimeout ?? 0);
|
updateIdleTimeout(themeConfig.value.idleTimeout ?? 0);
|
||||||
|
|
||||||
// 保存配置
|
// 保存配置
|
||||||
Local.remove('themeConfig');
|
Local.remove('themeConfig');
|
||||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新 favicon
|
// 更新 favicon
|
||||||
const updateFavicon = (url: string): void => {
|
export const updateFavicon = (url: string): void => {
|
||||||
const favicon = document.getElementById('favicon') as HTMLAnchorElement;
|
const favicon = document.getElementById('favicon') as HTMLAnchorElement;
|
||||||
favicon!.href = url ? url : 'data:;base64,=';
|
favicon!.href = url ? url : 'data:;base64,=';
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user