Ver Fonte

注释权限验证相关代码和属性

reghao há 4 anos atrás
pai
commit
77c3b04785
5 ficheiros alterados com 25 adições e 32 exclusões
  1. 1 1
      .env.production
  2. 1 1
      .env.staging
  3. 12 6
      src/router/index.js
  4. 10 7
      src/utils/check-power.vue
  5. 1 17
      src/views/home/index.vue

+ 1 - 1
.env.production

@@ -2,4 +2,4 @@
 ENV = 'production'
 
 # base api
-VUE_APP_BASE_API = 'http://api.reghao.icu'
+VUE_APP_BASE_API = 'http://api.reghao.cn'

+ 1 - 1
.env.staging

@@ -4,4 +4,4 @@
 ENV = 'staging'
 
 # base api
-VUE_APP_BASE_API = 'http://api.reghao.icu'
+VUE_APP_BASE_API = 'http://api.reghao.cn'

+ 12 - 6
src/router/index.js

@@ -2,7 +2,7 @@ import Vue from 'vue'
 import VueRouter from 'vue-router'
 import Index from '@/layout/index.vue'
 import Home from '@/views/home/index.vue'
-import checkPower from '@/utils/check-power.vue'
+// import checkPower from '@/utils/check-power.vue'
 
 Vue.use(VueRouter)
 const routes = [
@@ -232,14 +232,20 @@ router.beforeEach((to, from, next) => {
 
   const vuexStore = router.app.$options.store
   // router.app.$options.store 就是 this.$store
-  if (checkPower.updateUserRole(vuexStore.state.user.userInfo)) {
+  /* if (checkPower.updateUserRole(vuexStore.state.user.userInfo)) {
     vuexStore.state.user.userInfo.role = 'ROLE_USER'
     vuexStore.commit('SET_USER_INFO', vuexStore.state.user.userInfo)
-  }
+  }*/
 
-  const date = new Date().getTime()
+  // const date = new Date().getTime()
   if (vuexStore.state.user.userInfo != null) {
-    if (vuexStore.state.user.userInfo.expireTime > date) {
+    if (to.path === '/login') {
+      return next({ path: '/' })
+    }
+    return next()
+
+    // TODO 不判断用户是否过期
+    /* if (vuexStore.state.user.userInfo.expireTime > date) {
       if (to.path === '/login') {
         return next({ path: '/' })
       }
@@ -250,7 +256,7 @@ router.beforeEach((to, from, next) => {
         path: '/login',
         query: { redirect: to.fullPath }
       })
-    }
+    }*/
   } else {
     if (to.meta.requireAuth) {
       return next({

+ 10 - 7
src/utils/check-power.vue

@@ -1,7 +1,7 @@
 <script>
 
 function checkPower(userInfo) {
-  if (userInfo.role === 'ROLE_ADMIN') {
+  /* if (userInfo.role === 'ROLE_ADMIN') {
     return 'admin'
   }
   if (userInfo.role === 'ROLE_VIP') {
@@ -12,11 +12,13 @@ function checkPower(userInfo) {
   }
   if (userInfo.role === 'ROLE_USER') {
     return 'user'
-  }
+  }*/
+
+  return 'user'
 }
 
 function checkVip(userInfo) {
-  if (userInfo.role === 'ROLE_VIP') {
+  /* if (userInfo.role === 'ROLE_VIP') {
     if (userInfo.vipStopTime < new Date().getTime()) {
       return false
     }
@@ -25,17 +27,18 @@ function checkVip(userInfo) {
   if (userInfo.role === 'ROLE_ADMIN') {
     return true
   }
-  return false
+  return false*/
+  return true
 }
 
 function updateUserRole(userInfo) {
-  if (userInfo === null) {
+  /* if (userInfo === null) {
     return false
   }
   if (userInfo.role === 'ROLE_VIP' && userInfo.vipStopTime < new Date().getTime()) {
     return true
-  }
-  return false
+  }*/
+  return true
 }
 
 export default {

+ 1 - 17
src/views/home/index.vue

@@ -37,22 +37,6 @@ export default {
     window.removeEventListener('scroll', this.lazyLoading)
   },
   methods: {
-    getVideoList() {
-      fetch(`/api/media/video/post/recommend`, {
-        headers: {
-          'Content-Type': 'application/json; charset=UTF-8',
-          'X-XSRF-TOKEN': this.$cookies.get('XSRF-TOKEN')
-        },
-        method: 'GET',
-        credentials: 'include'
-      }).then(response => response.json())
-        .then(json => {
-          this.videoList = json.data.list
-        })
-        .catch(e => {
-          return null
-        })
-    },
     getRecommendVideo() {
       videoRecommend()
         .then(res => {
@@ -82,7 +66,7 @@ export default {
       if (scrollTop + clientHeight >= scrollHeight) {
         // TODO 页面滚动到底部时请求数据并渲染当前页面
         console.log('滚动到底部,触发')
-        this.getVideoList()
+        this.getRecommendVideo()
       }
     }
   }