feat: 系统标题支持i18n

This commit is contained in:
2025-02-12 15:03:55 +08:00
parent 07e9187a12
commit b1b00a3a02
8 changed files with 19 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
title: System Title
buttons:AccountSettings: Account
buttons:LoginOut: LoginOut
buttons:Login: Login

View File

@@ -1,3 +1,4 @@
title: 系统标题
buttons:AccountSettings: 账户设置
buttons:LoginOut: 退出系统
buttons:Login: 登录

View File

@@ -1,6 +1,6 @@
{
"Version": "5.9.0",
"Title": "PureAdmin",
"Period":"2024-present",
"FixedHeader": true,
"HiddenSideBar": false,
"MultiTagsCache": false,

View File

@@ -1,20 +1,17 @@
<script setup lang="ts">
import { useI18n } from "vue-i18n";
import { getConfig } from "@/config";
const TITLE = getConfig("Title");
const { t } = useI18n();
const Period = getConfig("Period");
</script>
<template>
<footer
class="layout-footer text-[rgba(0,0,0,0.6)] dark:text-[rgba(220,220,242,0.8)]"
>
Copyright © 2020-present
<a
class="hover:text-primary"
href="https://github.com/pure-admin"
target="_blank"
>
&nbsp;{{ TITLE }}
Copyright © {{ Period }}
<a class="hover:text-primary" href="#" target="_blank">
&nbsp;{{ t("title") }}
</a>
</footer>
</template>

View File

@@ -82,18 +82,18 @@ export function useNav() {
return pureApp.getDevice;
});
const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
const { $storage } = useGlobal<GlobalPropertiesApi>();
const layout = computed(() => {
return $storage?.layout?.layout;
});
const title = computed(() => {
return $config.Title;
return transformI18n("title");
});
/** 动态title */
function changeTitle(meta: routeMetaType) {
const Title = getConfig().Title;
const Title = transformI18n("title");
if (Title) document.title = `${transformI18n(meta.title)} | ${Title}`;
else document.title = transformI18n(meta.title);
}

View File

@@ -1,5 +1,4 @@
import "@/utils/sso";
import { getConfig } from "@/config";
import NProgress from "@/utils/progress";
import { transformI18n } from "@/plugins/i18n";
import { buildHierarchyTree } from "@/utils/tree";
@@ -119,7 +118,7 @@ router.beforeEach((to: ToRouteType, _from, next) => {
if (!externalLink) {
to.matched.some(item => {
if (!item.meta.title) return "";
const Title = getConfig().Title;
const Title = transformI18n("title");
if (Title) {
document.title = `${transformI18n(item.meta.title)} | ${Title}`;
} else document.title = transformI18n(item.meta.title);

View File

@@ -1,16 +1,16 @@
import { defineStore } from "pinia";
import { type setType, store, getConfig } from "../utils";
import { transformI18n } from "@/plugins/i18n";
export const useSettingStore = defineStore({
id: "setting",
state: (): setType => ({
title: getConfig().Title,
title: transformI18n("title"),
fixedHeader: getConfig().FixedHeader,
hiddenSideBar: getConfig().HiddenSideBar
}),
getters: {
getTitle(state) {
return state.title;
getTitle() {
return transformI18n("title");
},
getFixedHeader(state) {
return state.fixedHeader;

4
types/global.d.ts vendored
View File

@@ -83,7 +83,7 @@ declare global {
*/
interface PlatformConfigs {
Version?: string;
Title?: string;
Period?: string;
FixedHeader?: boolean;
HiddenSideBar?: boolean;
MultiTagsCache?: boolean;
@@ -116,7 +116,7 @@ declare global {
*/
interface StorageConfigs {
version?: string;
title?: string;
period?: string;
fixedHeader?: boolean;
hiddenSideBar?: boolean;
multiTagsCache?: boolean;