mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
Cherry-picked from PR branch (feat/payment-system-v2). - EasyPay: parse payurl2 for H5 mobile links, prefer on mobile - EasyPay: add device=mobile for popup mode on mobile - Backend: expand isMobile() to detect iPad/iPod - Frontend: auto-redirect on mobile instead of popup - Frontend: fallback to redirect when popup blocked - Stripe: use mobile_web client for WeChat Pay on mobile - StripePopup: typed interface, extractApiErrorMessage
12 lines
488 B
TypeScript
12 lines
488 B
TypeScript
/**
|
|
* Detect whether the current device is mobile.
|
|
* Uses navigator.userAgentData (modern API) with UA regex fallback.
|
|
*/
|
|
export function isMobileDevice(): boolean {
|
|
const nav = navigator as unknown as Record<string, unknown>
|
|
if (nav.userAgentData && typeof (nav.userAgentData as Record<string, unknown>).mobile === 'boolean') {
|
|
return (nav.userAgentData as Record<string, unknown>).mobile as boolean
|
|
}
|
|
return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent)
|
|
}
|