mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-10-13 21:29:19 +00:00
feat:优化图片保存逻辑
This commit is contained in:
parent
9b0df2f281
commit
b8f6f737e9
@ -61,7 +61,11 @@ export class welcomeNewcomerSetting extends plugin {
|
||||
const filePath = path.join(groupDir, '1');
|
||||
|
||||
try {
|
||||
await fs.promises.mkdir(groupDir, { recursive: true });
|
||||
if (!fs.existsSync(groupDir)) await fs.promises.mkdir(groupDir, { recursive: true });
|
||||
const oldFiles = await fs.promises.readdir(groupDir);
|
||||
for (const file of oldFiles) {
|
||||
if (file.startsWith('1.')) await fs.promises.unlink(path.join(groupDir, file));
|
||||
}
|
||||
const res = await axios.get(imgUrl, { responseType: 'arraybuffer' });
|
||||
const contentType = res.headers['content-type'] || '';
|
||||
const ext = contentType.includes('gif') ? 'gif' : 'jpg';
|
||||
|
Loading…
x
Reference in New Issue
Block a user