refactor: 重命名 QRScanner 函数,统一调用方式
This commit is contained in:
@@ -18,17 +18,17 @@ export function useQRScanner() {
|
||||
const { vibrate } = useHaptics();
|
||||
const isSupported = Capacitor.isNativePlatform();
|
||||
|
||||
const showError = async (message: string) => {
|
||||
async function showError(message: string) {
|
||||
const toast = await toastController.create({
|
||||
message,
|
||||
duration: 2000,
|
||||
position: "top",
|
||||
position: "bottom",
|
||||
color: "danger",
|
||||
});
|
||||
await toast.present();
|
||||
};
|
||||
|
||||
const openScanner = async (options?: ScannerOptions): Promise<QRScanResult | null> => {
|
||||
async function open(options?: ScannerOptions): Promise<QRScanResult | null> {
|
||||
try {
|
||||
if (!isSupported) {
|
||||
await showError(t("scanner.notSupported"));
|
||||
@@ -62,10 +62,10 @@ export function useQRScanner() {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
isSupported,
|
||||
openScanner,
|
||||
open,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user