From e69a201e9752299f89b0781daded571d0d930dfd Mon Sep 17 00:00:00 2001 From: Clansty Date: Sat, 4 Jan 2025 21:17:30 +0800 Subject: [PATCH] [+] Drag and drop to link card --- AquaNet/src/libs/i18n/en_ref.ts | 2 +- AquaNet/src/libs/i18n/zh.ts | 2 +- AquaNet/src/pages/Home/LinkCard.svelte | 28 +++++++++++++++++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/AquaNet/src/libs/i18n/en_ref.ts b/AquaNet/src/libs/i18n/en_ref.ts index 4c16ffdb..18c74716 100644 --- a/AquaNet/src/libs/i18n/en_ref.ts +++ b/AquaNet/src/libs/i18n/en_ref.ts @@ -92,7 +92,7 @@ export const EN_REF_HOME = { 'home.linkcard.account-card': 'Account Card', 'home.linkcard.registered': 'Registered', 'home.linkcard.lastused': 'Last used', - 'home.linkcard.enter-info': 'Please enter the following information', + 'home.linkcard.enter-info': 'Please enter the following information, or drag and drop your aime.txt / felica.txt file here', 'home.linkcard.access-code': 'The 20-digit access code on the back of your card. (If it doesn\'t work, please try scanning your card in game and enter the access code shown on screen)', 'home.linkcard.enter-sn1': 'Download the NFC Tools app on your phone', 'home.linkcard.enter-sn2': 'and scan your card. Then, enter the Serial Number.', diff --git a/AquaNet/src/libs/i18n/zh.ts b/AquaNet/src/libs/i18n/zh.ts index 07b6294b..dbc7e8ed 100644 --- a/AquaNet/src/libs/i18n/zh.ts +++ b/AquaNet/src/libs/i18n/zh.ts @@ -102,7 +102,7 @@ const zhHome: typeof EN_REF_HOME = { 'home.linkcard.account-card': "账户卡", 'home.linkcard.registered': "注册于", 'home.linkcard.lastused': "上次使用", - 'home.linkcard.enter-info': "请输入以下信息", + 'home.linkcard.enter-info': "请输入以下信息,或将 aime.txt / felica.txt 文件拖放到此区域", 'home.linkcard.access-code': "卡背面的20位卡号 (如果没有, 请尝试在游戏中扫描您的卡, 并输入屏幕上显示的卡号)", 'home.linkcard.enter-sn1': "在您的手机", 'home.linkcard.enter-sn2': "上下载 NFC Tools 并扫描您的卡。然后输入显示的 SN 号。", diff --git a/AquaNet/src/pages/Home/LinkCard.svelte b/AquaNet/src/pages/Home/LinkCard.svelte index 9ed4d50a..8c9e4dde 100644 --- a/AquaNet/src/pages/Home/LinkCard.svelte +++ b/AquaNet/src/pages/Home/LinkCard.svelte @@ -161,8 +161,7 @@ let inputAC = "" let errorAC = "" - function inputACChange(e: any) { - e = e as InputEvent + function inputACChange() { // Add spaces to the input const old = inputAC inputAC = inputAC.replace(/\D/g, '').replace(/(.{4})/g, '$1 ').replace(/ $/, '') @@ -174,8 +173,7 @@ let inputSN = "" let errorSN = "" - function inputSNChange(e: any) { - e = e as InputEvent + function inputSNChange() { // Add colons to the input const old = inputSN inputSN = inputSN.toUpperCase().replace(/[^0-9A-F]/g, '').replace(/(.{2})/g, '$1:').replace(/:$/, '') @@ -205,9 +203,29 @@ function isInput(e: KeyboardEvent) { return e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey } + + async function dropFile(e: DragEvent) { + e.preventDefault() + e.stopPropagation() + const file = e.dataTransfer?.files[0] + if (!file) return + switch (file.name.toLowerCase()) { + case "aime.txt": + inputSN = "" + inputAC = await file.text() + inputACChange() + break + case "felica.txt": + inputAC = "" + inputSN = await file.text() + inputSNChange() + break + } + } -