From 04a5beed89fc1c110822462696adad5bb7824cc2 Mon Sep 17 00:00:00 2001 From: Seven Date: Thu, 8 Jan 2026 15:23:25 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9B=86=E6=88=90=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E6=89=AB=E6=8F=8F=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=A7=86=E9=A2=91=E6=B5=81=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20vconsole=20=E5=92=8C=20SSL=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 4 - package.json | 2 + pnpm-lock.yaml | 37 +++ src/components/qr-scanner/index.vue | 353 ++-------------------------- src/composables/useQRScanner.ts | 54 ++--- src/main.ts | 7 + src/views/riwa/index.vue | 18 ++ src/views/user/index.vue | 2 +- vite.config.ts | 2 + 9 files changed, 108 insertions(+), 371 deletions(-) diff --git a/components.d.ts b/components.d.ts index c06c048..d8e837d 100644 --- a/components.d.ts +++ b/components.d.ts @@ -49,8 +49,6 @@ declare module 'vue' { IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet'] IonRow: typeof import('@ionic/vue')['IonRow'] IonSearchbar: typeof import('@ionic/vue')['IonSearchbar'] - IonSegment: typeof import('@ionic/vue')['IonSegment'] - IonSegmentButton: typeof import('@ionic/vue')['IonSegmentButton'] IonSelect: typeof import('@ionic/vue')['IonSelect'] IonSelectOption: typeof import('@ionic/vue')['IonSelectOption'] IonSpinner: typeof import('@ionic/vue')['IonSpinner'] @@ -109,8 +107,6 @@ declare global { const IonRouterOutlet: typeof import('@ionic/vue')['IonRouterOutlet'] const IonRow: typeof import('@ionic/vue')['IonRow'] const IonSearchbar: typeof import('@ionic/vue')['IonSearchbar'] - const IonSegment: typeof import('@ionic/vue')['IonSegment'] - const IonSegmentButton: typeof import('@ionic/vue')['IonSegmentButton'] const IonSelect: typeof import('@ionic/vue')['IonSelect'] const IonSelectOption: typeof import('@ionic/vue')['IonSelectOption'] const IonSpinner: typeof import('@ionic/vue')['IonSpinner'] diff --git a/package.json b/package.json index 20895cf..8d69b70 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "pinia": "^3.0.4", "qrcode": "^1.5.4", "tailwindcss": "^4.1.18", + "vconsole": "^3.15.1", "vee-validate": "^4.15.1", "vue": "^3.5.25", "vue-i18n": "^11.2.2", @@ -72,6 +73,7 @@ "@types/lodash-es": "^4.17.12", "@types/node": "^24.10.2", "@types/qrcode": "^1.5.6", + "@vitejs/plugin-basic-ssl": "^2.1.3", "@vitejs/plugin-legacy": "^7.2.1", "@vitejs/plugin-vue": "^6.0.2", "@vitejs/plugin-vue-jsx": "^5.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 30133e0..02e7301 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,6 +98,9 @@ importers: tailwindcss: specifier: ^4.1.18 version: 4.1.18 + vconsole: + specifier: ^3.15.1 + version: 3.15.1 vee-validate: specifier: ^4.15.1 version: 4.15.1(vue@3.5.25(typescript@5.9.3)) @@ -165,6 +168,9 @@ importers: '@types/qrcode': specifier: ^1.5.6 version: 1.5.6 + '@vitejs/plugin-basic-ssl': + specifier: ^2.1.3 + version: 2.1.3(vite@7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)) '@vitejs/plugin-legacy': specifier: ^7.2.1 version: 7.2.1(terser@5.44.1)(vite@7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2)) @@ -3698,6 +3704,12 @@ packages: '@vite-pwa/assets-generator': optional: true + '@vitejs/plugin-basic-ssl@2.1.3': + resolution: {integrity: sha512-mxZpCH6SjsAFkiVgaclJGTcYIHm2qxw4x2EP/AUlEVqHhk8ojU75thpvTalc5lAvIK3sJjpVxhzYNoLXOuJGKw==} + engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} + peerDependencies: + vite: ^6.0.0 || ^7.0.0 + '@vitejs/plugin-legacy@7.2.1': resolution: {integrity: sha512-CaXb/y0mlfu7jQRELEJJc2/5w2bX2m1JraARgFnvSB2yfvnCNJVWWlqAo6WjnKoepOwKx8gs0ugJThPLKCOXIg==} engines: {node: ^20.19.0 || >=22.12.0} @@ -4584,6 +4596,10 @@ packages: copy-paste@2.2.0: resolution: {integrity: sha512-jqSL4r9DSeiIvJZStLzY/sMLt9ToTM7RsK237lYOTG+KcbQJHGala3R1TUpa8h1p9adswVgIdV4qGbseVhL4lg==} + copy-text-to-clipboard@3.2.2: + resolution: {integrity: sha512-T6SqyLd1iLuqPA90J5N4cTalrtovCySh58iiZDGJ6FGznbclKh4UI+FGacQSgFzwKG77W7XT5gwbVEbd9cIH1A==} + engines: {node: '>=12'} + core-js-compat@3.47.0: resolution: {integrity: sha512-IGfuznZ/n7Kp9+nypamBhvwdwLsW6KC8IOaURw2doAK5e98AG3acVLdh0woOnEqCfUtS+Vu882JE4k/DAm3ItQ==} @@ -6818,6 +6834,9 @@ packages: muggle-string@0.4.1: resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} + mutation-observer@1.0.3: + resolution: {integrity: sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA==} + mute-stream@0.0.8: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} @@ -8700,6 +8719,9 @@ packages: reka-ui: ^2.0.0 vue: ^3.3.0 + vconsole@3.15.1: + resolution: {integrity: sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g==} + vee-validate@4.15.1: resolution: {integrity: sha512-DkFsiTwEKau8VIxyZBGdO6tOudD+QoUBPuHj3e6QFqmbfCRj1ArmYWue9lEp6jLSWBIw4XPlDLjFIZNLdRAMSg==} peerDependencies: @@ -12969,6 +12991,10 @@ snapshots: - workbox-build - workbox-window + '@vitejs/plugin-basic-ssl@2.1.3(vite@7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2))': + dependencies: + vite: 7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2) + '@vitejs/plugin-legacy@7.2.1(terser@5.44.1)(vite@7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2))': dependencies: '@babel/core': 7.28.5 @@ -13888,6 +13914,8 @@ snapshots: dependencies: iconv-lite: 0.4.24 + copy-text-to-clipboard@3.2.2: {} + core-js-compat@3.47.0: dependencies: browserslist: 4.28.1 @@ -16578,6 +16606,8 @@ snapshots: muggle-string@0.4.1: {} + mutation-observer@1.0.3: {} + mute-stream@0.0.8: {} nano-spawn@2.0.0: {} @@ -18854,6 +18884,13 @@ snapshots: transitivePeerDependencies: - '@vue/composition-api' + vconsole@3.15.1: + dependencies: + '@babel/runtime': 7.28.4 + copy-text-to-clipboard: 3.2.2 + core-js: 3.47.0 + mutation-observer: 1.0.3 + vee-validate@4.15.1(vue@3.5.25(typescript@5.9.3)): dependencies: '@vue/devtools-api': 7.7.9 diff --git a/src/components/qr-scanner/index.vue b/src/components/qr-scanner/index.vue index c5fa52e..8f81598 100644 --- a/src/components/qr-scanner/index.vue +++ b/src/components/qr-scanner/index.vue @@ -1,342 +1,33 @@ - - - - + diff --git a/src/composables/useQRScanner.ts b/src/composables/useQRScanner.ts index f7f7c3c..6ba3182 100644 --- a/src/composables/useQRScanner.ts +++ b/src/composables/useQRScanner.ts @@ -1,5 +1,4 @@ -import { CapacitorBarcodeScanner } from "@capacitor/barcode-scanner"; -import { Capacitor } from "@capacitor/core"; +import { CapacitorBarcodeScanner, CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerTypeHint } from "@capacitor/barcode-scanner"; import { toastController } from "@ionic/vue"; export interface QRScanResult { @@ -16,56 +15,41 @@ export interface ScannerOptions { export function useQRScanner() { const { t } = useI18n(); const { vibrate } = useHaptics(); - const isSupported = Capacitor.isNativePlatform(); - async function showError(message: string) { - const toast = await toastController.create({ - message, - duration: 2000, - position: "bottom", - color: "danger", - }); - await toast.present(); - }; - - async function open(options?: ScannerOptions): Promise { + async function open(options?: ScannerOptions) { try { - if (!isSupported) { - await showError(t("scanner.notSupported")); - return null; - } - vibrate(); const result = await CapacitorBarcodeScanner.scanBarcode({ - hint: 0, + hint: CapacitorBarcodeScannerTypeHint.QR_CODE, scanInstructions: options?.title || t("scanner.hint"), - cameraDirection: 1, + cameraDirection: CapacitorBarcodeScannerCameraDirection.BACK, }); - if (result.ScanResult) { - vibrate(); - return { - text: result.ScanResult, - format: result.format?.toString() || "UNKNOWN", - rawValue: result.ScanResult, - displayValue: result.ScanResult, - }; - } - - return null; + vibrate(); + return { + text: result.ScanResult, + format: result.format, + }; } catch (error: any) { console.log("error.message", error.message); if (error.code !== "OS-PLUG-BARC-0006") { - await showError(t("scanner.openError")); + const toast = await toastController.create({ + message: t("scanner.openError"), + duration: 2000, + position: "bottom", + color: "danger", + }); + await toast.present(); } - return null; } } + function close() { + } return { - isSupported, open, + close, }; } diff --git a/src/main.ts b/src/main.ts index 922bf48..a520081 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import { IonicVue } from "@ionic/vue"; import { createPinia } from "pinia"; +import VConsole from "vconsole"; import { useRegisterSW } from "virtual:pwa-register/vue"; import { createApp } from "vue"; import uiComponents from "@/ui"; @@ -66,6 +67,12 @@ watch(needRefresh, (refresh) => { } }); +if (import.meta.env.DEV) { + const vConsole = new VConsole(); + globalThis.vConsole = vConsole; + console.log("VConsole is enabled in development mode."); +} + function initTradingView() { const { VITE_TRADINGVIEW_LIBRARY_URL } = useEnv(); const promise1 = new Promise((resolve) => { diff --git a/src/views/riwa/index.vue b/src/views/riwa/index.vue index 0b62fb8..a422202 100644 --- a/src/views/riwa/index.vue +++ b/src/views/riwa/index.vue @@ -1,7 +1,22 @@