import { LOCAL_DEVICE_CODE } from '../constants/Localkey'; import { createUUID, localStorageGet, localStorageSet } from '../utils/Helper'; import { PlatformBridge, PlatformType } from './PlatformBridge'; export class H5PlatformBridge extends PlatformBridge { readonly type = PlatformType.H5; getUrlParam(name: string): string | null { if (!name || typeof window === 'undefined' || !window.location?.href) return null; const match = new RegExp(`[?&]${name}=([^&;]+?)(?:[&#;]|$)`).exec(window.location.href); const encodedValue = match?.[1]?.replace(/\+/g, '%20') ?? ''; if (!encodedValue) return null; try { return decodeURIComponent(encodedValue) || null; } catch { return null; } } getDeviceID(): string | null { let code = localStorageGet(LOCAL_DEVICE_CODE, ""); if (!code) { code = createUUID(); localStorageSet(LOCAL_DEVICE_CODE, code); } return code; } getAdID() { return ''; } }