pujiaming %!s(int64=2) %!d(string=hai) anos
pai
achega
9c2d4a91cd

+ 2 - 2
src/components/layout/header.vue

@@ -119,9 +119,9 @@ onMounted(() => {
 // 退出登录
 const logOut = () => {
   // console.log(22);
-  localStorage.removeItem('token')
-  router.push({ path: '/login' })
+  sessionStorage.removeItem('token')
   hasToken.value = ''
+  router.push({ path: '/login' })
 }
 const toSetting = () => {
   router.push('/settings')

+ 12 - 10
src/router/index.ts

@@ -104,20 +104,22 @@ const router = createRouter({
     return { top: 0 }
   }
 })
-
-router.beforeEach((to, from, next) => {
+const whteList = ['/home', '/login', '/my_game', '/cate', '/']
+router.beforeEach((to, _from, next) => {
   // ...
   // 返回 false 以取消导航
   // return false
-  console.log(to, from)
 
-  // const token = sessionStorage.getItem('token')
-  // if (!token && to.path !== '/login') {
-  //   next('/login')
-  // } else {
-  //   next()
-  // }
-  next()
+  const token = sessionStorage.getItem('token')
+  if (whteList.includes(to.path)) {
+    next()
+  } else {
+    if (!token) {
+      next('/login')
+    } else {
+      next()
+    }
+  }
 })
 router.afterEach(() => {
   getVersionFR()

+ 2 - 2
src/utils/version.ts

@@ -30,9 +30,9 @@ export function getVersion() {
 }
 export function getVersionFR() {
   // 或者 路由守卫afterEach 中加入
-  console.log(import.meta.env.VITE_ENV === 'development')
+  console.log(import.meta.env.DEV)
 
-  if (import.meta.env.VITE_ENV === 'development') return
+  if (import.meta.env.DEV) return
   const htmlFileUrl = `${location.origin}${location.pathname}`
   fetch(htmlFileUrl, {
     method: 'HEAD',

+ 7 - 8
src/views/mine.vue

@@ -23,18 +23,17 @@
         <img :src="prefix + item.screenshot" class="game-poster" :onerror="posterErrorFun" alt=""/>
       </li>
     </ul>
+    <div v-if="!token" :style="{ height: viewWidth + 'px' }" class="df fdc aic jcc">
+      <el-empty description="您还未登录!登录后可查询数据!">
+        <el-button style="color:#fff" color="#ed8c0f" @click="goLogin">去登录 &gt;&gt;</el-button>
+      </el-empty>
+    </div>
     <div class="more-action">
       <el-button v-if="params.page*params.pagesize < total" type="info" @click="loadMore">更多</el-button>
       <el-divider v-else>没有更多了</el-divider>
     </div>
   </div>
 
-  <div v-if="!token" :style="{ height: viewWidth + 'px' }" class="df fdc aic jcc">
-    <el-empty description="您还未登录!登录后可查询数据!">
-      <el-button style="color:#fff" color="#ed8c0f" @click="goLogin">去登录 &gt;&gt;</el-button>
-    </el-empty>
-  </div>
-
   <el-dialog  v-model="dialogVisible" title="游戏礼包" width="80%">
     <el-collapse v-if="giftData.length" v-model="activeName" accordion>
       <div v-for="(item, index) in giftData" :key="index" style="display: flex;justify-content: space-between; align-items: center;">
@@ -131,8 +130,8 @@ onMounted(() => {
     if (route.query.account || userAccount.value) {
       getMyGame(params)
     }
+    user.getUserProfile()
   }
-  user.getUserProfile()
 })
 
 const getMyGame = async(params:Params) => {
@@ -157,7 +156,7 @@ const loadMore = () => {
 }
 
 const goLogin = () => {
-  router.push({ path: 'p_login' })
+  router.push({ path: '/login' })
   local.remove('headerPath')
 }
 const giftData = ref<any[]>([])

+ 3 - 3
src/views/settings.vue

@@ -234,9 +234,9 @@ const blurValidate = (formEl: FormInstance | undefined) => {
     console.log(error)
   })
 }
-const checkAge = (a:any, b:any, callback: any) => {
-  console.log(a, b)
-
+const checkAge = (_a:any, _b:any, callback:any) => {
+  // ...args:any
+  // const callback = args[2]
   if (!ruleForm.new_password2.length || !ruleForm.new_password.length) {
     return callback()
   }

+ 3 - 1
src/vite-env.d.ts

@@ -12,7 +12,9 @@ interface ImportMetaEnv {
 
     readonly VITE_PROJECT_NAME: string
 
-    readonly VITE_ENV: any
+    readonly DEV: boolean
+
+    readonly VITE_ENV: boolean
 
 }