Przeglądaj źródła

更新多语言

gcj 3 lat temu
rodzic
commit
dc901e237c

+ 1 - 1
package.json

@@ -40,7 +40,7 @@
     "vue": "2.6.10",
     "vue-element-utils": "^0.2.1",
     "vue-esign": "^1.0.5",
-    "vue-i18n": "^8.24.5",
+    "vue-i18n": "^8.26.8",
     "vue-pdf": "^4.3.0",
     "vue-router": "3.0.6",
     "vuedraggable": "^2.24.3",

+ 19 - 6
src/components/inputModules/common/Header.vue

@@ -25,7 +25,7 @@
       </ul>
     </div>
     <div class="userName">
-      <template v-if="1 == 2">
+      <template v-if="routePath == '/curGoodsDetail'">
         <el-dropdown
           style="margin-right: 16px; cursor: pointer"
           trigger="click"
@@ -45,7 +45,9 @@
         </el-dropdown>
       </template>
       <div v-if="!userMessage" class="selectLoginOrRegistration">
-        <span @click="cutLoginReg">登录</span>
+        <span @click="cutLoginReg">{{
+          routePath == "/curGoodsDetail" ? $t("Key9") : "登录"
+        }}</span>
       </div>
       <!-- 用户头像和用户名 -->
       <div class="user" v-else>
@@ -65,11 +67,11 @@
         <div class="userShow" v-show="userShow">
           <p @click="gopresonal">
             <img src="../../../assets/login/project7.png" alt="" />
-            个人中心
+            {{ routePath == "/curGoodsDetail" ? $t("Key38") : "个人中心" }}
           </p>
           <p @click="QuitLogin">
             <img src="../../../assets/login/Frame77.png" alt="" />
-            退出登录
+            {{ routePath == "/curGoodsDetail" ? $t("Key39") : "退出登录" }}
           </p>
         </div>
       </div>
@@ -92,7 +94,7 @@ import {
   getStaticContent,
   getContentFile,
 } from "@/api/ajax";
-//import { setI18nLang } from "@/utils/i18n";
+import { setI18nLang } from "@/utils/i18n";
 import { saveSession, getSession, removeSession } from "@/utils/role";
 export default {
   name: "LayoutHeader",
@@ -160,6 +162,7 @@ export default {
       lang: "",
       is_exist: "false",
       headTimer: null,
+      routePath: "",
     };
   },
   watch: {},
@@ -176,7 +179,7 @@ export default {
       let _this = this;
       _this.LoginNavIndex = command;
       if (!_this.userMessage) {
-        this.$message.warning("请重新登录");
+        // this.$message.warning("请重新登录");
         window.location.href = "/";
         return;
       }
@@ -217,6 +220,13 @@ export default {
         }
       });
     },
+    async changeLang(command) {
+      console.log(command);
+      this.lang = command.language_name;
+      let lang_type = command.language_type;
+      await setI18nLang(lang_type);
+      this.$router.go(0);
+    },
     getChildSysList() {
       let _this = this;
       let MethodName = "login_control-GetChildSysList_CanEnter_PC";
@@ -249,6 +259,8 @@ export default {
   },
   created() {
     let _this = this;
+    let path = this.$route.path;
+    this.routePath = path;
     let config = getConfig();
     if (config) {
       _this.configInfor = JSON.parse(config);
@@ -266,6 +278,7 @@ export default {
       } else {
         _this.projectName = "学习中心";
       }
+      _this.getLangList();
       _this.getNotReadMessage();
       _this.headTimer = setInterval(() => {
         _this.getNotReadMessage();

+ 199 - 191
src/router/index.js

@@ -30,211 +30,219 @@ Vue.use(Router)
  * all roles can be accessed
  */
 export const constantRoutes = [{
-        path: '/404',
-        component: () =>
-            import ('@/views/404'),
-        hidden: true
-    },
-    {
-        path: '/login',
-        component: () =>
-            import ('@/views/login'),
-        hidden: true
-    },
-    {
-        path: '/EnterSys',
-        beforeEnter: (to, from, next) => {
-            let loadingInstance = Loading.service({
-                text: '跳转中...'
-            });
-            let config = getConfig();
-            if (config) {
-                let configObj = JSON.parse(config);
-                let path = handleSysType(configObj.sys_type, 'home');
-                if (path) {
-                    loadingInstance.close();
-                    if (configObj.sys_type == 'GCLS') {
-                        next(path);
-                    } else {
-                        window.location.href = path
-                    }
-                } else {
-                    loadingInstance.close();
-                    Message({
-                        message: '此路径不存在',
-                        type: 'error',
-                        showClose: true,
-                        duration: 0
-                    })
-                }
-            }
+  path: '/404',
+  component: () =>
+    import('@/views/404'),
+  hidden: true
+},
+{
+  path: '/login',
+  component: () =>
+    import('@/views/login'),
+  hidden: true
+},
+{
+  path: '/EnterSys',
+  beforeEnter: (to, from, next) => {
+    let loadingInstance = Loading.service({
+      text: '跳转中...'
+    });
+    let config = getConfig();
+    if (config) {
+      let configObj = JSON.parse(config);
+      let path = handleSysType(configObj.sys_type, 'home');
+      if (path) {
+        loadingInstance.close();
+        if (configObj.sys_type == 'GCLS') {
+          next(path);
+        } else {
+          window.location.href = path
         }
-    },
-    // {
-    //   path: '/',
-    //   redirect: '/EnterSys',
-    //   hidden: true
-    // },
-    {
-        path: '/input',
-        component: () =>
-            import ('@/views/input'),
-        hidden: true
-    },
-    {
-        path: '/input2',
-        component: () =>
-            import ('@/views/input2'),
-        hidden: true
-    },
-    {
-        path: '/input3',
-        component: () =>
-            import ('@/views/input3'),
-        hidden: true
-    },
-    {
-        path: '/',
-        component: () =>
-            import ('@/views/courseList'),
+      } else {
+        loadingInstance.close();
+        Message({
+          message: '此路径不存在',
+          type: 'error',
+          showClose: true,
+          duration: 0
+        })
+      }
+    }
+  }
+},
+// {
+//   path: '/',
+//   redirect: '/EnterSys',
+//   hidden: true
+// },
+{
+  path: '/input',
+  component: () =>
+    import('@/views/input'),
+  hidden: true
+},
+{
+  path: '/input2',
+  component: () =>
+    import('@/views/input2'),
+  hidden: true
+},
+{
+  path: '/input3',
+  component: () =>
+    import('@/views/input3'),
+  hidden: true
+},
+{
+  path: '/',
+  component: () =>
+    import('@/views/courseList'),
 
-    },
-    {
-        path: '/preview',
-        component: () =>
-            import ('@/views/preview')
-    },
-    {
-        path: '/login',
-        component: () =>
-            import ('@/views/login')
-    },
-    {
-        path: '/courseView',
-        component: () =>
-            import ('@/views/courseView')
-    },
-    {
-        path: '/bookView',
-        component: () =>
-            import ('@/views/bookView')
-    },
-    {
-        path: '/GoodsDetail',
-        beforeEnter: (to, from, next) => {
-            let loadingInstance = Loading.service({
-                text: '跳转中...'
-            });
-            let config = getConfig();
-            if (config) {
-                let configObj = JSON.parse(config);
-                let path = handleSysType(configObj.sys_type, 'goods');
-                if (path) {
-                    loadingInstance.close();
-                    if (configObj.sys_type == 'GCLS') {
-                        next(path);
-                    } else {
-                        window.location.href = path
-                    }
-                } else {
-                    loadingInstance.close();
-                    Message({
-                        message: '此路径不存在',
-                        type: 'error',
-                        showClose: true,
-                        duration: 0
-                    })
-                }
+},
+{
+  path: '/preview',
+  component: () =>
+    import('@/views/preview')
+},
+{
+  path: '/login',
+  component: () =>
+    import('@/views/login')
+},
+{
+  path: '/courseView',
+  component: () =>
+    import('@/views/courseView')
+},
+{
+  path: '/bookView',
+  component: () =>
+    import('@/views/bookView')
+},
+{
+  path: '/GoodsDetail',
+  beforeEnter: (to, from, next) => {
+    let loadingInstance = Loading.service({
+      text: '跳转中...'
+    });
+    let config = getConfig();
+    if (config) {
+      let configObj = JSON.parse(config);
+      let path = handleSysType(configObj.sys_type, 'goods');
+      if (path) {
+        loadingInstance.close();
+        if (configObj.sys_type == 'GCLS') {
+          next(path);
+        } else {
+          if (configObj.sys_type == 'NPC' || configObj.sys_type == 'NNPE') {
+            if (path.indexOf('/curGoodsDetail') > -1) {
+              next(path);
+            } else {
+              window.location.href = path
             }
+          } else {
+            window.location.href = path
+          }
+
         }
-    },
-    {
-        path: '/curGoodsDetail',
-        component: () =>
-            import ('@/views/TextbookDetail')
-    },
-    {
-        path: '/discountCodeList',
-        component: () =>
-            import ('@/views/discountCodeList')
-    },
-    {
-        path: '/adultInput',
-        component: () =>
-            import ('@/views/adultInput')
-    },
-    {
-        path: '/adultInput2',
-        component: () =>
-            import ('@/views/adultInput2')
-    },
-    {
-        path: "/BookBrowsing",
-        name: "BookBrowsing",
-        component: () =>
-            import ('@/views/BookView2')
-    },
-    // 404 page must be placed at the end !!!
-    { path: '*', redirect: '/', hidden: true }
+      } else {
+        loadingInstance.close();
+        Message({
+          message: '此路径不存在',
+          type: 'error',
+          showClose: true,
+          duration: 0
+        })
+      }
+    }
+  }
+},
+{
+  path: '/curGoodsDetail',
+  component: () =>
+    import('@/views/TextbookDetail')
+},
+{
+  path: '/discountCodeList',
+  component: () =>
+    import('@/views/discountCodeList')
+},
+{
+  path: '/adultInput',
+  component: () =>
+    import('@/views/adultInput')
+},
+{
+  path: '/adultInput2',
+  component: () =>
+    import('@/views/adultInput2')
+},
+{
+  path: "/BookBrowsing",
+  name: "BookBrowsing",
+  component: () =>
+    import('@/views/BookView2')
+},
+// 404 page must be placed at the end !!!
+{ path: '*', redirect: '/', hidden: true }
 ]
 
 const createRouter = () =>
-    new Router({
-        // mode: 'history', // require service support
-        scrollBehavior: () => ({ y: 0 }),
-        routes: constantRoutes
-    })
+  new Router({
+    // mode: 'history', // require service support
+    scrollBehavior: () => ({ y: 0 }),
+    routes: constantRoutes
+  })
 
 const router = createRouter()
 
 // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
 export function resetRouter() {
-    const newRouter = createRouter()
-    router.matcher = newRouter.matcher // reset router
+  const newRouter = createRouter()
+  router.matcher = newRouter.matcher // reset router
 }
 export function handleSysType(sys_type, path_type) {
-    let path = '';
-    let csArr = window.location.href.split('?');
-    let cs = csArr[1];
-    switch (sys_type) {
-        case 'GCLS':
-            console.log('全球汉语教学平台')
-            if (path_type == 'home') {
-                path = '/';
-            } else if (path_type == 'goods') {
-
-                path = '/curGoodsDetail?' + cs
-            }
-            break;
-        case 'NPC':
-            if (path_type == 'home') {
-                path = '/GCLS-Book-Component-NPC/#/EnterSys';
-            } else if (path_type == 'goods') {
-
-                path = '/curGoodsDetail?' + cs
-            }
-            break;
-        case 'NNPE':
-            if (path_type == 'home') {
-                path = '/GCLS-Book-Component-NNPE/#/EnterSys';
-            } else if (path_type == 'goods') {
-
-                path = '/curGoodsDetail?' + cs
-            }
-            break;
-        case 'AILP':
-            console.log('课后三点半')
-            if (path_type == 'home') {
-                path = '/GCLS-Book-AILP/#/EnterSys';
-            } else if (path_type == 'goods') {
-                path = '/GCLS-Book-AILP/#/GoodsDetail?' + cs;
-            }
-            break;
-        default:
-            path = '';
-            break;
-    }
-    return path;
+  let path = '';
+  let csArr = window.location.href.split('?');
+  let cs = csArr[1];
+  switch (sys_type) {
+    case 'GCLS':
+      console.log('全球汉语教学平台')
+      if (path_type == 'home') {
+        path = '/';
+      } else if (path_type == 'goods') {
+        path = '/curGoodsDetail?' + cs
+      }
+      break;
+    case 'NPC':
+      if (path_type == 'home') {
+        path = '/GCLS-Book-Component-NPC/#/EnterSys';
+      } else if (path_type == 'goods') {
+        //path = '/GCLS-Book-Component-NPC/#/GoodsDetail?' + cs
+        path = '/curGoodsDetail?' + cs
+      }
+      break;
+    case 'NNPE':
+      if (path_type == 'home') {
+        path = '/GCLS-Book-Component-NNPE/#/EnterSys';
+      } else if (path_type == 'goods') {
+        //path = '/GCLS-Book-Component-NNPE/#/GoodsDetail?' + cs;
+        path = '/curGoodsDetail?' + cs
+      }
+      break;
+    case 'AILP':
+      console.log('课后三点半')
+      if (path_type == 'home') {
+        path = '/GCLS-Book-AILP/#/EnterSys';
+      } else if (path_type == 'goods') {
+        path = '/GCLS-Book-AILP/#/GoodsDetail?' + cs;
+      }
+      break;
+    default:
+      path = '';
+      break;
+  }
+  return path;
 }
 
 export default router

+ 2 - 2
src/store/modules/lang.js

@@ -1,5 +1,5 @@
 import Cookies from 'js-cookie';
-import { getContent } from '@/api/ajax';
+import { getContentFile } from '@/api/ajax';
 
 const state = {
   language_type: localStorage.getItem('language_type') || 'ZH'
@@ -17,7 +17,7 @@ const actions = {
   updateLanguageType({ commit }, language_type) {
     return new Promise((reslove, reject) => {
       let MethodName = "login_control-UpdateLanguageType";
-      getContent(MethodName, { language_type })
+      getContentFile(MethodName, { language_type })
         .then(() => {
           commit('SET_UPDATE_LANGUAGE_TYPE', language_type);
           reslove();

+ 3 - 0
src/views/TextbookDetail.vue

@@ -357,6 +357,9 @@ export default {
   async created() {
     await updateWordPack({
       word_key_list: [
+        "Key9",
+        "Key38",
+        "Key39",
         "Key52",
         "Key53",
         "Key54",

+ 2 - 2
src/views/bookView.vue

@@ -5,7 +5,7 @@
         id="content-tree"
         :class="[fullTree ? 'content-tree-full' : 'content-tree']"
       >
-        <h2 class="catelog">目录</h2>
+        <h2 class="catelog"><!-- 目录 -->{{ $t("Key612") }}</h2>
         <div style="padding-left: 8px">
           <TreeView
             ref="treeView"
@@ -143,7 +143,7 @@ export default {
         _this.fullTree = false;
         document.getElementById("content-tree").style.display = "none";
       }
-    //   scrollTo(0,0)
+      //   scrollTo(0,0)
       // } else {
       //   this.chapterId = "";
       //   this.chapterName = "";

+ 1 - 1
vue.config.js

@@ -43,7 +43,7 @@ module.exports = {
       // change xxx-api/login => mock/login
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://gcls.utschool.cn/`,
+        target: `http://gcls.helxsoft.cn/`,
         // target: `http://gcls.helxsoft.cn/`,
         changeOrigin: true,
         pathRewrite: {