auth.vue 930 Bytes
<!--
 * @Date: 2022-08-29 13:55:31
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2022-12-06 20:56:54
 * @FilePath: /data-table/src/views/auth.vue
 * @Description: 授权模块
-->
<template>
  <div />
</template>

<script setup>
import { onMounted } from 'vue'
import { useAuthRedirect } from '@/composables'

const {
  getAuthTargetHash,
  getQueryValue,
  redirectToOpenIdAuth,
  savePendingAuthReturnGuard,
  markSkipCycleCheckForAuth,
} = useAuthRedirect();

onMounted(() => {
  const code = getQueryValue('code');
  const targetHash = getAuthTargetHash();
  // 兼容老的 /auth 入口时,也补上同一套一次性回退保护和周期检查跳过标记
  savePendingAuthReturnGuard(code, targetHash || '#/');
  markSkipCycleCheckForAuth();
  // 兼容老的 /auth 入口:统一交给 composable 计算并 replace 到后端授权地址
  redirectToOpenIdAuth(code, targetHash || '#/');
})
</script>