为更新后首次启动添加扩展报错提示;优化之前的代码

This commit is contained in:
IceCola 2024-05-16 23:40:35 +08:00
parent 17d422b8ca
commit e3e04e0f73
2 changed files with 27 additions and 18 deletions

View File

@ -845,7 +845,6 @@ const skills = {
return get.prompt("xinfu_zuilun") + "(可获得" + get.cnNumber(num) + "张牌)"; return get.prompt("xinfu_zuilun") + "(可获得" + get.cnNumber(num) + "张牌)";
}, },
async content(event, trigger, player) { async content(event, trigger, player) {
"step 0";
let num = 0; let num = 0;
const cards = get.cards(3); const cards = get.cards(3);
await game.cardsGotoOrdering(cards); await game.cardsGotoOrdering(cards);
@ -1389,7 +1388,6 @@ const skills = {
return get.type(event.card) == "trick" && event.targets.length > 1 && player.countCards("he") > 0; return get.type(event.card) == "trick" && event.targets.length > 1 && player.countCards("he") > 0;
}, },
async cost(event, trigger, player) { async cost(event, trigger, player) {
"step 0";
event.result = await player event.result = await player
.chooseCardTarget({ .chooseCardTarget({
filterCard: true, filterCard: true,
@ -1590,7 +1588,6 @@ const skills = {
return player.countCards("he") > 0; return player.countCards("he") > 0;
}, },
async cost(event, trigger, player) { async cost(event, trigger, player) {
"step 0";
event.result = await player event.result = await player
.chooseCard(get.prompt("kongsheng"), "将任意张牌置于武将牌上", "he", [1, player.countCards("he")]) .chooseCard(get.prompt("kongsheng"), "将任意张牌置于武将牌上", "he", [1, player.countCards("he")])
.set("ai", function (card) { .set("ai", function (card) {
@ -1630,13 +1627,13 @@ const skills = {
return get.type(i, false) == "equip" && player.hasUseTarget(i); return get.type(i, false) == "equip" && player.hasUseTarget(i);
}); });
if (cards.length > 0) { if (cards.length > 0) {
let card = cards[0]; let [card] = cards;
if (cards.length > 1) { if (cards.length > 1) {
const { result } = await player.chooseButton(true, ["选择要使用的装备牌", cards]).set("ai", function (button) { const { result } = await player.chooseButton(true, ["选择要使用的装备牌", cards]).set("ai", function (button) {
return get.order(button.link); return get.order(button.link);
}); });
if (!result.bool) continue; if (!result.bool) continue;
card = result.links[0]; [card] = result.links;
} }
await player.chooseUseTarget(card, true); await player.chooseUseTarget(card, true);
} else break; } else break;
@ -1961,6 +1958,7 @@ const skills = {
combo: "nzry_huaiju", combo: "nzry_huaiju",
}, },
}, },
// ----- 审查分界线喵 ----- 上面的代码已经经过了审查喵
nzry_kuizhu: { nzry_kuizhu: {
audio: 2, audio: 2,
trigger: { trigger: {

View File

@ -513,6 +513,8 @@ export async function boot() {
} }
delete _status.htmlbg; delete _status.htmlbg;
const isFirstStartAfterUpdate = !!window.noname_update;
// 无名杀更新日志 // 无名杀更新日志
if (window.noname_update) { if (window.noname_update) {
Reflect.set(lib, "version", window.noname_update.version); Reflect.set(lib, "version", window.noname_update.version);
@ -527,7 +529,7 @@ export async function boot() {
html` html`
<div <div
style="position: relative;width:50px;height:50px;border-radius:50px;background-image:url('${description style="position: relative;width:50px;height:50px;border-radius:50px;background-image:url('${description
.author.avatar_url}');background-size:cover;vertical-align:middle;" .author.avatar_url}');background-size:cover;vertical-align:middle;"
></div> ></div>
${description.author.login}于${description.published_at}发布 ${description.author.login}于${description.published_at}发布
`.trim(), `.trim(),
@ -633,6 +635,7 @@ export async function boot() {
for (const promise of _status.extensionLoading) { for (const promise of _status.extensionLoading) {
await promise.catch(async (error) => { await promise.catch(async (error) => {
if (extErrorList.includes(error)) return; if (extErrorList.includes(error)) return;
extErrorList.add(error);
if (!promiseErrorHandler || !promiseErrorHandler.onHandle) return; if (!promiseErrorHandler || !promiseErrorHandler.onHandle) return;
// @ts-ignore // @ts-ignore
await promiseErrorHandler.onHandle({ promise }); await promiseErrorHandler.onHandle({ promise });
@ -640,6 +643,14 @@ export async function boot() {
} }
// await Promise.allSettled(_status.extensionLoading); // await Promise.allSettled(_status.extensionLoading);
if (isFirstStartAfterUpdate && extErrorList.length) {
const stacktraces = extErrorList.map(e => e instanceof Error ? e.stack : String(e)).join("\n\n")
// game.saveConfig("update_first_log", stacktraces);
if(confirm(`扩展加载出错!是否重新载入游戏?\n本次更新可能导致了扩展出现了错误:\n${stacktraces}`)){
game.reload();
}
}
_status.extensionLoaded _status.extensionLoaded
.filter((name) => game.hasExtension(name)) .filter((name) => game.hasExtension(name))
.forEach((name) => { .forEach((name) => {
@ -778,18 +789,18 @@ function initSheet(libConfig) {
} }
Reflect.get(ui, "css").border_stylesheet.sheet.insertRule( Reflect.get(ui, "css").border_stylesheet.sheet.insertRule(
'#window .player>.framebg,#window #arena.long.mobile:not(.fewplayer) .player[data-position="0"]>.framebg{display:block;background-image:url("' + '#window .player>.framebg,#window #arena.long.mobile:not(.fewplayer) .player[data-position="0"]>.framebg{display:block;background-image:url("' +
lib.assetURL + lib.assetURL +
"theme/style/player/" + "theme/style/player/" +
bstyle + bstyle +
'1.png")}', '1.png")}',
0 0
); );
Reflect.get(ui, "css").border_stylesheet.sheet.insertRule( Reflect.get(ui, "css").border_stylesheet.sheet.insertRule(
'#window #arena.long:not(.fewplayer) .player>.framebg, #arena.oldlayout .player>.framebg{background-image:url("' + '#window #arena.long:not(.fewplayer) .player>.framebg, #arena.oldlayout .player>.framebg{background-image:url("' +
lib.assetURL + lib.assetURL +
"theme/style/player/" + "theme/style/player/" +
bstyle + bstyle +
'3.png")}', '3.png")}',
0 0
); );
Reflect.get(ui, "css").border_stylesheet.sheet.insertRule( Reflect.get(ui, "css").border_stylesheet.sheet.insertRule(
@ -818,14 +829,14 @@ function initSheet(libConfig) {
if (libConfig.control_style == "wood") { if (libConfig.control_style == "wood") {
Reflect.get(ui, "css").control_stylesheet = lib.init.sheet( Reflect.get(ui, "css").control_stylesheet = lib.init.sheet(
"#window .control,#window .menubutton,#window #system>div>div,#window #system>div>.pressdown2{background-image:" + "#window .control,#window .menubutton,#window #system>div>div,#window #system>div>.pressdown2{background-image:" +
str + str +
"}" "}"
); );
} else { } else {
Reflect.get(ui, "css").control_stylesheet = lib.init.sheet( Reflect.get(ui, "css").control_stylesheet = lib.init.sheet(
"#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:" + "#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:" +
str + str +
"}" "}"
); );
} }
} }