/* * @Author: 曹文丽 caowenli@yuan-info.com * @Date: 2023-06-15 20:34:47 * @LastEditors: 曹文丽 * @LastEditTime: 2023-06-28 17:55:49 * @FilePath: \safe-product-authority-browser\src\hooks\systemConfig.ts * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import { onMounted } from 'vue'; import { getSysInterfaceConfig } from '@/api/common'; import { useSystemConfigStoreWithOut } from '@/store/modules/systemConfig'; import { checkImagePathExistence, changeFavicon, addVersion, } from '@/utils/utils'; const systemConfig = useSystemConfigStoreWithOut(); export function useSystemConfig() { const initSystemConfig = () => { getSysInterfaceConfig().then((res) => { let { code, data } = res || {}; if (code == 200 && data) { let { loginBoxLayout, systemName, systemAbbreviation, backgroundPath, logoPath, } = data; systemName && systemConfig.$patch((state) => { document.title = systemName; state.systemName = systemName; }); // 系统简称; systemAbbreviation && systemConfig.$patch((state) => { state.systemAbbreviation = systemAbbreviation; }); loginBoxLayout && systemConfig.$patch((state) => { state.loginBoxLayout = loginBoxLayout == 'mid' ? 2 : loginBoxLayout == 'right' ? 1 : 3; }); if (backgroundPath) { const sIndex = backgroundPath.search('/serverAssets'); backgroundPath = backgroundPath.slice(sIndex, backgroundPath.length); logoPath = logoPath.slice(sIndex, logoPath.length); //检查背景图片是否存在 checkImagePathExistence(backgroundPath).then((res) => { systemConfig.$patch((state) => { state.backgroundPath = res; }); }); //检查icon图标是否存在 checkImagePathExistence(logoPath).then((res) => { systemConfig.$patch((state) => { state.logoPath = res; }); }); // 检查ico changeFavicon('/serverAssets/favicon.ico'); } } }); }; onMounted(() => { initSystemConfig(); }); return { initSystemConfig, }; }