فهرست منبع

修改token及根据环境判断router和config

lrf402788946 5 سال پیش
والد
کامیت
b0544c9c49
5فایلهای تغییر یافته به همراه6 افزوده شده و 20 حذف شده
  1. 3 15
      src/layout/layout-part/heads.vue
  2. 1 1
      src/router.js
  3. 0 2
      src/views/home/index.vue
  4. 1 1
      src/views/login/login.vue
  5. 1 1
      vue.config.js

+ 3 - 15
src/layout/layout-part/heads.vue

@@ -64,8 +64,8 @@ export default {
     html: '<ul class="popoverCon"><li>没有消息</li></ul><a class="popoverBtn">点击进入信息中心<span class="el-icon-d-arrow-right info_icon"></span></a>',
   }),
   created() {
-    // this.checkUrl();
     this.setUser();
+    this.check();
   },
   computed: {
     ...mapState(['user']),
@@ -73,20 +73,8 @@ export default {
   methods: {
     ...mapMutations(['setUser']),
     ...mapActions(['userOperation']),
-    checkUrl() {
-      if (this.user.corpid) return;
-      if (location.search.length > 0) {
-        let params = location.search.replace('?', '').split('=');
-        let key = params[0];
-        if (key.includes(`token`)) {
-          let token = params[1];
-          sessionStorage.setItem('token', token);
-          let info = jwt.decode(token);
-          this.setUser(info);
-          let turnTo = window.location.href.replace(window.location.search, '');
-          window.location.href = turnTo;
-        }
-      }
+    check() {
+      if (!this.user.corpid) this.$router.push({ path: '/login' });
     },
     toClose() {
       this.$refs.form.resetFields();

+ 1 - 1
src/router.js

@@ -4,7 +4,7 @@ Vue.use(Router);
 
 export default new Router({
   mode: 'history',
-  base: process.env.VUE_APP_ROUTER,
+  base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROUTER,
   routes: [
     {
       path: '/',

+ 0 - 2
src/views/home/index.vue

@@ -170,11 +170,9 @@ export default {
           let object = { ...val, avatar_url: result.data.avatar_url };
           // let object = { ...val, list: result.data };
           arr.push(object);
-          console.log(result);
         });
         //给this=>vue的实例下在中的list属性,赋予result.data的值
         this.$set(this, `resumeList`, arr);
-        console.log(arr);
       } else {
         this.$message.error(result.errmsg ? result.errmsg : 'error');
       }

+ 1 - 1
src/views/login/login.vue

@@ -149,7 +149,7 @@ export default {
         message: `${result.errcode}` === '0' ? '登录成功' : result.errmsg,
       });
       if (`${result.errcode}` === '0') {
-        sessionStorage.setItem('token', JSON.stringify(result.data));
+        sessionStorage.setItem('token', result.data);
         let info = jwt.decode(result.data);
         sessionStorage.setItem('user', JSON.stringify(info));
         this.$router.push({ path: '/' });

+ 1 - 1
vue.config.js

@@ -1,7 +1,7 @@
 const path = require('path');
 const resumeSrc = path.resolve(__dirname, '../web-common');
 module.exports = {
-  publicPath: '/www',
+  publicPath: process.env.NODE_ENV === 'development' ? '/' : '/www',
   configureWebpack: config => {
     Object.assign(config, {
       // 开发生产共同配置