zmp-cli 3.8.3-0 → 3.9.0
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/assets/index.js +0 -0
- package/build/index.js +0 -0
- package/config/index.js +0 -0
- package/create/index.js +0 -0
- package/create/templates/app-parameters.js +4 -2
- package/create/templates/copy-assets.js +0 -4
- package/create/templates/dist/generate-styles.dev.js +46 -0
- package/create/templates/generate-recoil.js +56 -0
- package/create/templates/generate-store.js +2 -4
- package/create/templates/generate-styles.js +1 -10
- package/create/templates/react/components/user-card.jsx +3 -3
- package/create/templates/react/copy-assets.js +38 -22
- package/create/templates/react/dist/generate-scripts.dev.js +5 -4
- package/create/templates/react/generate-home-page.js +10 -15
- package/create/templates/react/generate-root.js +22 -32
- package/create/templates/react/generate-scripts.js +6 -14
- package/create/templates/react/pages/404.js +27 -0
- package/create/templates/react/pages/about.js +52 -0
- package/create/templates/react/pages/catalog.js +112 -0
- package/create/templates/react/pages/dynamic-route.js +80 -0
- package/create/templates/react/pages/form.js +152 -0
- package/create/templates/react/pages/index copy.js +17 -0
- package/create/templates/react/pages/index.js +17 -0
- package/create/templates/react/pages/settings.js +76 -0
- package/create/templates/react/pages/user.js +56 -0
- package/create/templates/react-typescript/_tsconfig.json +0 -1
- package/create/templates/react-typescript/components/app-items.js +1 -1
- package/create/templates/react-typescript/components/user-card.js +6 -12
- package/create/templates/react-typescript/copy-assets.js +17 -9
- package/create/templates/react-typescript/dist/generate-scripts.dev.js +23 -0
- package/create/templates/react-typescript/generate-home-page.js +9 -12
- package/create/templates/react-typescript/generate-root.js +41 -53
- package/create/templates/react-typescript/generate-scripts.js +6 -14
- package/create/templates/react-typescript/pages/about.js +2 -9
- package/create/templates/react-typescript/pages/catalog.js +52 -0
- package/create/templates/react-typescript/pages/form.js +81 -13
- package/create/templates/react-typescript/pages/settings.js +37 -0
- package/create/templates/react-typescript/pages/user.js +16 -11
- package/create/templates/vue/generate-scripts.js +5 -1
- package/create/utils/generate-package-json.js +5 -1
- package/create/utils/get-options.js +21 -1
- package/deploy/index.js +0 -0
- package/login/index.js +0 -0
- package/migrate/index.js +0 -0
- package/package.json +2 -2
- package/start/index.js +0 -0
- package/build/dist/index.dev.js +0 -185
- package/config/dist/index.dev.js +0 -52
- package/create/dist/index.dev.js +0 -300
- package/create/templates/common/tailwind/styles.css +0 -0
- package/create/templates/core/dist/copy-assets.dev.js +0 -85
- package/create/templates/core/dist/generate-home-page.dev.js +0 -24
- package/create/templates/core/dist/generate-routes.dev.js +0 -43
- package/create/templates/core/dist/generate-scripts.dev.js +0 -40
- package/create/templates/dist/app-parameters.dev.js +0 -21
- package/create/templates/dist/copy-assets.dev.js +0 -113
- package/create/templates/dist/create-folders.dev.js +0 -25
- package/create/templates/dist/generate-routes.dev.js +0 -15
- package/create/templates/dist/generate-zmp-custom.dev.js +0 -46
- package/create/templates/react/dist/copy-assets.dev.js +0 -64
- package/create/templates/react/dist/generate-home-page.dev.js +0 -23
- package/create/templates/react/dist/generate-root.dev.js +0 -33
- package/create/templates/react/dist/generate-routes.dev.js +0 -20
- package/create/templates/react/pages/404.jsx +0 -17
- package/create/templates/react/pages/about.jsx +0 -42
- package/create/templates/react/pages/catalog.jsx +0 -39
- package/create/templates/react/pages/dynamic-route.jsx +0 -70
- package/create/templates/react/pages/form-tabs.jsx +0 -64
- package/create/templates/react/pages/form.jsx +0 -61
- package/create/templates/react/pages/left-page-1.jsx +0 -17
- package/create/templates/react/pages/left-page-2.jsx +0 -16
- package/create/templates/react/pages/product.jsx +0 -25
- package/create/templates/react/pages/settings.jsx +0 -28
- package/create/templates/react/pages/user-tabs.jsx +0 -31
- package/create/templates/react/pages/user.jsx +0 -28
- package/create/templates/svelte/dist/copy-assets.dev.js +0 -55
- package/create/templates/svelte/dist/generate-home-page.dev.js +0 -23
- package/create/templates/svelte/dist/generate-root.dev.js +0 -35
- package/create/templates/svelte/dist/generate-routes.dev.js +0 -25
- package/create/templates/svelte/dist/generate-scripts.dev.js +0 -22
- package/create/templates/vue/dist/copy-assets.dev.js +0 -55
- package/create/templates/vue/dist/generate-home-page.dev.js +0 -23
- package/create/templates/vue/dist/generate-root.dev.js +0 -35
- package/create/templates/vue/dist/generate-routes.dev.js +0 -27
- package/create/templates/vue/dist/generate-scripts.dev.js +0 -22
- package/create/utils/dist/generate-app-config.dev.js +0 -29
- package/create/utils/dist/generate-gitignore.dev.js +0 -7
- package/create/utils/dist/generate-package-json.dev.js +0 -72
- package/deploy/dist/index.dev.js +0 -196
- package/deploy/utils/dist/upload-app.dev.js +0 -113
- package/dist/index.dev.js +0 -355
- package/login/dist/index.dev.js +0 -236
- package/login/utils/dist/get-options.dev.js +0 -66
- package/scripts/dist/release.dev.js +0 -105
- package/start/dist/index.dev.js +0 -247
- package/ui/dist/server.dev.js +0 -208
- package/utils/dist/constants.dev.js +0 -10
- package/utils/dist/error.dev.js +0 -18
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
module.exports = (options) => {
|
|
5
|
+
if (options.stateManagement === 'recoil') {
|
|
6
|
+
return indent(
|
|
7
|
+
0,
|
|
8
|
+
`
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { useRecoilState } from 'recoil';
|
|
11
|
+
import { Page, Title, List, ListItem, Box, Button } from 'zmp-framework/react';
|
|
12
|
+
import { productsState } from '../state';
|
|
13
|
+
|
|
14
|
+
const CatalogPage = () => {
|
|
15
|
+
const [products, setProducts] = useRecoilState(productsState)
|
|
16
|
+
|
|
17
|
+
const addProduct = () => {
|
|
18
|
+
setProducts(p => [
|
|
19
|
+
...p,
|
|
20
|
+
{
|
|
21
|
+
id: '4',
|
|
22
|
+
title: 'Apple iPhone 12',
|
|
23
|
+
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis.'
|
|
24
|
+
}
|
|
25
|
+
])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Page name="catalog">
|
|
30
|
+
<Box m="0" p="4">
|
|
31
|
+
<Title>Catalog</Title>
|
|
32
|
+
<List>
|
|
33
|
+
{products.map((product) => (
|
|
34
|
+
<ListItem
|
|
35
|
+
key={product.id}
|
|
36
|
+
title={product.title}
|
|
37
|
+
link={\`/product/\${product.id}/\`}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</List>
|
|
41
|
+
{products.length === 3 && (
|
|
42
|
+
<Box>
|
|
43
|
+
<Button responsive typeName="secondary" onClick={addProduct}>
|
|
44
|
+
Add Product
|
|
45
|
+
</Button>
|
|
46
|
+
</Box>
|
|
47
|
+
)}
|
|
48
|
+
</Box>
|
|
49
|
+
</Page>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default CatalogPage;
|
|
54
|
+
`
|
|
55
|
+
).trim();
|
|
56
|
+
}
|
|
57
|
+
return indent(
|
|
58
|
+
0,
|
|
59
|
+
`
|
|
60
|
+
import React from "react";
|
|
61
|
+
import {
|
|
62
|
+
Page,
|
|
63
|
+
Title,
|
|
64
|
+
List,
|
|
65
|
+
ListItem,
|
|
66
|
+
Box,
|
|
67
|
+
Button,
|
|
68
|
+
useStore
|
|
69
|
+
} from "zmp-framework/react";
|
|
70
|
+
import store from "../store";
|
|
71
|
+
|
|
72
|
+
const CatalogPage = () => {
|
|
73
|
+
const products = useStore("products");
|
|
74
|
+
|
|
75
|
+
const addProduct = () => {
|
|
76
|
+
store.dispatch("addProduct", {
|
|
77
|
+
id: "4",
|
|
78
|
+
title: "Apple iPhone 12",
|
|
79
|
+
description:
|
|
80
|
+
"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi tempora similique reiciendis, error nesciunt vero, blanditiis pariatur dolor, minima sed sapiente rerum, dolorem corrupti hic modi praesentium unde saepe perspiciatis."
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Page name="catalog">
|
|
86
|
+
<Box m="0" p="4">
|
|
87
|
+
<Title>Catalog</Title>
|
|
88
|
+
<List>
|
|
89
|
+
{products.map((product) => (
|
|
90
|
+
<ListItem
|
|
91
|
+
key={product.id}
|
|
92
|
+
title={product.title}
|
|
93
|
+
link={\`/product/\${product.id}/\`}
|
|
94
|
+
/>
|
|
95
|
+
))}
|
|
96
|
+
</List>
|
|
97
|
+
{products.length === 3 && (
|
|
98
|
+
<Box>
|
|
99
|
+
<Button responsive typeName="secondary" onClick={addProduct}>
|
|
100
|
+
Add Product
|
|
101
|
+
</Button>
|
|
102
|
+
</Box>
|
|
103
|
+
)}
|
|
104
|
+
</Box>
|
|
105
|
+
</Page>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default CatalogPage;
|
|
110
|
+
`
|
|
111
|
+
).trim();
|
|
112
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
module.exports = (options) => {
|
|
5
|
+
return indent(
|
|
6
|
+
0,
|
|
7
|
+
`
|
|
8
|
+
import React from 'react'
|
|
9
|
+
import { Button, Box, List, ListItem, Page } from 'zmp-framework/react'
|
|
10
|
+
import NavbarBack from '../components/navbar-back';
|
|
11
|
+
|
|
12
|
+
const DymanicRoutePage = (props) => {
|
|
13
|
+
const { zmproute, zmprouter } = props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Page name="dynamic-route">
|
|
17
|
+
<NavbarBack title="Dynamic (Component) Route" />
|
|
18
|
+
<List>
|
|
19
|
+
<ListItem>
|
|
20
|
+
<div>
|
|
21
|
+
<div><strong>Route</strong></div>
|
|
22
|
+
<div>{zmproute.route.path}</div>
|
|
23
|
+
</div>
|
|
24
|
+
</ListItem>
|
|
25
|
+
<ListItem>
|
|
26
|
+
<div>
|
|
27
|
+
<div><strong>Url</strong></div>
|
|
28
|
+
<div>{zmproute.url}</div>
|
|
29
|
+
</div>
|
|
30
|
+
</ListItem>
|
|
31
|
+
<ListItem>
|
|
32
|
+
<div>
|
|
33
|
+
<div><strong>Path</strong></div>
|
|
34
|
+
<div>{zmproute.path}</div>
|
|
35
|
+
</div>
|
|
36
|
+
</ListItem>
|
|
37
|
+
<ListItem>
|
|
38
|
+
<div>
|
|
39
|
+
<div><strong>Hash</strong></div>
|
|
40
|
+
<div>{zmproute.hash}</div>
|
|
41
|
+
</div>
|
|
42
|
+
</ListItem>
|
|
43
|
+
<ListItem>
|
|
44
|
+
<div>
|
|
45
|
+
<div><strong>Params</strong></div>
|
|
46
|
+
<div>
|
|
47
|
+
<ul>
|
|
48
|
+
{Object.keys(zmproute.params).map(key => (<li key={key}>{key}: {zmproute.params[key]}</li>))}
|
|
49
|
+
</ul>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</ListItem>
|
|
53
|
+
<ListItem>
|
|
54
|
+
<div>
|
|
55
|
+
<div><strong>Query</strong></div>
|
|
56
|
+
<div>
|
|
57
|
+
<ul>
|
|
58
|
+
{Object.keys(zmproute.query).map(key => (<li key={key}>{key}: {zmproute.query[key]}</li>))}
|
|
59
|
+
</ul>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</ListItem>
|
|
63
|
+
</List>
|
|
64
|
+
<Box px={4} mb={4}>
|
|
65
|
+
<Button
|
|
66
|
+
typeName="primary"
|
|
67
|
+
responsive
|
|
68
|
+
onClick={() => zmprouter.back()}
|
|
69
|
+
>
|
|
70
|
+
Go back via Router API
|
|
71
|
+
</Button>
|
|
72
|
+
</Box>
|
|
73
|
+
</Page>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default DymanicRoutePage;
|
|
78
|
+
`
|
|
79
|
+
).trim();
|
|
80
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
module.exports = (options) => {
|
|
4
|
+
const { template } = options;
|
|
5
|
+
const hideNavBar =
|
|
6
|
+
template === 'tabs'
|
|
7
|
+
? `onPageBeforeIn={()=>{
|
|
8
|
+
//hide navbar
|
|
9
|
+
zmp.toolbar.hide('#app-tab-bar')
|
|
10
|
+
}}`
|
|
11
|
+
: '';
|
|
12
|
+
|
|
13
|
+
if (options.stateManagement === 'recoil') {
|
|
14
|
+
return indent(
|
|
15
|
+
0,
|
|
16
|
+
`
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { Button, Card, Input, Page, Box, zmp } from 'zmp-framework/react';
|
|
19
|
+
import { useRecoilState } from 'recoil';
|
|
20
|
+
import { userState } from '../state';
|
|
21
|
+
import NavbarBack from '../components/navbar-back';
|
|
22
|
+
|
|
23
|
+
const FormPage = () => {
|
|
24
|
+
const [user, setUser] = useRecoilState(userState)
|
|
25
|
+
|
|
26
|
+
const [form, setForm] = React.useState({ ...user });
|
|
27
|
+
const toast = React.useRef(null)
|
|
28
|
+
|
|
29
|
+
const handleChangeInput = (field, value) => {
|
|
30
|
+
setForm({ ...form, [field]: value })
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const handleSubmit = () => {
|
|
34
|
+
if (!toast.current) {
|
|
35
|
+
toast.current = zmp.toast.create({
|
|
36
|
+
text: 'Saved',
|
|
37
|
+
position: 'bottom',
|
|
38
|
+
closeTimeout: 2000,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
setUser(form);
|
|
42
|
+
toast.current.open()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Page
|
|
47
|
+
name="user-form"
|
|
48
|
+
${hideNavBar}
|
|
49
|
+
>
|
|
50
|
+
<NavbarBack title="Update user info" />
|
|
51
|
+
<Box>
|
|
52
|
+
<Card inset>
|
|
53
|
+
<Input
|
|
54
|
+
id="name"
|
|
55
|
+
label="Name"
|
|
56
|
+
type="text"
|
|
57
|
+
placeholder="Zalo"
|
|
58
|
+
value={form?.name}
|
|
59
|
+
onChange={(e) => handleChangeInput('name', e.target.value)}
|
|
60
|
+
/>
|
|
61
|
+
<Input
|
|
62
|
+
label="Avatar"
|
|
63
|
+
type="text"
|
|
64
|
+
placeholder="zalo@zalo.me"
|
|
65
|
+
value={form?.avatar}
|
|
66
|
+
onChange={(e) => handleChangeInput('avatar', e.target.value)}
|
|
67
|
+
/>
|
|
68
|
+
<Box mx="0" mt="4">
|
|
69
|
+
<Button responsive typeName="primary" onClick={handleSubmit}>
|
|
70
|
+
Submit
|
|
71
|
+
</Button>
|
|
72
|
+
</Box>
|
|
73
|
+
</Card>
|
|
74
|
+
</Box>
|
|
75
|
+
</Page>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default FormPage;
|
|
80
|
+
`
|
|
81
|
+
).trim();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return indent(
|
|
85
|
+
0,
|
|
86
|
+
`
|
|
87
|
+
import React from 'react';
|
|
88
|
+
import { Button, Card, Input, Page, useStore, zmp, Box } from 'zmp-framework/react';
|
|
89
|
+
import NavbarBack from '../components/navbar-back';
|
|
90
|
+
|
|
91
|
+
import store from '../store'
|
|
92
|
+
|
|
93
|
+
const FormPage = () => {
|
|
94
|
+
const user = useStore('user')
|
|
95
|
+
|
|
96
|
+
const [form, setForm] = React.useState({ ...user });
|
|
97
|
+
const toast = React.useRef(null)
|
|
98
|
+
|
|
99
|
+
const handleChangeInput = (field, value) => {
|
|
100
|
+
setForm({ ...form, [field]: value })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const handleSubmit = () => {
|
|
104
|
+
if (!toast.current) {
|
|
105
|
+
toast.current = zmp.toast.create({
|
|
106
|
+
text: 'Saved',
|
|
107
|
+
position: 'bottom',
|
|
108
|
+
closeTimeout: 2000,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
store.dispatch('setUser', form)
|
|
112
|
+
toast.current.open()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<Page
|
|
117
|
+
name="user-form"
|
|
118
|
+
${hideNavBar}
|
|
119
|
+
>
|
|
120
|
+
<NavbarBack title="Update user info" />
|
|
121
|
+
<Box>
|
|
122
|
+
<Card inset>
|
|
123
|
+
<Input
|
|
124
|
+
id="name"
|
|
125
|
+
label="Name"
|
|
126
|
+
type="text"
|
|
127
|
+
placeholder="Zalo"
|
|
128
|
+
value={form?.name}
|
|
129
|
+
onChange={(e) => handleChangeInput('name', e.target.value)}
|
|
130
|
+
/>
|
|
131
|
+
<Input
|
|
132
|
+
label="Avatar"
|
|
133
|
+
type="text"
|
|
134
|
+
placeholder="zalo@zalo.me"
|
|
135
|
+
value={form?.avatar}
|
|
136
|
+
onChange={(e) => handleChangeInput('avatar', e.target.value)}
|
|
137
|
+
/>
|
|
138
|
+
<Box mx="0" mt="4">
|
|
139
|
+
<Button responsive typeName="primary" onClick={handleSubmit}>
|
|
140
|
+
Submit
|
|
141
|
+
</Button>
|
|
142
|
+
</Box>
|
|
143
|
+
</Card>
|
|
144
|
+
</Box>
|
|
145
|
+
</Page>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default FormPage;
|
|
150
|
+
`
|
|
151
|
+
).trim();
|
|
152
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const copyUser = require('./user');
|
|
2
|
+
const copyForm = require('./form');
|
|
3
|
+
const copyDynamicRoute = require('./dynamic-route');
|
|
4
|
+
const copyAbout = require('./about');
|
|
5
|
+
const copy404 = require('./404');
|
|
6
|
+
const copySettings = require('./settings');
|
|
7
|
+
const copyCatalog = require('./catalog');
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
copyUser,
|
|
11
|
+
copyForm,
|
|
12
|
+
copyDynamicRoute,
|
|
13
|
+
copyAbout,
|
|
14
|
+
copy404,
|
|
15
|
+
copySettings,
|
|
16
|
+
copyCatalog,
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const copyUser = require('./user');
|
|
2
|
+
const copyForm = require('./form');
|
|
3
|
+
const copyDynamicRoute = require('./dynamic-route');
|
|
4
|
+
const copyAbout = require('./about');
|
|
5
|
+
const copy404 = require('./404');
|
|
6
|
+
const copySettings = require('./settings');
|
|
7
|
+
const copyCatalog = require('./catalog');
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
copyUser,
|
|
11
|
+
copyForm,
|
|
12
|
+
copyDynamicRoute,
|
|
13
|
+
copyAbout,
|
|
14
|
+
copy404,
|
|
15
|
+
copySettings,
|
|
16
|
+
copyCatalog,
|
|
17
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line no-unused-vars
|
|
4
|
+
module.exports = (options) => {
|
|
5
|
+
if (options.stateManagement === 'recoil') {
|
|
6
|
+
return indent(
|
|
7
|
+
0,
|
|
8
|
+
`
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { useRecoilValue } from 'recoil';
|
|
11
|
+
import {
|
|
12
|
+
Page,
|
|
13
|
+
List,
|
|
14
|
+
ListItem,
|
|
15
|
+
Title,
|
|
16
|
+
Box
|
|
17
|
+
} from "zmp-framework/react";
|
|
18
|
+
import UserCard from "../components/user-card";
|
|
19
|
+
import { userState } from '../state'
|
|
20
|
+
|
|
21
|
+
const SettingsPage = () => {
|
|
22
|
+
const user = useRecoilValue(userState);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Page name="settings">
|
|
26
|
+
<Box m="0" p="4">
|
|
27
|
+
<Title>Settings</Title>
|
|
28
|
+
<List className="m-0">
|
|
29
|
+
<ListItem link="/user/">
|
|
30
|
+
<UserCard user={user} />
|
|
31
|
+
</ListItem>
|
|
32
|
+
</List>
|
|
33
|
+
</Box>
|
|
34
|
+
</Page>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default SettingsPage;
|
|
39
|
+
`
|
|
40
|
+
).trim();
|
|
41
|
+
}
|
|
42
|
+
return indent(
|
|
43
|
+
0,
|
|
44
|
+
`
|
|
45
|
+
import React from "react";
|
|
46
|
+
import {
|
|
47
|
+
Page,
|
|
48
|
+
List,
|
|
49
|
+
ListItem,
|
|
50
|
+
useStore,
|
|
51
|
+
Title,
|
|
52
|
+
Box
|
|
53
|
+
} from "zmp-framework/react";
|
|
54
|
+
import UserCard from "../components/user-card";
|
|
55
|
+
|
|
56
|
+
const SettingsPage = () => {
|
|
57
|
+
const user = useStore("user");
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Page name="settings">
|
|
61
|
+
<Box m="0" p="4">
|
|
62
|
+
<Title>Settings</Title>
|
|
63
|
+
<List className="m-0">
|
|
64
|
+
<ListItem link="/user/">
|
|
65
|
+
<UserCard user={user} />
|
|
66
|
+
</ListItem>
|
|
67
|
+
</List>
|
|
68
|
+
</Box>
|
|
69
|
+
</Page>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default SettingsPage;
|
|
74
|
+
`
|
|
75
|
+
).trim();
|
|
76
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const indent = require('../../../utils/indent');
|
|
2
|
+
|
|
3
|
+
module.exports = (options) => {
|
|
4
|
+
const { template, stateManagement } = options;
|
|
5
|
+
const hideNavBar =
|
|
6
|
+
template === 'tabs'
|
|
7
|
+
? `
|
|
8
|
+
onPageBeforeIn={()=>{
|
|
9
|
+
//hide navbar
|
|
10
|
+
zmp.toolbar.hide('#app-tab-bar')
|
|
11
|
+
}}`
|
|
12
|
+
: '';
|
|
13
|
+
const modules = ['Avatar', 'List', 'ListItem', 'Page', 'Title'];
|
|
14
|
+
if (stateManagement === 'store') {
|
|
15
|
+
modules.push('useStore');
|
|
16
|
+
}
|
|
17
|
+
if (template === 'tabs') {
|
|
18
|
+
modules.push('zmp');
|
|
19
|
+
}
|
|
20
|
+
return indent(
|
|
21
|
+
0,
|
|
22
|
+
`
|
|
23
|
+
import React from 'react'
|
|
24
|
+
import { ${modules.join(', ')} } from 'zmp-framework/react'
|
|
25
|
+
import NavbarBack from '../components/navbar-back'${stateManagement === 'recoil' ? `
|
|
26
|
+
import { useRecoilValue } from 'recoil';
|
|
27
|
+
import { userState } from '../state';` : ''}
|
|
28
|
+
|
|
29
|
+
const UserPage = () => {
|
|
30
|
+
${stateManagement === 'recoil' ? 'const user = useRecoilValue(userState);' : `const user = useStore('user')`}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Page
|
|
34
|
+
name="user"${hideNavBar}
|
|
35
|
+
>
|
|
36
|
+
<NavbarBack
|
|
37
|
+
title="User info"
|
|
38
|
+
linkRight="/form"
|
|
39
|
+
labelRight="Edit"
|
|
40
|
+
/>
|
|
41
|
+
<div style={{ textAlign: 'center', marginTop: 32 }}>
|
|
42
|
+
<Avatar story online src={user.avatar.startsWith('http') ? user.avatar : null}>{user.avatar}</Avatar>
|
|
43
|
+
<Title style={{ marginTop: 8 }}>{user.name}</Title>
|
|
44
|
+
</div>
|
|
45
|
+
<List>
|
|
46
|
+
<ListItem title="Display name" after={user.name} />
|
|
47
|
+
<ListItem title="ID" after={user.id} />
|
|
48
|
+
</List>
|
|
49
|
+
</Page>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default UserPage;
|
|
54
|
+
`
|
|
55
|
+
).trim();
|
|
56
|
+
};
|
|
@@ -6,25 +6,19 @@ module.exports = (options) => {
|
|
|
6
6
|
`
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Avatar, Title } from 'zmp-framework/react';
|
|
9
|
+
import { userInfo } from 'zmp-sdk';
|
|
9
10
|
|
|
10
|
-
interface User {
|
|
11
|
-
online?: boolean,
|
|
12
|
-
avatar?: any,
|
|
13
|
-
displayName?: string,
|
|
14
|
-
email?: string,
|
|
15
|
-
story?: boolean,
|
|
16
|
-
}
|
|
17
11
|
interface UserProps {
|
|
18
|
-
user
|
|
12
|
+
user: userInfo
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
const UserCard: React.FunctionComponent<UserProps> = ({ user
|
|
15
|
+
const UserCard: React.FunctionComponent<UserProps> = ({ user }) => {
|
|
22
16
|
return (
|
|
23
17
|
<div style={{ display: 'flex', width: '100%' }}>
|
|
24
|
-
<Avatar story={user.
|
|
18
|
+
<Avatar story online src={user.avatar.startsWith('http') ? user.avatar : null}>{user.avatar}</Avatar>
|
|
25
19
|
<div style={{ marginLeft: 16 }}>
|
|
26
|
-
<Title style={{ marginBottom: 0 }}>{user.
|
|
27
|
-
<div>{user.
|
|
20
|
+
<Title style={{ marginBottom: 0 }}>{user.name}</Title>
|
|
21
|
+
<div>{user.id}</div>
|
|
28
22
|
</div>
|
|
29
23
|
</div>
|
|
30
24
|
)
|
|
@@ -2,13 +2,14 @@ const path = require('path');
|
|
|
2
2
|
const generateHomePage = require('./generate-home-page');
|
|
3
3
|
const generateRoot = require('./generate-root');
|
|
4
4
|
const generateStore = require('../generate-store');
|
|
5
|
+
const generateRecoil = require('../generate-recoil');
|
|
5
6
|
const copyComponents = require('./components');
|
|
6
7
|
const copyPages = require('./pages');
|
|
7
8
|
const copyViteConfig = require('./vite.config');
|
|
8
9
|
|
|
9
10
|
module.exports = (options) => {
|
|
10
11
|
const cwd = options.cwd || process.cwd();
|
|
11
|
-
const { template } = options;
|
|
12
|
+
const { template, stateManagement } = options;
|
|
12
13
|
const toCopy = [];
|
|
13
14
|
|
|
14
15
|
// Copy Pages
|
|
@@ -48,10 +49,10 @@ module.exports = (options) => {
|
|
|
48
49
|
const components = [
|
|
49
50
|
...(template !== 'blank'
|
|
50
51
|
? [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
{ fileName: 'app-items', content: 'copyAppItems' },
|
|
53
|
+
{ fileName: 'navbar-back', content: 'copyNavbarBack' },
|
|
54
|
+
{ fileName: 'user-card', content: 'copyUserCard' },
|
|
55
|
+
]
|
|
55
56
|
: []),
|
|
56
57
|
];
|
|
57
58
|
components.forEach(({ fileName, content }) => {
|
|
@@ -67,10 +68,17 @@ module.exports = (options) => {
|
|
|
67
68
|
to: path.resolve(cwd, 'src', 'components', 'app.tsx'),
|
|
68
69
|
});
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (stateManagement === 'recoil') {
|
|
72
|
+
toCopy.push({
|
|
73
|
+
content: generateRecoil(options),
|
|
74
|
+
to: path.resolve(cwd, 'src', 'state.ts'),
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
toCopy.push({
|
|
78
|
+
content: generateStore(options),
|
|
79
|
+
to: path.resolve(cwd, 'src', 'store.ts'),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
74
82
|
|
|
75
83
|
toCopy.push({
|
|
76
84
|
content: copyViteConfig(options),
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var templateIf = require('../../utils/template-if');
|
|
4
|
+
|
|
5
|
+
var indent = require('../../utils/indent');
|
|
6
|
+
|
|
7
|
+
var stylesExtension = require('../../utils/styles-extension');
|
|
8
|
+
|
|
9
|
+
module.exports = function (options) {
|
|
10
|
+
var cssPreProcessor = options.cssPreProcessor,
|
|
11
|
+
theming = options.theming,
|
|
12
|
+
customBuild = options.customBuild,
|
|
13
|
+
includeTailwind = options.includeTailwind;
|
|
14
|
+
var scripts = '';
|
|
15
|
+
scripts += indent(0, "\n // Import React and ReactDOM\n import React from 'react';\n import { createRoot } from 'react-dom/client';\n\n // Import ZMP\n import ZMP from '".concat(customBuild ? './zmp-custom.js' : 'zmp-framework/core/lite-bundle', "';\n\n // Import ZMP-React Plugin\n import ZMPReact from 'zmp-framework/react';").concat(includeTailwind ? "\n\n // Import tailwind styles\n import './css/tailwind.css';\n " : '', "\n\n // Import ZMP Styles\n ").concat(templateIf(customBuild, function () {
|
|
16
|
+
return "\n import './css/zmp-custom.less';\n ";
|
|
17
|
+
}, function () {
|
|
18
|
+
return "\n import 'zmp-framework/".concat(theming.useUiKits ? 'zmp-bundle.min.css' : 'zmp.min.css', "';\n ");
|
|
19
|
+
}), "\n\n // Import Icons and App Custom Styles\n ").concat(templateIf(theming.iconFonts, function () {
|
|
20
|
+
return "\n import './css/icons.css';\n ";
|
|
21
|
+
}), "\n import './css/app.").concat(stylesExtension(cssPreProcessor), "';\n\n // Import App Component\n import App from './components/app';\n import appConfig from '../app-config.json';\n\n if (!(window as any).APP_CONFIG) {\n (window as any).APP_CONFIG = appConfig\n }\n\n // Init ZMP React Plugin\n ZMP.use(ZMPReact)\n\n // Mount React App\n const root = createRoot(document.getElementById('app')!);\n root.render(React.createElement(App));\n "));
|
|
22
|
+
return scripts.trim();
|
|
23
|
+
};
|