kn-cli 1.0.59 → 1.0.61
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/build/build.sh +1 -1
- package/build/dev.sh +1 -1
- package/package.json +1 -1
- package/readme.md +3 -0
- package/src/build.js +28 -9
- package/templates/template_admin/build.sh +7 -1
- package/templates/template_admin/frontend_build.sh +4 -0
- package/templates/template_admin/readme.md +8 -0
- package/templates/template_app/build.sh +7 -1
- package/templates/template_app/frontend_build.sh +4 -0
- package/templates/template_app/readme.md +8 -0
- package/templates/template_oa/build.sh +7 -1
- package/templates/template_oa/frontend_build.sh +4 -0
- package/templates/template_oa/package.json +2 -1
- package/templates/template_oa/public/favicon.ico +0 -0
- package/templates/template_oa/public/index.html +1 -1
- package/templates/template_oa/public/src/_antd.less +0 -21
- package/templates/template_oa/public/src/_reset.less +3 -0
- package/templates/template_oa/public/src/_variable.less +1 -1
- package/templates/template_oa/public/src/assets/images/NY-pop-bg.png +0 -0
- package/templates/template_oa/public/src/components/Auth/index.jsx +1 -1
- package/templates/template_oa/public/src/components/Dialog/index.jsx +150 -0
- package/templates/template_oa/public/src/components/Dialog/index.less +123 -0
- package/templates/template_oa/public/src/components/Empty/index.jsx +23 -0
- package/templates/template_oa/public/src/components/Empty/index.less +6 -0
- package/templates/template_oa/public/src/components/FormRow/index.jsx +39 -0
- package/templates/template_oa/public/src/components/FormRow/index.less +67 -0
- package/templates/template_oa/public/src/components/FormTable/index.jsx +136 -0
- package/templates/template_oa/public/src/components/IFrame/index.less +1 -1
- package/templates/template_oa/public/src/components/Layout/Basic/index.jsx +18 -12
- package/templates/template_oa/public/src/components/Layout/Basic/index.less +21 -11
- package/templates/template_oa/public/src/components/Layout/index.jsx +2 -1
- package/templates/template_oa/public/src/components/Nav/index.jsx +163 -100
- package/templates/template_oa/public/src/components/Select/DepSelect/index.jsx +47 -0
- package/templates/template_oa/public/src/components/Select/StaffSelect/index.jsx +97 -0
- package/templates/template_oa/public/src/components/Select/StaffSelect/index.less +24 -0
- package/templates/template_oa/public/src/components/Toast/index.less +1 -1
- package/templates/template_oa/public/src/components/Upload/index.jsx +358 -0
- package/templates/template_oa/public/src/components/title/index.jsx +12 -0
- package/templates/template_oa/public/src/components/title/index.less +21 -0
- package/templates/template_oa/public/src/mock/cases.js +52 -0
- package/templates/template_oa/public/src/mock/index.js +2 -0
- package/templates/template_oa/public/src/pages/components/totalRecord/index.jsx +21 -0
- package/templates/template_oa/public/src/pages/components/totalRecord/index.less +16 -0
- package/templates/template_oa/public/src/pages/login/index.jsx +7 -9
- package/templates/template_oa/public/src/pages/my/index.jsx +14 -0
- package/templates/template_oa/public/src/pages/video/detail/index.jsx +14 -0
- package/templates/template_oa/public/src/pages/video/index.jsx +325 -23
- package/templates/template_oa/public/src/pages/video/index.less +3 -0
- package/templates/template_oa/public/src/provider/app.jsx +14 -81
- package/templates/template_oa/public/src/route.jsx +8 -2
- package/templates/template_oa/public/src/services/cases.js +7 -0
- package/templates/template_oa/public/src/services/common.js +132 -0
- package/templates/template_oa/public/src/services/index.js +42 -8
- package/templates/template_oa/public/src/services/video.js +1 -0
- package/templates/template_oa/public/src/utils/index.js +61 -1
- package/templates/template_oa/readme.md +8 -0
- package/templates/template_oa/webpack.api.js +10 -22
- package/templates/template_offcial/build.sh +7 -1
- package/templates/template_offcial/frontend_build.sh +5 -0
- package/templates/template_offcial/readme.md +8 -0
- package/templates/template_oa/public/favicon.png +0 -0
- package/templates/template_oa/public/src/components/mask/index.jsx +0 -47
- package/templates/template_oa/public/src/components/mask/index.less +0 -32
- package/templates/template_oa/public/src/dictionary/index.js +0 -39
- package/templates/template_oa/public/src/provider/menu.jsx +0 -20
- package/templates/template_oa/public/src/services/user.js +0 -26
|
@@ -1,19 +1,87 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import {usePaginationWithForm} from '@/hooks';
|
|
3
5
|
import {GET_LIST} from '@/services/video';
|
|
4
|
-
import {
|
|
6
|
+
import {GET_STAFF_LIST,GET_DEP_LIST} from '@/services/common';
|
|
7
|
+
|
|
8
|
+
import { Table, Input, Button, Form,Checkbox,Radio } from 'antd';
|
|
5
9
|
import {FormBlockByTitle} from '@/components/Layout/FormBlock';
|
|
6
10
|
import styles from './index.less';
|
|
7
11
|
import PageTitle from '@/pages/components/pageTitle';
|
|
12
|
+
import TotalRecord from '@/pages/components/totalRecord';
|
|
13
|
+
import {ShowErrorAlert,ShowAlert,ShowConfirm} from '@/components/Dialog';
|
|
14
|
+
import ShowToast from '@/components/Toast';
|
|
15
|
+
import Empty from '@/components/Empty';
|
|
16
|
+
import FormRow from '@/components/FormRow';
|
|
17
|
+
import FormTable from '@/components/FormTable';
|
|
18
|
+
import UploadHelper from '@/components/Upload';
|
|
19
|
+
import StaffSelect from '@/components/Select/StaffSelect';
|
|
20
|
+
import DepSelect from '@/components/Select/DepSelect';
|
|
21
|
+
import ProviderApp from '@/provider/app';
|
|
8
22
|
|
|
9
23
|
const Page = () => {
|
|
24
|
+
const providerApp = ProviderApp.useContainer();
|
|
25
|
+
const navigate= useNavigate();
|
|
10
26
|
const [form] = Form.useForm();
|
|
11
|
-
const
|
|
27
|
+
const [formEdit]= Form.useForm();
|
|
28
|
+
const [formTable]= Form.useForm();
|
|
29
|
+
const [staff,setStaffList] = useState(null);
|
|
30
|
+
const [depList,setDepList] = useState(null);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const [edit,setEdit]= useState(false);
|
|
34
|
+
const [noData,setNoData]= useState(true);
|
|
35
|
+
const [formData,setFormData]=useState({
|
|
36
|
+
name:'cc',
|
|
37
|
+
age:156,
|
|
38
|
+
files:[{client_name:'abc.jpg',server_link:'abc.jpg'}],
|
|
39
|
+
manager:'69379379356ab1b1a1920d9052021900',
|
|
40
|
+
managerName:'王悦',
|
|
41
|
+
dep:'816',
|
|
42
|
+
depName:'平台技术中心',
|
|
43
|
+
fruit:'西瓜',
|
|
44
|
+
color:'蓝色'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const [tableFormList,setTableFormList]=useState({
|
|
48
|
+
list:[
|
|
49
|
+
{id:'1',name:'name1',age:'age1'},
|
|
50
|
+
{id:'2',name:'name2',age:'age2'},
|
|
51
|
+
{id:'3',name:'name3',age:'age3'},
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const request = usePaginationWithForm({
|
|
12
56
|
service:GET_LIST,
|
|
13
|
-
pagination:{pageSize:10}
|
|
57
|
+
pagination:{pageSize:10},
|
|
58
|
+
form:form
|
|
14
59
|
})
|
|
15
60
|
|
|
61
|
+
const init=async ()=>{
|
|
62
|
+
let staff = GET_STAFF_LIST();
|
|
63
|
+
let ret = GET_DEP_LIST();
|
|
64
|
+
staff = await staff;
|
|
65
|
+
ret = await ret;
|
|
66
|
+
if(staff&&staff.code==1){
|
|
67
|
+
setStaffList(staff.info)
|
|
68
|
+
}
|
|
69
|
+
if(ret&&ret.code==1){
|
|
70
|
+
setDepList(ret.info);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
useEffect(()=>{
|
|
74
|
+
init();
|
|
75
|
+
},[])
|
|
76
|
+
useEffect(()=>{
|
|
77
|
+
if(request?.pagination?.total>0){
|
|
78
|
+
setNoData(false);
|
|
79
|
+
console.log('有数据了')
|
|
80
|
+
}
|
|
81
|
+
},[request.pagination])
|
|
82
|
+
|
|
16
83
|
useEffect(()=>{
|
|
84
|
+
console.log('初次查询')
|
|
17
85
|
request.update();
|
|
18
86
|
},[])
|
|
19
87
|
|
|
@@ -31,10 +99,6 @@ const Page = () => {
|
|
|
31
99
|
}
|
|
32
100
|
}];
|
|
33
101
|
|
|
34
|
-
useEffect(()=>{
|
|
35
|
-
console.log(request)
|
|
36
|
-
},[request])
|
|
37
|
-
|
|
38
102
|
const getDataSource=()=>{
|
|
39
103
|
if(request?.data?.length>0){
|
|
40
104
|
let req=request?.data[request.pagination.current-1]||[];
|
|
@@ -43,23 +107,145 @@ const Page = () => {
|
|
|
43
107
|
return [];
|
|
44
108
|
}
|
|
45
109
|
|
|
110
|
+
|
|
46
111
|
const onPageChange=(current,pageSize)=>{
|
|
47
112
|
request.update({pagination:{current,pageSize}})
|
|
48
113
|
}
|
|
49
114
|
const onSearch=()=>{
|
|
115
|
+
request.update();
|
|
116
|
+
}
|
|
117
|
+
const onReset=()=>{
|
|
118
|
+
request.reset();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const onDetail=()=>{
|
|
122
|
+
navigate('/video/detail')
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const onAlert= async (type)=>{
|
|
126
|
+
switch(type){
|
|
127
|
+
case 'ShowErrorAlert':{ShowErrorAlert('错误啦');}break;
|
|
128
|
+
case 'ShowAlert':{ShowAlert('提示框');}break;
|
|
129
|
+
case 'ShowConfirm':{
|
|
130
|
+
const req= await ShowConfirm({content:'你确定吗?'})
|
|
131
|
+
if(req){
|
|
132
|
+
ShowToast('确认')
|
|
133
|
+
}else{
|
|
134
|
+
ShowToast('取消')
|
|
135
|
+
}
|
|
136
|
+
}break;
|
|
137
|
+
case 'ShowToast':{
|
|
138
|
+
ShowToast('toast')
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
const onNoData=()=>{
|
|
144
|
+
setNoData(true)
|
|
145
|
+
}
|
|
146
|
+
const onEdit=()=>{
|
|
147
|
+
setEdit(true);
|
|
148
|
+
}
|
|
149
|
+
const onSave= async ()=>{
|
|
150
|
+
try{
|
|
151
|
+
const req= await formEdit.validateFields();
|
|
152
|
+
if(req){
|
|
153
|
+
setFormData(req)
|
|
154
|
+
}
|
|
155
|
+
}catch(ex){
|
|
156
|
+
ShowToast(ex);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
setEdit(false);
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
const onCancel=()=>{
|
|
163
|
+
formEdit.resetFields();
|
|
164
|
+
setEdit(false)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const createColumn=({formItemName,onAdd,onDel,onCopy})=> {
|
|
168
|
+
let ret = [
|
|
169
|
+
{
|
|
170
|
+
align: 'center',
|
|
171
|
+
dataIndex: 'name',
|
|
172
|
+
title:'name',
|
|
173
|
+
width: 60,
|
|
174
|
+
render: (text, record, index) => {
|
|
175
|
+
return (
|
|
176
|
+
<Form.Item name={[formItemName,index,'name']} >
|
|
177
|
+
<Input />
|
|
178
|
+
</Form.Item>
|
|
179
|
+
);
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
{
|
|
184
|
+
align: 'center',
|
|
185
|
+
dataIndex: 'age',
|
|
186
|
+
title:'age',
|
|
187
|
+
width: 60,
|
|
188
|
+
render: (text, record, index) => {
|
|
189
|
+
return (
|
|
190
|
+
<Form.Item name={[formItemName,index,'age']} >
|
|
191
|
+
<Input />
|
|
192
|
+
</Form.Item>
|
|
193
|
+
);
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
];
|
|
197
|
+
ret.push({
|
|
198
|
+
align: 'center',
|
|
199
|
+
dataIndex: 'oper',
|
|
200
|
+
title: '操作',
|
|
201
|
+
width: 120,
|
|
202
|
+
render: (text, record, index) => {
|
|
203
|
+
return (
|
|
204
|
+
<div>
|
|
205
|
+
<Button type='link' style={{marginRight:"12px"}} onClick={onDel.bind(this, record, index)} >
|
|
206
|
+
删除
|
|
207
|
+
</Button>
|
|
208
|
+
|
|
209
|
+
<Button type='link' style={{marginRight:"12px"}} onClick={onCopy.bind(this, record, index)}>
|
|
210
|
+
复制
|
|
211
|
+
</Button>
|
|
212
|
+
|
|
213
|
+
<Button type='link' onClick={onAdd.bind(this, record, index)}>
|
|
214
|
+
添加
|
|
215
|
+
</Button>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
);
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
return ret;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const onPrintFormTable= async ()=>{
|
|
226
|
+
|
|
227
|
+
try{
|
|
228
|
+
const req= await formTable.validateFields();
|
|
229
|
+
console.log(req);
|
|
230
|
+
}catch(ex){
|
|
231
|
+
ShowToast(ex);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const onLogout=()=>{
|
|
236
|
+
providerApp.logout();
|
|
50
237
|
}
|
|
51
|
-
const onReset=()=>{}
|
|
52
238
|
return (
|
|
53
239
|
<section className={styles.wrap}>
|
|
54
240
|
|
|
55
241
|
<PageTitle>周边商品维护</PageTitle>
|
|
56
|
-
<FormBlockByTitle title=''>
|
|
242
|
+
<FormBlockByTitle title='查询结果'>
|
|
57
243
|
<Form
|
|
58
244
|
form={form}
|
|
59
245
|
layout='inline'
|
|
60
246
|
colon={false}
|
|
61
247
|
>
|
|
62
|
-
<Form.Item name='
|
|
248
|
+
<Form.Item name='keywords' labelAlign='left' label='关键字'>
|
|
63
249
|
<Input placeholder='产品编码/产品名称/产品型号/部门/单号' />
|
|
64
250
|
</Form.Item>
|
|
65
251
|
|
|
@@ -70,20 +256,136 @@ const Page = () => {
|
|
|
70
256
|
重置
|
|
71
257
|
</Button>
|
|
72
258
|
</Form>
|
|
259
|
+
<TotalRecord count={request?.pagination?.total||'-'} right={
|
|
260
|
+
<>
|
|
261
|
+
<Button type='primary'className={styles.margin}>导出</Button>
|
|
262
|
+
<Button onClick={onDetail} className={styles.margin}>查看详情页面</Button>
|
|
263
|
+
<Button onClick={onNoData} className={styles.margin}>模拟空数据</Button>
|
|
264
|
+
|
|
265
|
+
</>
|
|
266
|
+
} />
|
|
267
|
+
{
|
|
268
|
+
noData?<Empty />:
|
|
269
|
+
<Table
|
|
270
|
+
className={styles.table}
|
|
271
|
+
rowKey='id'
|
|
272
|
+
columns={columns}
|
|
273
|
+
loading={!request?.data?.length>0}
|
|
274
|
+
dataSource={getDataSource()}
|
|
275
|
+
// pagination={false}
|
|
276
|
+
pagination={{
|
|
277
|
+
current:request?.pagination?.current,
|
|
278
|
+
pageSize:request?.pagination?.pageSize,
|
|
279
|
+
onChange:onPageChange,
|
|
280
|
+
total:request?.pagination?.total
|
|
281
|
+
}}
|
|
282
|
+
/>
|
|
283
|
+
}
|
|
284
|
+
</FormBlockByTitle>
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
<FormBlockByTitle title='表单' rightBtns={
|
|
288
|
+
edit?
|
|
289
|
+
(<>
|
|
290
|
+
<Button type='primary' onClick={onSave} className={styles.margin}>保存</Button>
|
|
291
|
+
<Button onClick={onCancel} className={styles.margin}>取消</Button>
|
|
292
|
+
</>):(<Button type='primary' onClick={onEdit} className={styles.margin}>编辑</Button>)
|
|
293
|
+
}>
|
|
294
|
+
<Form initialValues={formData} form={formEdit}>
|
|
295
|
+
<FormRow>
|
|
296
|
+
<FormRow.Col label='姓名' required editmode={edit} txtdata={formData?.name}>
|
|
297
|
+
<Form.Item name='name'>
|
|
298
|
+
<Input />
|
|
299
|
+
</Form.Item>
|
|
300
|
+
</FormRow.Col>
|
|
301
|
+
<FormRow.Col label='年龄' editmode={edit} txtdata={formData?.age}>
|
|
302
|
+
<Form.Item name='age'>
|
|
303
|
+
<Input />
|
|
304
|
+
</Form.Item>
|
|
305
|
+
</FormRow.Col>
|
|
306
|
+
</FormRow>
|
|
307
|
+
<FormRow>
|
|
308
|
+
<FormRow.Col label='负责人' editmode={edit} txtdata={formData?.managerName}>
|
|
309
|
+
<Form.Item name='manager'>
|
|
310
|
+
<StaffSelect
|
|
311
|
+
// mode='multiple'
|
|
312
|
+
userList={staff}
|
|
313
|
+
/>
|
|
314
|
+
</Form.Item>
|
|
315
|
+
</FormRow.Col>
|
|
316
|
+
<FormRow.Col label='部门' editmode={edit} txtdata={formData?.depName}>
|
|
317
|
+
<Form.Item name='dep'>
|
|
318
|
+
<DepSelect
|
|
319
|
+
// mode='multiple'
|
|
320
|
+
list={depList}
|
|
321
|
+
/>
|
|
322
|
+
</Form.Item>
|
|
323
|
+
</FormRow.Col>
|
|
324
|
+
</FormRow>
|
|
325
|
+
<FormRow>
|
|
326
|
+
<FormRow.Col label='水果' editmode={edit} txtdata={formData?.fruit}>
|
|
327
|
+
<Form.Item name='fruit'>
|
|
328
|
+
<Checkbox.Group options={[
|
|
329
|
+
{label:'苹果',value:'苹果'},
|
|
330
|
+
{label:'西瓜',value:'西瓜'},
|
|
331
|
+
{label:'桔子',value:'桔子'},
|
|
332
|
+
|
|
333
|
+
]}/>
|
|
334
|
+
</Form.Item>
|
|
335
|
+
</FormRow.Col>
|
|
336
|
+
<FormRow.Col label='颜色' editmode={edit} txtdata={formData?.color}>
|
|
337
|
+
<Form.Item name='color'>
|
|
338
|
+
<Radio.Group>
|
|
339
|
+
<Radio value="红色">红色</Radio>
|
|
340
|
+
<Radio value="黄色">黄色</Radio>
|
|
341
|
+
<Radio value="蓝色">蓝色</Radio>
|
|
342
|
+
</Radio.Group>
|
|
343
|
+
</Form.Item>
|
|
344
|
+
</FormRow.Col>
|
|
345
|
+
</FormRow>
|
|
346
|
+
|
|
347
|
+
<FormRow>
|
|
348
|
+
<FormRow.Col label='附件' editmode={true} >
|
|
349
|
+
<Form.Item name='files'>
|
|
350
|
+
<UploadHelper
|
|
351
|
+
disabled={!edit}
|
|
352
|
+
></UploadHelper>
|
|
353
|
+
</Form.Item>
|
|
354
|
+
</FormRow.Col>
|
|
355
|
+
</FormRow>
|
|
356
|
+
</Form>
|
|
357
|
+
</FormBlockByTitle>
|
|
73
358
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
359
|
+
<FormBlockByTitle title='表格中的表单'
|
|
360
|
+
rightBtns={
|
|
361
|
+
<Button type='primary' onClick={onPrintFormTable} className={styles.margin}>打印当前表单值</Button>
|
|
362
|
+
}>
|
|
363
|
+
<Form form={formTable} initialValues={{...tableFormList}}>
|
|
364
|
+
<FormTable
|
|
365
|
+
Table={Table}
|
|
366
|
+
initialValue={tableFormList.list}
|
|
367
|
+
form={formTable}
|
|
368
|
+
formItemName='list'
|
|
369
|
+
antTableOptions={{ bordered: true, pagination: false }}
|
|
370
|
+
newdata={{
|
|
371
|
+
name: '',
|
|
372
|
+
age:''
|
|
373
|
+
}}
|
|
374
|
+
columns={createColumn}
|
|
375
|
+
saveLast
|
|
376
|
+
/>
|
|
377
|
+
</Form>
|
|
378
|
+
</FormBlockByTitle>
|
|
379
|
+
<FormBlockByTitle title='其它功能'>
|
|
380
|
+
<Button className={styles.margin} onClick={onAlert.bind(this,'ShowErrorAlert')}>ShowErrorAlert</Button>
|
|
381
|
+
<Button className={styles.margin} onClick={onAlert.bind(this,'ShowAlert')}>ShowAlert</Button>
|
|
382
|
+
<Button className={styles.margin} onClick={onAlert.bind(this,'ShowConfirm')}>ShowConfirm</Button>
|
|
383
|
+
<Button className={styles.margin} onClick={onAlert.bind(this,'ShowToast')}>ShowToast</Button>
|
|
384
|
+
<Button className={styles.margin} onClick={onLogout}>登出OA</Button>
|
|
385
|
+
|
|
386
|
+
|
|
86
387
|
</FormBlockByTitle>
|
|
388
|
+
|
|
87
389
|
</section>
|
|
88
390
|
)
|
|
89
391
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { useState,useMemo, useEffect } from 'react';
|
|
2
2
|
import { useSearchParams,useNavigate } from 'react-router-dom';
|
|
3
|
+
import {setLogout} from '@/services';
|
|
3
4
|
|
|
4
5
|
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
6
|
|
|
10
7
|
const useApp=() =>{
|
|
11
8
|
const [search] = useSearchParams();
|
|
@@ -14,102 +11,38 @@ const useApp=() =>{
|
|
|
14
11
|
const [nav,setNavConfig] = useState({visible:true,syncDocumentTitle:false});
|
|
15
12
|
const [user,setUser] = useState(null);
|
|
16
13
|
|
|
17
|
-
const delay = useDelay();
|
|
18
14
|
|
|
19
|
-
const
|
|
20
|
-
|
|
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
|
-
}
|
|
15
|
+
const setNav=(config)=>{
|
|
16
|
+
setNavConfig({...nav,...config});
|
|
38
17
|
}
|
|
39
18
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
}
|
|
19
|
+
const logout=async ()=>{
|
|
20
|
+
if(BUILD_ENV=='localdebug'){
|
|
21
|
+
navigate('/login');
|
|
61
22
|
}else{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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;
|
|
23
|
+
let url = window.btoa(location.href);
|
|
24
|
+
let redirect=`${OA_HOST}/login?url=${url}`;
|
|
25
|
+
if(BUILD_ENV!='prod'){
|
|
26
|
+
redirect+='&debug=1';
|
|
78
27
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return false;
|
|
28
|
+
location.href=redirect;
|
|
29
|
+
|
|
82
30
|
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
const logout=async ()=>{
|
|
86
|
-
LOGOUT();
|
|
87
|
-
setUser(null);
|
|
88
|
-
setJwt('');
|
|
89
|
-
localStorage.removeItem('user');
|
|
90
|
-
navigate('/superAdminLogin');
|
|
91
31
|
}
|
|
92
32
|
setLogout(logout);
|
|
93
33
|
|
|
94
34
|
|
|
95
|
-
|
|
96
|
-
const setNav=(config)=>{
|
|
97
|
-
setNavConfig({...nav,...config});
|
|
98
|
-
}
|
|
99
35
|
const action=useMemo(()=>{
|
|
100
36
|
return {
|
|
101
37
|
loading,
|
|
102
38
|
setLoading,
|
|
103
|
-
isLogin,
|
|
104
|
-
login,
|
|
105
39
|
nav,
|
|
106
40
|
setNav,
|
|
107
|
-
logout,
|
|
108
41
|
setUser,
|
|
109
42
|
user,
|
|
110
|
-
|
|
43
|
+
logout
|
|
111
44
|
}
|
|
112
|
-
},[loading,nav,setNav,user,setUser,
|
|
45
|
+
},[loading,nav,setNav,user,setUser,logout]);
|
|
113
46
|
|
|
114
47
|
return action
|
|
115
48
|
}
|
|
@@ -4,7 +4,6 @@ import { Routes, Route, Navigate } from 'react-router-dom';
|
|
|
4
4
|
import { LayoutBasic, Layout } from '@/components/Layout';
|
|
5
5
|
import PageLoading from '@/components/Page/PageLoading';
|
|
6
6
|
|
|
7
|
-
import Nav from '@/components/Nav';
|
|
8
7
|
import Login from '@/pages/login';
|
|
9
8
|
// import {AuthLogin} from '@/components/Auth';
|
|
10
9
|
|
|
@@ -21,6 +20,9 @@ const delayLoader=(loader)=>{
|
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
const Video = React.lazy(()=>import('@/pages/video'));
|
|
23
|
+
const VideoDetail = React.lazy(()=>import('@/pages/video/detail'));
|
|
24
|
+
const My = React.lazy(()=>import('@/pages/my'));
|
|
25
|
+
|
|
24
26
|
|
|
25
27
|
export const RouteList = (
|
|
26
28
|
<Routes>
|
|
@@ -30,11 +32,15 @@ export const RouteList = (
|
|
|
30
32
|
<Route
|
|
31
33
|
path='/'
|
|
32
34
|
element={
|
|
33
|
-
<LayoutBasic
|
|
35
|
+
<LayoutBasic />
|
|
34
36
|
}
|
|
35
37
|
>
|
|
36
38
|
<Route path='/' element={<Navigate to="/video"></Navigate> } />
|
|
37
39
|
<Route path='/video' element={<Video />} />
|
|
40
|
+
<Route path='/video/detail' element={<VideoDetail />} />
|
|
41
|
+
<Route path='/my' element={<My />} />
|
|
42
|
+
|
|
43
|
+
|
|
38
44
|
|
|
39
45
|
</Route>
|
|
40
46
|
</Route>
|