nsgm-cli 2.0.6 → 2.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.
Files changed (59) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +161 -161
  3. package/client/layout/index.tsx +248 -245
  4. package/client/redux/reducers.ts +4 -4
  5. package/client/redux/store.ts +50 -50
  6. package/client/redux/template/manage/actions.ts +190 -190
  7. package/client/redux/template/manage/reducers.ts +118 -118
  8. package/client/redux/template/manage/types.ts +24 -24
  9. package/client/service/template/manage.ts +96 -96
  10. package/client/styled/common.ts +60 -27
  11. package/client/styled/layout/index.ts +25 -25
  12. package/client/styled/template/manage.ts +51 -51
  13. package/client/utils/common.ts +89 -86
  14. package/client/utils/cookie.ts +51 -51
  15. package/client/utils/fetch.ts +25 -25
  16. package/client/utils/menu.tsx +27 -27
  17. package/client/utils/sso.ts +205 -0
  18. package/generation/README.md +19 -19
  19. package/generation/app.js +2 -2
  20. package/generation/client/redux/reducers.ts +4 -4
  21. package/generation/client/utils/menu.tsx +27 -27
  22. package/generation/gitignore +4 -4
  23. package/generation/mysql.config.js +12 -13
  24. package/generation/next.config.js +6 -6
  25. package/generation/package.json +21 -26
  26. package/generation/project.config.js +13 -12
  27. package/generation/server/rest.js +23 -20
  28. package/generation/tsconfig.json +30 -30
  29. package/index.js +10 -10
  30. package/lib/args.d.ts +6 -6
  31. package/lib/args.js +53 -53
  32. package/lib/generate.d.ts +3 -3
  33. package/lib/generate.js +751 -736
  34. package/lib/index.d.ts +2 -2
  35. package/lib/index.js +272 -272
  36. package/lib/server/db.d.ts +5 -5
  37. package/lib/server/db.js +110 -110
  38. package/lib/server/graphql.d.ts +7 -7
  39. package/lib/server/graphql.js +119 -119
  40. package/lib/server/plugins/date.d.ts +5 -5
  41. package/lib/server/plugins/date.js +16 -16
  42. package/lib/tsconfig.build.tsbuildinfo +1 -1
  43. package/mysql.config.js +14 -14
  44. package/next-env.d.ts +6 -6
  45. package/next.config.js +2 -2
  46. package/package.json +126 -126
  47. package/pages/_app.tsx +54 -44
  48. package/pages/login.tsx +79 -0
  49. package/pages/template/manage.tsx +278 -278
  50. package/project.config.js +16 -14
  51. package/public/slbhealthcheck.html +9 -9
  52. package/scripts/shutdown.sh +9 -9
  53. package/scripts/startup.sh +34 -34
  54. package/server/apis/sso.js +44 -0
  55. package/server/apis/template.js +17 -17
  56. package/server/modules/template/schema.js +33 -33
  57. package/server/rest.js +24 -20
  58. package/server/sql/template.sql +8 -8
  59. package/generation/.DS_Store +0 -0
@@ -1,245 +1,248 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { Layout, Menu, Breadcrumb, Image, Select } 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
- import getConfig from 'next/config'
8
- import { ItemType, SubMenuType } from 'antd/lib/menu/hooks/useItems'
9
-
10
- const { Option } = Select
11
- const { SubMenu } = Menu
12
- const { Header, Content, Sider } = Layout
13
-
14
- const nextConfig = getConfig()
15
- const { publicRuntimeConfig } = nextConfig
16
- const { prefix } = publicRuntimeConfig
17
-
18
- const getLocationKey = () => {
19
- let result = {
20
- topMenu: '1',
21
- slideMenu: '0'
22
- }
23
-
24
- if (typeof window !== 'undefined') {
25
- const locationHref = window.location.href
26
-
27
- let locationHrefArr = locationHref.split('?')
28
- if (locationHrefArr.length > 0) {
29
- locationHrefArr = locationHrefArr[0].split('//')
30
-
31
- if (locationHrefArr.length > 1) {
32
- let locationStr = locationHrefArr[1]
33
- const locationIndex = locationStr.indexOf('/')
34
- locationStr = locationStr.substring(locationIndex)
35
-
36
- if (prefix && locationStr.indexOf(prefix) !== -1) {
37
- locationStr = locationStr.split(prefix)[1]
38
- }
39
-
40
- // console.log('locationStr', locationStr)
41
-
42
- _.each(menuConfig, (item, index) => {
43
- const { key, url, subMenus } = item
44
-
45
- if (subMenus) {
46
- _.each(subMenus, (subItem, subIndex) => {
47
- const { key: subKey, url: subUrl } = subItem
48
-
49
- if (locationStr === subUrl.split('?')[0]) {
50
- const subKeyArr = subKey.split('_')
51
- const subKeyArrLen = subKeyArr.length
52
-
53
- if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
54
-
55
- if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
56
-
57
- return false
58
- }
59
- })
60
- } else {
61
- if (url && locationStr === url.split('?')[0]) {
62
- result.topMenu = key
63
- return false
64
- }
65
- }
66
- })
67
- }
68
- }
69
- }
70
- // console.log('result', result)
71
- return result
72
- }
73
-
74
- const routerPush = (router: any, url: string) => {
75
- // console.log('routerPush', url)
76
- if (router && url) {
77
- if (prefix && url.indexOf(prefix) === -1) {
78
- url = prefix + url
79
- }
80
- router.push(url)
81
- }
82
- }
83
-
84
- const LayoutComponent = ({ user, children }) => {
85
- const router = useRouter()
86
- const [topMenuKey, setTopMenuKey] = useState('1')
87
- const [sliderMenuKey, setSliderMenuKey] = useState('1')
88
-
89
- // console.log('topMenuKey: ' + topMenuKey, ', sliderMenuKey: ' + sliderMenuKey, user)
90
-
91
- useEffect(() => {
92
- const { topMenu, slideMenu } = getLocationKey()
93
- setTopMenuKey(topMenu)
94
- setSliderMenuKey(slideMenu)
95
- }, [])
96
-
97
- const menuItems:any = []
98
- const menuItemsVertical:any = []
99
-
100
- _.each(menuConfig, (item, index) => {
101
- const { key, text, url, icon, subMenus } = item
102
-
103
- if (key) {
104
- const menuObj:ItemType = {
105
- label: text,
106
- key,
107
- onClick: () => {
108
- routerPush(router, url)
109
- setTopMenuKey(key)
110
-
111
- if (subMenus) {
112
- setSliderMenuKey('1')
113
- } else {
114
- setSliderMenuKey('0')
115
- }
116
- }
117
- }
118
-
119
- menuItems.push(menuObj)
120
- }
121
-
122
- if (subMenus) {
123
- const subMenusChildren:any = []
124
-
125
- _.each(subMenus, (subItem, subIndex) => {
126
- const { key: subKey, text: subText, url: subUrl } = subItem
127
-
128
- const subMenusChildrenObj:ItemType = {
129
- key: 'slider_' + subKey,
130
- label: subText,
131
- onClick: ()=>{
132
- routerPush(router, subUrl)
133
-
134
- const subKeyArr = subKey.split('_')
135
- const subKeyArrLen = subKeyArr.length
136
-
137
- // console.log(subKeyArr, subKeyArrLen)
138
-
139
- if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0])
140
- if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1])
141
- }
142
- }
143
-
144
- subMenusChildren.push(subMenusChildrenObj)
145
- })
146
-
147
- const subMenuObjVertical:SubMenuType = {
148
- key: 'slider_' + key,
149
- icon,
150
- label: text,
151
- onTitleClick: () => {
152
- setTopMenuKey(key)
153
- setSliderMenuKey('1')
154
- },
155
- children: subMenusChildren
156
- }
157
-
158
- menuItemsVertical.push(subMenuObjVertical)
159
- } else {
160
- if (key) {
161
- const menuObjVertical:ItemType = {
162
- label: text,
163
- icon,
164
- key: 'slider_' + key + '_0',
165
- onClick: () => {
166
- routerPush(router, url)
167
- setTopMenuKey(key)
168
- setSliderMenuKey('0')
169
- }
170
- }
171
-
172
- menuItemsVertical.push(menuObjVertical)
173
- }
174
- }
175
- })
176
-
177
- return (
178
- <Layout>
179
- <Container>
180
- <Header className="header">
181
- <div className="logo">
182
- <Image width={100} src={prefix + "/images/zhizuotu_1.png"} preview={false} />
183
- </div>
184
- <Menu theme="dark" mode="horizontal" defaultSelectedKeys={['1']} selectedKeys={[topMenuKey]} items={menuItems} />
185
- <div className="user">
186
- <div>Welcome</div>
187
- </div>
188
- </Header>
189
- <Layout>
190
- <Sider width={200} className="site-layout-background">
191
- <Menu
192
- mode="inline"
193
- defaultSelectedKeys={['slider_1_0']}
194
- defaultOpenKeys={['slider_1']}
195
- selectedKeys={['slider_' + topMenuKey + '_' + sliderMenuKey]}
196
- openKeys={['slider_' + topMenuKey]}
197
- style={{ height: '100%', borderRight: 0 }}
198
- items={menuItemsVertical}
199
- />
200
- </Sider>
201
- <Layout style={{ padding: '0 24px 24px' }}>
202
- <Breadcrumb style={{ margin: '16px 0' }}>
203
- {_.map(menuConfig, (item, index) => {
204
- const { key, text, subMenus } = item
205
-
206
- if (subMenus) {
207
- // console.log('subMenus', subMenus)
208
-
209
- let subContent:any = []
210
- _.each(subMenus, (subItem, subIndex) => {
211
- const { key: subKey, text: subText } = subItem
212
- // console.log('subKey', subKey, key, topMenuKey, sliderMenuKey)
213
-
214
- if (subKey === topMenuKey + '_' + sliderMenuKey) {
215
- subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{text}</Breadcrumb.Item>)
216
- subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{subText}</Breadcrumb.Item>)
217
- return false
218
- }
219
- })
220
- return subContent
221
- } else {
222
- if (key && key === topMenuKey) {
223
- return <Breadcrumb.Item key={'breadcrumb' + index}>{text}</Breadcrumb.Item>
224
- }
225
- }
226
- })}
227
- </Breadcrumb>
228
- <Content
229
- className="site-layout-background"
230
- style={{
231
- padding: 24,
232
- margin: 0,
233
- minHeight: 280
234
- }}
235
- >
236
- {children}
237
- </Content>
238
- </Layout>
239
- </Layout>
240
- </Container>
241
- </Layout>
242
- )
243
- }
244
-
245
- export default LayoutComponent
1
+ import React, { useEffect, useState } from 'react'
2
+ import { Layout, Menu, Breadcrumb, Image, Select } 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
+ import { logout } from '../utils/sso'
8
+ import getConfig from 'next/config'
9
+ import { ItemType, SubMenuType } from 'antd/lib/menu/hooks/useItems'
10
+
11
+ const { Option } = Select
12
+ const { SubMenu } = Menu
13
+ const { Header, Content, Sider } = Layout
14
+
15
+ const nextConfig = getConfig()
16
+ const { publicRuntimeConfig } = nextConfig
17
+ const { prefix } = publicRuntimeConfig
18
+
19
+ const getLocationKey = () => {
20
+ let result = {
21
+ topMenu: '1',
22
+ slideMenu: '0'
23
+ }
24
+
25
+ if (typeof window !== 'undefined') {
26
+ const locationHref = window.location.href
27
+
28
+ let locationHrefArr = locationHref.split('?')
29
+ if (locationHrefArr.length > 0) {
30
+ locationHrefArr = locationHrefArr[0].split('//')
31
+
32
+ if (locationHrefArr.length > 1) {
33
+ let locationStr = locationHrefArr[1]
34
+ const locationIndex = locationStr.indexOf('/')
35
+ locationStr = locationStr.substring(locationIndex)
36
+
37
+ if (prefix && locationStr.indexOf(prefix) !== -1) {
38
+ locationStr = locationStr.split(prefix)[1]
39
+ }
40
+
41
+ // console.log('locationStr', locationStr)
42
+
43
+ _.each(menuConfig, (item, index) => {
44
+ const { key, url, subMenus } = item
45
+
46
+ if (subMenus) {
47
+ _.each(subMenus, (subItem, subIndex) => {
48
+ const { key: subKey, url: subUrl } = subItem
49
+
50
+ if (locationStr === subUrl.split('?')[0]) {
51
+ const subKeyArr = subKey.split('_')
52
+ const subKeyArrLen = subKeyArr.length
53
+
54
+ if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
55
+
56
+ if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
57
+
58
+ return false
59
+ }
60
+ })
61
+ } else {
62
+ if (url && locationStr === url.split('?')[0]) {
63
+ result.topMenu = key
64
+ return false
65
+ }
66
+ }
67
+ })
68
+ }
69
+ }
70
+ }
71
+ // console.log('result', result)
72
+ return result
73
+ }
74
+
75
+ const routerPush = (router: any, url: string) => {
76
+ // console.log('routerPush', url)
77
+ if (router && url) {
78
+ if (prefix && url.indexOf(prefix) === -1) {
79
+ url = prefix + url
80
+ }
81
+ router.push(url)
82
+ }
83
+ }
84
+
85
+ const LayoutComponent = ({ user, children }) => {
86
+ const router = useRouter()
87
+ const [topMenuKey, setTopMenuKey] = useState('1')
88
+ const [sliderMenuKey, setSliderMenuKey] = useState('1')
89
+
90
+ // console.log('topMenuKey: ' + topMenuKey, ', sliderMenuKey: ' + sliderMenuKey, user)
91
+
92
+ useEffect(() => {
93
+ const { topMenu, slideMenu } = getLocationKey()
94
+ setTopMenuKey(topMenu)
95
+ setSliderMenuKey(slideMenu)
96
+ }, [])
97
+
98
+ const menuItems:any = []
99
+ const menuItemsVertical:any = []
100
+
101
+ _.each(menuConfig, (item, index) => {
102
+ const { key, text, url, icon, subMenus } = item
103
+
104
+ if (key) {
105
+ const menuObj:ItemType = {
106
+ label: text,
107
+ key,
108
+ onClick: () => {
109
+ routerPush(router, url)
110
+ setTopMenuKey(key)
111
+
112
+ if (subMenus) {
113
+ setSliderMenuKey('1')
114
+ } else {
115
+ setSliderMenuKey('0')
116
+ }
117
+ }
118
+ }
119
+
120
+ menuItems.push(menuObj)
121
+ }
122
+
123
+ if (subMenus) {
124
+ const subMenusChildren:any = []
125
+
126
+ _.each(subMenus, (subItem, subIndex) => {
127
+ const { key: subKey, text: subText, url: subUrl } = subItem
128
+
129
+ const subMenusChildrenObj:ItemType = {
130
+ key: 'slider_' + subKey,
131
+ label: subText,
132
+ onClick: ()=>{
133
+ routerPush(router, subUrl)
134
+
135
+ const subKeyArr = subKey.split('_')
136
+ const subKeyArrLen = subKeyArr.length
137
+
138
+ // console.log(subKeyArr, subKeyArrLen)
139
+
140
+ if (subKeyArrLen >= 1) setTopMenuKey(subKeyArr[0])
141
+ if (subKeyArrLen >= 2) setSliderMenuKey(subKeyArr[1])
142
+ }
143
+ }
144
+
145
+ subMenusChildren.push(subMenusChildrenObj)
146
+ })
147
+
148
+ const subMenuObjVertical:SubMenuType = {
149
+ key: 'slider_' + key,
150
+ icon,
151
+ label: text,
152
+ onTitleClick: () => {
153
+ setTopMenuKey(key)
154
+ setSliderMenuKey('1')
155
+ },
156
+ children: subMenusChildren
157
+ }
158
+
159
+ menuItemsVertical.push(subMenuObjVertical)
160
+ } else {
161
+ if (key) {
162
+ const menuObjVertical:ItemType = {
163
+ label: text,
164
+ icon,
165
+ key: 'slider_' + key + '_0',
166
+ onClick: () => {
167
+ routerPush(router, url)
168
+ setTopMenuKey(key)
169
+ setSliderMenuKey('0')
170
+ }
171
+ }
172
+
173
+ menuItemsVertical.push(menuObjVertical)
174
+ }
175
+ }
176
+ })
177
+
178
+ return (
179
+ <Layout>
180
+ <Container>
181
+ <Header className="header">
182
+ <div className="logo">
183
+ <Image width={100} src={prefix + "/images/zhizuotu_1.png"} preview={false} />
184
+ </div>
185
+ <Menu theme="dark" mode="horizontal" defaultSelectedKeys={['1']} selectedKeys={[topMenuKey]} items={menuItems} />
186
+ <div className="user">
187
+ <Select value={user?.displayName} onChange={() => { logout() }}>
188
+ <Option value=''>{'退出'}</Option>
189
+ </Select>
190
+ </div>
191
+ </Header>
192
+ <Layout>
193
+ <Sider width={200} className="site-layout-background">
194
+ <Menu
195
+ mode="inline"
196
+ defaultSelectedKeys={['slider_1_0']}
197
+ defaultOpenKeys={['slider_1']}
198
+ selectedKeys={['slider_' + topMenuKey + '_' + sliderMenuKey]}
199
+ openKeys={['slider_' + topMenuKey]}
200
+ style={{ height: '100%', borderRight: 0 }}
201
+ items={menuItemsVertical}
202
+ />
203
+ </Sider>
204
+ <Layout style={{ padding: '0 24px 24px' }}>
205
+ <Breadcrumb style={{ margin: '16px 0' }}>
206
+ {_.map(menuConfig, (item, index) => {
207
+ const { key, text, subMenus } = item
208
+
209
+ if (subMenus) {
210
+ // console.log('subMenus', subMenus)
211
+
212
+ let subContent:any = []
213
+ _.each(subMenus, (subItem, subIndex) => {
214
+ const { key: subKey, text: subText } = subItem
215
+ // console.log('subKey', subKey, key, topMenuKey, sliderMenuKey)
216
+
217
+ if (subKey === topMenuKey + '_' + sliderMenuKey) {
218
+ subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{text}</Breadcrumb.Item>)
219
+ subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{subText}</Breadcrumb.Item>)
220
+ return false
221
+ }
222
+ })
223
+ return subContent
224
+ } else {
225
+ if (key && key === topMenuKey) {
226
+ return <Breadcrumb.Item key={'breadcrumb' + index}>{text}</Breadcrumb.Item>
227
+ }
228
+ }
229
+ })}
230
+ </Breadcrumb>
231
+ <Content
232
+ className="site-layout-background"
233
+ style={{
234
+ padding: 24,
235
+ margin: 0,
236
+ minHeight: 280
237
+ }}
238
+ >
239
+ {children}
240
+ </Content>
241
+ </Layout>
242
+ </Layout>
243
+ </Container>
244
+ </Layout>
245
+ )
246
+ }
247
+
248
+ export default LayoutComponent
@@ -1,5 +1,5 @@
1
- import { templateManageReducer } from './template/manage/reducers'
2
-
3
- export default {
4
- templateManage: templateManageReducer,
1
+ import { templateManageReducer } from './template/manage/reducers'
2
+
3
+ export default {
4
+ templateManage: templateManageReducer,
5
5
  }
@@ -1,50 +1,50 @@
1
- import { useMemo } from 'react'
2
- import { combineReducers } from 'redux'
3
- import { configureStore } from '@reduxjs/toolkit'
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
-
12
- let combineReducer:any = function(){}
13
-
14
- if(reducersKeysLen > 0){
15
- combineReducer = combineReducers({ ...reducers })
16
- }
17
-
18
- export type RootState = ReturnType<typeof combineReducer>
19
-
20
- function initStore(initialState:any) {
21
- return configureStore({
22
- reducer: combineReducer,
23
- preloadedState: initialState,
24
- devTools: true,
25
- middleware: [thunkMiddleware]
26
- })
27
- }
28
-
29
- export const initializeStore = (preloadedState:any) => {
30
- let _store = store ?? initStore(preloadedState)
31
-
32
- if (preloadedState && store) {
33
- _store = initStore({
34
- ...store.getState(),
35
- ...preloadedState
36
- })
37
- store = undefined
38
- }
39
-
40
- if (typeof window === 'undefined') return _store
41
-
42
- if (!store) store = _store
43
-
44
- return _store
45
- }
46
-
47
- export function useStore(initialState:any) {
48
- const store = useMemo(() => initializeStore(initialState), [initialState])
49
- return store
50
- }
1
+ import { useMemo } from 'react'
2
+ import { combineReducers } from 'redux'
3
+ import { configureStore } from '@reduxjs/toolkit'
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
+
12
+ let combineReducer:any = function(){}
13
+
14
+ if(reducersKeysLen > 0){
15
+ combineReducer = combineReducers({ ...reducers })
16
+ }
17
+
18
+ export type RootState = ReturnType<typeof combineReducer>
19
+
20
+ function initStore(initialState:any) {
21
+ return configureStore({
22
+ reducer: combineReducer,
23
+ preloadedState: initialState,
24
+ devTools: true,
25
+ middleware: [thunkMiddleware]
26
+ })
27
+ }
28
+
29
+ export const initializeStore = (preloadedState:any) => {
30
+ let _store = store ?? initStore(preloadedState)
31
+
32
+ if (preloadedState && store) {
33
+ _store = initStore({
34
+ ...store.getState(),
35
+ ...preloadedState
36
+ })
37
+ store = undefined
38
+ }
39
+
40
+ if (typeof window === 'undefined') return _store
41
+
42
+ if (!store) store = _store
43
+
44
+ return _store
45
+ }
46
+
47
+ export function useStore(initialState:any) {
48
+ const store = useMemo(() => initializeStore(initialState), [initialState])
49
+ return store
50
+ }