浏览代码

修复打开分享页需要登陆的BUG

648540858 2 年之前
父节点
当前提交
228c57399a
共有 2 个文件被更改,包括 17 次插入14 次删除
  1. 2 2
      web_src/config/index.js
  2. 15 12
      web_src/src/App.vue

+ 2 - 2
web_src/config/index.js

@@ -12,14 +12,14 @@ module.exports = {
     assetsPublicPath: '/',
     proxyTable: {
       '/debug': {
-        target: 'http://localhost:18978',
+        target: 'http://localhost:18080',
         changeOrigin: true,
         pathRewrite: {
           '^/debug': '/'
         }
       },
       '/static/snap': {
-        target: 'http://localhost:18978',
+        target: 'http://localhost:18080',
         changeOrigin: true,
         // pathRewrite: {
         //   '^/static/snap': '/static/snap'

+ 15 - 12
web_src/src/App.vue

@@ -11,6 +11,7 @@ export default {
   data(){
     return {
       isLogin: false,
+      excludeLoginCheck: ["/play/wasm", "/play/rtc"],
       userInfo: { //保存用户信息
         nick: null,
         ulevel: null,
@@ -21,27 +22,29 @@ export default {
   },
   created() {
     if (userService.getToken() == null){
+      console.log(22222)
+      console.log(this.$route.path)
+      try {
+        if (this.excludeLoginCheck && this.excludeLoginCheck.length > 0) {
+          for (let i = 0; i < this.excludeLoginCheck.length; i++) {
+            if (this.$route.path.startsWith(this.excludeLoginCheck[i])){
+              return;
+            }
+          }
+        }
+      }catch (e) {
+        console.error(e)
+      }
       //如果没有登录状态则跳转到登录页
       this.$router.push('/login');
     }
   },
-  //监听路由检查登录
-  watch:{
-    "$route" : 'checkLogin'
-  },
+
   mounted(){
     //组件开始挂载时获取用户信息
     // this.getUserInfo();
   },
   methods: {
-    checkLogin(){
-      //检查是否存在session
-      if (userService.getToken() == null){
-        //如果没有登录状态则跳转到登录页
-        // this.$router.push('/login');
-      }
-
-    },
   },
   components: {}
 };