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.
- package/LICENSE +201 -201
- package/README.md +161 -161
- package/client/layout/index.tsx +248 -245
- package/client/redux/reducers.ts +4 -4
- package/client/redux/store.ts +50 -50
- package/client/redux/template/manage/actions.ts +190 -190
- package/client/redux/template/manage/reducers.ts +118 -118
- package/client/redux/template/manage/types.ts +24 -24
- package/client/service/template/manage.ts +96 -96
- package/client/styled/common.ts +60 -27
- package/client/styled/layout/index.ts +25 -25
- package/client/styled/template/manage.ts +51 -51
- package/client/utils/common.ts +89 -86
- package/client/utils/cookie.ts +51 -51
- package/client/utils/fetch.ts +25 -25
- package/client/utils/menu.tsx +27 -27
- package/client/utils/sso.ts +205 -0
- package/generation/README.md +19 -19
- package/generation/app.js +2 -2
- package/generation/client/redux/reducers.ts +4 -4
- package/generation/client/utils/menu.tsx +27 -27
- package/generation/gitignore +4 -4
- package/generation/mysql.config.js +12 -13
- package/generation/next.config.js +6 -6
- package/generation/package.json +21 -26
- package/generation/project.config.js +13 -12
- package/generation/server/rest.js +23 -20
- package/generation/tsconfig.json +30 -30
- package/index.js +10 -10
- package/lib/args.d.ts +6 -6
- package/lib/args.js +53 -53
- package/lib/generate.d.ts +3 -3
- package/lib/generate.js +751 -736
- package/lib/index.d.ts +2 -2
- package/lib/index.js +272 -272
- package/lib/server/db.d.ts +5 -5
- package/lib/server/db.js +110 -110
- package/lib/server/graphql.d.ts +7 -7
- package/lib/server/graphql.js +119 -119
- package/lib/server/plugins/date.d.ts +5 -5
- package/lib/server/plugins/date.js +16 -16
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/mysql.config.js +14 -14
- package/next-env.d.ts +6 -6
- package/next.config.js +2 -2
- package/package.json +126 -126
- package/pages/_app.tsx +54 -44
- package/pages/login.tsx +79 -0
- package/pages/template/manage.tsx +278 -278
- package/project.config.js +16 -14
- package/public/slbhealthcheck.html +9 -9
- package/scripts/shutdown.sh +9 -9
- package/scripts/startup.sh +34 -34
- package/server/apis/sso.js +44 -0
- package/server/apis/template.js +17 -17
- package/server/modules/template/schema.js +33 -33
- package/server/rest.js +24 -20
- package/server/sql/template.sql +8 -8
- package/generation/.DS_Store +0 -0
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { getLocalGraphql } from '../../utils/fetch'
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
|
|
4
|
-
export const getTemplateService = (page=0, pageSize=10) => {
|
|
5
|
-
const getTemplateQuery = `query ($page: Int, $pageSize: Int) { template(page: $page, pageSize: $pageSize) {
|
|
6
|
-
totalCounts items {
|
|
7
|
-
id name
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}`
|
|
11
|
-
|
|
12
|
-
return getLocalGraphql(getTemplateQuery, {
|
|
13
|
-
page,
|
|
14
|
-
pageSize
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const searchTemplateByIdService = (id: number) => {
|
|
19
|
-
|
|
20
|
-
const searchTemplateByIdQuery = `query ($id: Int) { templateGet(id: $id){
|
|
21
|
-
id name
|
|
22
|
-
}
|
|
23
|
-
}`
|
|
24
|
-
|
|
25
|
-
return getLocalGraphql(searchTemplateByIdQuery, {
|
|
26
|
-
id
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
|
|
31
|
-
const { name } = data
|
|
32
|
-
|
|
33
|
-
const searchTemplateQuery = `query ($page: Int, $pageSize: Int, $data: TemplateSearchInput) {
|
|
34
|
-
templateSearch(page: $page, pageSize: $pageSize, data: $data) {
|
|
35
|
-
totalCounts items {
|
|
36
|
-
id name
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}`
|
|
40
|
-
|
|
41
|
-
return getLocalGraphql(searchTemplateQuery, {
|
|
42
|
-
page,
|
|
43
|
-
pageSize,
|
|
44
|
-
data: {
|
|
45
|
-
name
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const addTemplateService = (data: any) => {
|
|
51
|
-
const { name } = data
|
|
52
|
-
|
|
53
|
-
const addTemplateQuery = `mutation ($data: TemplateAddInput) { templateAdd(data: $data) }`
|
|
54
|
-
|
|
55
|
-
return getLocalGraphql(addTemplateQuery, {
|
|
56
|
-
data: {
|
|
57
|
-
name
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export const updateTemplateService = (id: number, data: any) => {
|
|
63
|
-
const { name } = data
|
|
64
|
-
|
|
65
|
-
const updateTemplateQuery = `mutation ($id: Int, $data: TemplateAddInput) { templateUpdate(id: $id, data: $data) }`
|
|
66
|
-
|
|
67
|
-
return getLocalGraphql(updateTemplateQuery, {
|
|
68
|
-
id,
|
|
69
|
-
data: {
|
|
70
|
-
name
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const deleteTemplateService = (id: number) => {
|
|
76
|
-
const deleteTemplateQuery = `mutation ($id: Int) { templateDelete(id: $id) }`
|
|
77
|
-
|
|
78
|
-
return getLocalGraphql(deleteTemplateQuery, {
|
|
79
|
-
id
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const batchAddTemplateService = (datas: any) => {
|
|
84
|
-
const batchAddTemplateQuery = `mutation ($datas: [TemplateAddInput]) { templateBatchAdd(datas: $datas) }`
|
|
85
|
-
|
|
86
|
-
return getLocalGraphql(batchAddTemplateQuery, {
|
|
87
|
-
datas
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const batchDeleteTemplateService = (ids: any) => {
|
|
92
|
-
const batchDeleteTemplateQuery = `mutation ($ids: [Int]) { templateBatchDelete(ids: $ids) }`
|
|
93
|
-
|
|
94
|
-
return getLocalGraphql(batchDeleteTemplateQuery, {
|
|
95
|
-
ids
|
|
96
|
-
})
|
|
1
|
+
import { getLocalGraphql } from '../../utils/fetch'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
|
|
4
|
+
export const getTemplateService = (page=0, pageSize=10) => {
|
|
5
|
+
const getTemplateQuery = `query ($page: Int, $pageSize: Int) { template(page: $page, pageSize: $pageSize) {
|
|
6
|
+
totalCounts items {
|
|
7
|
+
id name
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}`
|
|
11
|
+
|
|
12
|
+
return getLocalGraphql(getTemplateQuery, {
|
|
13
|
+
page,
|
|
14
|
+
pageSize
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const searchTemplateByIdService = (id: number) => {
|
|
19
|
+
|
|
20
|
+
const searchTemplateByIdQuery = `query ($id: Int) { templateGet(id: $id){
|
|
21
|
+
id name
|
|
22
|
+
}
|
|
23
|
+
}`
|
|
24
|
+
|
|
25
|
+
return getLocalGraphql(searchTemplateByIdQuery, {
|
|
26
|
+
id
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
|
|
31
|
+
const { name } = data
|
|
32
|
+
|
|
33
|
+
const searchTemplateQuery = `query ($page: Int, $pageSize: Int, $data: TemplateSearchInput) {
|
|
34
|
+
templateSearch(page: $page, pageSize: $pageSize, data: $data) {
|
|
35
|
+
totalCounts items {
|
|
36
|
+
id name
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}`
|
|
40
|
+
|
|
41
|
+
return getLocalGraphql(searchTemplateQuery, {
|
|
42
|
+
page,
|
|
43
|
+
pageSize,
|
|
44
|
+
data: {
|
|
45
|
+
name
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const addTemplateService = (data: any) => {
|
|
51
|
+
const { name } = data
|
|
52
|
+
|
|
53
|
+
const addTemplateQuery = `mutation ($data: TemplateAddInput) { templateAdd(data: $data) }`
|
|
54
|
+
|
|
55
|
+
return getLocalGraphql(addTemplateQuery, {
|
|
56
|
+
data: {
|
|
57
|
+
name
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const updateTemplateService = (id: number, data: any) => {
|
|
63
|
+
const { name } = data
|
|
64
|
+
|
|
65
|
+
const updateTemplateQuery = `mutation ($id: Int, $data: TemplateAddInput) { templateUpdate(id: $id, data: $data) }`
|
|
66
|
+
|
|
67
|
+
return getLocalGraphql(updateTemplateQuery, {
|
|
68
|
+
id,
|
|
69
|
+
data: {
|
|
70
|
+
name
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const deleteTemplateService = (id: number) => {
|
|
76
|
+
const deleteTemplateQuery = `mutation ($id: Int) { templateDelete(id: $id) }`
|
|
77
|
+
|
|
78
|
+
return getLocalGraphql(deleteTemplateQuery, {
|
|
79
|
+
id
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const batchAddTemplateService = (datas: any) => {
|
|
84
|
+
const batchAddTemplateQuery = `mutation ($datas: [TemplateAddInput]) { templateBatchAdd(datas: $datas) }`
|
|
85
|
+
|
|
86
|
+
return getLocalGraphql(batchAddTemplateQuery, {
|
|
87
|
+
datas
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const batchDeleteTemplateService = (ids: any) => {
|
|
92
|
+
const batchDeleteTemplateQuery = `mutation ($ids: [Int]) { templateBatchDelete(ids: $ids) }`
|
|
93
|
+
|
|
94
|
+
return getLocalGraphql(batchDeleteTemplateQuery, {
|
|
95
|
+
ids
|
|
96
|
+
})
|
|
97
97
|
}
|
package/client/styled/common.ts
CHANGED
|
@@ -1,27 +1,60 @@
|
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 LoginContainer = styled.div`
|
|
21
|
+
margin: auto;
|
|
22
|
+
margin-top: 200px;
|
|
23
|
+
width: 250px;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
border: 1px solid gray;
|
|
29
|
+
border-radius: 5px;
|
|
30
|
+
padding: 20px;
|
|
31
|
+
|
|
32
|
+
.row {
|
|
33
|
+
width: 100%;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex: 1;
|
|
36
|
+
flex-direction: row;
|
|
37
|
+
justify-content: flex-start;
|
|
38
|
+
align-items: center;
|
|
39
|
+
|
|
40
|
+
.user-input {
|
|
41
|
+
width: 210px;
|
|
42
|
+
margin-bottom: 5px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.right {
|
|
47
|
+
margin-top: 10px;
|
|
48
|
+
justify-content: flex-end;
|
|
49
|
+
}
|
|
50
|
+
`
|
|
51
|
+
|
|
52
|
+
export const Loading = styled.div`
|
|
53
|
+
display: flex;
|
|
54
|
+
flex: 1;
|
|
55
|
+
flex-direction: row;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
align-items: center;
|
|
58
|
+
margin-top: 100px;
|
|
59
|
+
`
|
|
60
|
+
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
|
|
3
|
-
export const Container = styled.div`
|
|
4
|
-
.header {
|
|
5
|
-
position: relative;
|
|
6
|
-
|
|
7
|
-
.logo {
|
|
8
|
-
float: left;
|
|
9
|
-
width: 120px;
|
|
10
|
-
height: 31px;
|
|
11
|
-
// margin: 16px 24px 16px 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.site-layout-background {
|
|
15
|
-
background: #fff;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.user {
|
|
19
|
-
position: absolute;
|
|
20
|
-
right: 10px;
|
|
21
|
-
top: 0;
|
|
22
|
-
color: white;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
.header {
|
|
5
|
+
position: relative;
|
|
6
|
+
|
|
7
|
+
.logo {
|
|
8
|
+
float: left;
|
|
9
|
+
width: 120px;
|
|
10
|
+
height: 31px;
|
|
11
|
+
// margin: 16px 24px 16px 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.site-layout-background {
|
|
15
|
+
background: #fff;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.user {
|
|
19
|
+
position: absolute;
|
|
20
|
+
right: 10px;
|
|
21
|
+
top: 0;
|
|
22
|
+
color: white;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
26
|
`
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
|
|
3
|
-
export const Container = styled.div`
|
|
4
|
-
margin: 20px;
|
|
5
|
-
`
|
|
6
|
-
|
|
7
|
-
export const SearchRow = styled.div`
|
|
8
|
-
margin: 10px;
|
|
9
|
-
display: flex;
|
|
10
|
-
flex: 1;
|
|
11
|
-
flex-direction: row;
|
|
12
|
-
justify-content: space-between;
|
|
13
|
-
align-items: center;
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
export const ModalContainer = styled.div`
|
|
17
|
-
.line {
|
|
18
|
-
display: flex;
|
|
19
|
-
flex: 1;
|
|
20
|
-
flex-direction: row;
|
|
21
|
-
justify-content: flex-start;
|
|
22
|
-
align-items: flex-start;
|
|
23
|
-
height: 50px;
|
|
24
|
-
|
|
25
|
-
label {
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
justify-content: center;
|
|
29
|
-
align-items: flex-start;
|
|
30
|
-
width: 80px;
|
|
31
|
-
height: 32px;
|
|
32
|
-
margin-right: 5px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
input {
|
|
36
|
-
flex: 1;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.row {
|
|
40
|
-
display: flex;
|
|
41
|
-
flex-direction: row;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
align-items: center;
|
|
44
|
-
|
|
45
|
-
.item {
|
|
46
|
-
flex-direction: row;
|
|
47
|
-
justify-content: flex-start;
|
|
48
|
-
align-items: center;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
export const Container = styled.div`
|
|
4
|
+
margin: 20px;
|
|
5
|
+
`
|
|
6
|
+
|
|
7
|
+
export const SearchRow = styled.div`
|
|
8
|
+
margin: 10px;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex: 1;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
justify-content: space-between;
|
|
13
|
+
align-items: center;
|
|
14
|
+
`
|
|
15
|
+
|
|
16
|
+
export const ModalContainer = styled.div`
|
|
17
|
+
.line {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex: 1;
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
justify-content: flex-start;
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
height: 50px;
|
|
24
|
+
|
|
25
|
+
label {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
align-items: flex-start;
|
|
30
|
+
width: 80px;
|
|
31
|
+
height: 32px;
|
|
32
|
+
margin-right: 5px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input {
|
|
36
|
+
flex: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.row {
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: row;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
align-items: center;
|
|
44
|
+
|
|
45
|
+
.item {
|
|
46
|
+
flex-direction: row;
|
|
47
|
+
justify-content: flex-start;
|
|
48
|
+
align-items: center;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
52
|
`
|
package/client/utils/common.ts
CHANGED
|
@@ -1,86 +1,89 @@
|
|
|
1
|
-
import getConfig from 'next/config'
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
|
|
4
|
-
export const getLocalEnv = () => {
|
|
5
|
-
const nextConfig = getConfig()
|
|
6
|
-
const { publicRuntimeConfig } = nextConfig
|
|
7
|
-
let { env = 'uat' } = publicRuntimeConfig
|
|
8
|
-
env = env.toLowerCase()
|
|
9
|
-
return env
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const getLocalApiPrefix = () => {
|
|
13
|
-
const nextConfig = getConfig()
|
|
14
|
-
const { publicRuntimeConfig } = nextConfig
|
|
15
|
-
let { protocol, host, port, prefix, isExport } = publicRuntimeConfig
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
1
|
+
import getConfig from 'next/config'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
|
|
4
|
+
export const getLocalEnv = () => {
|
|
5
|
+
const nextConfig = getConfig()
|
|
6
|
+
const { publicRuntimeConfig } = nextConfig
|
|
7
|
+
let { env = 'uat' } = publicRuntimeConfig
|
|
8
|
+
env = env.toLowerCase()
|
|
9
|
+
return env
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getLocalApiPrefix = () => {
|
|
13
|
+
const nextConfig = getConfig()
|
|
14
|
+
const { publicRuntimeConfig } = nextConfig
|
|
15
|
+
let { protocol, host, port, prefix, isExport } = publicRuntimeConfig
|
|
16
|
+
|
|
17
|
+
let localApiPrefix = ''
|
|
18
|
+
|
|
19
|
+
if(!isExport){
|
|
20
|
+
if (typeof window !== 'undefined') {
|
|
21
|
+
const location = window.location
|
|
22
|
+
// console.log('location', location)
|
|
23
|
+
|
|
24
|
+
protocol = location.protocol
|
|
25
|
+
if (protocol.indexOf(':') != -1) {
|
|
26
|
+
protocol = protocol.split(':')[0]
|
|
27
|
+
}
|
|
28
|
+
host = location.hostname
|
|
29
|
+
port = location.port || (protocol.indexOf('https') !== -1 ? "443" : "80")
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
localApiPrefix = protocol + '://' + host + ':' + port + prefix
|
|
34
|
+
// console.log('localApiPrefix', localApiPrefix)
|
|
35
|
+
return localApiPrefix
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const handleXSS = (content: string) => {
|
|
39
|
+
content = content || ''
|
|
40
|
+
return content.replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/\'/g, ''')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
|
|
44
|
+
let result: any = null
|
|
45
|
+
_.each(modalObj, (value: any, key: string) => {
|
|
46
|
+
// console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
|
|
47
|
+
if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
|
|
48
|
+
if (_.trim(value) === '') {
|
|
49
|
+
result = {
|
|
50
|
+
key,
|
|
51
|
+
reason: '不能为空'
|
|
52
|
+
}
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
return result
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const getUrlParamByKey = (key: string) => {
|
|
61
|
+
let result = ''
|
|
62
|
+
if (typeof window !== 'undefined') {
|
|
63
|
+
const locationHref = window.location.href
|
|
64
|
+
if (locationHref.indexOf('?') !== -1) {
|
|
65
|
+
const locationHrefArr = locationHref.split('?')
|
|
66
|
+
if (locationHrefArr.length > 1) {
|
|
67
|
+
const paramsStr = locationHrefArr[1]
|
|
68
|
+
|
|
69
|
+
let params:any = []
|
|
70
|
+
if (paramsStr.indexOf('&') !== -1) {
|
|
71
|
+
params = paramsStr.split('&')
|
|
72
|
+
} else {
|
|
73
|
+
params.push(paramsStr)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_.each(params, (item, index) => {
|
|
77
|
+
if (item.indexOf('=') !== -1) {
|
|
78
|
+
const itemArr = item.split('=')
|
|
79
|
+
if (itemArr[0] === key) {
|
|
80
|
+
result = itemArr[1]
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result
|
|
89
|
+
}
|