diff --git a/src/layouts/BasicLayout.vue b/src/layouts/BasicLayout.vue index f6226867..f8c8f72a 100644 --- a/src/layouts/BasicLayout.vue +++ b/src/layouts/BasicLayout.vue @@ -10,7 +10,14 @@ import RightContent from './components/RightContent.vue'; import Tabs from './components/Tabs.vue'; import GlobalMask from '@/components/GlobalMask/index.vue'; import { scriptUrl } from '@/assets/js/icon_font_8d5l8fzk5b87iudi'; -import { computed, reactive, watch, onMounted, onUnmounted } from 'vue'; +import { + computed, + reactive, + watch, + onMounted, + onUnmounted, + nextTick, +} from 'vue'; import useLayoutStore from '@/store/modules/layout'; import useRouterStore from '@/store/modules/router'; import useTabsStore from '@/store/modules/tabs'; @@ -161,8 +168,27 @@ function fnLocale(m: MenuDataItem) { return title; } +/**检查系统名称是否超出范围进行滚动 */ +function fnCheckAppNameOverflow() { + const container: HTMLDivElement | null = document.querySelector('.app-name'); + if (!container) return; + const text: HTMLDivElement | null = container.querySelector('.marquee'); + if (!text) return; + if (text.offsetWidth > container.offsetWidth) { + text.classList.add('app-name_scrollable'); + } else { + text.classList.remove('app-name_scrollable'); + } +} + +watch( + () => appStore.appName, + () => nextTick(fnCheckAppNameOverflow) +); + // onMounted(() => { + fnCheckAppNameOverflow(); fnGetServerTime(); useAlarmStore().fnGetActiveAlarmInfo(); }); @@ -246,8 +272,10 @@ onUnmounted(() => { :alt="appStore.appName" :title="appStore.appName" /> -

- {{ appStore.appName }} +

+ + {{ appStore.appName }} +