修改eslint不推荐的写法
This commit is contained in:
parent
389526694a
commit
86a98eb3c8
|
@ -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<import('../../../../library/update.js').getRepoTagDescription> } */
|
||||
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,
|
||||
|
@ -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<import('../../../../library/update.js').getRepoTagDescription> } */
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue