2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 11:00:51 +08:00

fix:修正读取用户设置模板,模板不存在时报错

This commit is contained in:
Ctrlcvs 2022-12-18 13:06:09 +08:00
parent bda5cfc2d3
commit b8a0be1458

View File

@ -235,8 +235,10 @@ export default class note {
}
let urlType = this.note_file("xiaoyao");
let objFile = Object.keys(urlType)
let defFile;
if (objFile.length > 0) {
objFile = objFile[lodash.random(0, objFile.length - 1)]
defFile=objFile;
}
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
if (this.tempData[this.e.user_id] && this.tempData[this.e.user_id].type > -1&&this.tempData[this.e.user_id]?.temp?.length!==0) {
@ -261,10 +263,13 @@ export default class note {
mb2_icon: ""
})
}
// console.log(urlType,objFile,path_img)
img_path = `${urlType[objFile]}${path_img[mb]}`;
if (!fs.existsSync(img_path)) {
img_path=`${urlType[defFile]}${path_img[mb]}`;
}
}
var image = fs.readdirSync(img_path);
// console.log(fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/BJT-Templet/Template2`))
var list_img = [];
for (let val of image) {
list_img.push(val)