Merge pull request #1358 from nonameShijian/PR-Branch

为新客户端的导入扩展功能提前做适配
This commit is contained in:
Spmario233 2024-05-17 08:09:56 +08:00 committed by GitHub
commit b0ad3978d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -79,9 +79,9 @@ boot().then(() => {
});
}
} else {
// 成功导入后删除noname.config.txt
let searchParams = new URLSearchParams(location.search);
for (let [key, value] of searchParams) {
// 成功导入后删除noname.config.txt
if (key === "sendUpdate" && value === "true") {
game.promises
.readFileAsText("noname.config.txt")
@ -166,6 +166,15 @@ boot().then(() => {
location.href = url.origin + url.pathname;
});
}
// 新客户端导入扩展
else if (key === "importExtensionName") {
lib.config.extensions.add(value);
game.saveConfig("extensions", lib.config.extensions);
game.saveConfig(`extension_${value}_enable`, true);
alert(`扩展${value}已导入成功,点击确定重启游戏`);
const url = new URL(location.href);
location.href = url.origin + url.pathname;
}
}
}
});

View File

@ -8,6 +8,16 @@ import { checkVersion } from "../library/update.js";
export async function cordovaReady() {
if (lib.device == "android") {
// 新客户端导入扩展逻辑
window.addEventListener("importExtension", e => {
const extensionName = e.detail.extensionName;
lib.config.extensions.add(extensionName);
game.saveConfig("extensions", lib.config.extensions);
game.saveConfig(`extension_${extensionName}_enable`, true);
if (confirm(`扩展${extensionName}已导入成功,是否重启游戏?`)) {
game.reload();
}
}, false);
document.addEventListener("pause", function () {
if (!_status.paused2 && typeof _status.event.isMine == "function" && !_status.event.isMine()) {
ui.click.pause();