import { watch, unref } from 'vue'; import { useI18n } from '/@/hooks/web/useI18n'; import { useTitle as usePageTitle } from '@vueuse/core'; import { useRouter } from 'vue-router'; import { REDIRECT_NAME } from '/@/router/constant'; export function useTitle() { const { t } = useI18n(); const { currentRoute } = useRouter(); const pageTitle = usePageTitle(); watch( () => currentRoute.value.path, () => { const route = unref(currentRoute); if (route.name === REDIRECT_NAME) { return; } const tTitle = t(route?.meta?.title as string); // pageTitle.value = tTitle != '气象实况'?` ${tTitle} - 控制台`:`YX水文气象监测系统`; pageTitle.value = `YX水文气象监测系统`; }, { immediate: true } ); }