kn-cli 1.0.47 → 1.0.49
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/cli.config.js +3 -0
- package/build/webpack.config.js +61 -74
- package/package.json +1 -1
- package/readme.md +10 -0
- package/templates/template_admin/cli.config.js +3 -0
- package/templates/template_admin/package.json +1 -0
- package/templates/template_admin/public/src/components/Auth/index.jsx +1 -1
- package/templates/template_admin/public/src/components/TopMenu/index.jsx +1 -1
- package/templates/template_admin/public/src/dictionary/index.js +26 -90
- package/templates/template_admin/public/src/hooks/index.jsx +4 -2
- package/templates/template_admin/public/src/pages/material/index.jsx +74 -3
- package/templates/template_admin/public/src/pages/video/index.jsx +56 -3
- package/templates/template_admin/public/src/provider/app.jsx +1 -1
- package/templates/template_admin/public/src/route.jsx +0 -10
- package/templates/template_admin/public/src/services/video.js +33 -0
- package/templates/template_app/cli.config.js +3 -0
- package/templates/template_app/package.json +1 -0
- package/templates/template_app/public/src/_reset.less +1 -1
- package/templates/template_app/public/src/dictionary/index.js +26 -90
- package/templates/template_app/public/src/hooks/index.jsx +4 -7
- package/templates/template_app/public/src/mock/user.js +5 -7
- package/templates/template_app/public/src/pages/dictionary/index.jsx +33 -0
- package/templates/template_app/public/src/pages/index.jsx +9 -70
- package/templates/template_app/public/src/pages/list/index.jsx +88 -0
- package/templates/template_app/public/src/pages/list/index.less +22 -0
- package/templates/template_app/public/src/pages/login/index.jsx +0 -1
- package/templates/template_app/public/src/provider/app.jsx +22 -0
- package/templates/template_app/public/src/route.jsx +8 -0
- package/templates/template_app/public/src/services/index.js +34 -1
- package/templates/template_admin/public/src/hooks/useNextPage.jsx +0 -89
- package/templates/template_admin/public/src/pages/checkLogin/index.jsx +0 -13
- package/templates/template_admin/public/src/pages/index.jsx +0 -23
- package/templates/template_admin/public/src/pages/subHome/index.jsx +0 -12
- package/templates/template_admin/public/src/pages/subHome2/index.jsx +0 -12
- package/templates/template_admin/public/src/pages/subHome3/index.jsx +0 -12
- package/templates/template_app/public/src/hooks/useNextPage.jsx +0 -89
- package/templates/template_app/public/src/hooks/useSearch.jsx +0 -137
- package/templates/template_app/public/src/hooks/useUpdate.jsx +0 -11
- /package/templates/{template_admin/public/src/pages → template_app/public/src/pages/dictionary}/index.less +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
const Page = () => {
|
|
5
|
-
const query = useParams();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<p>subHome1 {JSON.stringify(query)}</p>
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default Page;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
const Page = () => {
|
|
5
|
-
const query = useParams();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<p>subHome2 {JSON.stringify(query)}</p>
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default Page;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
-
import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
const Page = () => {
|
|
5
|
-
const query = useParams();
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<p>subHome3 {JSON.stringify(query)}</p>
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default Page;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { useState,useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const DEFAULT_PAGE_SIZE=20;
|
|
5
|
-
const DEFAULT_PAGE_CURRENT=1;
|
|
6
|
-
|
|
7
|
-
const useNextPage=(props)=>{
|
|
8
|
-
const [search,setSearch] = useState(props.initSearch||{});
|
|
9
|
-
const [service] = useState(()=>props.service);
|
|
10
|
-
const [beforeService] = useState(()=>props.beforeService);
|
|
11
|
-
const [pagination,setPagination] = useState(()=>{
|
|
12
|
-
let temp = {
|
|
13
|
-
current:DEFAULT_PAGE_CURRENT,
|
|
14
|
-
pageSize:DEFAULT_PAGE_SIZE,
|
|
15
|
-
total:0,
|
|
16
|
-
startIdx:0,
|
|
17
|
-
more:false,
|
|
18
|
-
...props.pagination
|
|
19
|
-
};
|
|
20
|
-
temp.startIdx = (temp.current-1)*temp.pageSize;
|
|
21
|
-
return temp;
|
|
22
|
-
});
|
|
23
|
-
const resetCount = useRef(0);
|
|
24
|
-
const [data,setData] = useState([]);
|
|
25
|
-
|
|
26
|
-
const reset= async ()=>{
|
|
27
|
-
resetCount.current++;
|
|
28
|
-
let page = {...pagination};
|
|
29
|
-
page.current =1;
|
|
30
|
-
return refresh({pageValue:page})
|
|
31
|
-
}
|
|
32
|
-
const nextPage= async ()=>{
|
|
33
|
-
if(!pagination.more){
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
let page = {...pagination};
|
|
37
|
-
page.current= +page.current+1;
|
|
38
|
-
return refresh({pageValue:page})
|
|
39
|
-
}
|
|
40
|
-
const refresh= async ({searchValue,pageValue}={})=>{
|
|
41
|
-
searchValue = searchValue || search;
|
|
42
|
-
pageValue = pageValue || pagination;
|
|
43
|
-
searchValue = {...search,...searchValue};
|
|
44
|
-
pageValue = {...pagination,...pageValue};
|
|
45
|
-
|
|
46
|
-
const {current,pageSize} = pageValue;
|
|
47
|
-
let params = {...searchValue,current:current,pageSize:pageSize};
|
|
48
|
-
if(beforeService)params=beforeService(params);
|
|
49
|
-
if(!params)return;
|
|
50
|
-
|
|
51
|
-
setSearch(searchValue);
|
|
52
|
-
|
|
53
|
-
let ret = await service(params);
|
|
54
|
-
if(ret?.code==0){
|
|
55
|
-
const {page} = ret.data;
|
|
56
|
-
const current= +(page.pageNum||DEFAULT_PAGE_CURRENT);
|
|
57
|
-
const pageSize= +(page.pageSize||DEFAULT_PAGE_SIZE);
|
|
58
|
-
const total= +page.total;
|
|
59
|
-
const startIdx= (current-1)*pageSize;
|
|
60
|
-
const more = current*pageSize<total;
|
|
61
|
-
setPagination({
|
|
62
|
-
current,pageSize,total,startIdx,more
|
|
63
|
-
})
|
|
64
|
-
if(ret.data.list){
|
|
65
|
-
ret.data.list.map(item=>{
|
|
66
|
-
item.resetCount = resetCount.current;
|
|
67
|
-
})
|
|
68
|
-
let newData = current==1?[]:data;
|
|
69
|
-
newData[current-1] = ret.data.list;
|
|
70
|
-
setData([...newData])
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return ret;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
pagination,
|
|
79
|
-
search,
|
|
80
|
-
setSearch,
|
|
81
|
-
refresh,
|
|
82
|
-
reset,
|
|
83
|
-
nextPage,
|
|
84
|
-
data,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export default useNextPage;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { useRef,useState,useMemo, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 管理表格数据的查询搜索及分页
|
|
5
|
-
*/
|
|
6
|
-
const useSearch=(props)=>{
|
|
7
|
-
const [search,setSearch] = useState(props.initSearch||{});
|
|
8
|
-
const [service] = useState(()=>props.service);
|
|
9
|
-
const [beforeSearch] = useState(()=>props.beforeSearch);
|
|
10
|
-
const [beforeService] = useState(()=>props.beforeService);
|
|
11
|
-
|
|
12
|
-
const [pagination,setPagination] = useState(()=>{
|
|
13
|
-
let temp = {current:1,pageSize:10,total:0,startIdx:0,...props.pagination};
|
|
14
|
-
temp.startIdx = (temp.current-1)*temp.pageSize;
|
|
15
|
-
return temp;
|
|
16
|
-
});
|
|
17
|
-
const [updateData] = useState(()=>props.updateData);
|
|
18
|
-
const [orderInfo,setOrderInfo]=useState({});
|
|
19
|
-
|
|
20
|
-
const onPaginationChange=async (pageInfo,sorterInfo)=>{
|
|
21
|
-
let {current,pageSize} = pagination;
|
|
22
|
-
let orderValue=orderInfo;
|
|
23
|
-
if(pageInfo){
|
|
24
|
-
current = pageInfo.current;
|
|
25
|
-
pageSize = pageInfo.pageSize;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if(sorterInfo){
|
|
29
|
-
const {field,order}= sorterInfo;
|
|
30
|
-
if(field){
|
|
31
|
-
if(order){
|
|
32
|
-
orderInfo[field] = order;
|
|
33
|
-
}else{
|
|
34
|
-
delete orderInfo[field];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
orderValue = orderInfo;
|
|
38
|
-
setOrderInfo({...orderInfo});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let searchValue = await getSearchValue();
|
|
43
|
-
refresh({
|
|
44
|
-
searchValue,
|
|
45
|
-
pageValue:{pageSize,current},
|
|
46
|
-
orderValue});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const onSorter=async (sorter)=>{
|
|
50
|
-
const {field,order}= sorter;
|
|
51
|
-
if(field){
|
|
52
|
-
if(order){
|
|
53
|
-
orderInfo[field] = order;
|
|
54
|
-
}else{
|
|
55
|
-
delete orderInfo[field];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
setOrderInfo({...orderInfo});
|
|
59
|
-
console.log(`${JSON.stringify(orderInfo)}`);
|
|
60
|
-
refresh();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const getSearchValue=async ()=>{
|
|
67
|
-
let value={};
|
|
68
|
-
value = search;
|
|
69
|
-
|
|
70
|
-
if(beforeSearch){
|
|
71
|
-
value = beforeSearch(value);
|
|
72
|
-
}
|
|
73
|
-
return value;
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
const btnSearch=async ()=>{
|
|
77
|
-
let value = await getSearchValue();
|
|
78
|
-
if(value){
|
|
79
|
-
refresh({searchValue:value});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const btnReset=()=>{
|
|
83
|
-
formRef.resetFields();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const refresh= async ({searchValue,pageValue,orderValue}={})=>{
|
|
87
|
-
searchValue = searchValue || search;
|
|
88
|
-
pageValue = pageValue || pagination;
|
|
89
|
-
|
|
90
|
-
// 排序暂无
|
|
91
|
-
// orderValue = orderValue || orderInfo;
|
|
92
|
-
// let order=[];
|
|
93
|
-
// if(orderValue){
|
|
94
|
-
// Object.keys(orderValue).map(name=>{
|
|
95
|
-
// if(orderValue[name]==='ascend'){
|
|
96
|
-
// order.push(`${name}`);
|
|
97
|
-
// }else if(orderValue[name]==='descend'){
|
|
98
|
-
// order.push(`-${name}`);
|
|
99
|
-
// }
|
|
100
|
-
// })
|
|
101
|
-
// }
|
|
102
|
-
|
|
103
|
-
let {current,pageSize} = pageValue;
|
|
104
|
-
let params = {...searchValue,page:current,pageSize:pageSize};
|
|
105
|
-
if(beforeService)params=beforeService(params);
|
|
106
|
-
if(!params)return;
|
|
107
|
-
let ret = await service(params);
|
|
108
|
-
if(ret?.code==0){
|
|
109
|
-
const {page} = ret.data;
|
|
110
|
-
setPagination({
|
|
111
|
-
current:page.pageNum||1,
|
|
112
|
-
pageSize:page.pageSize||10,
|
|
113
|
-
total:page.total,
|
|
114
|
-
startIdx:(page.page-1)*page.pageSize
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if(updateData)updateData(ret);
|
|
119
|
-
return ret;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
onPaginationChange,
|
|
125
|
-
pagination,
|
|
126
|
-
btnSearch,
|
|
127
|
-
search,
|
|
128
|
-
setSearch,
|
|
129
|
-
refresh,
|
|
130
|
-
btnReset,
|
|
131
|
-
onSorter
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export default useSearch;
|
|
File without changes
|