Zimo пре 19 часа
родитељ
комит
53f8b5598f
3 измењених фајлова са 23 додато и 4 уклоњено
  1. 5 2
      src/components/Error/src/Error.vue
  2. 13 1
      src/permission.ts
  3. 5 1
      src/views/Error/404.vue

+ 5 - 2
src/components/Error/src/Error.vue

@@ -35,7 +35,8 @@ const errorMap: {
 }
 
 const props = defineProps({
-  type: propTypes.string.validate((v: string) => ['404', '500', '403'].includes(v)).def('404')
+  type: propTypes.string.validate((v: string) => ['404', '500', '403'].includes(v)).def('404'),
+  showButton: propTypes.bool.def(true)
 })
 
 const emit = defineEmits(['errorClick'])
@@ -51,7 +52,9 @@ const btnClick = () => {
       <img :src="errorMap[type].url" alt="" width="350" />
       <div class="text-14px text-[var(--el-color-info)]">{{ errorMap[type].message }}</div>
       <div class="mt-20px">
-        <ElButton type="primary" @click="btnClick">{{ errorMap[type].buttonText }}</ElButton>
+        <ElButton type="primary" v-if="showButton" @click="btnClick">{{
+          errorMap[type].buttonText
+        }}</ElButton>
       </div>
     </div>
   </div>

+ 13 - 1
src/permission.ts

@@ -141,6 +141,12 @@ router.beforeEach(async (to, from, next) => {
 
       authUtil.setToken(res)
 
+      // const source = to.query.source
+      // if (source) {
+      //   sessionStorage.setItem('LOGIN_SOURCE', source as string)
+      //   next({ path: '/oli-connection/monitoring' })
+      // }
+
       next({ path: '/index' })
     } else if (whiteList.indexOf(to.path) !== -1) {
       const code = to.query.code
@@ -155,7 +161,13 @@ router.beforeEach(async (to, from, next) => {
       }
       // next()
     } else {
-      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
+      const source = to.query.source
+      if (source) {
+        sessionStorage.setItem('LOGIN_SOURCE', source as string)
+      }
+      if (source) {
+        next(`/login?redirect=/oli-connection/monitoring`)
+      } else next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
     }
   }
 })

+ 5 - 1
src/views/Error/404.vue

@@ -1,7 +1,11 @@
 <template>
-  <Error @error-click="push('/')" />
+  <Error :show-button="source !== 'zhly'" @error-click="push('/')" />
 </template>
 <script lang="ts" setup>
 defineOptions({ name: 'Error404' })
 const { push } = useRouter()
+
+const route = useRoute()
+
+const source = computed(() => sessionStorage.getItem('LOGIN_SOURCE') || route.query.source)
 </script>