guanchunjie 3 years ago
parent
commit
57f3e627ea
4 changed files with 267 additions and 209 deletions
  1. 18 4
      src/utils/auth.js
  2. 17 4
      src/utils/index.js
  3. 126 95
      src/views/login/index.vue
  4. 106 106
      vue.config.js

+ 18 - 4
src/utils/auth.js

@@ -3,13 +3,27 @@ import Cookies from 'js-cookie'
 const TokenKey = 'GCLS_Token'
 
 export function getToken() {
-    return Cookies.get(TokenKey)
+  return Cookies.get(TokenKey)
 }
 
 export function setToken(token) {
-    return Cookies.set(TokenKey, token)
+  return Cookies.set(TokenKey, token)
 }
 
 export function removeToken() {
-    return Cookies.remove(TokenKey)
-}
+  return Cookies.remove(TokenKey)
+}
+
+const ConfigKey = 'GCLS_Config'
+
+export function getConfig() {
+  return Cookies.get(ConfigKey)
+}
+
+export function setConfig(val) {
+  return Cookies.set(ConfigKey, val)
+}
+
+export function removeConfig() {
+  return Cookies.remove(ConfigKey)
+}

+ 17 - 4
src/utils/index.js

@@ -1,6 +1,18 @@
-/**
- * Created by PanJiaChen on 16/11/18.
- */
+import { getLogin } from '@/api/api';
+import { setConfig } from './auth'
+//获取系统配置
+export function getConfig() {
+  return new Promise((resolve, reject) => {
+    let MethodName = 'sys_config_manager-GetLogo';
+    getLogin(MethodName, {}).then(res => {
+      setConfig(res)
+      resolve(res)
+    }).catch(err => {
+      reject(err);
+    })
+  })
+
+}
 
 /**
  * Parse the time to string
@@ -45,7 +57,7 @@ export function parseTime(time, cFormat) {
   const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
     const value = formatObj[key]
     // Note: getDay() returns 0 on Sunday
-    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
+    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
     return value.toString().padStart(2, '0')
   })
   return time_str
@@ -115,3 +127,4 @@ export function param2Obj(url) {
   })
   return obj
 }
+

+ 126 - 95
src/views/login/index.vue

@@ -1,96 +1,98 @@
 <template>
-  <div class="index" v-if="isPc">
-    <div class="shadow" v-if="LoginOrRegistration != 'signin'">
-      <LoginNav
-        :changeLoginReg="changeLoginReg"
-        :FatheruserMessage="userMessage"
-        :language_list="language_list"
-        :projectList="projectList"
-      />
-      <!-- <LayoutHeader /> -->
-      <div class="logoAndlogin">
-        <div class="LogoAndText">
-          <div class="logo">GCLS</div>
-          <div class="text">
-            <p class="p1">欢迎来到全球汉语教学平台</p>
-            <p class="p2">
-              这里有丰富的教学资源、先进的教学方法,无论您是教师或学生都能在这里尽情汲取养分!
-            </p>
+  <div class="index">
+    <template v-if="isPc">
+      <div class="shadow" v-if="LoginOrRegistration != 'signin'">
+        <LoginNav
+          :changeLoginReg="changeLoginReg"
+          :FatheruserMessage="userMessage"
+          :language_list="language_list"
+          :projectList="projectList"
+        />
+        <!-- <LayoutHeader /> -->
+        <div class="logoAndlogin">
+          <div class="LogoAndText">
+            <div class="logo">
+              <img :src="configInfor.logo_image_url" class="logo-img" />
+            </div>
+            <div class="text">
+              <p class="p1">欢迎来到{{ configInfor.title }}</p>
+              <p class="p2">
+                这里有丰富的教学资源、先进的教学方法,无论您是教师或学生都能在这里尽情汲取养分!
+              </p>
+            </div>
+          </div>
+          <div class="login" v-if="LoginOrRegistration == 'login'">
+            <Login
+              :ForgetType.sync="loginType"
+              :changeLoginReg="changeLoginReg"
+              :changeLoginType="changeLoginType"
+            />
           </div>
-        </div>
-        <div class="login" v-if="LoginOrRegistration == 'login'">
-          <Login
-            :ForgetType.sync="loginType"
-            :changeLoginReg="changeLoginReg"
-            :changeLoginType="changeLoginType"
-          />
-        </div>
-        <div
-          v-if="LoginOrRegistration == 'Forget password'"
-          class="ForgetPassword"
-        >
-          <ForgetPassword
-            :changeLoginReg="changeLoginReg"
-            :ForgetType.sync="loginType"
-            :changeLoginType="changeLoginType"
-          />
-        </div>
-        <div class="list" v-if="!LoginOrRegistration">
           <div
-            :class="projectIndex == item.id ? 'Selectproject' : ''"
-            @mousemove="projectMove(item)"
-            @mouseout="projectOut"
-            v-for="(item, i) in projectList"
-            :key="i"
-            @click="SelectProject(i)"
+            v-if="LoginOrRegistration == 'Forget password'"
+            class="ForgetPassword"
           >
-            <div>
-              <img
-                v-if="projectIndex == item.id"
-                :src="require('../../assets/login/' + item.selectImg + '.png')"
-                alt=""
-              />
-              <img
-                v-else
-                :src="require('../../assets/login/' + item.img + '.png')"
-                alt=""
-              />
-              <p>{{ item.name }}</p>
+            <ForgetPassword
+              :changeLoginReg="changeLoginReg"
+              :ForgetType.sync="loginType"
+              :changeLoginType="changeLoginType"
+            />
+          </div>
+          <div class="list" v-if="!LoginOrRegistration">
+            <div
+              :class="projectIndex == item.id ? 'Selectproject' : ''"
+              @mousemove="projectMove(item)"
+              @mouseout="projectOut"
+              v-for="(item, i) in projectList"
+              :key="i"
+              @click="SelectProject(i)"
+            >
+              <div>
+                <img
+                  v-if="projectIndex == item.id"
+                  :src="
+                    require('../../assets/login/' + item.selectImg + '.png')
+                  "
+                  alt=""
+                />
+                <img
+                  v-else
+                  :src="require('../../assets/login/' + item.img + '.png')"
+                  alt=""
+                />
+                <p>{{ item.name }}</p>
+              </div>
+              <p>{{ item.text }}</p>
             </div>
-            <p>{{ item.text }}</p>
           </div>
         </div>
-      </div>
-      <div class="bottom" v-if="LoginOrRegistration != 'signin'">
-        <div>
-          <span> About us </span>
-          <span>
-            <span style="margin-right: 16px"> Office: </span>
+        <div class="bottom" v-if="LoginOrRegistration != 'signin'">
+          <div>
+            <span> About us </span>
+            <span>
+              <span style="margin-right: 16px"> Office: </span>
 
-            hzmd@160.com
-          </span>
-          <span>
-            <span style="margin-right: 16px"> Tell: </span>
-            800-820-8820</span
-          >
-          <span>
-            <span style="margin-right: 16px"> Site: </span>
-            123 walton gorgla street town hall,beijing.CH</span
-          >
-        </div>
-        <div>
-          <span style="font-weight: bold"> Copyright </span>
-          © 2010-2021 HugeMind All rights reserved.
+              hzmd@160.com
+            </span>
+            <span>
+              <span style="margin-right: 16px"> Tell: </span>
+              800-820-8820</span
+            >
+            <span>
+              <span style="margin-right: 16px"> Site: </span>
+              123 walton gorgla street town hall,beijing.CH</span
+            >
+          </div>
+          <div>
+            <span style="font-weight: bold"> Copyright </span>
+            © 2010-2021 HugeMind All rights reserved.
+          </div>
         </div>
       </div>
-    </div>
-    <!-- <div v-if="LoginOrRegistration == 'signin'" class="signin">
-      <LoginNav2
-        :changeLoginReg="changeLoginReg"
-        :language_list="language_list"
-      />
-      <Registration :changeLoginReg="changeLoginReg" />
-    </div> -->
+    </template>
+    <template v-else>
+      <div class="empty"><p>跳转中...</p></div>
+    </template>
   </div>
 </template>
 
@@ -109,6 +111,8 @@ import LayoutHeader from "@/components/login/LayoutHeader";
 import { updateWordPack } from "@/utils/i18n";
 import { getToken, removeToken } from "@/utils/auth";
 
+import { getConfig } from "@/utils/index";
+
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: {
@@ -254,6 +258,7 @@ export default {
       projectIndex: null,
       userMessage: null,
       language_list: null,
+      configInfor: null,
     };
   },
   //计算属性 类似于data概念
@@ -556,20 +561,24 @@ export default {
         console.log("移动端");
       } else {
         console.log("PC端");
-        let user_name = JSON.parse(localStorage.getItem("user_name"));
-        if (user_name) {
-          if (user_name.user_type == "TEACHER") {
-            this.loginType = "teacher";
-          } else {
-            this.loginType = "student";
-          }
-        }
-        this.Islogin();
-        let type = this.$route.query.type;
-        if (type && type == "login") {
-          this.LoginOrRegistration = "login";
+        this._getConfig();
+      }
+    },
+    async _getConfig() {
+      this.configInfor = await getConfig();
+      let user_name = JSON.parse(localStorage.getItem("user_name"));
+      if (user_name) {
+        if (user_name.user_type == "TEACHER") {
+          this.loginType = "teacher";
+        } else {
+          this.loginType = "student";
         }
       }
+      this.Islogin();
+      let type = this.$route.query.type;
+      if (type && type == "login") {
+        this.LoginOrRegistration = "login";
+      }
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)
@@ -603,6 +612,21 @@ export default {
   background-size: cover;
   font-family: "sourceR";
   position: relative;
+  .empty {
+    background: #fff;
+    width: 100%;
+    height: 100vh;
+    overflow: hidden;
+    padding-top: 200px;
+    display: flex;
+    justify-content: center;
+    align-items: flex-start;
+    > p {
+      color: #3182bd;
+      font-size: 20px;
+      font-weight: bold;
+    }
+  }
   .shadow {
     min-height: 100vh;
     height: 100%;
@@ -637,6 +661,13 @@ export default {
         color: black;
         text-align: center;
         line-height: 136px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        > img {
+          max-height: 100%;
+          max-width: 100%;
+        }
       }
       .text {
         margin-left: 40px;

+ 106 - 106
vue.config.js

@@ -3,7 +3,7 @@ const path = require('path')
 const defaultSettings = require('./src/settings.js')
 
 function resolve(dir) {
-    return path.join(__dirname, dir)
+  return path.join(__dirname, dir)
 }
 
 const name = defaultSettings.title || '登录' // page title
@@ -17,116 +17,116 @@ 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: '/',
-    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.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: '/',
+  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')
-            }
+    proxy: {
+      // change xxx-api/login => mock/login
+      // detail: https://cli.vuejs.org/config/#devserver-proxy
+      [process.env.VUE_APP_BASE_API]: {
+        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')
+      }
+    }
+  },
+  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')
+        }
+      )
+  }
 }