-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (39 loc) · 833 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const fs = require('fs')
const xml =`<q-chart bindChartCreated="onChartCreated" chart-class='qchart'></q-chart>`
const xss = `page {
width: 100%;
height: 100%;
display: flex;
}
q-chart {
width: 100%;
height: 100%;
}
.qchart {
width: 100%;
height: 95%;
margin: auto;
}`
const write = (path,str)=>{
fs.writeFile(path,str,function(err){
if(err){
console.log(`${path} 写入失败`)
}else{
console.log(`${path} 写入成功`)
}
})
}
fs.readdir('./pages',function(err,files){
files.forEach(file => {
if(file!=='index'){
const subDir = fs.readdirSync(`./pages/${file}`)
subDir.forEach(sub=>{
const p = `pages/${file}/${sub}/${sub}`
const wxml = p+'.wxml'
const wxss = p+'.wxss'
write(wxml,xml)
write(wxss,xss)
})
}
});
})