index.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { getURLSearchParams } from '@/tools';
  2. const userAgent = navigator.userAgent;
  3. export function platformIsAIO() {
  4. return /Six\/applet \(AIO;.+\)/i.test(userAgent) || /aio\/\w+/i.test(userAgent);
  5. }
  6. export function platformIsAIO_1() {
  7. return /aio\/1\.0/i.test(userAgent);
  8. }
  9. export function getSerialNumberSync() {
  10. const match = userAgent.match(/sn\/(\w+)/i);
  11. return match?.[ 1 ] ?? (
  12. function() {
  13. const query = getURLSearchParams();
  14. return query.get('serial') ?? query.get('serialNumber') ?? query.get('sn') ?? void 0;
  15. }
  16. )();
  17. }
  18. let getNetworkWall = async (): Promise<"exterior" | "interior"> => {
  19. const controller = new AbortController();
  20. setTimeout(() => controller.abort(), 1000);
  21. const wall = await fetch(`https://wx.hzliuzhi.com/aio/`, { method: 'HEAD', mode: 'no-cors', signal: controller.signal }).then(
  22. () => 'exterior' as const,
  23. () => 'interior' as const,
  24. );
  25. return (getNetworkWall = () => Promise.resolve(wall), wall);
  26. };
  27. export { getNetworkWall };
  28. export * from './dialog.ui';
  29. export * from './notify.ui';
  30. export * from './toast.ui';