Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(i18n): add system names localization and update dashboard runtime info display

cuijianzhuang8ed089eec1b6
diff --git a/app/pages/dashboard/index.vue b/app/pages/dashboard/index.vue
index 1781997a..ec182ac3 100644
--- a/app/pages/dashboard/index.vue
+++ b/app/pages/dashboard/index.vue
@@ -208,7 +208,7 @@ const yearOptions = computed(() => {
:color="dashboardStats?.runningOn === 'docker' ? 'info' : 'success'"
variant="soft"
>
- {{ dashboardStats?.runningOn || 'unknown' }}
+ {{ $t(`dashboard.overview.section.runtimeInfo.systems.${dashboardStats?.runningOn || 'unknown'}`) }}
</UBadge>
</div>
<div>
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index 0a22aaf9..d992d9bf 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -382,7 +382,23 @@
"version": "Version",
"uptime": "Uptime",
"environment": "Environment",
- "lastUpdate": "Last Updated"
+ "lastUpdate": "Last Updated",
+ "systems": {
+ "windows": "Microsoft Windows",
+ "windows10": "Microsoft Windows 10",
+ "windows11": "Microsoft Windows 11",
+ "ubuntu": "Ubuntu",
+ "debian": "Debian",
+ "centos": "CentOS",
+ "redhat": "Red Hat Enterprise Linux",
+ "fedora": "Fedora",
+ "arch": "Arch Linux",
+ "alpine": "Alpine Linux",
+ "opensuse": "openSUSE",
+ "macos": "macOS",
+ "docker": "Docker Container",
+ "unknown": "Unknown System"
+ }
},
"memory": {
"title": "Memory Usage"
diff --git a/i18n/locales/ja.json b/i18n/locales/ja.json
index 27a62ce2..2ed6e2c9 100644
--- a/i18n/locales/ja.json
+++ b/i18n/locales/ja.json
@@ -377,7 +377,23 @@
"version": "ランニングバージョン",
"uptime": "実行時間",
"environment": "ランニング環境",
- "lastUpdate": "最後に更新されました"
+ "lastUpdate": "最後に更新されました",
+ "systems": {
+ "windows": "Microsoft Windows",
+ "windows10": "Microsoft Windows 10",
+ "windows11": "Microsoft Windows 11",
+ "ubuntu": "Ubuntu",
+ "debian": "Debian",
+ "centos": "CentOS",
+ "redhat": "Red Hat Enterprise Linux",
+ "fedora": "Fedora",
+ "arch": "Arch Linux",
+ "alpine": "Alpine Linux",
+ "opensuse": "openSUSE",
+ "macos": "macOS",
+ "docker": "Docker コンテナ",
+ "unknown": "不明なシステム"
+ }
},
"memory": {
"title": "メモリの使用"
diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.json
index aa21d352..22dfffe9 100644
--- a/i18n/locales/zh-Hans.json
+++ b/i18n/locales/zh-Hans.json
@@ -382,7 +382,23 @@
"version": "运行版本",
"uptime": "运行时间",
"environment": "运行环境",
- "lastUpdate": "最后更新"
+ "lastUpdate": "最后更新",
+ "systems": {
+ "windows": "Microsoft Windows",
+ "windows10": "Microsoft Windows 10",
+ "windows11": "Microsoft Windows 11",
+ "ubuntu": "Ubuntu",
+ "debian": "Debian",
+ "centos": "CentOS",
+ "redhat": "Red Hat Enterprise Linux",
+ "fedora": "Fedora",
+ "arch": "Arch Linux",
+ "alpine": "Alpine Linux",
+ "opensuse": "openSUSE",
+ "macos": "macOS",
+ "docker": "Docker 容器",
+ "unknown": "未知系统"
+ }
},
"memory": {
"title": "内存使用率"
diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.json
index e11bfb97..0255f18d 100644
--- a/i18n/locales/zh-Hant-HK.json
+++ b/i18n/locales/zh-Hant-HK.json
@@ -377,7 +377,23 @@
"version": "運行版本",
"uptime": "運行時間",
"environment": "運行環境",
- "lastUpdate": "最後更新"
+ "lastUpdate": "最後更新",
+ "systems": {
+ "windows": "Microsoft Windows",
+ "windows10": "Microsoft Windows 10",
+ "windows11": "Microsoft Windows 11",
+ "ubuntu": "Ubuntu",
+ "debian": "Debian",
+ "centos": "CentOS",
+ "redhat": "Red Hat Enterprise Linux",
+ "fedora": "Fedora",
+ "arch": "Arch Linux",
+ "alpine": "Alpine Linux",
+ "opensuse": "openSUSE",
+ "macos": "macOS",
+ "docker": "Docker 容器",
+ "unknown": "未知系統"
+ }
},
"memory": {
"title": "內存使用率"
diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.json
index ef2dcc0c..11b5bd70 100644
--- a/i18n/locales/zh-Hant-TW.json
+++ b/i18n/locales/zh-Hant-TW.json
@@ -377,7 +377,23 @@
"version": "運行版本",
"uptime": "運行時間",
"environment": "運行環境",
- "lastUpdate": "最後更新"
+ "lastUpdate": "最後更新",
+ "systems": {
+ "windows": "Microsoft Windows",
+ "windows10": "Microsoft Windows 10",
+ "windows11": "Microsoft Windows 11",
+ "ubuntu": "Ubuntu",
+ "debian": "Debian",
+ "centos": "CentOS",
+ "redhat": "Red Hat Enterprise Linux",
+ "fedora": "Fedora",
+ "arch": "Arch Linux",
+ "alpine": "Alpine Linux",
+ "opensuse": "openSUSE",
+ "macos": "macOS",
+ "docker": "Docker 容器",
+ "unknown": "未知系統"
+ }
},
"memory": {
"title": "內存使用率"
diff --git a/server/api/system/stats.get.ts b/server/api/system/stats.get.ts
index 23b343ba..541b713f 100644
--- a/server/api/system/stats.get.ts
+++ b/server/api/system/stats.get.ts
@@ -86,6 +86,37 @@ async function getMemoryStats() {
return memoryInfo
}
+// 系统信息映射函数
+function mapSystemInfo(distribution: string): string {
+ if (!distribution) return 'unknown'
+
+ // 转换为小写以便匹配
+ const distro = distribution.toLowerCase()
+
+ // Windows 系统映射
+ if (distro.includes('windows') || distro.includes('microsoft')) {
+ if (distro.includes('11')) return 'windows11'
+ if (distro.includes('10')) return 'windows10'
+ return 'windows'
+ }
+
+ // Linux 发行版映射
+ if (distro.includes('ubuntu')) return 'ubuntu'
+ if (distro.includes('debian')) return 'debian'
+ if (distro.includes('centos')) return 'centos'
+ if (distro.includes('redhat') || distro.includes('rhel')) return 'redhat'
+ if (distro.includes('fedora')) return 'fedora'
+ if (distro.includes('arch')) return 'arch'
+ if (distro.includes('alpine')) return 'alpine'
+ if (distro.includes('suse') || distro.includes('opensuse')) return 'opensuse'
+
+ // macOS 系统映射
+ if (distro.includes('macos') || distro.includes('darwin')) return 'macos'
+
+ // 其他情况返回原始值(处理未知系统)
+ return 'unknown'
+}
+
export default eventHandler(async (event) => {
await requireUserSession(event)
@@ -172,38 +203,23 @@ export default eventHandler(async (event) => {
})
}
- // 获取操作系统信息,处理编码问题
- let osInfo = 'unknown'
- try {
- if (await checkIfDocker()) {
- osInfo = 'docker'
- } else {
- const info = await si.osInfo()
- // 清理和标准化操作系统信息,避免编码问题
- let distro = info.distro || info.platform || 'unknown'
-
- // 处理常见的Windows系统名称
- if (distro.toLowerCase().includes('windows')) {
- if (distro.includes('11')) {
- osInfo = 'Microsoft Windows 11'
- } else if (distro.includes('10')) {
- osInfo = 'Microsoft Windows 10'
- } else {
- osInfo = 'Microsoft Windows'
- }
- } else {
- // 对于其他系统,尝试清理非ASCII字符
- osInfo = distro.replace(/[^\x00-\x7F]/g, '').trim() || 'unknown'
- }
+ // 获取系统信息并映射
+ let systemInfo = 'unknown'
+ if (await checkIfDocker()) {
+ systemInfo = 'docker'
+ } else {
+ try {
+ const osInfo = await si.osInfo()
+ systemInfo = mapSystemInfo(osInfo.distro)
+ } catch (error) {
+ console.warn('Failed to get OS info:', error)
+ systemInfo = 'unknown'
}
- } catch (error) {
- console.warn('Failed to get OS info:', error)
- osInfo = 'unknown'
}
return {
uptime: process.uptime() || 0,
- runningOn: osInfo,
+ runningOn: systemInfo,
memory: (await getMemoryStats()) || { used: 0, total: 0 },
photos: {
total: totalPhotos?.count || 0,