60 lines
2.2 KiB
Vue
Executable File
60 lines
2.2 KiB
Vue
Executable File
<script setup lang="ts">
|
||
import { computed } from 'vue'
|
||
import { useRoute } from 'vue-router'
|
||
import { useWindowSize } from '@vueuse/core'
|
||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||
|
||
import { ScreenEnum } from './enums/appEnums'
|
||
import useAppStore from './stores/modules/app'
|
||
import useSettingStore, { useAdminDark } from './stores/modules/setting'
|
||
import useUserStore from './stores/modules/user'
|
||
import ChatNotifyToast from './components/chat-notify-toast/index.vue'
|
||
import RevisitDueToast from './components/revisit-due-toast/index.vue'
|
||
import RouteLoadNotice from './components/route-load-notice/index.vue'
|
||
|
||
const appStore = useAppStore()
|
||
const settings = useSettingStore()
|
||
// Resolve the saved appearance, system mode and palette before routes render.
|
||
useAdminDark()
|
||
const userStore = useUserStore()
|
||
const route = useRoute()
|
||
|
||
/** 须先绑企微时 chat/notifications 会反复返回 code=10,无意义轮询且可能干扰 axios/路由;绑定页也不展示会话通知 */
|
||
const showChatNotifyToast = computed(
|
||
() =>
|
||
Boolean(userStore.token) &&
|
||
route.path !== '/bind-work-wechat' &&
|
||
!userStore.userInfo?.need_bind_work_wechat
|
||
)
|
||
const elConfig = {
|
||
zIndex: 2000,
|
||
locale: zhCn
|
||
}
|
||
const { width } = useWindowSize()
|
||
watch(
|
||
[width, () => settings.adminUi],
|
||
([value, ui], [previous, previousUi]) => {
|
||
// Don't reset transient v2 navigation within the same desktop breakpoint.
|
||
if (ui === 'v2' && ui === previousUi && previous !== undefined &&
|
||
value > ScreenEnum.SM && previous > ScreenEnum.SM &&
|
||
(value < ScreenEnum.MD) === (previous < ScreenEnum.MD)) return
|
||
appStore.syncSidebarViewport(value, ui)
|
||
},
|
||
{
|
||
immediate: true
|
||
}
|
||
)
|
||
</script>
|
||
|
||
<template>
|
||
<el-config-provider :locale="elConfig.locale" :z-index="elConfig.zIndex">
|
||
<router-view />
|
||
<route-load-notice />
|
||
<ChatNotifyToast v-if="showChatNotifyToast" />
|
||
<!-- 复诊到期弹窗(右下角):与会话通知并列挂载,复用同一条件避免未绑企微时无意义轮询 -->
|
||
<RevisitDueToast v-if="showChatNotifyToast" />
|
||
</el-config-provider>
|
||
</template>
|
||
|
||
<style></style>
|