From e2235300a9950486a98907f01e9c2315af39c6c0 Mon Sep 17 00:00:00 2001 From: yayunhuang Date: Fri, 23 Aug 2024 17:25:56 +0800 Subject: [PATCH] Move autoDoenload.js from public/ to src/ and update to use typescript --- public/scripts/autoDownload.js | 12 ------------ src/pages/download/_autoDownload.ts | 13 +++++++++++++ src/pages/{download.astro => download/index.astro} | 8 ++++---- .../download.css => pages/download/index.css} | 0 4 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 public/scripts/autoDownload.js create mode 100644 src/pages/download/_autoDownload.ts rename src/pages/{download.astro => download/index.astro} (93%) rename src/{styles/download.css => pages/download/index.css} (100%) diff --git a/public/scripts/autoDownload.js b/public/scripts/autoDownload.js deleted file mode 100644 index 908ac72..0000000 --- a/public/scripts/autoDownload.js +++ /dev/null @@ -1,12 +0,0 @@ -function ready(fn) { - if (document.readyState != "loading") { - fn(); - } else { - document.addEventListener("DOMContentLoaded", fn); - } -} -ready(main); - -function main() { - generateZIP(window.targetDeviceId); -} diff --git a/src/pages/download/_autoDownload.ts b/src/pages/download/_autoDownload.ts new file mode 100644 index 0000000..e99aadf --- /dev/null +++ b/src/pages/download/_autoDownload.ts @@ -0,0 +1,13 @@ +export function readyForAutoDownload(fn: () => void): void { + if (document.readyState != "loading") { + fn(); + } else { + document.addEventListener("DOMContentLoaded", fn); + } +} + +export function mainForAutoDownload(): void { + generateZIP((window as any).targetDeviceId); +} + +readyForAutoDownload(mainForAutoDownload); diff --git a/src/pages/download.astro b/src/pages/download/index.astro similarity index 93% rename from src/pages/download.astro rename to src/pages/download/index.astro index ecd0acb..474005a 100644 --- a/src/pages/download.astro +++ b/src/pages/download/index.astro @@ -1,7 +1,7 @@ --- -import BaseLayout from "../layouts/BaseLayout.astro"; -import "/src/styles/download.css"; -import ErrorPage from "../components/ErrorPage.astro"; +import BaseLayout from "../../layouts/BaseLayout.astro"; +import ErrorPage from "../../components/ErrorPage.astro"; +import "./index.css"; --- + -