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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| const { kebabCase } = require('lodash');
| const hicode = require('../hicode');
| function indexJsx(view, args) {
| return [
| hicode(args),
| `import React from 'react';`,
| `// import { Link } from 'react-router-dom';`,
| `// import { Modal } from 'antd-mobile';`,
| `// import { Icon } from 'antd';`,
| `// import chunk from 'lodash/chunk';`,
| `// import tree from 'hife/tree';`,
| ``,
| `import './style.scss';`,
| ``,
| `export default function ${view}({ loading }) {`,
| ` return (`,
| ` <div className="${kebabCase(view)}-main">`,
| ` ${view}`,
| ` </div>`,
| ` );`,
| ``,
| `}`,
| ``,
| `// export default class ${view} extends React.Component {`,
| `// constructor(props) {`,
| `// super(props);`,
| `// this.state = {`,
| `// value: ''`,
| `// };`,
| `// }`,
| ``,
| `// render() {`,
| `// return (`,
| `// <div className="${kebabCase(view)}-main">`,
| `// ${view}`,
| `// </div>`,
| `// );`,
| `// }`,
| ``,
| `// }`,
| ``
| ].join('\n');
|
| }
|
| function indexSass(view, args) {
| return [
| hicode(args),
| `@import '../../conf/vars';`,
| ``,
| `.${kebabCase(view)} {`,
| ` &-main {`,
| ` padding: 8px;`,
| ` }`,
| ``,
| `}`,
| ``
| ].join('\n');
| }
|
| module.exports = function (file, view, args) {
| switch (file) {
| case 'index.jsx':
| return indexJsx(view, args);
| case 'style.scss':
| return indexSass(view, args);
| default:
| throw new Error(`Unknown file: ${file}...`);
| }
| }
|
|