修复resolve()导致的未捕获的错误

This commit is contained in:
kuangshen04 2024-05-07 19:16:36 +08:00
parent ba0d91dff3
commit 97ada59167
1 changed files with 12 additions and 16 deletions

View File

@ -3554,17 +3554,15 @@ export class Click {
if (characterGroups)
Promise.all(
characterGroups.map((characterGroup) =>
new Promise((resolve, reject) => {
Promise.resolve().then(async () => {
const imageName = `group_${characterGroup}`,
information = lib.card[imageName];
if (!information) resolve(`${lib.assetURL}image/card/${imageName}.png`);
if (!information) return `${lib.assetURL}image/card/${imageName}.png`;
const image = information.image;
if (!image) resolve(`${lib.assetURL}image/card/${imageName}.png`);
else if (image.startsWith("db:"))
game.getDB("image", image.slice(3)).then(resolve, reject);
else if (image.startsWith("ext:"))
resolve(`${lib.assetURL}${image.replace(/^ext:/, "extension/")}`);
else resolve(`${lib.assetURL}${image}`);
if (!image) return `${lib.assetURL}image/card/${imageName}.png`;
if (image.startsWith("db:")) return await game.getDB("image", image.slice(3));
if (image.startsWith("ext:")) return `${lib.assetURL}${image.replace(/^ext:/, "extension/")}`;
return `${lib.assetURL}${image}`;
}).then(
(source) =>
new Promise((resolve, reject) => {
@ -3589,17 +3587,15 @@ export class Click {
);
else {
const characterGroup = nameInfo[1];
new Promise((resolve, reject) => {
Promise.resolve().then(async () => {
const imageName = `group_${characterGroup}`,
information = lib.card[imageName];
if (!information) resolve(`${lib.assetURL}image/card/${imageName}.png`);
if (!information) return `${lib.assetURL}image/card/${imageName}.png`;
const image = information.image;
if (!image) resolve(`${lib.assetURL}image/card/${imageName}.png`);
else if (image.startsWith("db:"))
game.getDB("image", image.slice(3)).then(resolve, reject);
else if (image.startsWith("ext:"))
resolve(`${lib.assetURL}${image.replace(/^ext:/, "extension/")}`);
else resolve(`${lib.assetURL}${image}`);
if (!image) return `${lib.assetURL}image/card/${imageName}.png`;
if (image.startsWith("db:")) return await game.getDB("image", image.slice(3));
if (image.startsWith("ext:")) return `${lib.assetURL}${image.replace(/^ext:/, "extension/")}`;
return `${lib.assetURL}${image}`;
})
.then(
(source) =>