mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
fix:修正读取用户设置模板,模板不存在时报错
This commit is contained in:
parent
bda5cfc2d3
commit
b8a0be1458
@ -235,8 +235,10 @@ export default class note {
|
|||||||
}
|
}
|
||||||
let urlType = this.note_file("xiaoyao");
|
let urlType = this.note_file("xiaoyao");
|
||||||
let objFile = Object.keys(urlType)
|
let objFile = Object.keys(urlType)
|
||||||
|
let defFile;
|
||||||
if (objFile.length > 0) {
|
if (objFile.length > 0) {
|
||||||
objFile = objFile[lodash.random(0, objFile.length - 1)]
|
objFile = objFile[lodash.random(0, objFile.length - 1)]
|
||||||
|
defFile=objFile;
|
||||||
}
|
}
|
||||||
let img_path = `./plugins/xiaoyao-cvs-plugin/resources/dailyNote/${path_img[mb]}`;
|
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) {
|
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: ""
|
mb2_icon: ""
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// console.log(urlType,objFile,path_img)
|
||||||
img_path = `${urlType[objFile]}${path_img[mb]}`;
|
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);
|
var image = fs.readdirSync(img_path);
|
||||||
// console.log(fs.readdirSync(`./plugins/xiaoyao-cvs-plugin/resources/dailyNote/BJT-Templet/Template2`))
|
|
||||||
var list_img = [];
|
var list_img = [];
|
||||||
for (let val of image) {
|
for (let val of image) {
|
||||||
list_img.push(val)
|
list_img.push(val)
|
||||||
|
Loading…
Reference in New Issue
Block a user