kn-cli 1.0.55 → 1.0.57

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 (215) hide show
  1. package/package.json +3 -1
  2. package/readme.md +4 -1
  3. package/templates/template_oa/.DS_Store +0 -0
  4. package/templates/template_oa/build.sh +2 -0
  5. package/templates/template_oa/cli.config.js +24 -0
  6. package/templates/template_oa/dev.sh +89 -0
  7. package/templates/template_oa/frontend_build.sh +83 -0
  8. package/templates/template_oa/init/prepare-commit-msg +5 -0
  9. package/templates/template_oa/init.sh +33 -0
  10. package/templates/template_oa/jsconfig.json +10 -0
  11. package/templates/template_oa/package-lock.json +1925 -0
  12. package/templates/template_oa/package.json +24 -0
  13. package/templates/template_oa/public/.DS_Store +0 -0
  14. package/templates/template_oa/public/404.html +26 -0
  15. package/templates/template_oa/public/favicon.ico +0 -0
  16. package/templates/template_oa/public/favicon.png +0 -0
  17. package/templates/template_oa/public/index.html +43 -0
  18. package/templates/template_oa/public/pluginjs/.DS_Store +0 -0
  19. package/templates/template_oa/public/src/.DS_Store +0 -0
  20. package/templates/template_oa/public/src/_antd.less +237 -0
  21. package/templates/template_oa/public/src/_reset.less +131 -0
  22. package/templates/template_oa/public/src/_variable.less +84 -0
  23. package/templates/template_oa/public/src/assets/.DS_Store +0 -0
  24. package/templates/template_oa/public/src/assets/iconfont/.DS_Store +0 -0
  25. package/templates/template_oa/public/src/assets/iconfont/iconfont.eot +0 -0
  26. package/templates/template_oa/public/src/assets/iconfont/iconfont.less +57 -0
  27. package/templates/template_oa/public/src/assets/iconfont/iconfont.svg +36 -0
  28. package/templates/template_oa/public/src/assets/iconfont/iconfont.ttf +0 -0
  29. package/templates/template_oa/public/src/assets/iconfont/iconfont.woff +0 -0
  30. package/templates/template_oa/public/src/assets/iconfont/iconfont.woff2 +0 -0
  31. package/templates/template_oa/public/src/assets/images/.DS_Store +0 -0
  32. package/templates/template_oa/public/src/assets/images/avatar.png +0 -0
  33. package/templates/template_oa/public/src/assets/images/loading.svg +40 -0
  34. package/templates/template_oa/public/src/components/.DS_Store +0 -0
  35. package/templates/template_oa/public/src/components/Alert/index.jsx +0 -0
  36. package/templates/template_oa/public/src/components/Alert/index.less +0 -0
  37. package/templates/template_oa/public/src/components/Auth/index.jsx +44 -0
  38. package/templates/template_oa/public/src/components/Footer/index.jsx +17 -0
  39. package/templates/template_oa/public/src/components/Footer/index.less +28 -0
  40. package/templates/template_oa/public/src/components/IFrame/index.jsx +37 -0
  41. package/templates/template_oa/public/src/components/IFrame/index.less +4 -0
  42. package/templates/template_oa/public/src/components/IconFont/index.jsx +10 -0
  43. package/templates/template_oa/public/src/components/IconFont/index.less +5 -0
  44. package/templates/template_oa/public/src/components/Layout/.DS_Store +0 -0
  45. package/templates/template_oa/public/src/components/Layout/Basic/index.jsx +31 -0
  46. package/templates/template_oa/public/src/components/Layout/Basic/index.less +74 -0
  47. package/templates/template_oa/public/src/components/Layout/CenterBody/index.jsx +15 -0
  48. package/templates/template_oa/public/src/components/Layout/CenterBody/index.less +36 -0
  49. package/templates/template_oa/public/src/components/Layout/FormBlock/index.jsx +23 -0
  50. package/templates/template_oa/public/src/components/Layout/FormBlock/index.less +34 -0
  51. package/templates/template_oa/public/src/components/Layout/Provider/index.jsx +12 -0
  52. package/templates/template_oa/public/src/components/Layout/index.jsx +26 -0
  53. package/templates/template_oa/public/src/components/Layout/index.less +8 -0
  54. package/templates/template_oa/public/src/components/Link/index.jsx +24 -0
  55. package/templates/template_oa/public/src/components/Link/index.less +11 -0
  56. package/templates/template_oa/public/src/components/Loading/index.jsx +14 -0
  57. package/templates/template_oa/public/src/components/Loading/index.less +85 -0
  58. package/templates/template_oa/public/src/components/Nav/index.jsx +121 -0
  59. package/templates/template_oa/public/src/components/Nav/index.less +38 -0
  60. package/templates/template_oa/public/src/components/Page/.DS_Store +0 -0
  61. package/templates/template_oa/public/src/components/Page/PageLoading/index.jsx +30 -0
  62. package/templates/template_oa/public/src/components/Page/PageLoading/index.less +29 -0
  63. package/templates/template_oa/public/src/components/Popup/index.jsx +22 -0
  64. package/templates/template_oa/public/src/components/Popup/index.less +18 -0
  65. package/templates/template_oa/public/src/components/Toast/index.jsx +60 -0
  66. package/templates/template_oa/public/src/components/Toast/index.less +43 -0
  67. package/templates/template_oa/public/src/components/mask/index.jsx +47 -0
  68. package/templates/template_oa/public/src/components/mask/index.less +32 -0
  69. package/templates/template_oa/public/src/dictionary/index.js +39 -0
  70. package/templates/template_oa/public/src/hooks/.DS_Store +0 -0
  71. package/templates/template_oa/public/src/hooks/index.jsx +20 -0
  72. package/templates/template_oa/public/src/hooks/useDelay.jsx +29 -0
  73. package/templates/template_oa/public/src/hooks/useImageLoader.jsx +27 -0
  74. package/templates/template_oa/public/src/hooks/useLoading.jsx +42 -0
  75. package/templates/template_oa/public/src/hooks/useLogin.jsx +33 -0
  76. package/templates/template_oa/public/src/hooks/usePreload.jsx +66 -0
  77. package/templates/template_oa/public/src/hooks/useScrollTop.jsx +32 -0
  78. package/templates/template_oa/public/src/hooks/useSearch.jsx +137 -0
  79. package/templates/template_oa/public/src/hooks/useUpdate.jsx +11 -0
  80. package/templates/template_oa/public/src/index.jsx +50 -0
  81. package/templates/template_oa/public/src/mock/auth.js +91 -0
  82. package/templates/template_oa/public/src/mock/index.js +63 -0
  83. package/templates/template_oa/public/src/mock/user.js +70 -0
  84. package/templates/template_oa/public/src/mock/utils.js +33 -0
  85. package/templates/template_oa/public/src/pages/.DS_Store +0 -0
  86. package/templates/template_oa/public/src/pages/components/pageTitle/index.jsx +13 -0
  87. package/templates/template_oa/public/src/pages/components/pageTitle/index.less +20 -0
  88. package/templates/template_oa/public/src/pages/login/index.jsx +27 -0
  89. package/templates/template_oa/public/src/pages/login/index.less +44 -0
  90. package/templates/template_oa/public/src/pages/video/index.jsx +91 -0
  91. package/templates/template_oa/public/src/pages/video/index.less +12 -0
  92. package/templates/template_oa/public/src/provider/app.jsx +119 -0
  93. package/templates/template_oa/public/src/provider/menu.jsx +20 -0
  94. package/templates/template_oa/public/src/route.jsx +43 -0
  95. package/templates/template_oa/public/src/services/.DS_Store +0 -0
  96. package/templates/template_oa/public/src/services/auth.js +121 -0
  97. package/templates/template_oa/public/src/services/index.js +181 -0
  98. package/templates/template_oa/public/src/services/user.js +26 -0
  99. package/templates/template_oa/public/src/services/video.js +33 -0
  100. package/templates/template_oa/public/src/utils/.DS_Store +0 -0
  101. package/templates/template_oa/public/src/utils/index.js +66 -0
  102. package/templates/template_oa/public/static/.DS_Store +0 -0
  103. package/templates/template_oa/public/static/about.html +1 -0
  104. package/templates/template_oa/public/static/kssoLogin.html +22 -0
  105. package/templates/template_oa/readme.md +60 -0
  106. package/templates/template_oa/release/.DS_Store +0 -0
  107. package/templates/template_oa/report.sh +68 -0
  108. package/templates/template_oa/tools/.DS_Store +0 -0
  109. package/templates/template_oa/tools/iconfont/.DS_Store +0 -0
  110. package/templates/template_oa/tools/iconfont/dist/.DS_Store +0 -0
  111. package/templates/template_oa/tools/iconfont/gulpfile.js +70 -0
  112. package/templates/template_oa/tools/iconfont/package.json +20 -0
  113. package/templates/template_oa/tools/iconfont/run.sh +39 -0
  114. package/templates/template_oa/tools/iconfont/svg/.DS_Store +0 -0
  115. package/templates/template_oa/tools/iconfont/svg/arrowBack.svg +1 -0
  116. package/templates/template_oa/tools/iconfont/svg/check.svg +1 -0
  117. package/templates/template_oa/tools/iconfont/svg/close.svg +1 -0
  118. package/templates/template_oa/tools/iconfont/svg/down.svg +1 -0
  119. package/templates/template_oa/tools/iconfont/svg/image.svg +1 -0
  120. package/templates/template_oa/tools/iconfont/svg/play.svg +1 -0
  121. package/templates/template_oa/tools/iconfont/svg/refresh.svg +1 -0
  122. package/templates/template_oa/tools/iconfont/svg/warn.svg +1 -0
  123. package/templates/template_oa/tools/iconfont/templates/_icons.css +26 -0
  124. package/templates/template_oa/tools/iconfont/templates/_icons.less +29 -0
  125. package/templates/template_oa/tools/iconfont/templates/index.html +56 -0
  126. package/templates/template_oa/tools/tinypng/.DS_Store +0 -0
  127. package/templates/template_oa/tools/tinypng/img/.DS_Store +0 -0
  128. package/templates/template_oa/tools/tinypng/package.json +11 -0
  129. package/templates/template_oa/tools/tinypng/run.sh +15 -0
  130. package/templates/template_oa/versionPublish.sh +27 -0
  131. package/templates/template_oa/webpack.api.js +62 -0
  132. package/templates/template_offcial/.gitignore +6 -0
  133. package/templates/template_offcial/build.sh +2 -0
  134. package/templates/template_offcial/cli.config.js +25 -0
  135. package/templates/template_offcial/dev.sh +89 -0
  136. package/templates/template_offcial/frontend_build.sh +83 -0
  137. package/templates/template_offcial/init/prepare-commit-msg +5 -0
  138. package/templates/template_offcial/init.sh +33 -0
  139. package/templates/template_offcial/jsconfig.json +10 -0
  140. package/templates/template_offcial/package.json +23 -0
  141. package/templates/template_offcial/public/404.html +26 -0
  142. package/templates/template_offcial/public/favicon.ico +0 -0
  143. package/templates/template_offcial/public/favicon.png +0 -0
  144. package/templates/template_offcial/public/index.html +52 -0
  145. package/templates/template_offcial/public/src/_antd.less +4 -0
  146. package/templates/template_offcial/public/src/_reset.less +130 -0
  147. package/templates/template_offcial/public/src/_variable.less +78 -0
  148. package/templates/template_offcial/public/src/assets/iconfont/iconfont.eot +0 -0
  149. package/templates/template_offcial/public/src/assets/iconfont/iconfont.less +57 -0
  150. package/templates/template_offcial/public/src/assets/iconfont/iconfont.svg +36 -0
  151. package/templates/template_offcial/public/src/assets/iconfont/iconfont.ttf +0 -0
  152. package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff +0 -0
  153. package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff2 +0 -0
  154. package/templates/template_offcial/public/src/assets/images/avatar.png +0 -0
  155. package/templates/template_offcial/public/src/assets/images/loading.svg +40 -0
  156. package/templates/template_offcial/public/src/components/Alert/index.jsx +0 -0
  157. package/templates/template_offcial/public/src/components/Alert/index.less +0 -0
  158. package/templates/template_offcial/public/src/components/Footer/index.jsx +32 -0
  159. package/templates/template_offcial/public/src/components/Footer/index.less +8 -0
  160. package/templates/template_offcial/public/src/components/Header/index.jsx +68 -0
  161. package/templates/template_offcial/public/src/components/Header/index.less +76 -0
  162. package/templates/template_offcial/public/src/components/IconFont/index.jsx +10 -0
  163. package/templates/template_offcial/public/src/components/IconFont/index.less +5 -0
  164. package/templates/template_offcial/public/src/components/Layout/Provider/index.jsx +12 -0
  165. package/templates/template_offcial/public/src/components/Layout/index.jsx +20 -0
  166. package/templates/template_offcial/public/src/components/Layout/index.less +20 -0
  167. package/templates/template_offcial/public/src/components/Link/index.jsx +24 -0
  168. package/templates/template_offcial/public/src/components/Link/index.less +11 -0
  169. package/templates/template_offcial/public/src/components/Page/PageLoading/index.jsx +30 -0
  170. package/templates/template_offcial/public/src/components/Page/PageLoading/index.less +29 -0
  171. package/templates/template_offcial/public/src/components/Popup/index.jsx +22 -0
  172. package/templates/template_offcial/public/src/components/Popup/index.less +18 -0
  173. package/templates/template_offcial/public/src/components/Toast/index.jsx +60 -0
  174. package/templates/template_offcial/public/src/components/Toast/index.less +43 -0
  175. package/templates/template_offcial/public/src/hooks/index.jsx +12 -0
  176. package/templates/template_offcial/public/src/hooks/useImageLoader.jsx +27 -0
  177. package/templates/template_offcial/public/src/hooks/useInToView.jsx +55 -0
  178. package/templates/template_offcial/public/src/hooks/usePreload.jsx +66 -0
  179. package/templates/template_offcial/public/src/hooks/useScroll.jsx +66 -0
  180. package/templates/template_offcial/public/src/index.jsx +50 -0
  181. package/templates/template_offcial/public/src/mock/index.js +63 -0
  182. package/templates/template_offcial/public/src/mock/user.js +70 -0
  183. package/templates/template_offcial/public/src/mock/utils.js +33 -0
  184. package/templates/template_offcial/public/src/pages/index.jsx +23 -0
  185. package/templates/template_offcial/public/src/pages/index.less +0 -0
  186. package/templates/template_offcial/public/src/pages/mobile/index.jsx +11 -0
  187. package/templates/template_offcial/public/src/pages/mobile/index.less +0 -0
  188. package/templates/template_offcial/public/src/pages/pc/index.jsx +45 -0
  189. package/templates/template_offcial/public/src/pages/pc/index.less +42 -0
  190. package/templates/template_offcial/public/src/provider/app.jsx +26 -0
  191. package/templates/template_offcial/public/src/route.jsx +26 -0
  192. package/templates/template_offcial/public/src/services/index.js +182 -0
  193. package/templates/template_offcial/public/src/services/user.js +26 -0
  194. package/templates/template_offcial/public/src/utils/index.js +109 -0
  195. package/templates/template_offcial/public/static/about.html +1 -0
  196. package/templates/template_offcial/readme.md +59 -0
  197. package/templates/template_offcial/report.sh +68 -0
  198. package/templates/template_offcial/tools/iconfont/gulpfile.js +70 -0
  199. package/templates/template_offcial/tools/iconfont/package.json +20 -0
  200. package/templates/template_offcial/tools/iconfont/run.sh +39 -0
  201. package/templates/template_offcial/tools/iconfont/svg/arrowBack.svg +1 -0
  202. package/templates/template_offcial/tools/iconfont/svg/check.svg +1 -0
  203. package/templates/template_offcial/tools/iconfont/svg/close.svg +1 -0
  204. package/templates/template_offcial/tools/iconfont/svg/down.svg +1 -0
  205. package/templates/template_offcial/tools/iconfont/svg/image.svg +1 -0
  206. package/templates/template_offcial/tools/iconfont/svg/play.svg +1 -0
  207. package/templates/template_offcial/tools/iconfont/svg/refresh.svg +1 -0
  208. package/templates/template_offcial/tools/iconfont/svg/warn.svg +1 -0
  209. package/templates/template_offcial/tools/iconfont/templates/_icons.css +26 -0
  210. package/templates/template_offcial/tools/iconfont/templates/_icons.less +29 -0
  211. package/templates/template_offcial/tools/iconfont/templates/index.html +56 -0
  212. package/templates/template_offcial/tools/tinypng/package.json +11 -0
  213. package/templates/template_offcial/tools/tinypng/run.sh +15 -0
  214. package/templates/template_offcial/versionPublish.sh +27 -0
  215. package/templates/template_offcial/webpack.api.js +36 -0
@@ -0,0 +1,91 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ import {usePagination} from '@/hooks';
3
+ import {GET_LIST} from '@/services/video';
4
+ import { Table, Input, Button, Form,DatePicker,Pagination } from 'antd';
5
+ import {FormBlockByTitle} from '@/components/Layout/FormBlock';
6
+ import styles from './index.less';
7
+ import PageTitle from '@/pages/components/pageTitle';
8
+
9
+ const Page = () => {
10
+ const [form] = Form.useForm();
11
+ const request = usePagination({
12
+ service:GET_LIST,
13
+ pagination:{pageSize:10}
14
+ })
15
+
16
+ useEffect(()=>{
17
+ request.update();
18
+ },[])
19
+
20
+ const columns=[{
21
+ dataIndex:'id',
22
+ title:'id',
23
+ render:(_,record,idx)=>{
24
+ return record.id;
25
+ }
26
+ },{
27
+ dataIndex:'value',
28
+ title:'数据值',
29
+ render:(_,record,idx)=>{
30
+ return record.value||'-'
31
+ }
32
+ }];
33
+
34
+ useEffect(()=>{
35
+ console.log(request)
36
+ },[request])
37
+
38
+ const getDataSource=()=>{
39
+ if(request?.data?.length>0){
40
+ let req=request?.data[request.pagination.current-1]||[];
41
+ return req;
42
+ }
43
+ return [];
44
+ }
45
+
46
+ const onPageChange=(current,pageSize)=>{
47
+ request.update({pagination:{current,pageSize}})
48
+ }
49
+ const onSearch=()=>{
50
+ }
51
+ const onReset=()=>{}
52
+ return (
53
+ <section className={styles.wrap}>
54
+
55
+ <PageTitle>周边商品维护</PageTitle>
56
+ <FormBlockByTitle title=''>
57
+ <Form
58
+ form={form}
59
+ layout='inline'
60
+ colon={false}
61
+ >
62
+ <Form.Item name='search' labelAlign='left' label='关键字'>
63
+ <Input placeholder='产品编码/产品名称/产品型号/部门/单号' />
64
+ </Form.Item>
65
+
66
+ <Button style={{marginRight:'12px'}} type='primary' onClick={onSearch}>
67
+ 查询
68
+ </Button>
69
+ <Button onClick={onReset}>
70
+ 重置
71
+ </Button>
72
+ </Form>
73
+
74
+ <Table
75
+ className={styles.table}
76
+ rowKey='id'
77
+ columns={columns}
78
+ loading={!request?.data?.length>0}
79
+ dataSource={getDataSource()} pagination={false} />
80
+ <Pagination
81
+ current={request?.pagination?.current}
82
+ pageSize={request?.pagination?.pageSize}
83
+ onChange={onPageChange}
84
+ total={request?.pagination?.total}
85
+ />
86
+ </FormBlockByTitle>
87
+ </section>
88
+ )
89
+ }
90
+
91
+ export default Page;
@@ -0,0 +1,12 @@
1
+
2
+ .wrap{
3
+ width: 100%;
4
+ height: 100%;
5
+ overflow: auto;
6
+ padding:10px 24px 24px 24px;
7
+ background-color: white;
8
+ }
9
+
10
+ .table{
11
+ margin:12px 0;
12
+ }
@@ -0,0 +1,119 @@
1
+ import { useState,useMemo, useEffect } from 'react';
2
+ import { useSearchParams,useNavigate } from 'react-router-dom';
3
+
4
+ import { createContainer } from "unstated-next"
5
+ import {useDelay} from '@/hooks';
6
+ import {setJwt,setLogout} from '@/services';
7
+ import {KSSO_LOGIN,LOGIN,LOGOUT} from '@/services/auth';
8
+ import {jumpUrl} from '@/utils';
9
+
10
+ const useApp=() =>{
11
+ const [search] = useSearchParams();
12
+ const navigate= useNavigate();
13
+ const [loading,setLoading] = useState(true);
14
+ const [nav,setNavConfig] = useState({visible:true,syncDocumentTitle:false});
15
+ const [user,setUser] = useState(null);
16
+
17
+ const delay = useDelay();
18
+
19
+ const isLogin=async ()=>{
20
+ await delay.wait(10);
21
+ if(!user){
22
+ try{
23
+ let userData = localStorage.getItem('user');
24
+ if(userData){
25
+ userData= JSON.parse(userData);
26
+ if(userData){
27
+ setUser(userData);
28
+ setJwt(userData.token);
29
+ return true;
30
+ }
31
+ }
32
+ }catch(ex){
33
+ return false;
34
+ }
35
+ }else{
36
+ return true;
37
+ }
38
+ }
39
+
40
+ const kssoLogin=async ()=>{
41
+ let code = search.get('code');
42
+ if(code){
43
+ var redirectUri = location.protocol + '//' + location.host + '/#/login';
44
+ //ksso auth登录
45
+ const req = await KSSO_LOGIN({code,redirectUri})
46
+ if(req?.code==0){
47
+ const userData = req?.data;
48
+ setUser(userData);
49
+ setJwt(userData.token);
50
+ localStorage.setItem('user',JSON.stringify(userData));
51
+
52
+ let redirect = search.get('redirect');
53
+ if(redirect){
54
+ jumpUrl(redirect,{replace:true});
55
+ return true;
56
+ }
57
+ navigate('/');
58
+ }else{
59
+ return false;
60
+ }
61
+ }else{
62
+ jumpUrl(`${location.protocol}//${location.host}/static/kssoLogin.html`,{replace:true})
63
+ }
64
+ return true;
65
+ }
66
+ const login=async (username,password)=>{
67
+ const req = await LOGIN({username,password});
68
+ if(req?.code==0){
69
+ const userData = req?.data;
70
+ setUser(userData);
71
+ setJwt(userData.token);
72
+ localStorage.setItem('user',JSON.stringify(userData));
73
+
74
+ let redirect = search.get('redirect');
75
+ if(redirect){
76
+ jumpUrl(redirect,{replace:true});
77
+ return true;
78
+ }
79
+ navigate('/');
80
+ }else{
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ const logout=async ()=>{
86
+ LOGOUT();
87
+ setUser(null);
88
+ setJwt('');
89
+ localStorage.removeItem('user');
90
+ navigate('/superAdminLogin');
91
+ }
92
+ setLogout(logout);
93
+
94
+
95
+
96
+ const setNav=(config)=>{
97
+ setNavConfig({...nav,...config});
98
+ }
99
+ const action=useMemo(()=>{
100
+ return {
101
+ loading,
102
+ setLoading,
103
+ isLogin,
104
+ login,
105
+ nav,
106
+ setNav,
107
+ logout,
108
+ setUser,
109
+ user,
110
+ kssoLogin
111
+ }
112
+ },[loading,nav,setNav,user,setUser,isLogin,kssoLogin,login]);
113
+
114
+ return action
115
+ }
116
+
117
+ const App = createContainer(useApp);
118
+
119
+ export default App;
@@ -0,0 +1,20 @@
1
+ import { useState,useMemo } from 'react';
2
+ import { createContainer } from "unstated-next"
3
+ import {GET_MENU} from '@/services/auth';
4
+
5
+ const useProvider=() =>{
6
+ const [menus,setMenus]= useState([]);
7
+
8
+ const reload= async ()=>{
9
+ await GET_MENU();
10
+ }
11
+ const action=useMemo(()=>{
12
+ return {
13
+ menus,setMenus
14
+ }
15
+ },[menus,setMenus]);
16
+ return action
17
+ }
18
+ const App = createContainer(useProvider);
19
+
20
+ export default App;
@@ -0,0 +1,43 @@
1
+ import React,{Suspense} from 'react';
2
+ import { Routes, Route, Navigate } from 'react-router-dom';
3
+
4
+ import { LayoutBasic, Layout } from '@/components/Layout';
5
+ import PageLoading from '@/components/Page/PageLoading';
6
+
7
+ import Nav from '@/components/Nav';
8
+ import Login from '@/pages/login';
9
+ // import {AuthLogin} from '@/components/Auth';
10
+
11
+
12
+ const delayLoader=(loader)=>{
13
+ return new Promise(resolve=>{
14
+ loader.then(req=>{
15
+ setTimeout(()=>{
16
+ resolve(req);
17
+ },5000)
18
+ })
19
+ })
20
+ }
21
+
22
+
23
+ const Video = React.lazy(()=>import('@/pages/video'));
24
+
25
+ export const RouteList = (
26
+ <Routes>
27
+ <Route path='/' element={<Suspense fallback={<PageLoading />}><Layout /></Suspense>}>
28
+ <Route path='login' element={<Login />} />
29
+
30
+ <Route
31
+ path='/'
32
+ element={
33
+ <LayoutBasic nav={<Nav />} />
34
+ }
35
+ >
36
+ <Route path='/' element={<Navigate to="/video"></Navigate> } />
37
+ <Route path='/video' element={<Video />} />
38
+
39
+ </Route>
40
+ </Route>
41
+ </Routes>
42
+ );
43
+
@@ -0,0 +1,121 @@
1
+ import {GET_DEFAULT,API_ROOT,POST_DEFAULT,GET_DEFAULT_CROSS} from './index.js';
2
+
3
+
4
+
5
+ let GET_LEFT_MENU_BUFF = null;
6
+ /**
7
+ * 左侧导航栏菜单
8
+ */
9
+ export async function GET_LEFT_MENU(force) {
10
+ if (!force && GET_LEFT_MENU_BUFF) return GET_LEFT_MENU_BUFF;
11
+ GET_LEFT_MENU_BUFF = await GET_DEFAULT_CROSS(`${API_HOST}/derivative_product/sidebar`);
12
+
13
+ // GET_LEFT_MENU_BUFF = {
14
+ // code: 1,
15
+ // info: [
16
+ // {
17
+ // id: 1,
18
+ // menu_name: '出库记录表',
19
+ // menu_code: 'deliveryRecord',
20
+ // icon: 'product',
21
+ // pid: 0,
22
+ // priv_id: null,
23
+ // link_path: '/#/deliveryRecord',
24
+ // status: 1,
25
+ // level: 1,
26
+ // order: 1,
27
+ // priv_func: null,
28
+ // link: 'http://dp.test.com/#/deliveryRecord',
29
+ // children: [],
30
+ // },
31
+ // {
32
+ // id: 2,
33
+ // menu_name: '库存汇总表',
34
+ // menu_code: 'store',
35
+ // icon: 'report',
36
+ // pid: 0,
37
+ // priv_id: null,
38
+ // link_path: '/#/store',
39
+ // status: 1,
40
+ // level: 1,
41
+ // order: 2,
42
+ // priv_func: null,
43
+ // link: 'http://dp.test.com/#/store',
44
+ // children: [],
45
+ // },
46
+ // {
47
+ // id: 4,
48
+ // menu_name: '系统管理',
49
+ // menu_code: 'system_manage',
50
+ // icon: 'system',
51
+ // pid: 0,
52
+ // priv_id: 7,
53
+ // link_path: '/',
54
+ // status: 1,
55
+ // level: 1,
56
+ // order: 7,
57
+ // priv_func: null,
58
+ // link: 'http://dp.test.com/',
59
+ // children: [
60
+ // {
61
+ // id: 5,
62
+ // menu_name: '周边商品维护',
63
+ // menu_code: 'product_config',
64
+ // icon: null,
65
+ // pid: 4,
66
+ // priv_id: 7,
67
+ // link_path: '/#/config/product',
68
+ // status: 1,
69
+ // level: 2,
70
+ // order: 8,
71
+ // priv_func: null,
72
+ // link: 'http://dp.test.com/#/config/product',
73
+ // children: [],
74
+ // },
75
+ // {
76
+ // id: 6,
77
+ // menu_name: '权限配置',
78
+ // menu_code: 'auth',
79
+ // icon: null,
80
+ // pid: 4,
81
+ // priv_id: 7,
82
+ // link_path: '/#/config/auth',
83
+ // status: 1,
84
+ // level: 2,
85
+ // order: 9,
86
+ // priv_func: null,
87
+ // link: 'http://dp.test.com/#/config/auth',
88
+ // children: [],
89
+ // },
90
+ // ],
91
+ // },
92
+ // ],
93
+ // };
94
+ return GET_LEFT_MENU_BUFF;
95
+ }
96
+
97
+
98
+ export function GET_MENU(){
99
+ return GET_DEFAULT(`${API_ROOT}/api/menu/nav`);
100
+ }
101
+
102
+
103
+
104
+ export function KSSO_LOGIN(params={
105
+ code:'',
106
+ redirectUri:'',
107
+ }){
108
+ return POST_DEFAULT(`${API_ROOT}/api/ksso/auth`,params)
109
+
110
+ }
111
+
112
+ export function LOGIN(params={
113
+ username:'',
114
+ password:'',
115
+ }){
116
+ return POST_DEFAULT(`${API_ROOT}/api/login`,params)
117
+
118
+ }
119
+ export function LOGOUT(){
120
+ return POST_DEFAULT(`${API_ROOT}/api/logout`)
121
+ }
@@ -0,0 +1,181 @@
1
+ import Axios from 'axios';
2
+ import qs from 'qs';
3
+ import { message } from 'antd';
4
+ const axios = Axios.create();
5
+ console.log(`========API_ROOT:${API_HOST}========`);
6
+
7
+ export const API_ROOT = API_HOST;
8
+ const tokenMode='header';//header,cookie
9
+ const tokenName='Authorization';
10
+
11
+ let Modal = {
12
+ error: (options) => {
13
+ message.error(options.content);
14
+ },
15
+ };
16
+
17
+ let jwt = '';
18
+ let logout = ()=>{}
19
+
20
+ export const setJwt = (value) => {
21
+ if(value==''){
22
+ localStorage.removeItem('jwt');
23
+ jwt='';
24
+ return;
25
+
26
+ }
27
+ localStorage.setItem('jwt', value);
28
+ jwt = value;
29
+ };
30
+
31
+ window.setJwt=setJwt;
32
+ export const setLogout=(fn)=>{
33
+ logout=fn;
34
+ }
35
+
36
+
37
+ axios.interceptors.request.use(function (config) {
38
+ const header = { 'X-Requested-With': 'XMLHttpRequest' };
39
+ if(tokenMode=='header'){
40
+ if (jwt) {
41
+ header[tokenName] = jwt;
42
+ }
43
+ }
44
+ if (config.headers) {
45
+ config.headers = { ...config.headers, ...header };
46
+ } else {
47
+ config.headers = header;
48
+ }
49
+
50
+ // 在发送请求之前做些什么
51
+ return config;
52
+ });
53
+
54
+ /**
55
+ * 统一拦截异常消息弹屏报错处理
56
+ * 如果希望某条消息不拦截,可以再发送消息时带上 noInterceptors:true|'all'
57
+ */
58
+ axios.interceptors.response.use(
59
+ function (response) {
60
+ // setJwt(response?.headers['set-token'] || jwt);
61
+ if (response.config.noInterceptors) {
62
+ return response;
63
+ }
64
+
65
+ if (Number(response.data.code) !== 0) {
66
+ console.log(`${JSON.stringify(response.data)}`);
67
+ Modal.error({ title: `注意`, content: `${response.data.message}(${response.data.code})` });
68
+ }
69
+ return response;
70
+ },
71
+ function (error) {
72
+ if (error.response.config.noInterceptors === 'all') {
73
+ return Promise.reject(error.response);
74
+ }
75
+ // jwt失效
76
+ if (error.response.status === 401) {
77
+ if(logout)logout();
78
+ return;
79
+ } else if (error.response.status === 403) {
80
+ Modal.error({
81
+ title: '提示',
82
+ content: `${error.response.data.message}`,
83
+ });
84
+ return;
85
+ }
86
+ Modal.error({
87
+ title: `网络错误${error.response.status}`,
88
+ content: `${error.response.config.url}`,
89
+ });
90
+ return null;
91
+ }
92
+ );
93
+
94
+
95
+
96
+
97
+ let buffer = {};
98
+ export async function GET_DEFAULT(url, param, options) {
99
+ if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
100
+ let now = Date.now();
101
+
102
+ let bufferItem;
103
+ if (options?.ttl) {
104
+ if (buffer[url]) {
105
+ bufferItem = buffer[url];
106
+ if (bufferItem.param == param && now <= bufferItem.endTime) {
107
+ return bufferItem?.response?.data || null;
108
+ }
109
+ }
110
+ }
111
+ let response = await axios({
112
+ method: 'GET',
113
+ url: param ? `${url}?${param}` : url,
114
+ ...options,
115
+ });
116
+
117
+ if (options?.ttl) {
118
+ if (!buffer[url]) {
119
+ buffer[url] = {};
120
+ }
121
+ buffer[url].param = param;
122
+ let ttl = options.ttl === true ? 1000 * 2 : options.ttl;
123
+ buffer[url].endTime = Date.now() + ttl;
124
+ buffer[url].response = response;
125
+ }
126
+
127
+ return response && response.data ? response.data : null;
128
+ }
129
+
130
+ export async function GET_DEFAULT_CROSS(url, param) {
131
+ if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
132
+
133
+ let response = await axios({
134
+ method: 'GET',
135
+ xsrfCookieName: '',
136
+ xsrfHeaderName: '',
137
+ withCredentials: true,
138
+ url: param ? `${url}?${param}` : url,
139
+ });
140
+ return response && response.data ? response.data : null;
141
+ }
142
+
143
+ export async function POST_DEFAULT(url, params, method, options) {
144
+ let data = params;
145
+ // if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
146
+ // if (typeof params === 'string') {
147
+ // data = params;
148
+ // } else {
149
+ // data = { ...params };
150
+ // }
151
+
152
+ let response = await axios({
153
+ method: method || 'POST',
154
+ url: url,
155
+ data,
156
+ ...options,
157
+ // headers: { 'content-type': 'application/x-www-form-urlencoded' },
158
+ });
159
+ return response && response.data ? response.data : null;
160
+ }
161
+
162
+ export async function POST_DEFAULT_CROSS(url, params) {
163
+ let data = {};
164
+ // if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
165
+
166
+ if (typeof params === 'string') {
167
+ data = params;
168
+ } else {
169
+ data = { ...params };
170
+ }
171
+ let response = await axios({
172
+ method: 'POST',
173
+ url: url,
174
+ xsrfCookieName: '',
175
+ xsrfHeaderName: '',
176
+ withCredentials: true,
177
+ data,
178
+ });
179
+
180
+ return response && response.data ? response.data : null;
181
+ }
@@ -0,0 +1,26 @@
1
+ import {GET_DEFAULT,PUT_DEFAULT,POST_DEFAULT,API_ROOT} from './index.js';
2
+
3
+
4
+
5
+ export function GET_USER(){
6
+ return GET_DEFAULT(`${HOST}/user`);
7
+ }
8
+
9
+ export function SET_USER(params={
10
+ name:'',
11
+ age:''
12
+ }){
13
+ return POST_DEFAULT(`${HOST}/user`,params)
14
+ }
15
+
16
+
17
+ export function GET_USER_LIST(params={
18
+ current:1,
19
+ pageSize:20
20
+ }){
21
+ return GET_DEFAULT(`${API_ROOT}/userList`,params)
22
+ }
23
+
24
+ export function GET_USER_TYPE(){
25
+ return GET_DEFAULT(`${API_ROOT}/userType`)
26
+ }
@@ -0,0 +1,33 @@
1
+
2
+
3
+ export function GET_LIST(params={
4
+ current:1,
5
+ pageSize:10,
6
+ keywords:''
7
+ }){
8
+ const {current,pageSize,keywords='-'}=params;
9
+ let list=[];
10
+ for(let i=0;i<200;i++){
11
+ list.push({
12
+ id:i,
13
+ value:`item-${i}-${keywords}`,
14
+ })
15
+ }
16
+ let total=200;
17
+ let startIdx = (current-1)*pageSize;
18
+ let data = list.splice(startIdx,pageSize);
19
+ let req= {
20
+ code:0,
21
+ data,
22
+ page:{
23
+ current,
24
+ pageSize,
25
+ total
26
+ }
27
+ };
28
+ return new Promise(resolve=>{
29
+ setTimeout(()=>{
30
+ resolve(req)
31
+ },500)
32
+ })
33
+ }