feat: add titles for settings

zio/stable
三咲智子 2023-01-04 21:57:12 +08:00
parent 9a167ee990
commit 377c015c91
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
11 changed files with 66 additions and 7 deletions

View File

@ -2,11 +2,10 @@ import { pwaInfo } from 'virtual:pwa-info'
import type { Link } from '@unhead/schema' import type { Link } from '@unhead/schema'
import type { Directions } from 'vue-i18n-routing' import type { Directions } from 'vue-i18n-routing'
import { buildInfo } from 'virtual:build-info' import { buildInfo } from 'virtual:build-info'
import { APP_NAME } from '~/constants'
import type { LocaleObject } from '#i18n' import type { LocaleObject } from '#i18n'
export function setupPageHeader() { export function setupPageHeader() {
const i18n = useI18n() const { locale, locales, t } = useI18n()
const link: Link[] = [] const link: Link[] = []
@ -30,19 +29,19 @@ export function setupPageHeader() {
} }
} }
const localeMap = (i18n.locales.value as LocaleObject[]).reduce((acc, l) => { const localeMap = (locales.value as LocaleObject[]).reduce((acc, l) => {
acc[l.code!] = l.dir ?? 'auto' acc[l.code!] = l.dir ?? 'auto'
return acc return acc
}, {} as Record<string, Directions>) }, {} as Record<string, Directions>)
useHeadFixed({ useHeadFixed({
htmlAttrs: { htmlAttrs: {
lang: () => i18n.locale.value, lang: () => locale.value,
dir: () => localeMap[i18n.locale.value] ?? 'auto', dir: () => localeMap[locale.value] ?? 'auto',
}, },
titleTemplate: (title) => { titleTemplate: (title) => {
let titleTemplate = title ? `${title} | ` : '' let titleTemplate = title ? `${title} | ` : ''
titleTemplate += APP_NAME titleTemplate += t('app_name')
if (buildInfo.env !== 'release') if (buildInfo.env !== 'release')
titleTemplate += ` (${buildInfo.env})` titleTemplate += ` (${buildInfo.env})`
return titleTemplate return titleTemplate

View File

@ -248,7 +248,7 @@
}, },
"featured_tags": { "featured_tags": {
"description": "人们可以在这些标签下浏览你的公共嘟文。", "description": "人们可以在这些标签下浏览你的公共嘟文。",
"label": "精选话题标签" "label": "精选话题标签"
}, },
"label": "个人资料" "label": "个人资料"
}, },

View File

@ -3,6 +3,12 @@ definePageMeta({
wideLayout: true, wideLayout: true,
}) })
const { t } = useI18n()
useHeadFixed({
title: () => t('nav.settings'),
})
const route = useRoute() const route = useRoute()
const isRootPath = computedEager(() => route.name === 'settings') const isRootPath = computedEager(() => route.name === 'settings')

View File

@ -1,6 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { buildInfo } from 'virtual:build-info' import { buildInfo } from 'virtual:build-info'
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.about.label')} | ${t('nav.settings')}`,
})
let showCommit = $ref(buildInfo.env !== 'release' && buildInfo.env !== 'dev') let showCommit = $ref(buildInfo.env !== 'release' && buildInfo.env !== 'dev')
const builtTime = useFormattedDateTime(buildInfo.time) const builtTime = useFormattedDateTime(buildInfo.time)

View File

@ -1,3 +1,11 @@
<script setup lang="ts">
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.interface.label')} | ${t('nav.settings')}`,
})
</script>
<template> <template>
<MainContent back-on-small-screen> <MainContent back-on-small-screen>
<template #title> <template #title>

View File

@ -1,3 +1,11 @@
<script setup lang="ts">
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.language.label')} | ${t('nav.settings')}`,
})
</script>
<template> <template>
<MainContent back-on-small-screen> <MainContent back-on-small-screen>
<template #title> <template #title>

View File

@ -1,3 +1,11 @@
<script setup lang="ts">
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.preferences.label')} | ${t('nav.settings')}`,
})
</script>
<template> <template>
<MainContent back-on-small-screen> <MainContent back-on-small-screen>
<template #title> <template #title>

View File

@ -9,6 +9,12 @@ definePageMeta({
keepalive: false, keepalive: false,
}) })
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.profile.appearance.title')} | ${t('nav.settings')}`,
})
const account = $computed(() => currentUser.value?.account) const account = $computed(() => currentUser.value?.account)
const onlineSrc = $computed(() => ({ const onlineSrc = $computed(() => ({

View File

@ -2,6 +2,12 @@
definePageMeta({ definePageMeta({
middleware: 'auth', middleware: 'auth',
}) })
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.profile.featured_tags.label')} | ${t('nav.settings')}`,
})
</script> </script>
<template> <template>

View File

@ -2,6 +2,12 @@
definePageMeta({ definePageMeta({
middleware: 'auth', middleware: 'auth',
}) })
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.profile.label')} | ${t('nav.settings')}`,
})
</script> </script>
<template> <template>

View File

@ -2,6 +2,12 @@
import { fileOpen } from 'browser-fs-access' import { fileOpen } from 'browser-fs-access'
import type { UserLogin } from '~/types' import type { UserLogin } from '~/types'
const { t } = useI18n()
useHeadFixed({
title: () => `${t('settings.users.label')} | ${t('nav.settings')}`,
})
const loggedInUsers = useUsers() const loggedInUsers = useUsers()
async function exportTokens() { async function exportTokens() {