feat: add DOMAIN_LABELS for chinese domain label (#322)

This commit is contained in:
Dream Hunter
2024-06-28 22:25:06 +08:00
committed by GitHub
parent de7c3d5176
commit 881e66e484
17 changed files with 1900 additions and 1659 deletions
+3 -2
View File
@@ -53,15 +53,16 @@ const apiFetch = async (path, options = {}) => {
const getOpenSettings = async (message) => {
try {
const res = await api.fetch("/open_api/settings");
const domainLabels = res["domainLabels"] || [];
Object.assign(openSettings.value, {
title: res["title"] || "",
prefix: res["prefix"] || "",
minAddressLen: res["minAddressLen"] || 1,
maxAddressLen: res["maxAddressLen"] || 30,
needAuth: res["needAuth"] || false,
domains: res["domains"].map((domain) => {
domains: res["domains"].map((domain, index) => {
return {
label: domain,
label: domainLabels.length > index ? domainLabels[index] : domain,
value: domain
}
}),
+1
View File
@@ -15,6 +15,7 @@ export const useGlobalState = createGlobalState(
enableUserDeleteEmail: false,
enableAutoReply: false,
enableIndexAbout: false,
/** @type {Array<{label: string, value: string}>} */
domains: [],
copyright: 'Dream Hunter',
cfTurnstileSiteKey: '',
+14 -3
View File
@@ -1,6 +1,6 @@
<script setup>
import useClipboard from 'vue-clipboard3'
import { onMounted, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import { Copy, User, ExchangeAlt } from '@vicons/fa'
@@ -19,7 +19,7 @@ const router = useRouter()
const {
jwt, settings, showAddressCredential, userJwt,
isTelegram
isTelegram, openSettings
} = useGlobalState()
const { locale, t } = useI18n({
@@ -52,6 +52,17 @@ const { locale, t } = useI18n({
const showChangeAddress = ref(false)
const showTelegramChangeAddress = ref(false)
const showLocalAddress = ref(false)
const addressLabel = computed(() => {
if (settings.value.address) {
const domain = settings.value.address.split('@')[1]
const domainLabel = openSettings.value.domains.find(
d => d.value === domain
)?.label;
if (!domainLabel) return settings.value.address;
return settings.value.address.replace('@' + domain, `@${domainLabel}`);
}
return settings.value.address;
})
const copy = async () => {
try {
@@ -79,7 +90,7 @@ onMounted(async () => {
<div v-else-if="settings.address">
<n-alert type="info" :show-icon="false">
<span>
<b>{{ settings.address }}</b>
<b>{{ addressLabel }}</b>
<n-button v-if="isTelegram" style="margin-left: 10px" @click="showTelegramChangeAddress = true"
size="small" tertiary type="primary">
<n-icon :component="ExchangeAlt" /> {{ t('addressManage') }}