From 39dc4ef11160b6ac4ed22a571ad5a0a85814c088 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 25 Apr 2024 11:23:53 +0800 Subject: [PATCH] refactor: implementation of browser tab title Signed-off-by: Ryan Wang --- ui/console-src/views/system/Login.vue | 17 +++++------------ ui/index.html | 2 +- ui/src/components/base-app/BaseApp.vue | 22 +++++++--------------- ui/src/composables/use-title.ts | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 ui/src/composables/use-title.ts diff --git a/ui/console-src/views/system/Login.vue b/ui/console-src/views/system/Login.vue index 22e37b5687..a116a702aa 100644 --- a/ui/console-src/views/system/Login.vue +++ b/ui/console-src/views/system/Login.vue @@ -5,14 +5,11 @@ import { useRouteQuery } from "@vueuse/router"; import SignupForm from "@/components/signup/SignupForm.vue"; import SocialAuthProviders from "@/components/login/SocialAuthProviders.vue"; import { useGlobalInfoFetch } from "@console/composables/use-global-info"; -import { useTitle } from "@vueuse/core"; -import { useI18n } from "vue-i18n"; -import { AppName } from "@/constants/app"; import MdiKeyboardBackspace from "~icons/mdi/keyboard-backspace"; import LocaleChange from "@/components/common/LocaleChange.vue"; +import { useAppTitle } from "@/composables/use-title"; const { globalInfo } = useGlobalInfoFetch(); -const { t } = useI18n(); const SIGNUP_TYPE = "signup"; @@ -32,14 +29,10 @@ function handleChangeType() { const isLoginType = computed(() => type.value !== SIGNUP_TYPE); -useTitle( - computed(() => { - const siteTitle = globalInfo.value?.siteTitle || AppName; - const routeTitle = t( - `core.${type.value === SIGNUP_TYPE ? SIGNUP_TYPE : "login"}.title` - ); - return [routeTitle, siteTitle].join(" - "); - }) +useAppTitle( + computed( + () => `core.${type.value === SIGNUP_TYPE ? SIGNUP_TYPE : "login"}.title` + ) );