refactor: 重构lib代码(无实质性功能更新,可不更新)

This commit is contained in:
bietiaop 2024-08-22 13:34:08 +08:00
parent a7f06d404b
commit aa3b7928ec
26 changed files with 547 additions and 483 deletions

View file

@ -9,7 +9,7 @@ import {
import { char } from '../../lib/convert.js';
import { getAllEquipID } from '../../lib/convert/equip.js';
import { getAllWeaponID } from '../../lib/convert/weapon.js';
import { imageResourcesPath } from '../../lib/path.js';
import * as LocalURI from '../../lib/download/const.js';
export async function downloadAll() {
if (!this.e.isMaster) return false;
@ -91,34 +91,11 @@ export async function downloadAll() {
}
const messages = [
'资源下载完成(成功的包含先前下载的图片)',
'角色图需下载' +
charIDs.length +
'张,成功' +
result.char.success +
'张,失败' +
result.char.failed +
'张',
'角色头像图需下载' +
charIDs.length +
'张,成功' +
result.charSquare.success +
'张,失败' +
result.charSquare.failed +
'张',
'套装图需下载' +
equipSprites.length +
'张,成功' +
result.equip.success +
'张,失败' +
result.equip.failed +
'张',
'武器图需下载' +
weaponSprites.length +
'张,成功' +
result.weapon.success +
'张,失败' +
result.weapon.failed +
'张',
`角色图需下载${charIDs.length}张,成功${result.char.success}张,失败${result.char.failed}`,
`角色头像图需下载${charIDs.length}张,成功${esult.charSquare.success}张,失败${result.charSquare.failed}`,
`角色头像图(练度统计)需下载${charIDs.length}张,成功${result.charSmallSquare.success}张,失败${result.charSmallSquare.failed}`,
`驱动盘套装图需下载${equipSprites.length}张,成功${result.equip.success}张,失败${result.equip.failed}`,
`武器图需下载${weaponSprites.length}张,成功${result.weapon.success}张,失败${result.weapon.failed}`,
];
await this.reply(messages.join('\n'));
}
@ -129,8 +106,10 @@ export async function deleteAll() {
false,
{ at: true, recallMsg: 100 }
);
if (fs.existsSync(imageResourcesPath)) {
fs.rmSync(imageResourcesPath, { recursive: true });
for (const dir of LocalURI) {
if (fs.existsSync(dir)) {
fs.rmSync(dir, { recursive: true });
}
}
await this.reply('资源图片已删除!', false, { at: true, recallMsg: 100 });
}

View file

@ -1,5 +1,5 @@
import { char } from '../../lib/convert.js';
import { downloadFile } from '../../lib/download.js';
import { downloadFile } from '../../lib/download/core.js';
import { imageResourcesPath } from '../../lib/path.js';
import common from '../../../../lib/common/common.js';
import fs from 'fs';