feat: add TITLE in worker for custom website title (#276)

This commit is contained in:
Dream Hunter
2024-05-26 16:21:27 +08:00
committed by GitHub
parent 268f3d6446
commit 1f8edbc295
14 changed files with 93 additions and 10 deletions

View File

@@ -54,6 +54,7 @@ const getOpenSettings = async (message) => {
try {
const res = await api.fetch("/open_api/settings");
Object.assign(openSettings.value, {
title: res["title"] || "",
prefix: res["prefix"] || "",
needAuth: res["needAuth"] || false,
domains: res["domains"].map((domain) => {

View File

@@ -226,7 +226,7 @@ onBeforeUnmount(() => {
ID: {{ row.id }}
</n-tag>
<n-tag type="info">
{{ row.created_at }}
{{ `${row.created_at} UTC` }}
</n-tag>
<n-tag type="info">
FROM: {{ row.source }}
@@ -247,7 +247,7 @@ onBeforeUnmount(() => {
ID: {{ curMail.id }}
</n-tag>
<n-tag type="info">
{{ curMail.created_at }}
{{ `${curMail.created_at} UTC` }}
</n-tag>
<n-tag type="info">
FROM: {{ curMail.source }}
@@ -320,7 +320,7 @@ onBeforeUnmount(() => {
ID: {{ row.id }}
</n-tag>
<n-tag type="info">
{{ row.created_at }}
{{ `${row.created_at} UTC` }}
</n-tag>
<n-tag type="info">
FROM: {{ row.source }}
@@ -342,7 +342,7 @@ onBeforeUnmount(() => {
ID: {{ curMail.id }}
</n-tag>
<n-tag type="info">
{{ curMail.created_at }}
{{ `${curMail.created_at} UTC` }}
</n-tag>
<n-tag type="info">
FROM: {{ curMail.source }}

View File

@@ -134,7 +134,7 @@ onMounted(async () => {
ID: {{ row.id }}
</n-tag>
<n-tag type="info">
{{ row.created_at }}
{{ `${row.created_at} UTC` }}
</n-tag>
<n-tag v-if="showEMailFrom" type="info">
FROM: {{ row.address }}
@@ -155,7 +155,7 @@ onMounted(async () => {
ID: {{ curMail.id }}
</n-tag>
<n-tag type="info">
{{ curMail.created_at }}
{{ `${curMail.created_at} UTC` }}
</n-tag>
<n-tag type="info">
FROM: {{ curMail.address }}
@@ -195,7 +195,7 @@ onMounted(async () => {
ID: {{ row.id }}
</n-tag>
<n-tag type="info">
{{ row.created_at }}
{{ `${row.created_at} UTC` }}
</n-tag>
<n-tag v-if="showEMailFrom" type="info">
FROM: {{ row.address }}
@@ -217,7 +217,7 @@ onMounted(async () => {
ID: {{ curMail.id }}
</n-tag>
<n-tag type="info">
{{ curMail.created_at }}
{{ `${curMail.created_at} UTC` }}
</n-tag>
<n-tag type="info">
FROM: {{ curMail.address }}

View File

@@ -3,6 +3,7 @@ import App from './App.vue'
import { createI18n } from 'vue-i18n'
import router from './router'
import { registerSW } from 'virtual:pwa-register'
import { createHead } from '@unhead/vue'
registerSW({ immediate: true })
const i18n = createI18n({
@@ -16,7 +17,9 @@ const i18n = createI18n({
messages: {}
}
})
const head = createHead()
const app = createApp(App)
app.use(i18n)
app.use(router)
app.use(head)
app.mount('#app')

View File

@@ -7,6 +7,7 @@ export const useGlobalState = createGlobalState(
const toggleDark = useToggle(isDark)
const loading = ref(false);
const openSettings = ref({
title: '',
prefix: '',
needAuth: false,
adminContact: '',

View File

@@ -1,6 +1,7 @@
<script setup>
import { ref, h, computed, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { useHead } from '@unhead/vue'
import { useRoute, useRouter, RouterLink } from 'vue-router'
import { useIsMobile } from '../utils/composables'
import {
@@ -15,7 +16,7 @@ const message = useMessage()
const {
localeCache, toggleDark, isDark, isTelegram,
showAuth, adminAuth, auth, loading
showAuth, adminAuth, auth, loading, openSettings
} = useGlobalState()
const route = useRoute()
const router = useRouter()
@@ -182,6 +183,13 @@ const menuOptions = computed(() => [
}
]);
useHead({
title: () => openSettings.value.title || t('title'),
meta: [
{ name: "description", content: openSettings.value.description || t('title') },
]
});
onMounted(async () => {
await api.getOpenSettings(message);
});
@@ -191,7 +199,7 @@ onMounted(async () => {
<div>
<n-page-header>
<template #title>
<h3>{{ t('title') }}</h3>
<h3>{{ openSettings.title || t('title') }}</h3>
</template>
<template #avatar>
<n-avatar style="margin-left: 10px;" src="/logo.png" />