瀏覽代碼

feat: update language settings and localization for improved multilingual support

- Change VITE_APP_LANG from en to zh-cn in .env.development for development environment consistency
- Refactor layout components to utilize translation function for menu items and dialog labels
- Enhance localization files with new terms for password management and user actions
yb 3 周之前
父節點
當前提交
9a37660bf7
共有 4 個文件被更改,包括 50 次插入26 次删除
  1. 1 1
      .env.development
  2. 23 23
      src/layout/index.vue
  3. 13 1
      src/locales/en.json
  4. 13 1
      src/locales/zh-cn.json

+ 1 - 1
.env.development

@@ -4,7 +4,7 @@ NODE_ENV=development
 # 应用标题
 VITE_APP_TITLE=摄像头管理系统
 
-VITE_APP_LANG=en
+VITE_APP_LANG=zh-cn
 
 # API 基础路径 (通过 Vite proxy 转发到 https://tg-live-game.pwtk.cc)
 VITE_APP_BASE_API=/api

+ 23 - 23
src/layout/index.vue

@@ -19,43 +19,43 @@
       >
         <el-menu-item index="/machine">
           <el-icon><Monitor /></el-icon>
-          <template #title>机器管理</template>
+          <template #title>{{ t('机器管理') }}</template>
         </el-menu-item>
 
         <el-menu-item index="/camera">
           <el-icon><VideoCamera /></el-icon>
-          <template #title>摄像头管理</template>
+          <template #title>{{ t('摄像头管理') }}</template>
         </el-menu-item>
 
         <el-menu-item index="/user">
           <el-icon><UserFilled /></el-icon>
-          <template #title>用户管理</template>
+          <template #title>{{ t('用户管理') }}</template>
         </el-menu-item>
         <el-menu-item index="/video-demo">
           <el-icon><VideoPlay /></el-icon>
-          <template #title>视频测试</template>
+          <template #title>{{ t('视频测试') }}</template>
         </el-menu-item>
 
         <el-sub-menu index="/stream">
           <template #title>
             <el-icon><Film /></el-icon>
-            <span>Cloudflare Stream</span>
+            <span>{{ t('Cloudflare Stream') }}</span>
           </template>
           <el-menu-item index="/stream/videos">
             <el-icon><Film /></el-icon>
-            <template #title>视频管理</template>
+            <template #title>{{ t('视频管理') }}</template>
           </el-menu-item>
           <el-menu-item index="/stream/live">
             <el-icon><VideoCameraFilled /></el-icon>
-            <template #title>直播管理</template>
+            <template #title>{{ t('直播管理') }}</template>
           </el-menu-item>
           <el-menu-item index="/stream/config">
             <el-icon><Setting /></el-icon>
-            <template #title>Stream 配置</template>
+            <template #title>{{ t('Stream 配置') }}</template>
           </el-menu-item>
           <el-menu-item index="/stream-test">
             <el-icon><Monitor /></el-icon>
-            <template #title>快速测试</template>
+            <template #title>{{ t('快速测试') }}</template>
           </el-menu-item>
         </el-sub-menu>
       </el-menu>
@@ -85,8 +85,8 @@
             </span>
             <template #dropdown>
               <el-dropdown-menu>
-                <el-dropdown-item command="changePassword">修改密码</el-dropdown-item>
-                <el-dropdown-item command="logout">退出登录</el-dropdown-item>
+                <el-dropdown-item command="changePassword">{{ t('修改密码') }}</el-dropdown-item>
+                <el-dropdown-item command="logout">{{ t('退出登录') }}</el-dropdown-item>
               </el-dropdown-menu>
             </template>
           </el-dropdown>
@@ -103,26 +103,26 @@
     </el-container>
 
     <!-- 修改密码弹窗 -->
-    <el-dialog v-model="passwordDialogVisible" title="修改密码" width="400px" :close-on-click-modal="false">
+    <el-dialog v-model="passwordDialogVisible" :title="t('修改密码')" width="400px" :close-on-click-modal="false">
       <el-form ref="passwordFormRef" :model="passwordForm" :rules="passwordRules" label-width="80px">
-        <el-form-item label="原密码" prop="oldPassword">
+        <el-form-item :label="t('原密码')" prop="oldPassword">
           <el-input v-model="passwordForm.oldPassword" type="password" show-password placeholder="请输入原密码" />
         </el-form-item>
-        <el-form-item label="新密码" prop="newPassword">
+        <el-form-item :label="t('新密码')" prop="newPassword">
           <el-input v-model="passwordForm.newPassword" type="password" show-password placeholder="请输入新密码" />
         </el-form-item>
-        <el-form-item label="确认密码" prop="confirmPassword">
+        <el-form-item :label="t('确认密码')" prop="confirmPassword">
           <el-input
             v-model="passwordForm.confirmPassword"
             type="password"
             show-password
-            placeholder="请再次输入新密码"
+            :placeholder="t('请再次输入新密码')"
           />
         </el-form-item>
       </el-form>
       <template #footer>
-        <el-button @click="passwordDialogVisible = false">取消</el-button>
-        <el-button type="primary" :loading="passwordLoading" @click="handleChangePassword">确定</el-button>
+        <el-button @click="passwordDialogVisible = false">{{ t('取消') }}</el-button>
+        <el-button type="primary" :loading="passwordLoading" @click="handleChangePassword">{{ t('确定') }}</el-button>
       </template>
     </el-dialog>
   </el-container>
@@ -182,20 +182,20 @@ const passwordForm = reactive({
 
 const validateConfirmPassword = (_rule: any, value: string, callback: any) => {
   if (value !== passwordForm.newPassword) {
-    callback(new Error('两次输入的密码不一致'))
+    callback(new Error(t('两次输入的密码不一致')))
   } else {
     callback()
   }
 }
 
 const passwordRules: FormRules = {
-  oldPassword: [{ required: true, message: '请输入原密码', trigger: 'blur' }],
+  oldPassword: [{ required: true, message: t('请输入原密码'), trigger: 'blur' }],
   newPassword: [
-    { required: true, message: '请输入新密码', trigger: 'blur' },
-    { min: 6, message: '密码长度不能少于6位', trigger: 'blur' }
+    { required: true, message: t('请输入新密码'), trigger: 'blur' },
+    { min: 6, message: t('密码长度不能少于6位'), trigger: 'blur' }
   ],
   confirmPassword: [
-    { required: true, message: '请再次输入新密码', trigger: 'blur' },
+    { required: true, message: t('请再次输入新密码'), trigger: 'blur' },
     { validator: validateConfirmPassword, trigger: 'blur' }
   ]
 }

+ 13 - 1
src/locales/en.json

@@ -10,5 +10,17 @@
   "直播管理": "Live Management",
   "Stream 配置": "Stream Configuration",
   "审计日志": "Audit Log",
-  "观看统计": "Watching Statistics"
+  "观看统计": "Watching Statistics",
+  "修改密码": "Change Password",
+  "退出登录": "Logout",
+  "原密码": "Old Password",
+  "新密码": "New Password",
+  "确认密码": "Confirm Password",
+  "请再次输入新密码": "Please enter the new password again",
+  "密码长度不能少于6位": "Password length must be at least 6 characters",
+  "请输入原密码": "Please enter the old password",
+  "请输入新密码": "Please enter the new password",
+  "两次输入的密码不一致": "The passwords entered twice do not match",
+  "取消": "Cancel",
+  "确定": "Confirm"
 }

+ 13 - 1
src/locales/zh-cn.json

@@ -10,5 +10,17 @@
   "直播管理": "直播管理",
   "Stream 配置": "Stream 配置",
   "审计日志": "审计日志",
-  "观看统计": "观看统计"
+  "观看统计": "观看统计",
+  "修改密码": "修改密码",
+  "退出登录": "退出登录",
+  "原密码": "原密码",
+  "新密码": "新密码",
+  "确认密码": "确认密码",
+  "请再次输入新密码": "请再次输入新密码",
+  "密码长度不能少于6位": "密码长度不能少于6位",
+  "请输入原密码": "请输入原密码",
+  "请输入新密码": "请输入新密码",
+  "两次输入的密码不一致": "两次输入的密码不一致",
+  "取消": "取消",
+  "确定": "确定"
 }