Browse Source

多语言

natasha 3 years ago
parent
commit
2c463b99ba

+ 17 - 2
src/App.vue

@@ -1,12 +1,27 @@
 <template>
 <template>
-  <div id="app">
+  <div id="app" :dir="dir">
     <keep-alive>
     <keep-alive>
       <router-view v-if="$route.meta.keepAlive" />
       <router-view v-if="$route.meta.keepAlive" />
     </keep-alive>
     </keep-alive>
     <router-view v-if="!$route.meta.keepAlive" />
     <router-view v-if="!$route.meta.keepAlive" />
   </div>
   </div>
 </template>
 </template>
-
+<script>
+export default {
+  name: "App",
+  data() {
+    return {
+      dir: "ltr",
+    };
+  },
+  created() {
+    let lang_type = localStorage.getItem("language_type");
+    if (lang_type == "AR") {
+      this.dir = "rtl";
+    }
+  },
+};
+</script>
 <style>
 <style>
 * {
 * {
   margin: 0;
   margin: 0;

+ 6 - 3
src/components/Header.vue

@@ -24,7 +24,7 @@
     <div class="userName">
     <div class="userName">
       <template>
       <template>
         <el-dropdown
         <el-dropdown
-          style="margin-right: 16px; cursor: pointer"
+          style="cursor: pointer"
           trigger="click"
           trigger="click"
           @command="changeLang"
           @command="changeLang"
         >
         >
@@ -57,7 +57,7 @@
           "
           "
           alt=""
           alt=""
         />
         />
-        <span @click="userShow = !userShow">{{
+        <span @click="userShow = !userShow" :class="[language_type=='AR'?'languageAR':'']">{{
           userMessage.user_real_name
           userMessage.user_real_name
         }}</span>
         }}</span>
         <div class="userShow" v-show="userShow">
         <div class="userShow" v-show="userShow">
@@ -382,7 +382,6 @@ export default {
       display: flex;
       display: flex;
       justify-content: center;
       justify-content: center;
       align-items: center;
       align-items: center;
-      margin-left: 23px;
       cursor: pointer;
       cursor: pointer;
       img {
       img {
         width: 24px;
         width: 24px;
@@ -419,6 +418,7 @@ export default {
       cursor: pointer;
       cursor: pointer;
       position: relative;
       position: relative;
       color: #000000;
       color: #000000;
+      margin: 0 23px 0 16px;
       > img {
       > img {
         width: 34px;
         width: 34px;
         height: 34px;
         height: 34px;
@@ -427,6 +427,9 @@ export default {
         color: #000000;
         color: #000000;
         font-size: 16px;
         font-size: 16px;
         padding-left: 10px;
         padding-left: 10px;
+        &.languageAR{
+            padding: 0 10px 0 0;
+        }
       }
       }
       .userShow {
       .userShow {
         position: absolute;
         position: absolute;

+ 4 - 2
src/components/learnCenter/Course.vue

@@ -6,7 +6,7 @@
         <span>
         <span>
           <img src="../../assets/learncenter/listTitleImg1.png" alt="" />
           <img src="../../assets/learncenter/listTitleImg1.png" alt="" />
         </span>
         </span>
-        课程
+        <b>课程</b>
       </div>
       </div>
       <div class="more" @click="gotolist">
       <div class="more" @click="gotolist">
         <span> 查看更多 </span>
         <span> 查看更多 </span>
@@ -87,7 +87,6 @@ export default {
         height: 42px;
         height: 42px;
         border-radius: 50%;
         border-radius: 50%;
         background: linear-gradient(215.75deg, #ffa05a 17.74%, #ffb952 82.17%);
         background: linear-gradient(215.75deg, #ffa05a 17.74%, #ffb952 82.17%);
-        margin-right: 16px;
         display: flex;
         display: flex;
         align-items: center;
         align-items: center;
         justify-content: center;
         justify-content: center;
@@ -96,6 +95,9 @@ export default {
           height: 15px;
           height: 15px;
         }
         }
       }
       }
+      b{
+          margin: 0 16px;
+      }
     }
     }
     .title2 {
     .title2 {
       font-weight: bold;
       font-weight: bold;

+ 30 - 9
src/components/learnCenter/HeaderOne.vue

@@ -1,27 +1,27 @@
 <template>
 <template>
   <div :class="type ? 'HeaderTwo' : 'HeaderOne'">
   <div :class="type ? 'HeaderTwo' : 'HeaderOne'">
     <div>
     <div>
-      <span class="befor" @click="gohome">
+      <span class="befor" @click="gohome" :class="[language_type=='AR'?'languageAR':'']">
         <img src="../../assets/learncenter/Frame3.png" alt="" />
         <img src="../../assets/learncenter/Frame3.png" alt="" />
       </span>
       </span>
-      <span v-if="classilfyID"> > </span>
+      <span v-if="classilfyID" :class="[language_type=='AR'?'languageAR':'']"> > </span>
       <span
       <span
         v-if="classilfyID"
         v-if="classilfyID"
-        v-text="classilfyID == 'TEXTBOOK' ? '教材' : '课程'"
+        v-text="classilfyID == 'TEXTBOOK' ? $t('Key44') : '课程'"
         @click="back"
         @click="back"
       ></span>
       ></span>
-      <span class="arrows" v-if="title"> > </span>
+      <span class="arrows" v-if="title" :class="[language_type=='AR'?'languageAR':'']"> > </span>
       <span @click="back" class="text">{{ title }}</span>
       <span @click="back" class="text">{{ title }}</span>
       <!-- <span class="text" v-if="type"> TEXTBOOK </span> -->
       <!-- <span class="text" v-if="type"> TEXTBOOK </span> -->
 
 
-      <span class="arrows" v-if="text"> > </span>
+      <span class="arrows" v-if="text" :class="[language_type=='AR'?'languageAR':'']"> > </span>
       <span class="text" v-if="text">{{ name }}</span>
       <span class="text" v-if="text">{{ name }}</span>
     </div>
     </div>
     <div>
     <div>
       <div :class="type ? 'Headseek' : 'seek'" @keydown="keyDownSeekData">
       <div :class="type ? 'Headseek' : 'seek'" @keydown="keyDownSeekData">
         <el-input
         <el-input
           style="width: 300px"
           style="width: 300px"
-          placeholder="请输入内容"
+          :placeholder="$t('Key46')"
           v-model="SeekName"
           v-model="SeekName"
         >
         >
         </el-input>
         </el-input>
@@ -30,12 +30,14 @@
           @click="gotoSeekResult"
           @click="gotoSeekResult"
           src="../../assets/learncenter/Group2149.png"
           src="../../assets/learncenter/Group2149.png"
           alt=""
           alt=""
+          :class="[language_type=='AR'?'languageAR':'']"
         />
         />
         <img
         <img
           v-else
           v-else
           @click="gotoSeekResult"
           @click="gotoSeekResult"
           src="../../assets/learncenter/Group 2148.png"
           src="../../assets/learncenter/Group 2148.png"
           alt=""
           alt=""
+          :class="[language_type=='AR'?'languageAR':'']"
         />
         />
       </div>
       </div>
     </div>
     </div>
@@ -45,6 +47,8 @@
 <script>
 <script>
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
 //例如:import 《组件名称》from ‘《组件路径》';
+import { mapGetters } from "vuex";
+import { updateWordPack } from "@/utils/i18n";
 export default {
 export default {
   //import引入的组件需要注入到对象中才能使用
   //import引入的组件需要注入到对象中才能使用
   components: {},
   components: {},
@@ -64,7 +68,9 @@ export default {
     };
     };
   },
   },
   //计算属性 类似于data概念
   //计算属性 类似于data概念
-  computed: {},
+  computed: {
+      ...mapGetters(["language_type"]),
+  },
   //监控data中数据变化
   //监控data中数据变化
   watch: {
   watch: {
     keycode(newval, oldval) {
     keycode(newval, oldval) {
@@ -90,7 +96,7 @@ export default {
 
 
     gotoSeekResult() {
     gotoSeekResult() {
       if (this.SeekName == "") {
       if (this.SeekName == "") {
-        this.$message.warning("请输入内容");
+        this.$message.warning(this.$t('Key46'));
         return;
         return;
       }
       }
       // 如果不是在搜索结果页面就跳到搜索结果页面
       // 如果不是在搜索结果页面就跳到搜索结果页面
@@ -119,6 +125,10 @@ export default {
   //生命周期 - 创建完成(可以访问当前this实例)
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
   created() {
     this.SeekName = this.keycode || "";
     this.SeekName = this.keycode || "";
+    updateWordPack({
+        word_key_list: ["Key44","Key46"],
+    });
+    console.log(this.title)
   },
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {},
   mounted() {},
@@ -151,8 +161,12 @@ export default {
     display: flex;
     display: flex;
     align-items: center;
     align-items: center;
     > span {
     > span {
-      margin-left: 15px;
+    //   margin-left: 15px;
+      margin: 0 7px;
       cursor: pointer;
       cursor: pointer;
+    //   &.languageAR{
+    //       margin: 0 7px;
+    //   }
     }
     }
     .befor {
     .befor {
       img {
       img {
@@ -168,6 +182,9 @@ export default {
       position: relative;
       position: relative;
       right: 10px;
       right: 10px;
     }
     }
+    .languageAR::before {
+      right: -10px;
+    }
     .text {
     .text {
       font-weight: bold;
       font-weight: bold;
       font-size: 16px;
       font-size: 16px;
@@ -186,6 +203,10 @@ export default {
       right: 19px;
       right: 19px;
       top: 7px;
       top: 7px;
       cursor: pointer;
       cursor: pointer;
+      &.languageAR{
+          left: 19px;
+          right: auto;
+      }
     }
     }
   }
   }
 }
 }

+ 10 - 2
src/components/learnCenter/Textbook.vue

@@ -6,7 +6,7 @@
         <span>
         <span>
           <img src="../../assets/learncenter/listTitleImg2.png" alt="" />
           <img src="../../assets/learncenter/listTitleImg2.png" alt="" />
         </span>
         </span>
-        教材
+        <b>{{$t("Key44")}}</b>
       </div>
       </div>
       <div class="more" @click="gotolist">
       <div class="more" @click="gotolist">
         <span> 查看更多 </span>
         <span> 查看更多 </span>
@@ -30,6 +30,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
+import { updateWordPack } from "@/utils/i18n";
 export default {
 export default {
   props: ["classList", "type"],
   props: ["classList", "type"],
   data() {
   data() {
@@ -63,6 +64,11 @@ export default {
       window.open(href, "_blank");
       window.open(href, "_blank");
     },
     },
   },
   },
+  created(){
+    updateWordPack({
+        word_key_list: ["Key44","Key46"],
+    });
+  },
 };
 };
 </script>
 </script>
 
 
@@ -87,7 +93,6 @@ export default {
         height: 42px;
         height: 42px;
         border-radius: 50%;
         border-radius: 50%;
         background: linear-gradient(28.36deg, #ff7d8a 13.41%, #ff616c 84.14%);
         background: linear-gradient(28.36deg, #ff7d8a 13.41%, #ff616c 84.14%);
-        margin-right: 16px;
         display: flex;
         display: flex;
         align-items: center;
         align-items: center;
         justify-content: center;
         justify-content: center;
@@ -96,6 +101,9 @@ export default {
           height: 15px;
           height: 15px;
         }
         }
       }
       }
+      b{
+          margin: 0 16px;
+      }
     }
     }
     .title2 {
     .title2 {
       font-weight: bold;
       font-weight: bold;

+ 1 - 1
src/main.js

@@ -17,7 +17,6 @@ import "@/common/font/font.css"
 import "@/permission"
 import "@/permission"
 import i18n from "@/utils/i18n"
 import i18n from "@/utils/i18n"
 
 
-Vue.use(i18n);
 // element 下拉框下拉加载
 // element 下拉框下拉加载
 Vue.directive('loadmore', {
 Vue.directive('loadmore', {
     bind(el, binding) {
     bind(el, binding) {
@@ -36,5 +35,6 @@ Vue.directive('loadmore', {
 new Vue({
 new Vue({
     router,
     router,
     store,
     store,
+    i18n,
     render: h => h(App)
     render: h => h(App)
 }).$mount('#app')
 }).$mount('#app')

+ 1 - 11
src/store/modules/lang.js

@@ -18,17 +18,7 @@ const actions = {
     updateLanguageType({ commit }, language_type) {
     updateLanguageType({ commit }, language_type) {
         return new Promise((reslove, reject) => {
         return new Promise((reslove, reject) => {
             let MethodName = "login_control-UpdateLanguageType";
             let MethodName = "login_control-UpdateLanguageType";
-            let userInfor = JSON.parse(getToken());
-
-            let UserCode = "",
-                UserType = "",
-                SessionID = "";
-            if (userInfor) {
-                UserCode = userInfor.user_code;
-                UserType = userInfor.user_type;
-                SessionID = userInfor.session_id;
-            }
-            getContent(MethodName, UserCode, UserType, SessionID, { language_type })
+            getContent(MethodName, { language_type })
                 .then(() => {
                 .then(() => {
                     commit('SET_UPDATE_LANGUAGE_TYPE', language_type);
                     commit('SET_UPDATE_LANGUAGE_TYPE', language_type);
                     reslove();
                     reslove();

+ 7 - 2
src/views/learn-center/ListPage.vue

@@ -43,6 +43,7 @@ import { cousrseAPI, TextbookAPI } from "@/api/api";
 
 
 import Cookies from "js-cookie";
 import Cookies from "js-cookie";
 import HeaderOne from "@/components/learnCenter/HeaderOne";
 import HeaderOne from "@/components/learnCenter/HeaderOne";
+import { updateWordPack } from "@/utils/i18n";
 
 
 export default {
 export default {
   name: "teacher_edu",
   name: "teacher_edu",
@@ -62,6 +63,7 @@ export default {
       pageNum: 1,
       pageNum: 1,
       pageSize: 8,
       pageSize: 8,
       loading: false,
       loading: false,
+      headerOneTitle: ""
     };
     };
   },
   },
   computed: {
   computed: {
@@ -140,13 +142,16 @@ export default {
       }
       }
     },
     },
   },
   },
-  created() {
+  async created() {
     this.navName = this.$route.query.id;
     this.navName = this.$route.query.id;
+    await updateWordPack({
+        word_key_list: ["Key44","Key46"],
+    });
     if (this.navName == "COURSE") {
     if (this.navName == "COURSE") {
       this.headerOneTitle = "课程";
       this.headerOneTitle = "课程";
     }
     }
     if (this.navName == "TEXTBOOK") {
     if (this.navName == "TEXTBOOK") {
-      this.headerOneTitle = "教材";
+      this.headerOneTitle = this.$t("Key44");
     }
     }
     this.getData();
     this.getData();
   },
   },

+ 8 - 4
src/views/learn-center/Seekresult.vue

@@ -24,7 +24,7 @@
           {{ item }}
           {{ item }}
         </div>
         </div>
       </div>
       </div>
-      <template v-if="dataList.total_count != 0">
+      <template v-if="dataList && dataList.total_count !== 0">
         <div class="class_list" v-if="dataList">
         <div class="class_list" v-if="dataList">
           <!-- 根据课程和教材进行分别传值 -->
           <!-- 根据课程和教材进行分别传值 -->
           <component
           <component
@@ -79,7 +79,7 @@ import HeaderOne from "@/components/learnCenter/HeaderOne";
 import ClassicalCourse from "@/components/learnCenter/ClassicalCourse";
 import ClassicalCourse from "@/components/learnCenter/ClassicalCourse";
 import Course from "@/components/learnCenter/Course";
 import Course from "@/components/learnCenter/Course";
 import Textbook from "@/components/learnCenter/Textbook";
 import Textbook from "@/components/learnCenter/Textbook";
-
+import { updateWordPack } from "@/utils/i18n";
 export default {
 export default {
   props: [],
   props: [],
   components: {
   components: {
@@ -101,7 +101,7 @@ export default {
       pageSize: 8,
       pageSize: 8,
       targetPage: 1,
       targetPage: 1,
       loading: false,
       loading: false,
-      classilfyList: ['课程', '教材'],
+      classilfyList: ['课程', this.$t("Key44")],
       classilfyIndex: 0,
       classilfyIndex: 0,
       classilfyID: null,
       classilfyID: null,
     }
     }
@@ -214,6 +214,9 @@ export default {
     //   this.getData("教材");
     //   this.getData("教材");
     //   this.classilfyIndex = 1;
     //   this.classilfyIndex = 1;
     // }
     // }
+    updateWordPack({
+        word_key_list: ["Key44"],
+    });
   },
   },
 }
 }
 </script>
 </script>
@@ -261,12 +264,13 @@ export default {
       margin-top: 16px;
       margin-top: 16px;
       margin-bottom: 16px;
       margin-bottom: 16px;
       > div {
       > div {
-        width: 72px;
+        min-width: 52px;
         height: 32px;
         height: 32px;
         display: flex;
         display: flex;
         justify-content: center;
         justify-content: center;
         align-items: center;
         align-items: center;
         cursor: pointer;
         cursor: pointer;
+        padding: 0 10px;
       }
       }
       .sele {
       .sele {
         background: #ff9900;
         background: #ff9900;

+ 15 - 14
src/views/learn-center/index.vue

@@ -13,7 +13,7 @@
           active-text-color="#FF9900"
           active-text-color="#FF9900"
         >
         >
           <el-menu-item index="COURSE">课程</el-menu-item>
           <el-menu-item index="COURSE">课程</el-menu-item>
-          <el-menu-item index="TEXTBOOK">教材</el-menu-item>
+          <el-menu-item index="TEXTBOOK">{{$t("Key44")}}</el-menu-item>
           <!-- <el-menu-item index="LIVE LESSON">LIVE LESSON</el-menu-item>
           <!-- <el-menu-item index="LIVE LESSON">LIVE LESSON</el-menu-item>
         <el-menu-item index="VIDEO COURSE">VIDEO COURSE</el-menu-item> -->
         <el-menu-item index="VIDEO COURSE">VIDEO COURSE</el-menu-item> -->
         </el-menu>
         </el-menu>
@@ -21,13 +21,14 @@
           <el-input
           <el-input
             v-model="SeekName"
             v-model="SeekName"
             style="width: 300px"
             style="width: 300px"
-            placeholder="请输入内容"
+            :placeholder="$t('Key46')"
           >
           >
           </el-input>
           </el-input>
           <img
           <img
             @click="gotoSeekResult"
             @click="gotoSeekResult"
             src="../../assets/learncenter/Group2149.png"
             src="../../assets/learncenter/Group2149.png"
             alt=""
             alt=""
+            :class="[language_type=='AR'?'languageAR':'']"
           />
           />
         </div>
         </div>
       </div>
       </div>
@@ -61,6 +62,7 @@
 </template>
 </template>
 
 
 <script>
 <script>
+import { mapGetters } from "vuex";
 import Header from "@/components/Header";
 import Header from "@/components/Header";
 import Course from "@/components/learnCenter/Course";
 import Course from "@/components/learnCenter/Course";
 import Textbook from "@/components/learnCenter/Textbook";
 import Textbook from "@/components/learnCenter/Textbook";
@@ -68,6 +70,7 @@ import Live from "@/components/learnCenter/Live";
 import VideoCourse from "@/components/learnCenter/VideoCourse";
 import VideoCourse from "@/components/learnCenter/VideoCourse";
 import Cookies from "js-cookie";
 import Cookies from "js-cookie";
 import { cousrseAPI, TextbookAPI } from "@/api/api";
 import { cousrseAPI, TextbookAPI } from "@/api/api";
+import { updateWordPack } from "@/utils/i18n";
 export default {
 export default {
   name: "lear_center",
   name: "lear_center",
   components: {
   components: {
@@ -121,17 +124,6 @@ export default {
           price: "19.9",
           price: "19.9",
         },
         },
       ],
       ],
-      dimSeekData: [
-        {
-          value: "dsadqwjkldjwklqjdlkcnx",
-        },
-        {
-          value: "dsadqwjkldjwklqjdlkcnx",
-        },
-        {
-          value: "dsadqwjkldjwklqjdlkcnx",
-        },
-      ],
       disSeekShow: false,
       disSeekShow: false,
       loading: false,
       loading: false,
       ImageList: [
       ImageList: [
@@ -157,7 +149,9 @@ export default {
       SeekName: "",
       SeekName: "",
     };
     };
   },
   },
-  computed: {},
+  computed: {
+    ...mapGetters(["language_type"]),
+  },
   methods: {
   methods: {
     // 切换导航
     // 切换导航
     handleSelect(key, keyPath) {
     handleSelect(key, keyPath) {
@@ -228,6 +222,9 @@ export default {
       .catch(() => {
       .catch(() => {
         this.loading = false;
         this.loading = false;
       });
       });
+    updateWordPack({
+        word_key_list: ["Key44","Key46"],
+    });
   },
   },
 };
 };
 </script>
 </script>
@@ -283,6 +280,10 @@ export default {
       right: 19px;
       right: 19px;
       top: 7px;
       top: 7px;
       cursor: pointer;
       cursor: pointer;
+      &.languageAR{
+          left: 19px;
+          right: auto;
+      }
     }
     }
   }
   }
   .main {
   .main {