@fmdevui/fm-dev
Version:
Page level components developed based on Element Plus.
55 lines (52 loc) • 2.35 kB
JavaScript
import { Local } from '../storage/index.mjs';
import { storeToRefs } from 'pinia';
import '../../stores/index.mjs';
import { PUB } from '../const/index.mjs';
import '../../api/index.mjs';
import emitter from '../emit/index.mjs';
import { useThemeConfig } from '../../stores/themeConfig.mjs';
import { feature, useSysApi } from '../../api/sys/index.mjs';
async function loadSysInfo(tenantid) {
const storesThemeConfig = useThemeConfig();
const { themeConfig } = storeToRefs(storesThemeConfig);
const [err, res] = await feature(useSysApi().getSysInfo(Number(tenantid)));
if (err) {
themeConfig.value.logoUrl = "logo.png";
Local.remove(PUB.themeConfig);
Local.set(PUB.themeConfig, storesThemeConfig.themeConfig);
return;
} else {
if (res.data.type != "success" || res.data.result == null) return;
const data = res.data.result;
themeConfig.value.logoUrl = data.logo;
themeConfig.value.globalTitle = data.title;
themeConfig.value.globalViceTitle = data.viceTitle;
themeConfig.value.globalViceTitleMsg = data.viceDesc;
themeConfig.value.icp = data.icp;
themeConfig.value.icpUrl = data.icpUrl;
themeConfig.value.isWatermark = data.watermark != null;
themeConfig.value.watermarkText = data.watermark;
themeConfig.value.copyright = data.copyright;
themeConfig.value.version = data.version;
themeConfig.value.primary = data.themeColor;
themeConfig.value.layout = data.layout;
themeConfig.value.animation = data.animation;
themeConfig.value.secondVer = data.secondVer;
themeConfig.value.captcha = data.captcha;
themeConfig.value.forceChangePassword = data.forceChangePassword;
themeConfig.value.passwordExpirationTime = data.passwordExpirationTime;
themeConfig.value.i18NSwitch = data.i18NSwitch;
themeConfig.value.idleTimeout = data.idleTimeout;
themeConfig.value.onlineNotice = data.onlineNotice;
window.__env__.VITE_SM_PUBLIC_KEY = data.publicKey;
updateFavicon(data.logo);
emitter.emit("updateIdleTimeoutchange", themeConfig.value.idleTimeout ?? 0);
Local.remove(PUB.themeConfig);
Local.set(PUB.themeConfig, storesThemeConfig.themeConfig);
}
}
const updateFavicon = (url) => {
const favicon = document.getElementById("favicon");
favicon.href = url ? url : "data:;base64,=";
};
export { loadSysInfo, updateFavicon };