nsgm-cli 1.0.24 → 1.0.26
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/generation/client/layout/index.tsx +223 -223
- package/generation/client/redux/reducers.ts +5 -5
- package/generation/client/redux/store.ts +44 -44
- package/generation/client/styled/common.ts +28 -28
- package/generation/client/utils/common.ts +45 -45
- package/generation/client/utils/fetch.ts +25 -25
- package/generation/client/utils/menu.tsx +26 -26
- package/generation/package.json +20 -20
- package/generation/pages/_document.tsx +53 -53
- package/generation/tsconfig.json +28 -28
- package/lib/generate.js +2 -2
- package/lib/index.js +19 -19
- package/lib/server/graphql.js +7 -7
- package/lib/server/plugins/date.js +2 -2
- package/package.json +3 -3
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { Layout, Menu, Breadcrumb, Image } from 'antd'
|
|
3
|
-
import { Container } from '../styled/layout'
|
|
4
|
-
import { useRouter } from 'next/router'
|
|
5
|
-
import _ from 'lodash'
|
|
6
|
-
import menuConfig from '../utils/menu'
|
|
7
|
-
|
|
8
|
-
const { SubMenu } = Menu
|
|
9
|
-
const { Header, Content, Sider } = Layout
|
|
10
|
-
|
|
11
|
-
const getLocationKey = () => {
|
|
12
|
-
const result = {
|
|
13
|
-
topMenu: '1',
|
|
14
|
-
slideMenu: '0'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof window !== 'undefined') {
|
|
18
|
-
const locationHref = window.location.href
|
|
19
|
-
|
|
20
|
-
let locationHrefArr = locationHref.split('?')
|
|
21
|
-
if (locationHrefArr.length > 0) {
|
|
22
|
-
locationHrefArr = locationHrefArr[0].split('//')
|
|
23
|
-
|
|
24
|
-
if (locationHrefArr.length > 1) {
|
|
25
|
-
let locationStr = locationHrefArr[1]
|
|
26
|
-
const locationIndex = locationStr.indexOf('/')
|
|
27
|
-
locationStr = locationStr.substring(locationIndex)
|
|
28
|
-
|
|
29
|
-
console.log('locationStr', locationStr)
|
|
30
|
-
|
|
31
|
-
_.each(menuConfig, (item:any, index:any) => {
|
|
32
|
-
const { key, url, subMenus } = item
|
|
33
|
-
|
|
34
|
-
if (subMenus) {
|
|
35
|
-
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
36
|
-
const { key: subKey, url: subUrl } = subItem
|
|
37
|
-
|
|
38
|
-
if (locationStr === subUrl.split('?')[0]) {
|
|
39
|
-
const subKeyArr = subKey.split('_')
|
|
40
|
-
const subKeyArrLen = subKeyArr.length
|
|
41
|
-
|
|
42
|
-
if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
|
|
43
|
-
if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
|
|
44
|
-
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
} else {
|
|
49
|
-
if (locationStr === url.split('?')[0]) {
|
|
50
|
-
result.topMenu = key
|
|
51
|
-
return false
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
console.log('result', result)
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const routerPush = (router: any, url: string) => {
|
|
63
|
-
console.log('routerPush', url)
|
|
64
|
-
|
|
65
|
-
if (router && url) {
|
|
66
|
-
router.push(url)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const LayoutComponent = ({ children }) => {
|
|
71
|
-
const router = useRouter()
|
|
72
|
-
const [topMenuKey, setTopMenuKey] = useState('1')
|
|
73
|
-
const [sliderMenuKey, setSliderMenuKey] = useState('1')
|
|
74
|
-
|
|
75
|
-
console.log('topMenuKey: ' + topMenuKey, ', sliderMenuKey: ' + sliderMenuKey)
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
const { topMenu, slideMenu } = getLocationKey()
|
|
79
|
-
setTopMenuKey(topMenu)
|
|
80
|
-
setSliderMenuKey(slideMenu)
|
|
81
|
-
}, [])
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<Layout>
|
|
85
|
-
<Container>
|
|
86
|
-
<Header className="header">
|
|
87
|
-
<div className="logo">
|
|
88
|
-
<Image width={100} src="../images/zhizuotu_1.png" preview={false} />
|
|
89
|
-
</div>
|
|
90
|
-
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['1']} selectedKeys={[topMenuKey]}>
|
|
91
|
-
{_.map(menuConfig, (item:any, index:any) => {
|
|
92
|
-
const { key, text, url, subMenus } = item
|
|
93
|
-
if (key) {
|
|
94
|
-
return (
|
|
95
|
-
<Menu.Item
|
|
96
|
-
key={key}
|
|
97
|
-
onClick={() => {
|
|
98
|
-
routerPush(router, url)
|
|
99
|
-
setTopMenuKey(key)
|
|
100
|
-
|
|
101
|
-
if (subMenus) {
|
|
102
|
-
setSliderMenuKey('1')
|
|
103
|
-
} else {
|
|
104
|
-
setSliderMenuKey('0')
|
|
105
|
-
}
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
{text}
|
|
109
|
-
</Menu.Item>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
|
-
})}
|
|
113
|
-
</Menu>
|
|
114
|
-
</Header>
|
|
115
|
-
<Layout>
|
|
116
|
-
<Sider width={200} className="site-layout-background">
|
|
117
|
-
<Menu
|
|
118
|
-
mode="inline"
|
|
119
|
-
defaultSelectedKeys={['slider_1_0']}
|
|
120
|
-
defaultOpenKeys={['slider_1']}
|
|
121
|
-
selectedKeys={['slider_' + topMenuKey + '_' + sliderMenuKey]}
|
|
122
|
-
openKeys={['slider_' + topMenuKey]}
|
|
123
|
-
style={{ height: '100%', borderRight: 0 }}
|
|
124
|
-
>
|
|
125
|
-
{_.map(menuConfig, (item:any, index:any) => {
|
|
126
|
-
const { key, text, url, icon, subMenus } = item
|
|
127
|
-
|
|
128
|
-
if (subMenus) {
|
|
129
|
-
return (
|
|
130
|
-
<SubMenu
|
|
131
|
-
key={'slider_' + key}
|
|
132
|
-
icon={icon}
|
|
133
|
-
title={text}
|
|
134
|
-
onTitleClick={() => {
|
|
135
|
-
setTopMenuKey(key)
|
|
136
|
-
setSliderMenuKey('1')
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
{_.map(subMenus, (subItem:any, subIndex:any) => {
|
|
140
|
-
const { key: subKey, text: subText, url: subUrl } = subItem
|
|
141
|
-
return (
|
|
142
|
-
<Menu.Item
|
|
143
|
-
key={'slider_' + subKey}
|
|
144
|
-
onClick={() => {
|
|
145
|
-
routerPush(router, subUrl)
|
|
146
|
-
|
|
147
|
-
const subKeyArr = subKey.split('_')
|
|
148
|
-
const subKeyArrLen = subKeyArr.length
|
|
149
|
-
|
|
150
|
-
console.log(subKeyArr, subKeyArrLen)
|
|
151
|
-
|
|
152
|
-
if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0])
|
|
153
|
-
|
|
154
|
-
if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1])
|
|
155
|
-
}}
|
|
156
|
-
>
|
|
157
|
-
{subText}
|
|
158
|
-
</Menu.Item>
|
|
159
|
-
)
|
|
160
|
-
})}
|
|
161
|
-
</SubMenu>
|
|
162
|
-
)
|
|
163
|
-
} else {
|
|
164
|
-
if (key) {
|
|
165
|
-
return (
|
|
166
|
-
<Menu.Item
|
|
167
|
-
key={'slider_' + key + '_0'}
|
|
168
|
-
icon={icon}
|
|
169
|
-
onClick={() => {
|
|
170
|
-
routerPush(router, url)
|
|
171
|
-
setTopMenuKey(key)
|
|
172
|
-
setSliderMenuKey('0')
|
|
173
|
-
}}
|
|
174
|
-
>
|
|
175
|
-
{text}
|
|
176
|
-
</Menu.Item>
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
})}
|
|
181
|
-
</Menu>
|
|
182
|
-
</Sider>
|
|
183
|
-
<Layout style={{ padding: '0 24px 24px' }}>
|
|
184
|
-
<Breadcrumb style={{ margin: '16px 0' }}>
|
|
185
|
-
{_.map(menuConfig, (item:any, index:any) => {
|
|
186
|
-
const { key, text, subMenus } = item
|
|
187
|
-
|
|
188
|
-
if (key && key === topMenuKey) {
|
|
189
|
-
if (subMenus) {
|
|
190
|
-
const subContent = []
|
|
191
|
-
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
192
|
-
const { key: subKey, text: subText } = subItem
|
|
193
|
-
if (subKey === key + '_' + sliderMenuKey) {
|
|
194
|
-
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{text}</Breadcrumb.Item>)
|
|
195
|
-
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{subText}</Breadcrumb.Item>)
|
|
196
|
-
return false
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
return subContent
|
|
200
|
-
} else {
|
|
201
|
-
return <Breadcrumb.Item key={'breadcrumb' + index}>{text}</Breadcrumb.Item>
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
})}
|
|
205
|
-
</Breadcrumb>
|
|
206
|
-
<Content
|
|
207
|
-
className="site-layout-background"
|
|
208
|
-
style={{
|
|
209
|
-
padding: 24,
|
|
210
|
-
margin: 0,
|
|
211
|
-
minHeight: 280
|
|
212
|
-
}}
|
|
213
|
-
>
|
|
214
|
-
{children}
|
|
215
|
-
</Content>
|
|
216
|
-
</Layout>
|
|
217
|
-
</Layout>
|
|
218
|
-
</Container>
|
|
219
|
-
</Layout>
|
|
220
|
-
)
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export default LayoutComponent
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Layout, Menu, Breadcrumb, Image } from 'antd'
|
|
3
|
+
import { Container } from '../styled/layout'
|
|
4
|
+
import { useRouter } from 'next/router'
|
|
5
|
+
import _ from 'lodash'
|
|
6
|
+
import menuConfig from '../utils/menu'
|
|
7
|
+
|
|
8
|
+
const { SubMenu } = Menu
|
|
9
|
+
const { Header, Content, Sider } = Layout
|
|
10
|
+
|
|
11
|
+
const getLocationKey = () => {
|
|
12
|
+
const result = {
|
|
13
|
+
topMenu: '1',
|
|
14
|
+
slideMenu: '0'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (typeof window !== 'undefined') {
|
|
18
|
+
const locationHref = window.location.href
|
|
19
|
+
|
|
20
|
+
let locationHrefArr = locationHref.split('?')
|
|
21
|
+
if (locationHrefArr.length > 0) {
|
|
22
|
+
locationHrefArr = locationHrefArr[0].split('//')
|
|
23
|
+
|
|
24
|
+
if (locationHrefArr.length > 1) {
|
|
25
|
+
let locationStr = locationHrefArr[1]
|
|
26
|
+
const locationIndex = locationStr.indexOf('/')
|
|
27
|
+
locationStr = locationStr.substring(locationIndex)
|
|
28
|
+
|
|
29
|
+
console.log('locationStr', locationStr)
|
|
30
|
+
|
|
31
|
+
_.each(menuConfig, (item:any, index:any) => {
|
|
32
|
+
const { key, url, subMenus } = item
|
|
33
|
+
|
|
34
|
+
if (subMenus) {
|
|
35
|
+
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
36
|
+
const { key: subKey, url: subUrl } = subItem
|
|
37
|
+
|
|
38
|
+
if (locationStr === subUrl.split('?')[0]) {
|
|
39
|
+
const subKeyArr = subKey.split('_')
|
|
40
|
+
const subKeyArrLen = subKeyArr.length
|
|
41
|
+
|
|
42
|
+
if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
|
|
43
|
+
if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
|
|
44
|
+
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
} else {
|
|
49
|
+
if (locationStr === url.split('?')[0]) {
|
|
50
|
+
result.topMenu = key
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
console.log('result', result)
|
|
59
|
+
return result
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const routerPush = (router: any, url: string) => {
|
|
63
|
+
console.log('routerPush', url)
|
|
64
|
+
|
|
65
|
+
if (router && url) {
|
|
66
|
+
router.push(url)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const LayoutComponent = ({ children }) => {
|
|
71
|
+
const router = useRouter()
|
|
72
|
+
const [topMenuKey, setTopMenuKey] = useState('1')
|
|
73
|
+
const [sliderMenuKey, setSliderMenuKey] = useState('1')
|
|
74
|
+
|
|
75
|
+
console.log('topMenuKey: ' + topMenuKey, ', sliderMenuKey: ' + sliderMenuKey)
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const { topMenu, slideMenu } = getLocationKey()
|
|
79
|
+
setTopMenuKey(topMenu)
|
|
80
|
+
setSliderMenuKey(slideMenu)
|
|
81
|
+
}, [])
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Layout>
|
|
85
|
+
<Container>
|
|
86
|
+
<Header className="header">
|
|
87
|
+
<div className="logo">
|
|
88
|
+
<Image width={100} src="../images/zhizuotu_1.png" preview={false} />
|
|
89
|
+
</div>
|
|
90
|
+
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['1']} selectedKeys={[topMenuKey]}>
|
|
91
|
+
{_.map(menuConfig, (item:any, index:any) => {
|
|
92
|
+
const { key, text, url, subMenus } = item
|
|
93
|
+
if (key) {
|
|
94
|
+
return (
|
|
95
|
+
<Menu.Item
|
|
96
|
+
key={key}
|
|
97
|
+
onClick={() => {
|
|
98
|
+
routerPush(router, url)
|
|
99
|
+
setTopMenuKey(key)
|
|
100
|
+
|
|
101
|
+
if (subMenus) {
|
|
102
|
+
setSliderMenuKey('1')
|
|
103
|
+
} else {
|
|
104
|
+
setSliderMenuKey('0')
|
|
105
|
+
}
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{text}
|
|
109
|
+
</Menu.Item>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
})}
|
|
113
|
+
</Menu>
|
|
114
|
+
</Header>
|
|
115
|
+
<Layout>
|
|
116
|
+
<Sider width={200} className="site-layout-background">
|
|
117
|
+
<Menu
|
|
118
|
+
mode="inline"
|
|
119
|
+
defaultSelectedKeys={['slider_1_0']}
|
|
120
|
+
defaultOpenKeys={['slider_1']}
|
|
121
|
+
selectedKeys={['slider_' + topMenuKey + '_' + sliderMenuKey]}
|
|
122
|
+
openKeys={['slider_' + topMenuKey]}
|
|
123
|
+
style={{ height: '100%', borderRight: 0 }}
|
|
124
|
+
>
|
|
125
|
+
{_.map(menuConfig, (item:any, index:any) => {
|
|
126
|
+
const { key, text, url, icon, subMenus } = item
|
|
127
|
+
|
|
128
|
+
if (subMenus) {
|
|
129
|
+
return (
|
|
130
|
+
<SubMenu
|
|
131
|
+
key={'slider_' + key}
|
|
132
|
+
icon={icon}
|
|
133
|
+
title={text}
|
|
134
|
+
onTitleClick={() => {
|
|
135
|
+
setTopMenuKey(key)
|
|
136
|
+
setSliderMenuKey('1')
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
{_.map(subMenus, (subItem:any, subIndex:any) => {
|
|
140
|
+
const { key: subKey, text: subText, url: subUrl } = subItem
|
|
141
|
+
return (
|
|
142
|
+
<Menu.Item
|
|
143
|
+
key={'slider_' + subKey}
|
|
144
|
+
onClick={() => {
|
|
145
|
+
routerPush(router, subUrl)
|
|
146
|
+
|
|
147
|
+
const subKeyArr = subKey.split('_')
|
|
148
|
+
const subKeyArrLen = subKeyArr.length
|
|
149
|
+
|
|
150
|
+
console.log(subKeyArr, subKeyArrLen)
|
|
151
|
+
|
|
152
|
+
if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0])
|
|
153
|
+
|
|
154
|
+
if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1])
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
{subText}
|
|
158
|
+
</Menu.Item>
|
|
159
|
+
)
|
|
160
|
+
})}
|
|
161
|
+
</SubMenu>
|
|
162
|
+
)
|
|
163
|
+
} else {
|
|
164
|
+
if (key) {
|
|
165
|
+
return (
|
|
166
|
+
<Menu.Item
|
|
167
|
+
key={'slider_' + key + '_0'}
|
|
168
|
+
icon={icon}
|
|
169
|
+
onClick={() => {
|
|
170
|
+
routerPush(router, url)
|
|
171
|
+
setTopMenuKey(key)
|
|
172
|
+
setSliderMenuKey('0')
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
{text}
|
|
176
|
+
</Menu.Item>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
})}
|
|
181
|
+
</Menu>
|
|
182
|
+
</Sider>
|
|
183
|
+
<Layout style={{ padding: '0 24px 24px' }}>
|
|
184
|
+
<Breadcrumb style={{ margin: '16px 0' }}>
|
|
185
|
+
{_.map(menuConfig, (item:any, index:any) => {
|
|
186
|
+
const { key, text, subMenus } = item
|
|
187
|
+
|
|
188
|
+
if (key && key === topMenuKey) {
|
|
189
|
+
if (subMenus) {
|
|
190
|
+
const subContent = []
|
|
191
|
+
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
192
|
+
const { key: subKey, text: subText } = subItem
|
|
193
|
+
if (subKey === key + '_' + sliderMenuKey) {
|
|
194
|
+
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{text}</Breadcrumb.Item>)
|
|
195
|
+
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{subText}</Breadcrumb.Item>)
|
|
196
|
+
return false
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
return subContent
|
|
200
|
+
} else {
|
|
201
|
+
return <Breadcrumb.Item key={'breadcrumb' + index}>{text}</Breadcrumb.Item>
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
})}
|
|
205
|
+
</Breadcrumb>
|
|
206
|
+
<Content
|
|
207
|
+
className="site-layout-background"
|
|
208
|
+
style={{
|
|
209
|
+
padding: 24,
|
|
210
|
+
margin: 0,
|
|
211
|
+
minHeight: 280
|
|
212
|
+
}}
|
|
213
|
+
>
|
|
214
|
+
{children}
|
|
215
|
+
</Content>
|
|
216
|
+
</Layout>
|
|
217
|
+
</Layout>
|
|
218
|
+
</Container>
|
|
219
|
+
</Layout>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default LayoutComponent
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// import { templateManageReducer } from './template/manage/reducers'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
// templateManage: templateManageReducer,
|
|
5
|
-
}
|
|
1
|
+
// import { templateManageReducer } from './template/manage/reducers'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
// templateManage: templateManageReducer,
|
|
5
|
+
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
import { createStore, applyMiddleware, combineReducers } from 'redux'
|
|
3
|
-
import { composeWithDevTools } from 'redux-devtools-extension'
|
|
4
|
-
import thunkMiddleware from 'redux-thunk'
|
|
5
|
-
import reducers from './reducers'
|
|
6
|
-
import _ from 'lodash'
|
|
7
|
-
|
|
8
|
-
let store:any
|
|
9
|
-
|
|
10
|
-
const reducersKeysLen = _.keys(reducers).length
|
|
11
|
-
const combineReducer = combineReducers((reducersKeysLen === 0) ? {} : { ...reducers })
|
|
12
|
-
|
|
13
|
-
export type RootState = ReturnType<typeof combineReducer>
|
|
14
|
-
|
|
15
|
-
function initStore(initialState:any) {
|
|
16
|
-
return createStore(
|
|
17
|
-
combineReducer,
|
|
18
|
-
initialState,
|
|
19
|
-
composeWithDevTools(applyMiddleware(thunkMiddleware))
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const initializeStore = (preloadedState:any) => {
|
|
24
|
-
let _store = store ?? initStore(preloadedState)
|
|
25
|
-
|
|
26
|
-
if (preloadedState && store) {
|
|
27
|
-
_store = initStore({
|
|
28
|
-
...store.getState(),
|
|
29
|
-
...preloadedState
|
|
30
|
-
})
|
|
31
|
-
store = undefined
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (typeof window === 'undefined') return _store
|
|
35
|
-
|
|
36
|
-
if (!store) store = _store
|
|
37
|
-
|
|
38
|
-
return _store
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function useStore(initialState:any) {
|
|
42
|
-
const memoStore = useMemo(() => initializeStore(initialState), [initialState])
|
|
43
|
-
return memoStore
|
|
44
|
-
}
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { createStore, applyMiddleware, combineReducers } from 'redux'
|
|
3
|
+
import { composeWithDevTools } from 'redux-devtools-extension'
|
|
4
|
+
import thunkMiddleware from 'redux-thunk'
|
|
5
|
+
import reducers from './reducers'
|
|
6
|
+
import _ from 'lodash'
|
|
7
|
+
|
|
8
|
+
let store:any
|
|
9
|
+
|
|
10
|
+
const reducersKeysLen = _.keys(reducers).length
|
|
11
|
+
const combineReducer = combineReducers((reducersKeysLen === 0) ? {} : { ...reducers })
|
|
12
|
+
|
|
13
|
+
export type RootState = ReturnType<typeof combineReducer>
|
|
14
|
+
|
|
15
|
+
function initStore(initialState:any) {
|
|
16
|
+
return createStore(
|
|
17
|
+
combineReducer,
|
|
18
|
+
initialState,
|
|
19
|
+
composeWithDevTools(applyMiddleware(thunkMiddleware))
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const initializeStore = (preloadedState:any) => {
|
|
24
|
+
let _store = store ?? initStore(preloadedState)
|
|
25
|
+
|
|
26
|
+
if (preloadedState && store) {
|
|
27
|
+
_store = initStore({
|
|
28
|
+
...store.getState(),
|
|
29
|
+
...preloadedState
|
|
30
|
+
})
|
|
31
|
+
store = undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof window === 'undefined') return _store
|
|
35
|
+
|
|
36
|
+
if (!store) store = _store
|
|
37
|
+
|
|
38
|
+
return _store
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function useStore(initialState:any) {
|
|
42
|
+
const memoStore = useMemo(() => initializeStore(initialState), [initialState])
|
|
43
|
+
return memoStore
|
|
44
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import styled, { createGlobalStyle } from 'styled-components'
|
|
2
|
-
|
|
3
|
-
export const GlobalStyle = createGlobalStyle`
|
|
4
|
-
html,body,#__next {
|
|
5
|
-
height: 100%;
|
|
6
|
-
border: 1px solid white;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
body {
|
|
10
|
-
background-color: ${(props: any) => (props.whiteColor ? 'white' : 'black')};
|
|
11
|
-
font-family: Helvetica;
|
|
12
|
-
margin: 0;
|
|
13
|
-
}
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
export const Container = styled.div`
|
|
17
|
-
margin: 20px;
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
export const Loading = styled.div`
|
|
21
|
-
display: flex;
|
|
22
|
-
flex: 1;
|
|
23
|
-
flex-direction: row;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
align-items: center;
|
|
26
|
-
margin-top: 100px;
|
|
27
|
-
`
|
|
28
|
-
|
|
1
|
+
import styled, { createGlobalStyle } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const GlobalStyle = createGlobalStyle`
|
|
4
|
+
html,body,#__next {
|
|
5
|
+
height: 100%;
|
|
6
|
+
border: 1px solid white;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
body {
|
|
10
|
+
background-color: ${(props: any) => (props.whiteColor ? 'white' : 'black')};
|
|
11
|
+
font-family: Helvetica;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
export const Container = styled.div`
|
|
17
|
+
margin: 20px;
|
|
18
|
+
`
|
|
19
|
+
|
|
20
|
+
export const Loading = styled.div`
|
|
21
|
+
display: flex;
|
|
22
|
+
flex: 1;
|
|
23
|
+
flex-direction: row;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
align-items: center;
|
|
26
|
+
margin-top: 100px;
|
|
27
|
+
`
|
|
28
|
+
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import getConfig from 'next/config'
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
|
|
4
|
-
export const getLocalApiPrefix = () => {
|
|
5
|
-
const nextConfig = getConfig()
|
|
6
|
-
const { publicRuntimeConfig } = nextConfig
|
|
7
|
-
let { protocol, host, port } = publicRuntimeConfig
|
|
8
|
-
|
|
9
|
-
if (typeof window !== 'undefined') {
|
|
10
|
-
const location = window.location
|
|
11
|
-
// console.log('location', location)
|
|
12
|
-
protocol = location.protocol
|
|
13
|
-
if (protocol.indexOf(':') !== -1) {
|
|
14
|
-
protocol = protocol.split(':')[0]
|
|
15
|
-
}
|
|
16
|
-
host = location.hostname
|
|
17
|
-
port = location.port
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const localApiPrefix = protocol + '://' + host + ':' + port
|
|
21
|
-
// console.log('localApiPrefix', localApiPrefix)
|
|
22
|
-
return localApiPrefix
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const handleXSS = (content: string) => {
|
|
26
|
-
content = content || ''
|
|
27
|
-
return content.replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/\'/g, ''')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
|
|
31
|
-
let result: any = null
|
|
32
|
-
_.each(modalObj, (value: any, key: string) => {
|
|
33
|
-
// console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
|
|
34
|
-
if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
|
|
35
|
-
if (_.trim(value) === '') {
|
|
36
|
-
result = {
|
|
37
|
-
key,
|
|
38
|
-
reason: '不能为空'
|
|
39
|
-
}
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
return result
|
|
45
|
-
}
|
|
1
|
+
import getConfig from 'next/config'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
|
|
4
|
+
export const getLocalApiPrefix = () => {
|
|
5
|
+
const nextConfig = getConfig()
|
|
6
|
+
const { publicRuntimeConfig } = nextConfig
|
|
7
|
+
let { protocol, host, port } = publicRuntimeConfig
|
|
8
|
+
|
|
9
|
+
if (typeof window !== 'undefined') {
|
|
10
|
+
const location = window.location
|
|
11
|
+
// console.log('location', location)
|
|
12
|
+
protocol = location.protocol
|
|
13
|
+
if (protocol.indexOf(':') !== -1) {
|
|
14
|
+
protocol = protocol.split(':')[0]
|
|
15
|
+
}
|
|
16
|
+
host = location.hostname
|
|
17
|
+
port = location.port
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const localApiPrefix = protocol + '://' + host + ':' + port
|
|
21
|
+
// console.log('localApiPrefix', localApiPrefix)
|
|
22
|
+
return localApiPrefix
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const handleXSS = (content: string) => {
|
|
26
|
+
content = content || ''
|
|
27
|
+
return content.replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/\'/g, ''')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
|
|
31
|
+
let result: any = null
|
|
32
|
+
_.each(modalObj, (value: any, key: string) => {
|
|
33
|
+
// console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
|
|
34
|
+
if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
|
|
35
|
+
if (_.trim(value) === '') {
|
|
36
|
+
result = {
|
|
37
|
+
key,
|
|
38
|
+
reason: '不能为空'
|
|
39
|
+
}
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
return result
|
|
45
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import { getLocalApiPrefix } from './common'
|
|
3
|
-
|
|
4
|
-
export const getLocalGraphql = (query: string, variables: any = {}) => {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
axios
|
|
7
|
-
.post(getLocalApiPrefix() + '/graphql', {
|
|
8
|
-
query,
|
|
9
|
-
variables
|
|
10
|
-
})
|
|
11
|
-
.then((res) => {
|
|
12
|
-
// console.log('axios_res', res)
|
|
13
|
-
if (res) {
|
|
14
|
-
const { data } = res
|
|
15
|
-
resolve(data)
|
|
16
|
-
} else {
|
|
17
|
-
reject()
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
.catch((_e) => {
|
|
21
|
-
// console.error('axios_e', _e)
|
|
22
|
-
reject(_e)
|
|
23
|
-
})
|
|
24
|
-
})
|
|
25
|
-
}
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { getLocalApiPrefix } from './common'
|
|
3
|
+
|
|
4
|
+
export const getLocalGraphql = (query: string, variables: any = {}) => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
axios
|
|
7
|
+
.post(getLocalApiPrefix() + '/graphql', {
|
|
8
|
+
query,
|
|
9
|
+
variables
|
|
10
|
+
})
|
|
11
|
+
.then((res) => {
|
|
12
|
+
// console.log('axios_res', res)
|
|
13
|
+
if (res) {
|
|
14
|
+
const { data } = res
|
|
15
|
+
resolve(data)
|
|
16
|
+
} else {
|
|
17
|
+
reject()
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.catch((_e) => {
|
|
21
|
+
// console.error('axios_e', _e)
|
|
22
|
+
reject(_e)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { BookOutlined, SolutionOutlined } from '@ant-design/icons'
|
|
2
|
-
|
|
3
|
-
let key = 0
|
|
4
|
-
|
|
5
|
-
export default [
|
|
6
|
-
{
|
|
7
|
-
key: (++key).toString(),
|
|
8
|
-
text: '介绍',
|
|
9
|
-
url: '/',
|
|
10
|
-
icon: <BookOutlined />,
|
|
11
|
-
subMenus: null
|
|
12
|
-
}
|
|
13
|
-
/*{
|
|
14
|
-
key: (++key).toString(),
|
|
15
|
-
text: '模板',
|
|
16
|
-
url: '/template/manage',
|
|
17
|
-
icon: <SolutionOutlined />,
|
|
18
|
-
subMenus: [
|
|
19
|
-
{
|
|
20
|
-
key: key + '_1',
|
|
21
|
-
text: '模板1',
|
|
22
|
-
url: '/template/manage'
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
},*/
|
|
26
|
-
]
|
|
1
|
+
import { BookOutlined, SolutionOutlined } from '@ant-design/icons'
|
|
2
|
+
|
|
3
|
+
let key = 0
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{
|
|
7
|
+
key: (++key).toString(),
|
|
8
|
+
text: '介绍',
|
|
9
|
+
url: '/',
|
|
10
|
+
icon: <BookOutlined />,
|
|
11
|
+
subMenus: null
|
|
12
|
+
}
|
|
13
|
+
/*{
|
|
14
|
+
key: (++key).toString(),
|
|
15
|
+
text: '模板',
|
|
16
|
+
url: '/template/manage',
|
|
17
|
+
icon: <SolutionOutlined />,
|
|
18
|
+
subMenus: [
|
|
19
|
+
{
|
|
20
|
+
key: key + '_1',
|
|
21
|
+
text: '模板1',
|
|
22
|
+
url: '/template/manage'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},*/
|
|
26
|
+
]
|
package/generation/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "nsgm-cli-project",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "nsgm dev",
|
|
8
|
-
"build": "next build",
|
|
9
|
-
"start": "nsgm start",
|
|
10
|
-
"export": "nsgm export",
|
|
11
|
-
"init": "nsgm init",
|
|
12
|
-
"upgrade": "nsgm upgrade",
|
|
13
|
-
"create": "nsgm create",
|
|
14
|
-
"delete": "nsgm delete",
|
|
15
|
-
"postversion": "git push && git push --tags",
|
|
16
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
-
},
|
|
18
|
-
"author": "",
|
|
19
|
-
"license": "ISC"
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "nsgm-cli-project",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "nsgm dev",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "nsgm start",
|
|
10
|
+
"export": "nsgm export",
|
|
11
|
+
"init": "nsgm init",
|
|
12
|
+
"upgrade": "nsgm upgrade",
|
|
13
|
+
"create": "nsgm create",
|
|
14
|
+
"delete": "nsgm delete",
|
|
15
|
+
"postversion": "git push && git push --tags",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC"
|
|
20
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import Document, {
|
|
2
|
-
Html,
|
|
3
|
-
Head,
|
|
4
|
-
Main,
|
|
5
|
-
NextScript,
|
|
6
|
-
DocumentContext
|
|
7
|
-
} from 'next/document'
|
|
8
|
-
import { ServerStyleSheet } from 'styled-components'
|
|
9
|
-
|
|
10
|
-
const MyDocument = () => {
|
|
11
|
-
return (
|
|
12
|
-
<Html>
|
|
13
|
-
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui"/>
|
|
14
|
-
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
15
|
-
<meta charSet="utf-8"/>
|
|
16
|
-
<Head/>
|
|
17
|
-
<body>
|
|
18
|
-
<Main />
|
|
19
|
-
<NextScript />
|
|
20
|
-
</body>
|
|
21
|
-
</Html>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
MyDocument.renderDocument = Document.renderDocument
|
|
26
|
-
|
|
27
|
-
MyDocument.getInitialProps = async (ctx: DocumentContext) => {
|
|
28
|
-
const sheet = new ServerStyleSheet()
|
|
29
|
-
const originalRenderPage = ctx.renderPage
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
ctx.renderPage = () =>
|
|
33
|
-
originalRenderPage({
|
|
34
|
-
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const initialProps = await Document.getInitialProps(ctx)
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
...initialProps,
|
|
41
|
-
styles: (
|
|
42
|
-
<>
|
|
43
|
-
{initialProps.styles}
|
|
44
|
-
{sheet.getStyleElement()}
|
|
45
|
-
</>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
} finally {
|
|
49
|
-
sheet.seal()
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default MyDocument
|
|
1
|
+
import Document, {
|
|
2
|
+
Html,
|
|
3
|
+
Head,
|
|
4
|
+
Main,
|
|
5
|
+
NextScript,
|
|
6
|
+
DocumentContext
|
|
7
|
+
} from 'next/document'
|
|
8
|
+
import { ServerStyleSheet } from 'styled-components'
|
|
9
|
+
|
|
10
|
+
const MyDocument = () => {
|
|
11
|
+
return (
|
|
12
|
+
<Html>
|
|
13
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui"/>
|
|
14
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
15
|
+
<meta charSet="utf-8"/>
|
|
16
|
+
<Head/>
|
|
17
|
+
<body>
|
|
18
|
+
<Main />
|
|
19
|
+
<NextScript />
|
|
20
|
+
</body>
|
|
21
|
+
</Html>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
MyDocument.renderDocument = Document.renderDocument
|
|
26
|
+
|
|
27
|
+
MyDocument.getInitialProps = async (ctx: DocumentContext) => {
|
|
28
|
+
const sheet = new ServerStyleSheet()
|
|
29
|
+
const originalRenderPage = ctx.renderPage
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
ctx.renderPage = () =>
|
|
33
|
+
originalRenderPage({
|
|
34
|
+
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const initialProps = await Document.getInitialProps(ctx)
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...initialProps,
|
|
41
|
+
styles: (
|
|
42
|
+
<>
|
|
43
|
+
{initialProps.styles}
|
|
44
|
+
{sheet.getStyleElement()}
|
|
45
|
+
</>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
} finally {
|
|
49
|
+
sheet.seal()
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default MyDocument
|
package/generation/tsconfig.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"lib": [
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"strict": false,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"noEmit": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"module": "esnext",
|
|
16
|
-
"moduleResolution": "node",
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"jsx": "preserve"
|
|
20
|
-
},
|
|
21
|
-
"include": [
|
|
22
|
-
"next-env.d.ts",
|
|
23
|
-
"**/*.ts",
|
|
24
|
-
"**/*.tsx"
|
|
25
|
-
],
|
|
26
|
-
"exclude": [
|
|
27
|
-
"node_modules"
|
|
28
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": [
|
|
5
|
+
"dom",
|
|
6
|
+
"dom.iterable",
|
|
7
|
+
"esnext"
|
|
8
|
+
],
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"strict": false,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"module": "esnext",
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
"jsx": "preserve"
|
|
20
|
+
},
|
|
21
|
+
"include": [
|
|
22
|
+
"next-env.d.ts",
|
|
23
|
+
"**/*.ts",
|
|
24
|
+
"**/*.tsx"
|
|
25
|
+
],
|
|
26
|
+
"exclude": [
|
|
27
|
+
"node_modules"
|
|
28
|
+
]
|
|
29
29
|
}
|
package/lib/generate.js
CHANGED
|
@@ -75,7 +75,7 @@ var copyFileSync = function (source, dest, upgradeFlag) {
|
|
|
75
75
|
var handleReplace = function (_a) {
|
|
76
76
|
var regex = _a.regex, replacement = _a.replacement, paths = _a.paths;
|
|
77
77
|
if (replaceFlag) {
|
|
78
|
-
replace_1.default({
|
|
78
|
+
(0, replace_1.default)({
|
|
79
79
|
regex: regex,
|
|
80
80
|
replacement: replacement,
|
|
81
81
|
paths: paths,
|
|
@@ -91,7 +91,7 @@ var replaceInFileAll = function (array, index, callback) {
|
|
|
91
91
|
var arrayLen = array.length;
|
|
92
92
|
if (index < arrayLen) {
|
|
93
93
|
var item = array[index];
|
|
94
|
-
replace_in_file_1.replaceInFile(item, function (error, changedFiles) {
|
|
94
|
+
(0, replace_in_file_1.replaceInFile)(item, function (error, changedFiles) {
|
|
95
95
|
if (error) {
|
|
96
96
|
console.error('Error occurred:', error);
|
|
97
97
|
}
|
package/lib/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var generate_1 = require("./generate");
|
|
|
20
20
|
var lodash_1 = __importDefault(require("lodash"));
|
|
21
21
|
var resolve = path_1.default.resolve;
|
|
22
22
|
var curFolder = process.cwd();
|
|
23
|
-
var processArgvs = args_1.getProcessArgvs(2);
|
|
23
|
+
var processArgvs = (0, args_1.getProcessArgvs)(2);
|
|
24
24
|
console.log('processArgvs', processArgvs);
|
|
25
25
|
var command = processArgvs.command, dictionary = processArgvs.dictionary, controller = processArgvs.controller, action = processArgvs.action;
|
|
26
26
|
var handleServer = function (server) {
|
|
@@ -46,7 +46,7 @@ var handleServer = function (server) {
|
|
|
46
46
|
};
|
|
47
47
|
var startExpress = function (options, callback) {
|
|
48
48
|
// console.info('startExpress', curFolder)
|
|
49
|
-
var app = next_1.default(options);
|
|
49
|
+
var app = (0, next_1.default)(options);
|
|
50
50
|
var handle = app.getRequestHandler();
|
|
51
51
|
app
|
|
52
52
|
.prepare()
|
|
@@ -55,21 +55,21 @@ var startExpress = function (options, callback) {
|
|
|
55
55
|
callback();
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
var server = express_1.default();
|
|
58
|
+
var server = (0, express_1.default)();
|
|
59
59
|
server.use(body_parser_1.default.urlencoded({
|
|
60
60
|
extended: false
|
|
61
61
|
}));
|
|
62
62
|
server.use(body_parser_1.default.json());
|
|
63
|
-
server.use(express_fileupload_1.default());
|
|
63
|
+
server.use((0, express_fileupload_1.default)());
|
|
64
64
|
server.use('/static', express_1.default.static(path_1.default.join(__dirname, 'public')));
|
|
65
|
-
server.use('/graphql', graphql_1.default(command));
|
|
65
|
+
server.use('/graphql', (0, graphql_1.default)(command));
|
|
66
66
|
handleServer(server);
|
|
67
67
|
server.get('*', function (req, res) {
|
|
68
68
|
// console.log('originalUrl', req.originalUrl)
|
|
69
|
-
var parsedUrl = url_1.parse(req.url, true);
|
|
69
|
+
var parsedUrl = (0, url_1.parse)(req.url, true);
|
|
70
70
|
return handle(req, res, parsedUrl);
|
|
71
71
|
});
|
|
72
|
-
var nextConfig = config_1.default();
|
|
72
|
+
var nextConfig = (0, config_1.default)();
|
|
73
73
|
var publicRuntimeConfig = nextConfig.publicRuntimeConfig;
|
|
74
74
|
var protocol = publicRuntimeConfig.protocol, host = publicRuntimeConfig.host, port = publicRuntimeConfig.port;
|
|
75
75
|
server.listen(port, function () {
|
|
@@ -84,10 +84,10 @@ var startExpress = function (options, callback) {
|
|
|
84
84
|
exports.startExpress = startExpress;
|
|
85
85
|
switch (command) {
|
|
86
86
|
case 'dev':
|
|
87
|
-
exports.startExpress({ dev: true }, null);
|
|
87
|
+
(0, exports.startExpress)({ dev: true }, null);
|
|
88
88
|
break;
|
|
89
89
|
case 'start':
|
|
90
|
-
exports.startExpress({ dev: false }, null);
|
|
90
|
+
(0, exports.startExpress)({ dev: false }, null);
|
|
91
91
|
break;
|
|
92
92
|
case 'build':
|
|
93
93
|
case 'export':
|
|
@@ -100,12 +100,12 @@ switch (command) {
|
|
|
100
100
|
shellCommand += ' -o ' + dictionary;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
child_process_1.exec(shellCommand, {}, function (err, stdout, stderr) {
|
|
103
|
+
(0, child_process_1.exec)(shellCommand, {}, function (err, stdout, stderr) {
|
|
104
104
|
if (err) {
|
|
105
105
|
console.log(err);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
console.log("stdout: "
|
|
108
|
+
console.log("stdout: ".concat(stdout));
|
|
109
109
|
});
|
|
110
110
|
break;
|
|
111
111
|
case 'init':
|
|
@@ -142,20 +142,20 @@ switch (command) {
|
|
|
142
142
|
}
|
|
143
143
|
console.log('initFlag', initFlag_1);
|
|
144
144
|
if (initFlag_1) {
|
|
145
|
-
generate_1.initFiles(dictionary);
|
|
145
|
+
(0, generate_1.initFiles)(dictionary);
|
|
146
146
|
}
|
|
147
147
|
break;
|
|
148
148
|
case 'upgrade':
|
|
149
|
-
generate_1.initFiles(dictionary, true);
|
|
149
|
+
(0, generate_1.initFiles)(dictionary, true);
|
|
150
150
|
break;
|
|
151
151
|
case 'create':
|
|
152
152
|
console.log(command, controller, action);
|
|
153
153
|
if (controller !== '') {
|
|
154
154
|
if (action === '') {
|
|
155
|
-
generate_1.createFiles(controller, 'manage');
|
|
155
|
+
(0, generate_1.createFiles)(controller, 'manage');
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
158
|
-
generate_1.createFiles(controller, action);
|
|
158
|
+
(0, generate_1.createFiles)(controller, action);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
break;
|
|
@@ -163,16 +163,16 @@ switch (command) {
|
|
|
163
163
|
console.log(command, controller, action);
|
|
164
164
|
if (controller !== '') {
|
|
165
165
|
if (action === '' || action === 'all') {
|
|
166
|
-
generate_1.deleteFiles(controller, 'all');
|
|
166
|
+
(0, generate_1.deleteFiles)(controller, 'all');
|
|
167
167
|
}
|
|
168
168
|
else {
|
|
169
|
-
generate_1.deleteFiles(controller, action);
|
|
169
|
+
(0, generate_1.deleteFiles)(controller, action);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
break;
|
|
173
173
|
case 'version':
|
|
174
|
-
exports.startExpress({ dev: true }, function () {
|
|
175
|
-
var nextConfig = config_1.default();
|
|
174
|
+
(0, exports.startExpress)({ dev: true }, function () {
|
|
175
|
+
var nextConfig = (0, config_1.default)();
|
|
176
176
|
var publicRuntimeConfig = nextConfig.publicRuntimeConfig;
|
|
177
177
|
var version = publicRuntimeConfig.version;
|
|
178
178
|
console.log('version: ' + version);
|
package/lib/server/graphql.js
CHANGED
|
@@ -20,18 +20,18 @@ var fs_1 = __importDefault(require("fs"));
|
|
|
20
20
|
var lodash_1 = __importDefault(require("lodash"));
|
|
21
21
|
var path_1 = require("path");
|
|
22
22
|
var date_1 = __importDefault(require("./plugins/date"));
|
|
23
|
-
var defaultPath = path_1.resolve(__dirname, './modules/');
|
|
23
|
+
var defaultPath = (0, path_1.resolve)(__dirname, './modules/');
|
|
24
24
|
var typeDefFileName = 'schema.js';
|
|
25
25
|
var resolverFileName = 'resolver.js';
|
|
26
26
|
var curFolder = process.cwd();
|
|
27
|
-
var outModulesPath = path_1.resolve(curFolder + '/server/modules/');
|
|
27
|
+
var outModulesPath = (0, path_1.resolve)(curFolder + '/server/modules/');
|
|
28
28
|
var handleOutPlugins = function () {
|
|
29
29
|
var result = {};
|
|
30
|
-
var outPluginsPath = path_1.resolve(curFolder + '/server/plugins/');
|
|
30
|
+
var outPluginsPath = (0, path_1.resolve)(curFolder + '/server/plugins/');
|
|
31
31
|
if (fs_1.default.existsSync(outPluginsPath)) {
|
|
32
32
|
var list = fs_1.default.readdirSync(outPluginsPath);
|
|
33
33
|
list.forEach(function (item) {
|
|
34
|
-
var resolverPath = path_1.resolve(outPluginsPath + '/' + item);
|
|
34
|
+
var resolverPath = (0, path_1.resolve)(outPluginsPath + '/' + item);
|
|
35
35
|
var stat = fs_1.default.statSync(resolverPath);
|
|
36
36
|
var isFile = stat.isFile();
|
|
37
37
|
if (isFile) {
|
|
@@ -105,14 +105,14 @@ function generateTypeDefsAndResolvers() {
|
|
|
105
105
|
return { querySchemes: querySchemes, mutationSchemes: mutationSchemes, subscriptionSchemes: subscriptionSchemes, typeSchemes: typeSchemes, resolvers: resolvers, scalarStr: scalarStr };
|
|
106
106
|
}
|
|
107
107
|
var _a = generateTypeDefsAndResolvers(), querySchemesV = _a.querySchemes, mutationSchemesV = _a.mutationSchemes, subscriptionSchemesV = _a.subscriptionSchemes, typeSchemesV = _a.typeSchemes, resolversV = _a.resolvers, scalarStrV = _a.scalarStr;
|
|
108
|
-
var schemaStr = "\n "
|
|
108
|
+
var schemaStr = "\n ".concat(scalarStrV, "\n\n type Query { \n ").concat(querySchemesV.join('\n'), " \n }\n\n type Mutation { \n ").concat(mutationSchemesV.join('\n'), " \n }\n\n type Subscription { \n ").concat(subscriptionSchemesV.join('\n'), " \n }\n\n ").concat(typeSchemesV.join('\n'), "\n");
|
|
109
109
|
exports.default = (function (command) {
|
|
110
110
|
if (command === 'dev') {
|
|
111
111
|
console.log('schemaStr', schemaStr);
|
|
112
112
|
console.log('resolvers', resolversV);
|
|
113
113
|
}
|
|
114
|
-
return express_graphql_1.graphqlHTTP({
|
|
115
|
-
schema: graphql_1.buildSchema(schemaStr),
|
|
114
|
+
return (0, express_graphql_1.graphqlHTTP)({
|
|
115
|
+
schema: (0, graphql_1.buildSchema)(schemaStr),
|
|
116
116
|
rootValue: resolversV,
|
|
117
117
|
graphiql: true
|
|
118
118
|
});
|
|
@@ -9,8 +9,8 @@ var graphql_1 = require("graphql");
|
|
|
9
9
|
var customScalarDate = new graphql_1.GraphQLScalarType({
|
|
10
10
|
name: 'Date',
|
|
11
11
|
description: 'Date custom scalar type',
|
|
12
|
-
parseValue: function (value) { return moment_1.default(value).valueOf(); },
|
|
13
|
-
serialize: function (value) { return moment_1.default(value).format('YYYY-MM-DD HH:mm:ss:SSS'); },
|
|
12
|
+
parseValue: function (value) { return (0, moment_1.default)(value).valueOf(); },
|
|
13
|
+
serialize: function (value) { return (0, moment_1.default)(value).format('YYYY-MM-DD HH:mm:ss:SSS'); },
|
|
14
14
|
parseLiteral: function (ast) { return (ast.kind === language_1.Kind.INT ? parseInt(ast.value, 10) : null); }
|
|
15
15
|
});
|
|
16
16
|
exports.default = { Date: customScalarDate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nsgm-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "A CLI tool to run Next/Style-components and Graphql/Mysql fullstack project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"@types/mysql": "^2.15.17",
|
|
99
99
|
"@types/next": "^9.0.0",
|
|
100
100
|
"@types/node": "^14.14.22",
|
|
101
|
-
"@types/react": "
|
|
102
|
-
"@types/react-dom": "^
|
|
101
|
+
"@types/react": "18.0.1",
|
|
102
|
+
"@types/react-dom": "^18.0.11",
|
|
103
103
|
"@types/react-redux": "^7.1.16",
|
|
104
104
|
"@types/shelljs": "^0.8.8",
|
|
105
105
|
"@types/styled-components": "^5.1.7",
|