Просмотр исходного кода

feat(installer): add language configuration and internationalization support

- 在 electron 安装配置中添加语言设置 language: "1033"
- 为设备检查模块添加国际化支持
- 将硬编码的中文提示文本替换为 i18n 全局翻译
- 更新英文和中文语言文件,添加设备检查相关的翻译键值对
- 重构 checkStore 中的错误消息为可本地化的字符串模板
panqiuyao 1 день назад
Родитель
Сommit
6f8237aedc

+ 2 - 1
electron/config/builder.json

@@ -37,7 +37,8 @@
     "createStartMenuShortcut": true,
     "shortcutName": "智惠映AI自动拍照机",
     "deleteAppDataOnUninstall": false,
-    "include": "build/script/installer.nsh"
+    "include": "build/script/installer.nsh",
+    "language": "1033"
   },
   "publish": [
     {

+ 9 - 0
frontend/src/locales/en.ts

@@ -611,4 +611,13 @@ export default {
     progress: 'Checking up to',
   },
 
+  // checkStore 设备检查
+  checkStore: {
+    notConnected: 'Not Connected',
+    cameraNotConnected: 'Camera not connected, please connect the camera.',
+    checkFailed: 'Check failed: {error}',
+    photoMachineConnectFailed: 'Photo machine connection failed',
+    photoMachineConnectFailedDetail: 'Photo machine connection failed. Please reconnect the photo machine and try again. You may try restarting the photo machine, unplugging and replugging the USB cable, or performing a forced initialization. Please check if the camera and turntable are in standby or sleep mode. If confirmed not in sleep, check if all connection cables are properly connected. Then try again. If the problem persists, please call: 15957854217, 18805712182.',
+  },
+
 }

+ 9 - 0
frontend/src/locales/zh-CN.ts

@@ -618,4 +618,13 @@ export default {
     progress: '共检查至',
   },
 
+  // checkStore 设备检查
+  checkStore: {
+    notConnected: '未连接',
+    cameraNotConnected: '相机未连接,请链接相机。',
+    checkFailed: '检查失败: {error}',
+    photoMachineConnectFailed: '拍照机连接失败',
+    photoMachineConnectFailedDetail: '拍照机连接失败,请重新检查,可以尝试重新启动拍照机,插拔USB口,强制初始化等,请检查相机和支撑转盘是否待机休眠。如果确认未休眠,请检查各种连接线是否,正常连上。然后再重试一次,一直无法解决问题,请致电:15957854217,18805712182。',
+  },
+
 }

+ 11 - 10
frontend/src/stores/modules/check.ts

@@ -6,6 +6,7 @@ import client from "./client";
 import {ElMessage} from "element-plus";
 import  configInfo  from '@/stores/modules/config';
 import { useUserInfo } from './user';
+import i18n from '@/locales';
 const socketStore = socket();
 const clientStore = client();
 const userInfoStore = useUserInfo();
@@ -22,22 +23,22 @@ export const checkInfo = defineStore('checkInfo', () => {
         mcu: {
             status: 0,
             msg_type: "connect_mcu",
-            msg: "未连接",
+            msg: i18n.global.t('checkStore.notConnected'),
         },
         blue_tooth: {
             status: 0,
             msg_type: "connect_bluetooth",
-            msg: "未连接",
+            msg: i18n.global.t('checkStore.notConnected'),
         },
         cam_control: {
             status: 0,
             msg_type: "cam_control",
-            msg: "未连接",
+            msg: i18n.global.t('checkStore.notConnected'),
         },
 /*        camera: {
             status: 0,
             msg_type: "camera",
-            msg: "未连接",
+            msg: i18n.global.t('checkStore.notConnected'),
         },*/
     });
 
@@ -101,7 +102,7 @@ export const checkInfo = defineStore('checkInfo', () => {
             clearInterval(CKTimerInterval)
             checkTime.value = 0
             mcu.isInitSend = false
-            return '拍照机连接失败,请重新检查,可以尝试重新启动拍照机,插拔USB口,强制初始化等,请检查相机和支撑转盘是否待机休眠。如果确认未休眠,请检查各种连接线是否,正常连上。然后再重试一次,一直无法解决问题,请致电:15957854217,18805712182。';
+            return i18n.global.t('checkStore.photoMachineConnectFailedDetail');
         }
         for (const device of Object.values(devices)) {
             if (device.status === -1  && device.msg_type !== 'connect_bluetooth') {
@@ -155,7 +156,7 @@ export const checkInfo = defineStore('checkInfo', () => {
 
                   if(!result  && checkTime.value > 0){
                       devices.cam_control.status = -1;
-                      devices.cam_control.msg = '相机未连接,请链接相机。';
+                      devices.cam_control.msg = i18n.global.t('checkStore.cameraNotConnected');
                   }
               });
 
@@ -246,7 +247,7 @@ export const checkInfo = defineStore('checkInfo', () => {
         } catch (error) {
             console.error(`Error checking ${deviceName}:`, error);
             devices[deviceName].status = -1;
-            devices[deviceName].msg = `检查失败: ${error.message}`;
+            devices[deviceName].msg = i18n.global.t('checkStore.checkFailed', { error: error.message });
         }
     };
 
@@ -276,7 +277,7 @@ export const checkInfo = defineStore('checkInfo', () => {
     const reCheckAction = async () => {
         for (const device of Object.values(devices)) {
             device.status = 0;
-            device.msg = "未连接";
+            device.msg = i18n.global.t('checkStore.notConnected');
         }
         mcu.status = -0;
         mcu.isInitSend = false;
@@ -294,11 +295,11 @@ export const checkInfo = defineStore('checkInfo', () => {
                     devices.mcu.status = -1;
                     mcu.status = -1;
                     mcu.isInitSend = false;
-                    devices.mcu.msg = '拍照机连接失败';
+                    devices.mcu.msg = i18n.global.t('checkStore.photoMachineConnectFailed');
                 }
                 if( devices.cam_control.status !== 2 ){
                     devices.cam_control.status = -1;
-                    devices.cam_control.msg = '拍照机连接失败';
+                    devices.cam_control.msg = i18n.global.t('checkStore.photoMachineConnectFailed');
                 }
             }
         },1000)

+ 16 - 17
public/dist/index.html

@@ -1,17 +1,16 @@
-<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <link rel="icon" type="image/svg+xml" href="./vite.svg" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>智惠映AI自动拍照机</title>
-    <script type="module" crossorigin src="./assets/index-C2B0o40u.js"></script>
-    <link rel="stylesheet" crossorigin href="./assets/index-B8MPi9a0.css">
-  </head>
-  <body>
-    <div id="app"></div>
-<!--    <script  src="/src/views/components/PictureEditor/js/fabric.js"></script>-->
-    <script src="./js/fabric.js"></script>
-
-  </body>
-</html>
+<!doctype html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <link rel="icon" type="image/svg+xml" href="./vite.svg" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>智惠映AI自动拍照机</title>
+    <script type="module" crossorigin src="./assets/index-DauRGOUR.js"></script>
+    <link rel="stylesheet" crossorigin href="./assets/index-CVUrA3Me.css">
+  </head>
+  <body>
+    <div id="app"></div>
+<!--    <script  src="/src/views/components/PictureEditor/js/fabric.js"></script>-->
+    <script src="./js/fabric.js"></script>

+  </body>
+</html>