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