From 6e8514644e9630d6762105db0536af8626b1582a Mon Sep 17 00:00:00 2001 From: teaSummer Date: Tue, 2 Jul 2024 17:47:01 +0800 Subject: [PATCH] fix: auto save versions --- scripts/main.js | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/scripts/main.js b/scripts/main.js index fd77fd2..5968331 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -41,26 +41,33 @@ const createSuperLabel = ((url, id) => { }); // 更新提示 创建 -const createUpdateLayer = ((abbr, lastVersion, latestVersion, download, deviceInfo, flag) => { +const createUpdateLayer = ((abbr, lastVersion, latestVersion, download, device, deviceInfo, flag) => { ++updateLayerNumber; + const stableOrDev = ((flag == 'release') ? 'stable' : 'dev'); const dom = ` -
-
-
- ${abbr} - - - ${latestVersion} -
- ${lastVersion} - => - ${latestVersion} -
- (${deviceInfo}) -
- -
`; +
+
+
+ ${abbr} + + + ${latestVersion} +
+ ${lastVersion} + => + ${latestVersion} +
+ (${deviceInfo}) +
+ +
`; $('sidebar').before(dom); + $(`.update-layer-${updateLayerNumber} .download`).click(() => { + const set = ((version, stableOrDev) => { + localStorage.setItem(`last-${device}-${abbr}-${stableOrDev}-download`, version); + }); + set(latestVersion, stableOrDev); + }); }); // 更新提示 删除 @@ -512,14 +519,14 @@ $(document).ready(() => { const lastStableVersion = localStorage.getItem(`last-${device}-${abbr}-stable-download`); const latestStableVersion = launcher.version; if (lastStableVersion && lastStableVersion != latestStableVersion) { - createUpdateLayer(abbr, lastStableVersion, latestStableVersion, launcher.download, deviceInfo, 'release'); + createUpdateLayer(abbr, lastStableVersion, latestStableVersion, launcher.download, device, deviceInfo, 'release'); }; }; if (launcher.hasOwnProperty('dev')) { const lastDevVersion = localStorage.getItem(`last-${device}-${abbr}-dev-download`); const latestDevVersion = launcher.dev.version; if (lastDevVersion && lastDevVersion != latestDevVersion) { - createUpdateLayer(abbr, lastDevVersion, latestDevVersion, launcher.dev.download, deviceInfo, 'preRelease'); + createUpdateLayer(abbr, lastDevVersion, latestDevVersion, launcher.dev.download, device, deviceInfo, 'preRelease'); }; }; };