@wiajs/core 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/util/wiapage.js +27 -14
package/package.json
CHANGED
package/util/wiapage.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* 自动根据page目录文件生成 src目录的pages.js 文件
|
|
4
5
|
*/
|
|
@@ -81,7 +82,7 @@ async function getPage(dir) {
|
|
|
81
82
|
try {
|
|
82
83
|
dir = dir || process.cwd();
|
|
83
84
|
const src = path.join(dir, './src');
|
|
84
|
-
_cfg = require(path.join(
|
|
85
|
+
_cfg = require(path.join(dir, './wia.config.js'));
|
|
85
86
|
const rs = [];
|
|
86
87
|
// 获取目标项目目录、子目录下的文件MD5对象
|
|
87
88
|
await getFile(path.join(src, './page'), rs, src);
|
|
@@ -160,25 +161,36 @@ function makeFile(pf, name, dir) {
|
|
|
160
161
|
const src = path.join(dir, './src');
|
|
161
162
|
|
|
162
163
|
const p = [];
|
|
164
|
+
const ns = [];
|
|
163
165
|
Object.keys(pf).forEach(k => {
|
|
164
166
|
const f = pf[k].replace(/.js$/, '');
|
|
165
167
|
p.push(`import ${k} from '${f}';`);
|
|
168
|
+
ns.push(` '${f}': ${k},`);
|
|
166
169
|
});
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
// Object.keys(pf).forEach(k => {
|
|
172
|
+
// const n = k[0].toLowerCase() + k.slice(1);
|
|
173
|
+
// ns.push(` '${n}': ${k},`);
|
|
174
|
+
// });
|
|
175
|
+
|
|
176
|
+
// webpack
|
|
177
|
+
// p.push(`
|
|
178
|
+
// export default class ${name[0].toUpperCase() + name.slice(1)} {
|
|
179
|
+
// init() {
|
|
180
|
+
// ${ns.join('\n')}
|
|
181
|
+
// }
|
|
182
|
+
// }
|
|
183
|
+
// `);
|
|
184
|
+
|
|
185
|
+
// vite
|
|
174
186
|
p.push(`
|
|
175
|
-
|
|
176
|
-
init() {
|
|
187
|
+
const ${name} = {
|
|
177
188
|
${ns.join('\n')}
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
`);
|
|
189
|
+
};
|
|
181
190
|
|
|
191
|
+
export default ${name};
|
|
192
|
+
`);
|
|
193
|
+
|
|
182
194
|
// 将内容写入page.js 文件
|
|
183
195
|
const ps = p.join('\n');
|
|
184
196
|
if (!_.isEmpty(ps)) {
|
|
@@ -249,8 +261,9 @@ function clear(dir) {
|
|
|
249
261
|
dir = dir || process.cwd();
|
|
250
262
|
const src = path.join(dir, './src');
|
|
251
263
|
const ps = `
|
|
252
|
-
|
|
253
|
-
|
|
264
|
+
const pages = {};
|
|
265
|
+
|
|
266
|
+
export default pages;
|
|
254
267
|
`;
|
|
255
268
|
let lastH = '';
|
|
256
269
|
const f = path.join(src, './pages.js');
|