From 3d7bd6362f6c9af95eb1c6b734027cd5802c8666 Mon Sep 17 00:00:00 2001 From: break27 Date: Thu, 9 Jul 2026 15:15:15 +0800 Subject: [PATCH] fix: button state in during closing --- index.html | 10 +++++----- main.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 365247a..72d578b 100644 --- a/index.html +++ b/index.html @@ -241,7 +241,7 @@ async function handlePrimaryButtonClick() { break; case 'READY': let locale = $('#locale').value; - let options = { locale, mapping: new Object(), writable: new Boolean(writable) }; + let options = { locale, subcategories, mapping: new Object(), writable: new Boolean(writable), start: 2, limit: null }; for (let element of $.all("input[type='number'].params")) { parameters[element.id] = element.disabled ? null : element.valueAsNumber; @@ -264,9 +264,8 @@ async function handlePrimaryButtonClick() { } if (options.slice) { - options.start = $('#offset').valueAsNumber * $('#chunksize').valueAsNumber + 2; options.limit = Math.min(minor || major, $('#chunksize').valueAsNumber); - options.subcategories = subcategories.length > 0 ? subcategories: null; + options.start += $('#offset').valueAsNumber * $('#chunksize').valueAsNumber; } await Rpc2.invoke('begin', options, parameters); @@ -432,8 +431,8 @@ while (await new Promise(o => setTimeout(o, 1000, true))) { $('#remainingLabel').innerText = ''; break; case 'CLOSING': - try { - if (writable === null) break; + if (writable) try { + $.all('#actions > button').forEach(e => e.disabled = true); let data = await filereader().then(([_, b]) => Rpc2.invoke('merge', new Uint8Array(b).toBase64())); await writable.write(Uint8Array.fromBase64(data)); await writable.close(); @@ -443,6 +442,7 @@ while (await new Promise(o => setTimeout(o, 1000, true))) { await writable.abort().catch(() => void 0); } writable = null; + continue; case 'RUNNING': $('#send > span.text').innerText = 'Pause'; $('#send').classList.add('pulse'); diff --git a/main.py b/main.py index d60048f..7c022be 100644 --- a/main.py +++ b/main.py @@ -93,7 +93,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')): result = dict() col = headers.index(header) + 1 - for row in range(options.get('start', 2), limit + 1): + for row in range(options.get('start'), limit + 1): key = str(wb.active.cell(row, col).value) result[key] = result.get(key, 0) + 1 @@ -318,7 +318,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')): buffer = BytesIO(data) target = load_workbook(buffer) - for row in range(options.get('start', 2), limit + 1): + for row in range(options.get('start'), limit + 1): c1 = wb.active.cell(row, index + 1) c2 = target.active.cell(row, index + 1) if not (c1.value and str(c1.value).strip()):