😎代码优化(加载系统信息)
This commit is contained in:
parent
f76e4e7d36
commit
5ad402e8b7
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2024.12.19",
|
||||
"lastBuildTime": "2024.12.20",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -74,7 +74,7 @@
|
||||
"vue-router": "^4.5.0",
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vxe-pc-ui": "^4.3.37",
|
||||
"vxe-pc-ui": "^4.3.38",
|
||||
"vxe-table": "^4.8.10",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||
@ -103,7 +103,7 @@
|
||||
"sass": "^1.83.0",
|
||||
"terser": "^5.37.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.3",
|
||||
"vite": "^6.0.4",
|
||||
"vite-plugin-cdn-import": "^1.0.1",
|
||||
"vite-plugin-compression2": "^1.3.3",
|
||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||
|
||||
@ -21,8 +21,6 @@ import { Local, Session } from '/@/utils/storage';
|
||||
import mittBus from '/@/utils/mitt';
|
||||
import setIntroduction from '/@/utils/setIconfont';
|
||||
// import Watermark from '/@/utils/watermark';
|
||||
import { SysConfigApi } from '/@/api-services';
|
||||
import { getAPI } from '/@/utils/axios-utils';
|
||||
|
||||
// 引入组件
|
||||
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
||||
@ -99,7 +97,6 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// 阻止火狐浏览器在拖动时打开新窗口
|
||||
document.body.ondrop = function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
@ -24,21 +24,17 @@ import { setupVXETable } from '/@/hooks/setupVXETableHook';
|
||||
// IM聊天框
|
||||
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);
|
||||
|
||||
directive(app);
|
||||
other.elSvg(app);
|
||||
// 加载系统信息
|
||||
import { loadSysInfo } from '/@/utils/sysInfo';
|
||||
loadSysInfo();
|
||||
|
||||
app.use(pinia).use(router).use(ElementPlus).use(setupVXETable).use(i18n).use(VueGridLayout).use(VForm3).use(VueSignaturePad).use(vue3TreeOrg).use(JwChat).mount('#app');
|
||||
}
|
||||
initApp();
|
||||
const app = createApp(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');
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
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';
|
||||
|
||||
const storesThemeConfig = useThemeConfig();
|
||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||
|
||||
// 加载系统信息
|
||||
export async function loadSysInfo () {
|
||||
export async function loadSysInfo() {
|
||||
const [err, res] = await feature(getAPI(SysConfigApi).apiSysConfigSysInfoGet());
|
||||
if (err) {
|
||||
// 置空 logo 地址
|
||||
@ -39,9 +42,12 @@ export async function loadSysInfo () {
|
||||
themeConfig.value.secondVer = data.sysSecondVer;
|
||||
themeConfig.value.captcha = data.sysCaptcha;
|
||||
// 开启强制修改密码
|
||||
themeConfig.value.sysForceChangePassword = data.sysForceChangePassword;
|
||||
themeConfig.value.forceChangePassword = data.sysForceChangePassword;
|
||||
// 是否验证密码有效期
|
||||
themeConfig.value.passwordExpirationTime = data.sysPasswordExpirationTime;
|
||||
// 密码加解密公匙
|
||||
window.__env__.VITE_SM_PUBLIC_KEY = data.publicKey;
|
||||
|
||||
// 更新 favicon
|
||||
updateFavicon(data.sysLogo);
|
||||
|
||||
@ -49,10 +55,10 @@ export async function loadSysInfo () {
|
||||
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