From 86a98eb3c8d023ebcb5a1579c4e0943d271f2539 Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Tue, 16 Apr 2024 20:48:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9eslint=E4=B8=8D=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/ui/create/menu/pages/otherMenu.js | 136 ++++++++++++----------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/noname/ui/create/menu/pages/otherMenu.js b/noname/ui/create/menu/pages/otherMenu.js index 07e96dbd2..1dd130c4f 100644 --- a/noname/ui/create/menu/pages/otherMenu.js +++ b/noname/ui/create/menu/pages/otherMenu.js @@ -56,6 +56,9 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM saveButton.style.display = "none"; saveButton.style.transition = "opacity 0.3s"; + /** + * @this { HTMLDivElement } + */ var clickMode = function () { if (this.classList.contains("off")) return; var active = this.parentNode.querySelector(".active"); @@ -166,79 +169,17 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM checkDevVersionButton.disabled = true; checkVersionButton.disabled = true; - function refresh() { + const refresh = () => { checkVersionButton.disabled = false; checkVersionButton.innerHTML = "检查游戏更新"; checkDevVersionButton.disabled = false; checkDevVersionButton.innerHTML = "更新到开发版"; } - if (!dev) { - getRepoTags() - .then((tags) => tags.filter((tag) => tag.name != "v1998")[0]) - .then((tag) => { - game.saveConfig("check_version", tag.name.slice(1)); - if (typeof lib.config["version_description_" + tag.name] == "object") { - /** @type { ReturnType } */ - const description = lib.config["version_description_" + tag.name]; - return description; - } else return getRepoTagDescription(tag.name); - }) - .then((description) => { - // 保存版本信息 - if (typeof lib.config["version_description_" + description.name] != "object") { - game.saveConfig("version_description_" + description.name, description); - } - const versionResult = checkVersion(lib.version, description.name); - if (versionResult === 0) { - // forcecheck: 为false的时候是自动检测更新的调用 - if (forcecheck === false || !confirm("版本已是最新,是否强制更新?")) { - refresh(); - return; - } - } - const str = - versionResult > 0 - ? `有新版本${description.name}可用,是否下载?` - : `本地版本${lib.version}高于或等于github版本${description.name},是否强制下载?`; - const str2 = description.body; - if (navigator.notification && navigator.notification.confirm) { - navigator.notification.confirm( - str2, - function (index) { - if (index == 1) { - download(description); - } else refresh(); - }, - str, - ["确定", "取消"] - ); - } else { - if (confirm(str + "\n" + str2)) { - download(description); - } else refresh(); - } - }) - .catch((e) => { - alert("获取更新失败: " + e); - refresh(); - }); - } else { - if (confirm("将要直接下载dev版本的完整包,是否继续?")) { - download({ - name: "noname-PR-Branch", - assets: [], - zipball_url: - "https://ghproxy.cc/https://github.com/libccy/noname/archive/PR-Branch.zip", - }); - } else { - refresh(); - } - } /** * @param {{ assets: any; author?: { login: string; avatar_url: string; html_url: string; }; body?: string; html_url?: string; name: any; published_at?: string; zipball_url: any; }} description */ - function download(description) { + const download = description => { const progress = createProgress( "正在更新" + description.name, 1, @@ -333,7 +274,7 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM .then(() => { cp.exec( `start /b ${__dirname}\\noname-server.exe -platform=electron`, - () => {} + () => { } ); function loadURL() { let myAbortController = @@ -385,6 +326,69 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM throw e; }); } + + if (!dev) { + getRepoTags() + .then((tags) => tags.filter((tag) => tag.name != "v1998")[0]) + .then((tag) => { + game.saveConfig("check_version", tag.name.slice(1)); + if (typeof lib.config["version_description_" + tag.name] == "object") { + /** @type { ReturnType } */ + const description = lib.config["version_description_" + tag.name]; + return description; + } else return getRepoTagDescription(tag.name); + }) + .then((description) => { + // 保存版本信息 + if (typeof lib.config["version_description_" + description.name] != "object") { + game.saveConfig("version_description_" + description.name, description); + } + const versionResult = checkVersion(lib.version, description.name); + if (versionResult === 0) { + // forcecheck: 为false的时候是自动检测更新的调用 + if (forcecheck === false || !confirm("版本已是最新,是否强制更新?")) { + refresh(); + return; + } + } + const str = + versionResult > 0 + ? `有新版本${description.name}可用,是否下载?` + : `本地版本${lib.version}高于或等于github版本${description.name},是否强制下载?`; + const str2 = description.body; + if (navigator.notification && navigator.notification.confirm) { + navigator.notification.confirm( + str2, + function (index) { + if (index == 1) { + download(description); + } else refresh(); + }, + str, + ["确定", "取消"] + ); + } else { + if (confirm(str + "\n" + str2)) { + download(description); + } else refresh(); + } + }) + .catch((e) => { + alert("获取更新失败: " + e); + refresh(); + }); + } else { + if (confirm("将要直接下载dev版本的完整包,是否继续?")) { + download({ + name: "noname-PR-Branch", + assets: [], + zipball_url: + "https://ghproxy.cc/https://github.com/libccy/noname/archive/PR-Branch.zip", + }); + } else { + refresh(); + } + } } }; @@ -406,7 +410,7 @@ export const otherMenu = function (/** @type { boolean | undefined } */ connectM checkAssetButton.innerHTML = "正在检查更新"; checkAssetButton.disabled = true; - function refresh() { + const refresh = () => { checkAssetButton.innerHTML = "检查素材更新"; checkAssetButton.disabled = false; }