Bladeren bron

更新多语言

gcj 3 jaren geleden
bovenliggende
commit
e0955569cc

+ 14 - 10
src/components/Header.vue

@@ -43,7 +43,7 @@
         </el-dropdown>
       </template>
       <div v-if="!userMessage" class="selectLoginOrRegistration">
-        <span @click="cutLoginReg">登录</span>
+        <span @click="cutLoginReg">{{ $t("Key9") }}</span>
       </div>
       <!-- 用户头像和用户名 -->
       <div class="user" v-else>
@@ -57,17 +57,21 @@
           "
           alt=""
         />
-        <span @click="userShow = !userShow" :class="[language_type=='AR'?'languageAR':'']">{{
-          userMessage.user_real_name
-        }}</span>
+        <span
+          @click="userShow = !userShow"
+          :class="[language_type == 'AR' ? 'languageAR' : '']"
+          >{{ userMessage.user_real_name }}</span
+        >
         <div class="userShow" v-show="userShow">
           <p @click="gotoPersonalcenter">
             <img src="../assets/login/project7.png" alt="" />
-            个人中心
+            <!-- 个人中心 -->
+            {{ $t("Key38") }}
           </p>
           <p @click="QuitLogin">
             <img src="../assets/login/Frame77.png" alt="" />
-            退出登录
+            <!-- 退出登录 -->
+            {{ $t("Key39") }}
           </p>
         </div>
       </div>
@@ -170,7 +174,7 @@ export default {
     // 前往个人中心
     gotoPersonalcenter() {
       if (!this.userMessage) {
-        this.$message.warning("请先登录");
+        this.$message.warning(this.$t("Key573"));
         return;
       }
       // let MethodName = "login_control-CreateAccessCode";
@@ -189,7 +193,7 @@ export default {
       let _this = this;
       _this.LoginNavIndex = command;
       if (!_this.userMessage) {
-        this.$message.warning("请先登录");
+        this.$message.warning(this.$t("Key573"));
         this.projectName = "学习中心";
         window.location.href = "/";
         return;
@@ -427,8 +431,8 @@ export default {
         color: #000000;
         font-size: 16px;
         padding-left: 10px;
-        &.languageAR{
-            padding: 0 10px 0 0;
+        &.languageAR {
+          padding: 0 10px 0 0;
         }
       }
       .userShow {

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

@@ -18,7 +18,10 @@
         <div class="listImage">
           <!-- <el-image lazy :src="item.picture_url" alt=""></el-image> -->
           <img v-if="item.picture_url" :src="item.picture_url" alt="" />
-          <span v-else>加载失败</span>
+          <span v-else>
+            <!-- 加载失败 -->
+            {{ $t("Key323") }}
+          </span>
         </div>
 
         <p class="one_name">{{ item.name }}</p>

+ 39 - 18
src/components/learnCenter/HeaderOne.vue

@@ -1,20 +1,41 @@
 <template>
   <div :class="type ? 'HeaderTwo' : 'HeaderOne'">
     <div>
-      <span class="befor" @click="gohome" :class="[language_type=='AR'?'languageAR':'']">
+      <span
+        class="befor"
+        @click="gohome"
+        :class="[language_type == 'AR' ? 'languageAR' : '']"
+      >
         <img src="../../assets/learncenter/Frame3.png" alt="" />
       </span>
-      <span v-if="classilfyID" :class="[language_type=='AR'?'languageAR':'']"> > </span>
       <span
         v-if="classilfyID"
-        v-text="classilfyID == 'TEXTBOOK' ? $t('Key44') : '课程'"
+        :class="[language_type == 'AR' ? 'languageAR' : '']"
+      >
+        >
+      </span>
+      <span
+        v-if="classilfyID"
+        v-text="classilfyID == 'TEXTBOOK' ? $t('Key44') : $t('Key215')"
         @click="back"
       ></span>
-      <span class="arrows" v-if="title" :class="[language_type=='AR'?'languageAR':'']"> > </span>
+      <span
+        class="arrows"
+        v-if="title"
+        :class="[language_type == 'AR' ? 'languageAR' : '']"
+      >
+        >
+      </span>
       <span @click="back" class="text">{{ title }}</span>
       <!-- <span class="text" v-if="type"> TEXTBOOK </span> -->
 
-      <span class="arrows" v-if="text" :class="[language_type=='AR'?'languageAR':'']"> > </span>
+      <span
+        class="arrows"
+        v-if="text"
+        :class="[language_type == 'AR' ? 'languageAR' : '']"
+      >
+        >
+      </span>
       <span class="text" v-if="text">{{ name }}</span>
     </div>
     <div>
@@ -30,14 +51,14 @@
           @click="gotoSeekResult"
           src="../../assets/learncenter/Group2149.png"
           alt=""
-          :class="[language_type=='AR'?'languageAR':'']"
+          :class="[language_type == 'AR' ? 'languageAR' : '']"
         />
         <img
           v-else
           @click="gotoSeekResult"
           src="../../assets/learncenter/Group 2148.png"
           alt=""
-          :class="[language_type=='AR'?'languageAR':'']"
+          :class="[language_type == 'AR' ? 'languageAR' : '']"
         />
       </div>
     </div>
@@ -69,7 +90,7 @@ export default {
   },
   //计算属性 类似于data概念
   computed: {
-      ...mapGetters(["language_type"]),
+    ...mapGetters(["language_type"]),
   },
   //监控data中数据变化
   watch: {
@@ -96,7 +117,7 @@ export default {
 
     gotoSeekResult() {
       if (this.SeekName == "") {
-        this.$message.warning(this.$t('Key46'));
+        this.$message.warning(this.$t("Key46"));
         return;
       }
       // 如果不是在搜索结果页面就跳到搜索结果页面
@@ -126,9 +147,9 @@ export default {
   created() {
     this.SeekName = this.keycode || "";
     updateWordPack({
-        word_key_list: ["Key44","Key46"],
+      word_key_list: ["Key44", "Key46"],
     });
-    console.log(this.title)
+    console.log(this.title);
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {},
@@ -161,12 +182,12 @@ export default {
     display: flex;
     align-items: center;
     > span {
-    //   margin-left: 15px;
+      //   margin-left: 15px;
       margin: 0 7px;
       cursor: pointer;
-    //   &.languageAR{
-    //       margin: 0 7px;
-    //   }
+      //   &.languageAR{
+      //       margin: 0 7px;
+      //   }
     }
     .befor {
       img {
@@ -203,9 +224,9 @@ export default {
       right: 19px;
       top: 7px;
       cursor: pointer;
-      &.languageAR{
-          left: 19px;
-          right: auto;
+      &.languageAR {
+        left: 19px;
+        right: auto;
       }
     }
   }

+ 1 - 1
src/components/learnCenter/Textbook.vue

@@ -18,7 +18,7 @@
         <div class="listImage">
           <!-- <el-image lazy :src="item.picture_url" alt=""></el-image> -->
           <img v-if="item.picture_url" :src="item.picture_url" alt="" />
-          <span v-else>加载失败</span>
+          <span v-else> {{ $t("Key323") }}</span>
         </div>
         <p class="one_name">{{ item.name }}</p>
         <p class="price">

+ 16 - 3
src/permission.js

@@ -33,13 +33,22 @@ router.beforeEach(async (to, from, next) => {
           next()
         } catch (error) {
           Message.error(error || 'Has Error')
-          next(`/login?redirect=${to.path}`)
+          if (process.env.NODE_ENV == "development") {
+            next(`/login?redirect=${to.path}`)
+          } else {
+            window.location.href = "/"
+          }
+
           NProgress.done()
         }
       }
     } else {
       removeToken();
-      next(`/login?redirect=${to.path}`)
+      if (process.env.NODE_ENV == "development") {
+        next(`/login?redirect=${to.path}`)
+      } else {
+        window.location.href = "/"
+      }
       NProgress.done()
     }
     //=======重点部分以上=======
@@ -51,7 +60,11 @@ router.beforeEach(async (to, from, next) => {
       next()
     } else {
       // other pages that do not have permission to access are redirected to the login page.
-      next(`/login?redirect=${to.path}`)
+      if (process.env.NODE_ENV == "development") {
+        next(`/login?redirect=${to.path}`)
+      } else {
+        window.location.href = "/"
+      }
       NProgress.done()
     }
   }

+ 12 - 5
src/views/learn-center/ListPage.vue

@@ -40,8 +40,6 @@ import Course from "@/components/learnCenter/Course";
 import Textbook from "@/components/learnCenter/Textbook";
 
 import { cousrseAPI, TextbookAPI } from "@/api/api";
-
-import Cookies from "js-cookie";
 import HeaderOne from "@/components/learnCenter/HeaderOne";
 import { updateWordPack } from "@/utils/i18n";
 
@@ -63,7 +61,7 @@ export default {
       pageNum: 1,
       pageSize: 8,
       loading: false,
-      headerOneTitle: ""
+      headerOneTitle: "",
     };
   },
   computed: {
@@ -145,10 +143,19 @@ export default {
   async created() {
     this.navName = this.$route.query.id;
     await updateWordPack({
-        word_key_list: ["Key44","Key46"],
+      word_key_list: [
+        "Key8",
+        "Key38",
+        "Key39",
+        "Key573",
+        "Key44",
+        "Key46",
+        "Key323",
+        "Key215",
+      ],
     });
     if (this.navName == "COURSE") {
-      this.headerOneTitle = "课程";
+      this.headerOneTitle = this.$t("Key215");
     }
     if (this.navName == "TEXTBOOK") {
       this.headerOneTitle = this.$t("Key44");

+ 15 - 2
src/views/learn-center/Seekresult.vue

@@ -58,7 +58,10 @@
       <template v-else>
         <div class="nomore">
           <img src="../../assets/learncenter/noSeekResult.png" alt="" />
-          <p class="p1">抱歉,我找不到相关的内容。</p>
+          <p class="p1">
+            <!-- 抱歉,我找不到相关的内容。 -->
+            {{ $t("Key547") }}
+          </p>
           <!-- <p class="p2">Try the following keywords</p> -->
           <!-- <div class="keywords">
           <span>live lesson</span>
@@ -215,7 +218,17 @@ export default {
     //   this.classilfyIndex = 1;
     // }
     await updateWordPack({
-      word_key_list: ["Key44", "Key215", "Key248"],
+      word_key_list: [
+        "Key8",
+        "Key38",
+        "Key39",
+        "Key573",
+        "Key44",
+        "Key215",
+        "Key248",
+        "Key323",
+        "Key547",
+      ],
     });
     this.classilfyList = [this.$t("Key215"), this.$t("Key44")];
   },

+ 11 - 1
src/views/learn-center/index.vue

@@ -226,7 +226,17 @@ export default {
         this.loading = false;
       });
     await updateWordPack({
-      word_key_list: ["Key44", "Key46", "Key147", "Key215"],
+      word_key_list: [
+        "Key8",
+        "Key38",
+        "Key39",
+        "Key44",
+        "Key46",
+        "Key147",
+        "Key215",
+        "Key323",
+        "Key573",
+      ],
     });
     this.isData = true;
   },

+ 4 - 0
src/views/login.vue

@@ -420,6 +420,10 @@ $fc: rgb(24, 144, 255);
 }
 .login-left {
   // flex: 1;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
   margin: 0 auto;
 }
 .login-right {

+ 116 - 116
vue.config.js

@@ -4,7 +4,7 @@ const defaultSettings = require('./src/settings.js')
 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
@@ -15,125 +15,125 @@ const name = defaultSettings.title || '学习中心' // page title
 // You can change the port by the following methods:
 // port = 9528 npm run dev OR npm run dev --port = 9528
 const port = process.env.port || process.env.npm_config_port || 9590 // dev port
-    // All configuration item explanations can be find in https://cli.vuejs.org/config/
+// 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-LC',
-    // publicPath: '/',
-    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
-            // http://mk.wmjh.cn
-            [process.env.VUE_APP_BASE_API]: {
-                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-LC',
+  // publicPath: '/',
+  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
+      // http://mk.wmjh.cn
+      [process.env.VUE_APP_BASE_API]: {
+        target: `http://gcls.utschool.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: [
+      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'
+    }])
 
-        // when there are many pages, it will cause too many meaningless requests
-        config.plugins.delete('prefetch')
+    // 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()
+    // 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')
+    })
+  }
 }