| | |
| | | |
| | | import { computed, onMounted, ref, watch } from 'vue'; |
| | | |
| | | import { useDebounceFn } from '@vueuse/core'; |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | import { AuthenticationLoginExpiredModal, useVbenModal } from '@vben/common-ui'; |
| | | import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants'; |
| | | import { useWatermark } from '@vben/hooks'; |
| | |
| | | import { $t } from '#/locales'; |
| | | import { router } from '#/router'; |
| | | import { useAuthStore } from '#/store'; |
| | | import { |
| | | loadPortalUiConfig, |
| | | savePortalUiConfigToServer, |
| | | } from '#/utils/portal-ui-config'; |
| | | import LoginForm from '#/views/_core/authentication/login.vue'; |
| | | import PortalBrandText from '#/components/portal/portal-brand-text.vue'; |
| | | |
| | |
| | | handleNotificationGetUnreadCount(); |
| | | } |
| | | |
| | | // ========== 门户字号全局配置(存数据库,所有用户共用) ========== |
| | | /** 已同步到数据库的字号,用于避免读取后回写 */ |
| | | let portalFontBaseline: null | { home: number; menu: number } = null; |
| | | /** 保存失败只提示一次,避免连续调节时反复弹窗 */ |
| | | let portalFontSaveWarned = false; |
| | | |
| | | const persistPortalFontConfig = useDebounceFn(async () => { |
| | | const home = preferences.app.homeFontSize; |
| | | const menu = preferences.navigation.fontSize; |
| | | if (portalFontBaseline && portalFontBaseline.home === home && portalFontBaseline.menu === menu) { |
| | | return; |
| | | } |
| | | try { |
| | | await savePortalUiConfigToServer({ homeFontSize: home, menuFontSize: menu }); |
| | | portalFontBaseline = { home, menu }; |
| | | portalFontSaveWarned = false; |
| | | } catch { |
| | | if (!portalFontSaveWarned) { |
| | | portalFontSaveWarned = true; |
| | | message.warning('字号已在本机生效,但保存到全局失败,请确认是否有参数配置修改权限'); |
| | | } |
| | | } |
| | | }, 800); |
| | | |
| | | watch( |
| | | () => [preferences.app.homeFontSize, preferences.navigation.fontSize], |
| | | () => persistPortalFontConfig(), |
| | | ); |
| | | |
| | | // ========== 初始化 ========== |
| | | onMounted(() => { |
| | | onMounted(async () => { |
| | | // 读取数据库中的全局字号配置并应用 |
| | | await loadPortalUiConfig(); |
| | | portalFontBaseline = { |
| | | home: preferences.app.homeFontSize, |
| | | menu: preferences.navigation.fontSize, |
| | | }; |
| | | // 首次加载未读数量 |
| | | handleNotificationGetUnreadCount(); |
| | | // 轮询刷新未读数量 |