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 77ce9218..8c9e4dde 100644 --- a/AquaNet/src/pages/Home/LinkCard.svelte +++ b/AquaNet/src/pages/Home/LinkCard.svelte @@ -161,13 +161,10 @@ let inputAC = "" let errorAC = "" - function inputACChange(e: any) { - e = e as InputEvent + function inputACChange() { // Add spaces to the input const old = inputAC - if (e.inputType === "insertText" && inputAC.length % 5 === 4 && inputAC.length < 24) - inputAC += " " - inputAC = inputAC.slice(0, 24) + inputAC = inputAC.replace(/\D/g, '').replace(/(.{4})/g, '$1 ').replace(/ $/, '') if (inputAC !== old) errorAC = "" } @@ -176,13 +173,10 @@ let inputSN = "" let errorSN = "" - function inputSNChange(e: any) { - e = e as InputEvent + function inputSNChange() { // Add colons to the input const old = inputSN - if (e.inputType === "insertText" && inputSN.length % 3 === 2 && inputSN.length < 23) - inputSN += ":" - inputSN = inputSN.toUpperCase().slice(0, 23) + inputSN = inputSN.toUpperCase().replace(/[^0-9A-F]/g, '').replace(/(.{2})/g, '$1:').replace(/:$/, '') if (inputSN !== old) errorSN = "" } @@ -209,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 + } + } -