代码拉取完成,页面将自动刷新
const fs = require('fs');
const path = require('path');
fs.readdir("./packages", (err, files) => {
files.forEach((item, index) => {
fs.readdirSync(path.resolve(__dirname, `./packages/${item}/output`)).forEach((item2) => {
if (item2.endsWith(".zip")) {
fs.renameSync(path.resolve(__dirname, `./packages/${item}/output/${item2}`), path.resolve(__dirname, `./packages/${item}/output/插件包.zip`))
}
if (item2.endsWith(".png") || item2.endsWith(".jpg")) {
fs.renameSync(path.resolve(__dirname, `./packages/${item}/output/${item2}`), path.resolve(__dirname, `./packages/${item}/output/preview.png`))
}
})
})
})
fs.readdir("./packages", (err, files) => {
let pic = [], zipFile = []
files.forEach((item) => {
!fs.existsSync(path.resolve(__dirname, `./packages/${item}/output/preview.png`)) && pic.push(item)
!fs.existsSync(path.resolve(__dirname, `./packages/${item}/output/插件包.zip`)) && zipFile.push(item)
})
console.log(`未传入zip包的样例:${JSON.stringify(zipFile, null, 2)}\n未传入预览图的样例:${JSON.stringify(pic, null, 2)}`);
})
const templates = require('./templates.json');
fs.readdir("./packages", (err, files) => {
let fileMap = files.map((item) => {
let itemArr = item.split("-")
let isVue = itemArr[itemArr.length - 2] === "vue" ? true : false
let picPath = fs.existsSync(path.resolve(__dirname, `./packages/${item}/output/preview.png`))
? `https://gitee.com/njsmartdata/sdata-plugins/raw/master/packages/${item}/output/preview.png`
: ""
let zipPath = fs.existsSync(path.resolve(__dirname, `./packages/${item}/output/插件包.zip`))
? encodeURI(`https://gitee.com/njsmartdata/sdata-plugins/raw/master/packages/${item}/output/插件包.zip`)
: "暂无"
let plugin = isVue ? itemArr.slice(0, -2).join("-") : itemArr.slice(0, -1).join("-")
let pluginName = templates[plugin].name
let templateType = isVue ? "Vue 2" : "React"
let sourcePath = `https://gitee.com/njsmartdata/sdata-plugins/tree/master/packages/${item}`
// return [picPath, pluginName, plugin, "", templateType, sourcePath, zipPath]
return {
picPath: picPath ? JSON.stringify([{previewUrl: picPath, url: picPath, name: picPath}]) : "暂无", pluginName, plugin, description: "", templateType, sourcePath, zipPath
}
})
fs.writeFile("./fileMap.json", JSON.stringify(fileMap, null, 2), () => {
})
console.log(fileMap);
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。