소스 검색

多语言

guanchunjie 3 년 전
부모
커밋
59e71a5269
7개의 변경된 파일326개의 추가작업 그리고 195개의 파일을 삭제
  1. 0 3
      src/common/font/font.css
  2. 4 1
      src/components/Personalcenter/AccountSet.vue
  3. 38 30
      src/components/Personalcenter/Mycollect.vue
  4. 33 23
      src/components/common/Header.vue
  5. 16 11
      src/utils/i18n.js
  6. 117 9
      src/views/Personalcenter.vue
  7. 118 118
      vue.config.js

+ 0 - 3
src/common/font/font.css

@@ -60,6 +60,3 @@
   font-family: 'sourceR';
   src: url('SourceSansPro-Regular.ttf');
 }
-#app{
-  font-family: "sourceR";
-}

+ 4 - 1
src/components/Personalcenter/AccountSet.vue

@@ -149,7 +149,7 @@
               <el-button
                 class="btn"
                 @click="cancleJoinOrg"
-                style="margin-right: 16px"
+                style="margin-right: 16px; margin-left: 16px"
                 >取消</el-button
               >
               <el-button type="warning" class="btn" @click="joinOrg"
@@ -532,6 +532,7 @@ export default {
         }
         span {
           margin-left: 10px;
+          margin-right: 10px;
         }
       }
       .btn {
@@ -551,12 +552,14 @@ export default {
         line-height: 150%;
         color: #ff3f3f;
         margin-left: 24px;
+        margin-right: 24px;
       }
       .delOrgBox {
         display: flex;
       }
       .delOrg {
         margin-left: 24px;
+        margin-right: 24px;
         height: 100%;
         cursor: pointer;
         width: 24px;

+ 38 - 30
src/components/Personalcenter/Mycollect.vue

@@ -21,9 +21,15 @@
         <!-- <el-menu-item index="all">全部</el-menu-item> -->
         <el-menu-item index="book">教材</el-menu-item>
         <el-menu-item index="teaching">教学课程</el-menu-item>
-        <el-menu-item index="video" v-if="userType != 'STUDENT'">视频</el-menu-item>
-        <el-menu-item index="live" v-if="userType != 'STUDENT'">直播</el-menu-item>
-        <el-menu-item index="jiaoyan" v-if="userType != 'STUDENT'">教研资料</el-menu-item>
+        <el-menu-item index="video" v-if="userType != 'STUDENT'"
+          >视频</el-menu-item
+        >
+        <el-menu-item index="live" v-if="userType != 'STUDENT'"
+          >直播</el-menu-item
+        >
+        <el-menu-item index="jiaoyan" v-if="userType != 'STUDENT'"
+          >教研资料</el-menu-item
+        >
         <el-menu-item index="hanzi">字词</el-menu-item>
         <el-menu-item index="sentence">句子</el-menu-item>
       </el-menu>
@@ -43,18 +49,18 @@
               />
             </div>
             <template v-if="/^[\u4e00-\u9fa5]/.test(item.new_word.new_word)">
-                <Hanzi
-                    :item="item"
-                    :index="index"
-                    @getMyCollectionList="getMyCollectionList"
-                />
+              <Hanzi
+                :item="item"
+                :index="index"
+                @getMyCollectionList="getMyCollectionList"
+              />
             </template>
             <template v-else>
-                <Enword
-                    :item="item"
-                    :index="index"
-                    @getMyCollectionList="getMyCollectionList"
-                />
+              <Enword
+                :item="item"
+                :index="index"
+                @getMyCollectionList="getMyCollectionList"
+              />
             </template>
           </div>
           <div class="main-content" v-else-if="item.goods_type == 502">
@@ -68,21 +74,23 @@
                 class="check-img"
               />
             </div>
-            <template v-if="/^[\u4e00-\u9fa5]/.test(item.sentence.sentence_text)">
-                <Sentence
-                    :key="item.id"
-                    :sItem="item"
-                    :index="index"
-                    @getMyCollectionList="getMyCollectionList"
-                />
+            <template
+              v-if="/^[\u4e00-\u9fa5]/.test(item.sentence.sentence_text)"
+            >
+              <Sentence
+                :key="item.id"
+                :sItem="item"
+                :index="index"
+                @getMyCollectionList="getMyCollectionList"
+              />
             </template>
             <template v-else>
-                <SentenceEn
-                    :key="item.id"
-                    :sItem="item"
-                    :index="index"
-                    @getMyCollectionList="getMyCollectionList"
-                />
+              <SentenceEn
+                :key="item.id"
+                :sItem="item"
+                :index="index"
+                @getMyCollectionList="getMyCollectionList"
+              />
             </template>
           </div>
           <div class="main-content" v-else>
@@ -185,8 +193,8 @@ import Payment from "../common/Payment.vue";
 import { jumpPath } from "@/utils/jumpPath";
 import Hanzi from "../common/Hanzi.vue";
 import Sentence from "../common/Sentence.vue";
-import SentenceEn from "../common/SentenceEn.vue"
-import Enword from "../common/Enword.vue"
+import SentenceEn from "../common/SentenceEn.vue";
+import Enword from "../common/Enword.vue";
 
 export default {
   name: "MyCollect",
@@ -202,13 +210,13 @@ export default {
     SentenceEn,
     Enword,
   },
-  props: ['userType'],
+  props: ["userType"],
   data() {
     //这里存放数据
     return {
       navType: "6",
       isEmpty: false,
-      activeIndex: "all",
+      activeIndex: "book",
       list: [],
       goods_name: "", // 商品名称,模糊查询,空表示查询所有
       goods_id_list: [], // 商品 ID 列表,空表示查询所有商品

+ 33 - 23
src/components/common/Header.vue

@@ -3,15 +3,25 @@
   <div class="LoginNav">
     <div class="logo">
       <template v-if="configInfor">
-        <img :src="configInfor.logo_image_url" alt="logo" class="logo-image" @click="handleSelect" />
+        <img
+          :src="configInfor.logo_image_url"
+          alt="logo"
+          class="logo-image"
+          @click="handleSelect"
+        />
       </template>
       <template v-else>
-        <span class="logo-img"> logo </span>
+        <span class="logo-img" @click="handleSelect"> logo </span>
       </template>
       <ul class="logo-projectlist">
-          <li v-for="(itemI,indexI) in projectList" :key="indexI" :class="indexI==LoginNavIndex?'active':''" @click="handleCommand(indexI)">
-              {{ itemI.name }}
-          </li>
+        <li
+          v-for="(itemI, indexI) in projectList"
+          :key="indexI"
+          :class="indexI == LoginNavIndex ? 'active' : ''"
+          @click="handleCommand(indexI)"
+        >
+          {{ itemI.name }}
+        </li>
       </ul>
     </div>
     <div class="userName">
@@ -279,25 +289,25 @@ export default {
     }
     display: flex;
     align-items: center;
-    .logo-projectlist{
-        display: flex;
-        padding: 0 24px;
-        height: 64px;
-        li{
-            padding: 0 12px;
-            color: rgba(0, 0, 0, 0.45);
-            font-size: 16px;
-            line-height: 64px;
-            font-weight: 500;
-            cursor: pointer;
-            &:hover{
-                background: #F6F6F6;
-            }
-            &.active{
-                color: #FF9900;
-                background: #FFEFD6;
-            }
+    .logo-projectlist {
+      display: flex;
+      padding: 0 24px;
+      height: 64px;
+      li {
+        padding: 0 12px;
+        color: rgba(0, 0, 0, 0.45);
+        font-size: 16px;
+        line-height: 64px;
+        font-weight: 500;
+        cursor: pointer;
+        &:hover {
+          background: #f6f6f6;
         }
+        &.active {
+          color: #ff9900;
+          background: #ffefd6;
+        }
+      }
     }
   }
   .userName {

+ 16 - 11
src/utils/i18n.js

@@ -47,18 +47,23 @@ export async function setI18nLang(language_type) {
  * @param {Object} Parameter word_key_list 需要读取的词汇
  */
 export function updateWordPack(Parameter) {
-  Parameter.language_type = store.getters.language_type;
-  let MethodName = 'language_manager-GetWordPack';
-  getStaticContent(MethodName, Parameter).then(data => {
-    let localWord = i18n.messages[data.language_type];
-    if (localWord === undefined) {
-      localWord = {};
-    }
-    let wordPack = Object.assign(localWord, data.word_pack);
+  return new Promise((resolve, reject) => {
+    Parameter.language_type = store.getters.language_type;
+    let MethodName = 'language_manager-GetWordPack';
+    getStaticContent(MethodName, Parameter).then(data => {
+      let localWord = i18n.messages[data.language_type];
+      if (localWord === undefined) {
+        localWord = {};
+      }
+      let wordPack = Object.assign(localWord, data.word_pack);
+
+      i18n.setLocaleMessage(data.language_type, wordPack);
+      resolve()
+    }).catch(err => {
+      reject(err)
+    });
+  })
 
-    i18n.setLocaleMessage(data.language_type, wordPack);
-    // localStorage.setItem('i18n-message', JSON.stringify(i18n.messages));
-  });
 }
 
 export default i18n;

+ 117 - 9
src/views/Personalcenter.vue

@@ -12,7 +12,14 @@
             <div class="shade">
               <div class="photo">
                 <div>
-                  <img :src="userMessage.image_url?userMessage.image_url:require('../assets/login/Group3214.png')" alt="" />
+                  <img
+                    :src="
+                      userMessage.image_url
+                        ? userMessage.image_url
+                        : require('../assets/login/Group3214.png')
+                    "
+                    alt=""
+                  />
                   <img
                     class="edit-avator"
                     src="../assets/Personalcenter/edit-avator.png"
@@ -26,7 +33,7 @@
             </div>
           </div>
           <!-- 导航 -->
-          <div class="navList">
+          <div class="navList" :dir="dir">
             <div
               :class="SeleNavId == item.id ? 'select' : ''"
               v-for="(item, i) in navList"
@@ -51,10 +58,13 @@
             </div>
           </div>
         </div>
-        <div class="right">
+        <div class="right" :dir="dir">
           <Mymessage v-if="SeleNavId == 0" />
           <Mytextbook v-if="SeleNavId == 1" />
-          <Teachcourse v-if="SeleNavId == 2" :userType="userMessage.user_type" />
+          <Teachcourse
+            v-if="SeleNavId == 2"
+            :userType="userMessage.user_type"
+          />
           <Traincourse v-if="SeleNavId == 3" />
           <TeachMaterial v-if="SeleNavId == 4" />
           <OrderManage v-if="SeleNavId == 5" />
@@ -99,6 +109,8 @@ import myUpload from "@/components/vue-image-crop-upload/upload-2.vue";
 
 import { getContent, getLearnWebContent } from "@/api/ajax";
 
+import { updateWordPack } from "@/utils/i18n";
+
 export default {
   name: "Personalcenter",
   components: {
@@ -117,6 +129,7 @@ export default {
   data() {
     //这里存放数据
     return {
+      dir: "ltr",
       userInfor: null,
       userMessage: null, //登录信息
       SeleNavId: 0,
@@ -328,21 +341,116 @@ export default {
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
-  created() {
+  async created() {
+    let lang_type = localStorage.getItem("language_type");
+    if (lang_type == "AR") {
+      this.dir = "rtl";
+    }
     let userInfor = getToken();
-
+    if (this.$route.query.SeleNavId) {
+      this.SeleNavId = this.$route.query.SeleNavId;
+    }
     if (userInfor) {
       let user = JSON.parse(getToken());
       this.userMessage = user;
+      await updateWordPack({
+        word_key_list: ["Key60"],
+      });
+      this.teachList = [
+        {
+          id: 0,
+          name: this.$t("Key60"),
+          imgSrc: "nav1",
+          selectSrc: "nav1-1",
+        },
+        {
+          id: 1,
+          name: "我的教材",
+          imgSrc: "nav2",
+          selectSrc: "nav2-1",
+        },
+        {
+          id: 2,
+          name: "教学课程",
+          imgSrc: "nav3",
+          selectSrc: "nav3-1",
+        },
+        {
+          id: 3,
+          name: "教培课程",
+          imgSrc: "nav4",
+          selectSrc: "nav4-1",
+        },
+        {
+          id: 4,
+          name: "教研材料",
+          imgSrc: "nav5",
+          selectSrc: "nav5-1",
+        },
+        {
+          id: 5,
+          name: "订单管理",
+          imgSrc: "nav6",
+          selectSrc: "nav6-1",
+        },
+        {
+          id: 6,
+          name: "我的收藏",
+          imgSrc: "nav7",
+          selectSrc: "nav7-1",
+        },
+        {
+          id: 7,
+          name: "账户设置",
+          imgSrc: "nav8",
+          selectSrc: "nav8-1",
+        },
+      ];
+      this.stuList = [
+        {
+          id: 0,
+          name: this.$t("Key60"),
+          imgSrc: "nav1",
+          selectSrc: "nav1-1",
+        },
+        {
+          id: 1,
+          name: "我的教材",
+          imgSrc: "nav2",
+          selectSrc: "nav2-1",
+        },
+        {
+          id: 2,
+          name: "教学课程",
+          imgSrc: "nav3",
+          selectSrc: "nav3-1",
+        },
+        {
+          id: 5,
+          name: "订单管理",
+          imgSrc: "nav6",
+          selectSrc: "nav6-1",
+        },
+        {
+          id: 6,
+          name: "我的收藏",
+          imgSrc: "nav7",
+          selectSrc: "nav7-1",
+        },
+        {
+          id: 7,
+          name: "账户设置",
+          imgSrc: "nav8",
+          selectSrc: "nav8-1",
+        },
+      ];
+      this.stuList = [];
       if (user.user_type == "TEACHER") {
         this.navList = this.teachList;
       } else {
         this.navList = this.stuList;
       }
     }
-    if(this.$route.query.SeleNavId){
-        this.SeleNavId = this.$route.query.SeleNavId
-    }
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {

+ 118 - 118
vue.config.js

@@ -5,7 +5,7 @@ const CompressionPlugin = require('compression-webpack-plugin');
 
 
 function resolve(dir) {
-    return path.join(__dirname, dir)
+  return path.join(__dirname, dir)
 }
 
 const name = defaultSettings.title || '个人中心' // page title
@@ -19,127 +19,127 @@ const port = process.env.port || process.env.npm_config_port || 9528 // dev port
 
 // All configuration item explanations can be find in https://cli.vuejs.org/config/
 module.exports = {
-    /**
-     * You will need to set publicPath if you plan to deploy your site under a sub path,
-     * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
-     * then publicPath should be set to "/bar/".
-     * In most cases please use '/' !!!
-     * Detail: https://cli.vuejs.org/config/#publicpath
-     */
-    publicPath: process.env.NODE_ENV === 'development' ? '/' : '/GCLS-Personal',
-    outputDir: 'dist',
-    assetsDir: 'static',
-    lintOnSave: false,
-    productionSourceMap: false,
-    devServer: {
-        port: port,
-        open: true,
-        overlay: {
-            warnings: false,
-            errors: true
-        },
-        proxy: {
-            // 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/`,
-                changeOrigin: true,
-                pathRewrite: {
-                    ['^' + process.env.VUE_APP_BASE_API]: ''
-                }
-            }
-        },
-        // after: require('./mock/mock-server.js')
+  /**
+   * You will need to set publicPath if you plan to deploy your site under a sub path,
+   * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
+   * then publicPath should be set to "/bar/".
+   * In most cases please use '/' !!!
+   * Detail: https://cli.vuejs.org/config/#publicpath
+   */
+  publicPath: process.env.NODE_ENV === 'development' ? '/' : '/GCLS-Personal',
+  outputDir: 'dist',
+  assetsDir: 'static',
+  lintOnSave: false,
+  productionSourceMap: false,
+  devServer: {
+    port: port,
+    open: true,
+    overlay: {
+      warnings: false,
+      errors: true
     },
-    configureWebpack: {
-        // provide the app's title in webpack's name field, so that
-        // it can be accessed in index.html to inject the correct title.
-        name: name,
-        resolve: {
-            alias: {
-                '@': resolve('src')
-            }
-        },
-        plugins: [
-
-            new CompressionPlugin({
-                algorithm: 'gzip', // 使用gzip压缩
-                test: /\.js$|\.html$|\.css$/, // 匹配文件名
-                minRatio: 0.8, // 压缩率小于0.8才会压缩
-                threshold: 10240, // 对超过10k的数据压缩
-                deleteOriginalAssets: false // 是否删除未压缩的源文件,谨慎设置,如果希望提供非gzip的资源,可不设置或者设置为false(比如删除打包后的gz后还可以加载到原始资源文件)
-            })
-        ]
+    proxy: {
+      // 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/`,
+        changeOrigin: true,
+        pathRewrite: {
+          ['^' + process.env.VUE_APP_BASE_API]: ''
+        }
+      }
     },
-    chainWebpack(config) {
-        // it can improve the speed of the first screen, it is recommended to turn on preload
-        config.plugin('preload').tap(() => [{
-            rel: 'preload',
-            // to ignore runtime.js
-            // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
-            fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
-            include: 'initial'
-        }])
+    // after: require('./mock/mock-server.js')
+  },
+  configureWebpack: {
+    // provide the app's title in webpack's name field, so that
+    // it can be accessed in index.html to inject the correct title.
+    name: name,
+    resolve: {
+      alias: {
+        '@': resolve('src')
+      }
+    },
+    plugins: [
 
-        // when there are many pages, it will cause too many meaningless requests
-        config.plugins.delete('prefetch')
+      new CompressionPlugin({
+        algorithm: 'gzip', // 使用gzip压缩
+        test: /\.js$|\.html$|\.css$/, // 匹配文件名
+        minRatio: 0.8, // 压缩率小于0.8才会压缩
+        threshold: 10240, // 对超过10k的数据压缩
+        deleteOriginalAssets: false // 是否删除未压缩的源文件,谨慎设置,如果希望提供非gzip的资源,可不设置或者设置为false(比如删除打包后的gz后还可以加载到原始资源文件)
+      })
+    ]
+  },
+  chainWebpack(config) {
+    // it can improve the speed of the first screen, it is recommended to turn on preload
+    config.plugin('preload').tap(() => [{
+      rel: 'preload',
+      // to ignore runtime.js
+      // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
+      fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
+      include: 'initial'
+    }])
 
-        // set svg-sprite-loader
-        config.module
-            .rule('svg')
-            .exclude.add(resolve('src/icons'))
-            .end()
-        config.module
-            .rule('icons')
-            .test(/\.svg$/)
-            .include.add(resolve('src/icons'))
-            .end()
-            .use('svg-sprite-loader')
-            .loader('svg-sprite-loader')
-            .options({
-                symbolId: 'icon-[name]'
-            })
-            .end()
+    // when there are many pages, it will cause too many meaningless requests
+    config.plugins.delete('prefetch')
+
+    // set svg-sprite-loader
+    config.module
+      .rule('svg')
+      .exclude.add(resolve('src/icons'))
+      .end()
+    config.module
+      .rule('icons')
+      .test(/\.svg$/)
+      .include.add(resolve('src/icons'))
+      .end()
+      .use('svg-sprite-loader')
+      .loader('svg-sprite-loader')
+      .options({
+        symbolId: 'icon-[name]'
+      })
+      .end()
 
-        config
-            .when(process.env.NODE_ENV !== 'development',
-                config => {
-                    config
-                        .plugin('ScriptExtHtmlWebpackPlugin')
-                        .after('html')
-                        .use('script-ext-html-webpack-plugin', [{
-                            // `runtime` must same as runtimeChunk name. default is `runtime`
-                            inline: /runtime\..*\.js$/
-                        }])
-                        .end()
-                    config
-                        .optimization.splitChunks({
-                            chunks: 'all',
-                            cacheGroups: {
-                                libs: {
-                                    name: 'chunk-libs',
-                                    test: /[\\/]node_modules[\\/]/,
-                                    priority: 10,
-                                    chunks: 'initial' // only package third parties that are initially dependent
-                                },
-                                elementUI: {
-                                    name: 'chunk-elementUI', // split elementUI into a single package
-                                    priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-                                    test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
-                                },
-                                commons: {
-                                    name: 'chunk-commons',
-                                    test: resolve('src/components'), // can customize your rules
-                                    minChunks: 3, //  minimum common number
-                                    priority: 5,
-                                    reuseExistingChunk: true
-                                }
-                            }
-                        })
-                        // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
-                    config.optimization.runtimeChunk('single')
+    config
+      .when(process.env.NODE_ENV !== 'development',
+        config => {
+          config
+            .plugin('ScriptExtHtmlWebpackPlugin')
+            .after('html')
+            .use('script-ext-html-webpack-plugin', [{
+              // `runtime` must same as runtimeChunk name. default is `runtime`
+              inline: /runtime\..*\.js$/
+            }])
+            .end()
+          config
+            .optimization.splitChunks({
+              chunks: 'all',
+              cacheGroups: {
+                libs: {
+                  name: 'chunk-libs',
+                  test: /[\\/]node_modules[\\/]/,
+                  priority: 10,
+                  chunks: 'initial' // only package third parties that are initially dependent
+                },
+                elementUI: {
+                  name: 'chunk-elementUI', // split elementUI into a single package
+                  priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
+                  test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
+                },
+                commons: {
+                  name: 'chunk-commons',
+                  test: resolve('src/components'), // can customize your rules
+                  minChunks: 3, //  minimum common number
+                  priority: 5,
+                  reuseExistingChunk: true
                 }
-            )
-    }
+              }
+            })
+          // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
+          config.optimization.runtimeChunk('single')
+        }
+      )
+  }
 }