|
@@ -1,7 +1,7 @@
|
|
|
import { processMethod, scanAccountMethod } from '@/request/api';
|
|
|
import router from '@/router';
|
|
|
|
|
|
-import { platformIsAIO } from '@/platform';
|
|
|
+import { platformIsAIO, platformIsAIO_1 } from '@/platform';
|
|
|
|
|
|
export function waitFor(condition: () => boolean | Promise<boolean>, timeout: number = 300 * 1000) {
|
|
|
const start = Date.now();
|
|
@@ -25,8 +25,8 @@ export default function bridgeLoader(): DEV.Loader {
|
|
|
window.AIO ??= {};
|
|
|
window.AIO.scan ??= (value) => {
|
|
|
if (!value) return -1;
|
|
|
- const event = new CustomEvent('scan', { detail: { code: value, state: 0, type: -1 } });
|
|
|
- Bridge.getInstance().dispatchEvent(event);
|
|
|
+ const event = new CustomEvent('scan', { detail: { code: 0, data: { code: value, state: 0, type: -1 } } });
|
|
|
+ window.bridge.dispatchEvent(event);
|
|
|
return 0;
|
|
|
};
|
|
|
window.AIO.print ??= (value) => {
|
|
@@ -34,9 +34,10 @@ export default function bridgeLoader(): DEV.Loader {
|
|
|
};
|
|
|
|
|
|
return async function () {
|
|
|
+ if (platformIsAIO_1()) window.bridge = new EventTarget() as InstanceType<typeof Bridge>;
|
|
|
if (platformIsAIO()) {
|
|
|
await waitFor(() => window.bridge != null);
|
|
|
- Bridge.getInstance().addEventListener('scan', async ({ detail }) => {
|
|
|
+ window.bridge.addEventListener('scan', async ({ detail }) => {
|
|
|
if (detail.code !== 0 || detail.data?.code == null) return;
|
|
|
const route = unref(router.currentRoute);
|
|
|
if (route.meta?.scan) {
|