Browse Source

feat: 中英文件

anxiaoxia 2 days ago
parent
commit
8c6179dffc
5 changed files with 69 additions and 2 deletions
  1. 1 1
      package.json
  2. 26 0
      src/locales/en.json
  3. 14 0
      src/locales/index.js
  4. 26 0
      src/locales/zh-CN.json
  5. 2 1
      src/main.ts

+ 1 - 1
package.json

@@ -42,6 +42,7 @@
     "vue": "^3.5.13",
     "vue": "^3.5.13",
     "vue-class-component": "^8.0.0-0",
     "vue-class-component": "^8.0.0-0",
     "vue-draggable-next": "^2.0.1",
     "vue-draggable-next": "^2.0.1",
+    "vue-i18n": "^11.0.0-rc.1",
     "vue-image-crop-upload": "^2.5.0",
     "vue-image-crop-upload": "^2.5.0",
     "vue-property-decorator": "^9.1.2",
     "vue-property-decorator": "^9.1.2",
     "vue-router": "4.0",
     "vue-router": "4.0",
@@ -105,7 +106,6 @@
     "vue-jest": "^5.0.0-alpha.8",
     "vue-jest": "^5.0.0-alpha.8",
     "webpackbar": "^5.0.0-3"
     "webpackbar": "^5.0.0-3"
   },
   },
-
   "lint-staged": {
   "lint-staged": {
     "*.{js,jsx,vue,ts,tsx}": [
     "*.{js,jsx,vue,ts,tsx}": [
       "vue-cli-service lint",
       "vue-cli-service lint",

+ 26 - 0
src/locales/en.json

@@ -0,0 +1,26 @@
+ 
+{
+    "login": {
+      "title": "Login",
+      "tips": "Welcome back!"
+    },
+    "env":{
+        "humidity":"Humidity",
+        "temperature":"Temperature"
+    },
+    "audio":{
+        "title":"Audio"
+    },
+    "screen":{
+        "title":"Casting"
+    },
+    "lamp":{
+        "title":"Lighting"
+    },
+    "air":{
+        "title":"AC"
+    },
+    "curtains":{
+        "title":"Curtains"
+    }
+  }

+ 14 - 0
src/locales/index.js

@@ -0,0 +1,14 @@
+import { createI18n } from 'vue-i18n'
+import en from './en.json'
+import zhCN from './zh-CN.json'
+
+const i18n = createI18n({
+  legacy: false,        // 关闭兼容模式
+  locale: 'zh-CN',      // 默认语言
+  messages: {
+    'en': en,
+    'zh-CN': zhCN
+  }
+})
+
+export default i18n

+ 26 - 0
src/locales/zh-CN.json

@@ -0,0 +1,26 @@
+{
+    "login": {
+      "title": "登录",
+      "tips": "欢迎回来!"
+    },
+    "env":{
+        "humidity":"湿度",
+        "temperature":"温度"
+    },
+    "audio":{
+        "title":"音响"
+    },
+    "screen":{
+        "title":"投屏"
+    },
+    "lamp":{
+        "title":"照明"
+    },
+    "air":{
+        "title":"空调"
+    },
+    "curtains":{
+        "title":"窗帘"
+    }
+
+  }

+ 2 - 1
src/main.ts

@@ -10,6 +10,7 @@ import '@/utils/flexible.js';
 import 'default-passive-events';
 import 'default-passive-events';
 import { Icon, Loading, Popup, Tab, Tabs, Toast } from 'vant';
 import { Icon, Loading, Popup, Tab, Tabs, Toast } from 'vant';
 import 'vant/lib/index.css';
 import 'vant/lib/index.css';
+import i18n from '@/locales'
 const app = createApp(App)
 const app = createApp(App)
 
 
 // Toast.setDefaultOptions()
 // Toast.setDefaultOptions()
@@ -27,4 +28,4 @@ app.config.globalProperties.$fileUrl = 'http://api.sagacloud.cn/dp-auxiliary/ima
 app.config.globalProperties.$toast = Toast
 app.config.globalProperties.$toast = Toast
 app.config.globalProperties.$loadingStart = loadingStart
 app.config.globalProperties.$loadingStart = loadingStart
 app.config.globalProperties.$loadinngEnd = loadinngEnd
 app.config.globalProperties.$loadinngEnd = loadinngEnd
-app.use(Toast).use(Icon).use(Tabs).use(Tab).use(Loading).use(Popup).use(store).use(router).mount('#app')
+app.use(Toast).use(Icon).use(Tabs).use(Tab).use(Loading).use(Popup).use(store).use(router).use(i18n).mount('#app')