Merge pull request '加载系统信息放到页面初始化前' (#209) from 362270511/Admin.NET.Pro:main into main
Reviewed-on: http://101.43.53.74:3000/Admin.NET/Admin.NET.Pro/pulls/209
This commit is contained in:
commit
f76e4e7d36
@ -99,65 +99,6 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
// 加载系统信息
|
||||
const loadSysInfo = () => {
|
||||
getAPI(SysConfigApi)
|
||||
.apiSysConfigSysInfoGet()
|
||||
.then((res) => {
|
||||
if (res.data.type != 'success') return;
|
||||
|
||||
const data = res.data.result;
|
||||
// 系统logo
|
||||
themeConfig.value.logoUrl = data.sysLogo;
|
||||
// 主标题
|
||||
themeConfig.value.globalTitle = data.sysTitle;
|
||||
// 副标题
|
||||
themeConfig.value.globalViceTitle = data.sysViceTitle;
|
||||
// 系统说明
|
||||
themeConfig.value.globalViceTitleMsg = data.sysViceDesc;
|
||||
// Icp备案信息
|
||||
themeConfig.value.icp = data.sysIcp;
|
||||
themeConfig.value.icpUrl = data.sysIcpUrl;
|
||||
// 水印
|
||||
themeConfig.value.isWatermark = data.sysWatermark != null;
|
||||
themeConfig.value.watermarkText = data.sysWatermark;
|
||||
// 版权说明
|
||||
themeConfig.value.copyright = data.sysCopyright;
|
||||
// 登录验证
|
||||
themeConfig.value.secondVer = data.sysSecondVer;
|
||||
themeConfig.value.captcha = data.sysCaptcha;
|
||||
// 开启强制修改密码
|
||||
themeConfig.value.forceChangePassword = data.sysForceChangePassword;
|
||||
// 是否验证密码有效期
|
||||
themeConfig.value.passwordExpirationTime = data.sysPasswordExpirationTime;
|
||||
// 密码加解密公匙
|
||||
window.__env__.VITE_SM_PUBLIC_KEY = data.publicKey;
|
||||
|
||||
// 更新 favicon
|
||||
updateFavicon(data.sysLogo);
|
||||
|
||||
// 保存配置
|
||||
Local.remove('themeConfig');
|
||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||
})
|
||||
.catch(() => {
|
||||
// 置空 logo 地址
|
||||
themeConfig.value.logoUrl = '';
|
||||
// 保存配置
|
||||
Local.remove('themeConfig');
|
||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||
return;
|
||||
});
|
||||
};
|
||||
|
||||
// 更新 favicon
|
||||
const updateFavicon = (url: string): void => {
|
||||
const favicon = document.getElementById('favicon') as HTMLAnchorElement;
|
||||
favicon!.href = url ? url : 'data:;base64,=';
|
||||
};
|
||||
|
||||
// 加载系统信息
|
||||
loadSysInfo();
|
||||
|
||||
// 阻止火狐浏览器在拖动时打开新窗口
|
||||
document.body.ondrop = function (event) {
|
||||
|
||||
@ -26,11 +26,19 @@ import JwChat from 'jwchat';
|
||||
import 'jwchat/lib/style.css';
|
||||
// 关闭自动打印
|
||||
import { disAutoConnect } from 'vue-plugin-hiprint';
|
||||
import { loadSysInfo } from '/@/utils/sysInfo';
|
||||
disAutoConnect();
|
||||
//加载系统信息放在app.vue会和挂载router产生异步冲突
|
||||
//由于挂载的机制是异步的,导致还没有获取到数据库的系统信息的时候,【密码加解密公匙】则一直为空(特别是在网络不好的情况下)
|
||||
//由于获取验证码需要【密码加解密公匙】信息,如果没有则会一直刷新页面,导致登录页面会一直刷新
|
||||
async function initApp() {
|
||||
// 加载系统信息
|
||||
await loadSysInfo();
|
||||
const app = createApp(App);
|
||||
|
||||
const app = createApp(App);
|
||||
directive(app);
|
||||
other.elSvg(app);
|
||||
|
||||
directive(app);
|
||||
other.elSvg(app);
|
||||
|
||||
app.use(pinia).use(router).use(ElementPlus).use(setupVXETable).use(i18n).use(VueGridLayout).use(VForm3).use(VueSignaturePad).use(vue3TreeOrg).use(JwChat).mount('#app');
|
||||
app.use(pinia).use(router).use(ElementPlus).use(setupVXETable).use(i18n).use(VueGridLayout).use(VForm3).use(VueSignaturePad).use(vue3TreeOrg).use(JwChat).mount('#app');
|
||||
}
|
||||
initApp();
|
||||
58
Web/src/utils/sysInfo.ts
Normal file
58
Web/src/utils/sysInfo.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { Local } from '/@/utils/storage';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||
const storesThemeConfig = useThemeConfig();
|
||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||
import { SysConfigApi } from '/@/api-services';
|
||||
import { feature, getAPI } from '/@/utils/axios-utils';
|
||||
// 加载系统信息
|
||||
export async function loadSysInfo () {
|
||||
const [err, res] = await feature(getAPI(SysConfigApi).apiSysConfigSysInfoGet());
|
||||
if (err) {
|
||||
// 置空 logo 地址
|
||||
themeConfig.value.logoUrl = '';
|
||||
// 保存配置
|
||||
Local.remove('themeConfig');
|
||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||
return;
|
||||
} else {
|
||||
if (res.data.type != 'success') return;
|
||||
|
||||
const data = res.data.result;
|
||||
// 系统logo
|
||||
themeConfig.value.logoUrl = data.sysLogo;
|
||||
// 主标题
|
||||
themeConfig.value.globalTitle = data.sysTitle;
|
||||
// 副标题
|
||||
themeConfig.value.globalViceTitle = data.sysViceTitle;
|
||||
// 系统说明
|
||||
themeConfig.value.globalViceTitleMsg = data.sysViceDesc;
|
||||
// Icp备案信息
|
||||
themeConfig.value.icp = data.sysIcp;
|
||||
themeConfig.value.icpUrl = data.sysIcpUrl;
|
||||
// 水印
|
||||
themeConfig.value.isWatermark = data.sysWatermark != null;
|
||||
themeConfig.value.watermarkText = data.sysWatermark;
|
||||
// 版权说明
|
||||
themeConfig.value.copyright = data.sysCopyright;
|
||||
// 登录验证
|
||||
themeConfig.value.secondVer = data.sysSecondVer;
|
||||
themeConfig.value.captcha = data.sysCaptcha;
|
||||
// 开启强制修改密码
|
||||
themeConfig.value.sysForceChangePassword = data.sysForceChangePassword;
|
||||
// 密码加解密公匙
|
||||
window.__env__.VITE_SM_PUBLIC_KEY = data.publicKey;
|
||||
// 更新 favicon
|
||||
updateFavicon(data.sysLogo);
|
||||
|
||||
// 保存配置
|
||||
Local.remove('themeConfig');
|
||||
Local.set('themeConfig', storesThemeConfig.themeConfig);
|
||||
}
|
||||
};
|
||||
|
||||
// 更新 favicon
|
||||
const updateFavicon = (url: string): void => {
|
||||
const favicon = document.getElementById('favicon') as HTMLAnchorElement;
|
||||
favicon!.href = url ? url : 'data:;base64,=';
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user