403.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="error404">
  3. <error code="403" title="您的账号权限不足,请联系管理员添加权限!" :show-btn="false">
  4. <template #content>
  5. <div class="flex justify-center">
  6. <img class="w-[150px] h-[150px]" src="@/assets/images/no_perms.png" alt="" />
  7. </div>
  8. </template>
  9. </error>
  10. </div>
  11. </template>
  12. <script lang="ts" setup>
  13. import Error from './components/error.vue'
  14. import { onMounted } from 'vue'
  15. import { useRoute } from 'vue-router'
  16. import {PageEnum} from "@/enums/pageEnum"
  17. import {clearAuthInfo} from "@/utils/auth";
  18. const router = useRouter()
  19. const route = useRoute()
  20. // 从环境变量获取白名单
  21. const allowedDomains = import.meta.env.VITE_ALLOWED_DOMAINS?.split(',') || []
  22. console.warn("***allowedDomains***",allowedDomains)
  23. onMounted(() => {
  24. const redirectUrl = allowedDomains[0]
  25. // const redirectUrl = route.query.redirect as string
  26. if (redirectUrl) {
  27. try {
  28. const url = new URL(decodeURIComponent(redirectUrl))
  29. // const isAllowed = allowedDomains.some((domain: string) =>
  30. // url.hostname.endsWith(domain)
  31. // )
  32. if (url) {
  33. setTimeout(() => {
  34. // window.location.href = url.toString()
  35. clearAuthInfo()
  36. router.push(PageEnum.LOGIN)
  37. }, 1500)
  38. } else {
  39. console.error(`不安全的跳转地址:`, redirectUrl)
  40. }
  41. } catch (e) {
  42. console.error('URL 解析错误:', e)
  43. }
  44. }
  45. })
  46. </script>