fix: 同步浏览器标题显示

This commit is contained in:
Nixevol
2026-07-05 01:02:39 +08:00
parent 4d32a117e2
commit 5207af30f1
5 changed files with 28 additions and 1 deletions
+11 -1
View File
@@ -55,7 +55,7 @@
</template>
<script setup lang="ts">
import { computed, h, onMounted, onUnmounted, ref } from 'vue';
import { computed, h, onMounted, onUnmounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { NIcon } from 'naive-ui';
@@ -113,6 +113,7 @@ const menuOptions = computed<MenuOption[]>(() => {
const activeKey = computed(() => (['artwork-detail', 'artwork-trace-codes', 'traceCodes'].includes(route.name as string) ? 'artworks' : (route.name as string)));
const currentTitle = computed(() => (activeKey.value ? t(`menu.${activeKey.value}`) : ''));
const browserTitle = computed(() => (currentTitle.value ? `${currentTitle.value} - ${appName.value}` : appName.value));
const userOptions = computed(() => [
{ label: t('menu.profile'), key: 'profile', icon: renderIcon(KeyOutline) },
@@ -152,6 +153,15 @@ async function loadSettings() {
/* ignore */
}
}
watch(
browserTitle,
(title) => {
document.title = title;
},
{ immediate: true },
);
onMounted(async () => {
resizeHandler = () => {
collapsed.value = window.innerWidth < 900;
+2
View File
@@ -92,9 +92,11 @@ onMounted(async () => {
try {
const info = await appApi.info();
appName.value = info.appName || t('pages.login.title');
document.title = appName.value;
appIconUrl.value = resolveAppIcon(info.appIconUrl);
setFavicon(appIconUrl.value);
} catch {
document.title = appName.value;
setFavicon(appIconUrl.value);
}
});