feat(web-admin): skip desktop chrome and login page inside mp webview routes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-09-14 16:15:08 +08:00
1 parent 5eb7b0b193
commit c0721786ff
3 files changed
+54 -3

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
export const MP_WEBVIEW_PATH_PREFIX = '/m/'
export function isMpWebviewPath(path: string): boolean {
return (path || '').startsWith(MP_WEBVIEW_PATH_PREFIX)
}
export function getWxMiniProgram(): {
reLaunch?: (opt: { url: string }) => void
navigateBack?: (opt?: { delta?: number }) => void
} | null {
if (typeof window === 'undefined') return null
const wxObj = (window as unknown as { wx?: { miniProgram?: unknown } }).wx
const mini = wxObj?.miniProgram as
| { reLaunch?: (opt: { url: string }) => void; navigateBack?: (opt?: { delta?: number }) => void }
| undefined
return mini || null
}
export function redirectToMiniLogin(): void {
const mini = getWxMiniProgram()
if (mini?.reLaunch) {
mini.reLaunch({ url: '/pages/login/login' })
return
}
// 非小程序:只展示空态,禁止跳管理端登录
}
export function stripMpTicketFromUrl(
path: string,
query: Record<string, unknown>
): Record<string, unknown> {
const next = { ...query }
delete next.mpTicket
return next
}