index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <router-view class="bg-white" />
  3. </template>
  4. <script lang="ts" setup>
  5. import { defineComponent, provide } from 'vue'
  6. import { useRoute, useRouter } from 'vue-router'
  7. import Cookie from 'js-cookie'
  8. defineComponent({
  9. name: 'IndentManageIndex',
  10. })
  11. provide('mediaRegExp', /^(https?:)?\/\/.+(.com.au\/|.com\/)/)
  12. const $route = useRoute()
  13. const token = Cookie.get('indent-token')
  14. // 访问非登录页, 未登录状态调整登录页
  15. if (!token && $route.path !== '/indent-manage/login') {
  16. const $router = useRouter()
  17. const originQuery = $route.query as {
  18. [key: string]: string
  19. }
  20. const params: any = {
  21. origin: encodeURIComponent($route.fullPath),
  22. }
  23. if (originQuery.u?.length && originQuery.p?.length) {
  24. params.action = 'autoLogin'
  25. params.p = originQuery.p.trim()
  26. params.u = originQuery.u.trim()
  27. }
  28. console.log('未登录重定向')
  29. $router.replace({
  30. path: '/indent-manage/login',
  31. query: params,
  32. })
  33. }
  34. </script>
  35. <style>
  36. .bg-white {
  37. background-color: #fefefe;
  38. }
  39. </style>