Files
zyt/admin/src/utils/wecomBindGuard.ts
2026-04-07 18:13:03 +08:00

11 lines
503 B
TypeScript

/**
* 判断浏览器地址栏是否处于「企微绑定页 OAuth 回调」(带 code)。
* 用于避免 axios 在 router.currentRoute 尚未同步完成时执行 router.replace('/bind-work-wechat') 把 query 整段清掉。
*/
export function isBrowserOnWecomBindOAuthLanding(): boolean {
if (typeof window === 'undefined') return false
const { pathname, search } = window.location
if (!pathname.includes('bind-work-wechat')) return false
return /(?:^|[?&])code=/.test(search)
}