Skip to content

Commit

Permalink
fix:修复面板图问题
Browse files Browse the repository at this point in the history
修复删除所有面板图后无法使用默认面板图,以及能够上传不存在角色面板图的问题
  • Loading branch information
erzaozi committed Nov 3, 2024
1 parent 9b2e1b7 commit 61d4008
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
8 changes: 6 additions & 2 deletions apps/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ export class Character extends plugin {
return;
}

const rolePicUrl = fs.existsSync(rolePicDir)
? `file://${rolePicDir}/${fs.readdirSync(rolePicDir).filter(file => path.extname(file).toLowerCase() === '.webp')[Math.floor(Math.random() * fs.readdirSync(rolePicDir).length)]}`
const webpFiles = fs.existsSync(rolePicDir)
? fs.readdirSync(rolePicDir).filter(file => path.extname(file).toLowerCase() === '.webp')
: [];

const rolePicUrl = webpFiles.length > 0
? `file://${rolePicDir}/${webpFiles[Math.floor(Math.random() * webpFiles.length)]}`
: roleDetail.data.role.rolePicUrl;

imgList.push(rolePicUrl);
Expand Down
25 changes: 5 additions & 20 deletions apps/imgUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ export class ImgUploader extends plugin {
const wiki = new Wiki();
character = await wiki.getAlias(character);

const wikiData = await wiki.getPage('1105');
if (!wikiData.status) { return e.reply('获取Wiki列表失败, 请稍后重试.'); }
else {
if (!wikiData?.results?.records?.some(item => item.name === character)) { return e.reply(`${char} 是谁啊... 俺找遍了索拉里斯都没找到这人~`); }
const entryData = await wiki.getEntry(character, '1105');
if (!entryData.status) {
return await e.reply(`当前没有共鸣者 ${character}`);
}

const images = [...(e.img || [])];
Expand Down Expand Up @@ -173,14 +172,7 @@ export class ImgUploader extends plugin {
return true;
}

const wiki = new Wiki();
character = await wiki.getAlias(character);

const wikiData = await wiki.getPage('1105');
if (!wikiData.status) { return e.reply('获取Wiki列表失败, 请稍后重试.'); }
else {
if (!wikiData?.results?.records?.some(item => item.name === character)) { return e.reply(`${char} 是谁啊... 俺找遍了索拉里斯都没找到这人~`); }
}
character = await new Wiki().getAlias(character);

const imageDir = path.join(pluginResources, 'rolePic', character);
const images = fs.existsSync(imageDir) && fs.readdirSync(imageDir);
Expand Down Expand Up @@ -216,14 +208,7 @@ export class ImgUploader extends plugin {
let [, character, index] = e.msg.match(this.rule[3].reg);
if (!character) return e.reply('请输入正确的命令格式,如:[~删除今汐面板图1]');

const wiki = new Wiki();
character = await wiki.getAlias(character);

const wikiData = await wiki.getPage('1105');
if (!wikiData.status) { return e.reply('获取Wiki列表失败, 请稍后重试.'); }
else {
if (!wikiData?.results?.records?.some(item => item.name === character)) { return e.reply(`${char} 是谁啊... 俺找遍了索拉里斯都没找到这人~`); }
}
character = await new Wiki().getAlias(character);

const imageDir = path.join(pluginResources, 'rolePic', character);
const imageList = fs.existsSync(imageDir) ? fs.readdirSync(imageDir) : [];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "waves-plugin",
"version": "1.5.7",
"version": "1.5.8",
"description": "基于 Yunzai 的鸣潮游戏数据查询插件",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 61d4008

Please sign in to comment.