From 8d5871ca395462ecc535d37fd634eb680c8128fb Mon Sep 17 00:00:00 2001 From: chenqi Date: Thu, 25 Jun 2026 16:36:18 +0800 Subject: [PATCH] feat(i18n): translate system title, tenant name, shorten English translation, add tooltip --- healthlink-his-ui/src/i18n/autoTranslate.js | 3 + .../src/layout/components/Sidebar/Logo.vue | 71 ++++++++++++------- healthlink-his-ui/src/views/login.vue | 12 +++- 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/healthlink-his-ui/src/i18n/autoTranslate.js b/healthlink-his-ui/src/i18n/autoTranslate.js index abc1b9194..26725b456 100644 --- a/healthlink-his-ui/src/i18n/autoTranslate.js +++ b/healthlink-his-ui/src/i18n/autoTranslate.js @@ -83,6 +83,9 @@ const translationDict = { '首页': 'Home', '仪表盘': 'Dashboard', '个人中心': 'Profile', '帮助': 'Help', '关于': 'About', '版本': 'Version', '在线': 'Online', '离线': 'Offline', '已连接': 'Connected', '未连接': 'Disconnected', + '医院信息管理系统': 'Hospital HIS', '医院管理系统': 'Hospital HIS', + '信息管理系统': 'Info System', '管理系统': 'Management System', + '经创贺联': 'HealthLink', 'HIS': 'HIS', '元': 'Yuan', '次': 'Times', '天': 'Days', '小时': 'Hours', '分钟': 'Minutes', '条': 'Items', '个': 'Items', '项': 'Items', '次/分': 'Times/min', // 菜单专用术语 diff --git a/healthlink-his-ui/src/layout/components/Sidebar/Logo.vue b/healthlink-his-ui/src/layout/components/Sidebar/Logo.vue index fb5a79ce1..65f73c109 100755 --- a/healthlink-his-ui/src/layout/components/Sidebar/Logo.vue +++ b/healthlink-his-ui/src/layout/components/Sidebar/Logo.vue @@ -7,31 +7,37 @@ sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground, }" > - - + @@ -41,8 +47,9 @@ import useSettingsStore from '@/store/modules/settings'; import useUserStore from '@/store/modules/user'; import {computed} from 'vue'; import {useI18n} from 'vue-i18n'; +import {autoTranslate} from '@/i18n/autoTranslate'; -const {t} = useI18n(); +const {t, locale} = useI18n(); defineProps({ collapse: { @@ -51,11 +58,25 @@ defineProps({ }, }); -const title = computed(() => import.meta.env.VITE_APP_TITLE || t('sidebar.defaultTitle')); const settingsStore = useSettingsStore(); const userStore = useUserStore(); + +// 系统标题:优先用 i18n 翻译,fallback 到环境变量 +const title = computed(() => { + const envTitle = import.meta.env.VITE_APP_TITLE; + if (locale.value === 'zh-CN') return envTitle || t('sidebar.defaultTitle'); + // 非中文时,用自动翻译 + return autoTranslate(envTitle || '医院信息管理系统'); +}); + +// 租户/医院名称:非中文时尝试自动翻译 +const displayName = computed(() => { + const name = userStore.tenantName || userStore.hospitalName || userStore.orgName || ''; + if (!name || locale.value === 'zh-CN') return name; + return autoTranslate(name); +}); + const sideTheme = computed(() => settingsStore.sideTheme); -const displayName = computed(() => userStore.tenantName || userStore.hospitalName || userStore.orgName || ''); const textColor = computed(() => { return sideTheme.value === 'theme-dark' ? '#fff' : '#303133'; diff --git a/healthlink-his-ui/src/views/login.vue b/healthlink-his-ui/src/views/login.vue index f85da17e9..7c5a6ad8d 100755 --- a/healthlink-his-ui/src/views/login.vue +++ b/healthlink-his-ui/src/views/login.vue @@ -15,7 +15,7 @@ />

- {{ currentTenantName || settings.systemName }} + {{ brandTitle }}

{{ $t('login.systemSubtitle') }} @@ -229,7 +229,7 @@  · {{ $t('login.backendVersion') }} v{{ formattedBackendVersion }}

@@ -250,6 +250,7 @@ import useUserStore from '@/store/modules/user'; import {ElMessage} from 'element-plus'; import {getSystemVersion} from '@/api/system/info'; import logoNew from '@/assets/logo/LOGO.jpg'; +import {autoTranslate} from '@/i18n/autoTranslate'; const userStore = useUserStore(); const route = useRoute(); @@ -304,6 +305,13 @@ const loginForm = ref({ const tenantOptions = ref([]); const currentTenantName = ref(''); +// 品牌标题:非中文时自动翻译 +const brandTitle = computed(() => { + const name = currentTenantName.value || settings.systemName; + if (!name || locale.value === 'zh-CN') return name; + return autoTranslate(name); +}); + const loginRules = computed(() => ({ username: [{ required: true, trigger: 'blur', message: t('login.validationUsername') }], password: [{ required: true, trigger: 'blur', message: t('login.validationPassword') }],