kn-cli 1.0.64 → 1.0.66
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/package.json +2 -1
- package/readme.md +6 -0
- package/src/create.js +2 -0
- package/templates/template_admin/public/src/mock/index.js +0 -2
- package/templates/template_app/public/src/mock/index.js +0 -2
- package/templates/template_oa/public/src/components/IFrame/index.jsx +3 -0
- package/templates/template_oa/public/src/mock/index.js +0 -2
- package/templates/template_oa/webpack.api.js +7 -3
- package/templates/template_oa_jwt/build.sh +7 -0
- package/templates/template_oa_jwt/cli.config.js +30 -0
- package/templates/template_oa_jwt/dev.sh +89 -0
- package/templates/template_oa_jwt/frontend_build.sh +88 -0
- package/templates/template_oa_jwt/init/prepare-commit-msg +5 -0
- package/templates/template_oa_jwt/init.sh +33 -0
- package/templates/template_oa_jwt/jsconfig.json +10 -0
- package/templates/template_oa_jwt/package.json +25 -0
- package/templates/template_oa_jwt/public/404.html +26 -0
- package/templates/template_oa_jwt/public/favicon.ico +0 -0
- package/templates/template_oa_jwt/public/index.html +44 -0
- package/templates/template_oa_jwt/public/src/_antd.less +216 -0
- package/templates/template_oa_jwt/public/src/_reset.less +134 -0
- package/templates/template_oa_jwt/public/src/_variable.less +84 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_oa_jwt/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_oa_jwt/public/src/assets/images/NY-pop-bg.png +0 -0
- package/templates/template_oa_jwt/public/src/assets/images/avatar.png +0 -0
- package/templates/template_oa_jwt/public/src/assets/images/loading.svg +40 -0
- package/templates/template_oa_jwt/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_oa_jwt/public/src/components/Alert/index.less +0 -0
- package/templates/template_oa_jwt/public/src/components/Auth/index.jsx +44 -0
- package/templates/template_oa_jwt/public/src/components/Dialog/index.jsx +150 -0
- package/templates/template_oa_jwt/public/src/components/Dialog/index.less +123 -0
- package/templates/template_oa_jwt/public/src/components/Empty/index.jsx +23 -0
- package/templates/template_oa_jwt/public/src/components/Empty/index.less +6 -0
- package/templates/template_oa_jwt/public/src/components/Footer/index.jsx +17 -0
- package/templates/template_oa_jwt/public/src/components/Footer/index.less +28 -0
- package/templates/template_oa_jwt/public/src/components/FormRow/index.jsx +39 -0
- package/templates/template_oa_jwt/public/src/components/FormRow/index.less +67 -0
- package/templates/template_oa_jwt/public/src/components/FormTable/index.jsx +137 -0
- package/templates/template_oa_jwt/public/src/components/FormTable/index.less +18 -0
- package/templates/template_oa_jwt/public/src/components/IFrame/index.jsx +44 -0
- package/templates/template_oa_jwt/public/src/components/IFrame/index.less +4 -0
- package/templates/template_oa_jwt/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_oa_jwt/public/src/components/IconFont/index.less +5 -0
- package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.jsx +52 -0
- package/templates/template_oa_jwt/public/src/components/Layout/Basic/index.less +82 -0
- package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.jsx +15 -0
- package/templates/template_oa_jwt/public/src/components/Layout/CenterBody/index.less +36 -0
- package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.jsx +23 -0
- package/templates/template_oa_jwt/public/src/components/Layout/FormBlock/index.less +37 -0
- package/templates/template_oa_jwt/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_oa_jwt/public/src/components/Layout/index.jsx +27 -0
- package/templates/template_oa_jwt/public/src/components/Layout/index.less +8 -0
- package/templates/template_oa_jwt/public/src/components/Link/index.jsx +24 -0
- package/templates/template_oa_jwt/public/src/components/Link/index.less +11 -0
- package/templates/template_oa_jwt/public/src/components/Loading/index.jsx +16 -0
- package/templates/template_oa_jwt/public/src/components/Loading/index.less +96 -0
- package/templates/template_oa_jwt/public/src/components/Nav/index.jsx +184 -0
- package/templates/template_oa_jwt/public/src/components/Nav/index.less +38 -0
- package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_oa_jwt/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_oa_jwt/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_oa_jwt/public/src/components/Popup/index.less +18 -0
- package/templates/template_oa_jwt/public/src/components/Select/DepSelect/index.jsx +47 -0
- package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.jsx +97 -0
- package/templates/template_oa_jwt/public/src/components/Select/StaffSelect/index.less +24 -0
- package/templates/template_oa_jwt/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_oa_jwt/public/src/components/Toast/index.less +43 -0
- package/templates/template_oa_jwt/public/src/components/Upload/index.jsx +358 -0
- package/templates/template_oa_jwt/public/src/components/title/index.jsx +12 -0
- package/templates/template_oa_jwt/public/src/components/title/index.less +21 -0
- package/templates/template_oa_jwt/public/src/dictionary/index.js +20 -0
- package/templates/template_oa_jwt/public/src/hooks/index.jsx +21 -0
- package/templates/template_oa_jwt/public/src/hooks/useDelay.jsx +29 -0
- package/templates/template_oa_jwt/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_oa_jwt/public/src/hooks/useLoading.jsx +42 -0
- package/templates/template_oa_jwt/public/src/hooks/useLogin.jsx +33 -0
- package/templates/template_oa_jwt/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_oa_jwt/public/src/hooks/useScrollTop.jsx +32 -0
- package/templates/template_oa_jwt/public/src/hooks/useSearch.jsx +137 -0
- package/templates/template_oa_jwt/public/src/hooks/useUpdate.jsx +11 -0
- package/templates/template_oa_jwt/public/src/index.jsx +50 -0
- package/templates/template_oa_jwt/public/src/mock/common.js +484 -0
- package/templates/template_oa_jwt/public/src/mock/index.js +61 -0
- package/templates/template_oa_jwt/public/src/mock/user.js +70 -0
- package/templates/template_oa_jwt/public/src/mock/utils.js +33 -0
- package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.jsx +13 -0
- package/templates/template_oa_jwt/public/src/pages/components/pageTitle/index.less +20 -0
- package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.jsx +21 -0
- package/templates/template_oa_jwt/public/src/pages/components/totalRecord/index.less +16 -0
- package/templates/template_oa_jwt/public/src/pages/demo/detail/index.jsx +14 -0
- package/templates/template_oa_jwt/public/src/pages/demo/index.jsx +399 -0
- package/templates/template_oa_jwt/public/src/pages/demo/index.less +15 -0
- package/templates/template_oa_jwt/public/src/pages/login/index.jsx +29 -0
- package/templates/template_oa_jwt/public/src/pages/login/index.less +44 -0
- package/templates/template_oa_jwt/public/src/pages/redirect/index.jsx +31 -0
- package/templates/template_oa_jwt/public/src/provider/app.jsx +66 -0
- package/templates/template_oa_jwt/public/src/route.jsx +45 -0
- package/templates/template_oa_jwt/public/src/services/common.js +133 -0
- package/templates/template_oa_jwt/public/src/services/demo.js +41 -0
- package/templates/template_oa_jwt/public/src/services/index.js +266 -0
- package/templates/template_oa_jwt/public/src/services/token.js +132 -0
- package/templates/template_oa_jwt/public/src/utils/index.js +115 -0
- package/templates/template_oa_jwt/public/static/about.html +1 -0
- package/templates/template_oa_jwt/public/static/kssoLogin.html +22 -0
- package/templates/template_oa_jwt/public/static/noAuth.html +217 -0
- package/templates/template_oa_jwt/public/static/noAuth.png +0 -0
- package/templates/template_oa_jwt/readme.md +71 -0
- package/templates/template_oa_jwt/report.sh +68 -0
- package/templates/template_oa_jwt/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_oa_jwt/tools/iconfont/package.json +20 -0
- package/templates/template_oa_jwt/tools/iconfont/run.sh +39 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_oa_jwt/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_oa_jwt/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_oa_jwt/tools/iconfont/templates/index.html +56 -0
- package/templates/template_oa_jwt/tools/tinypng/package.json +11 -0
- package/templates/template_oa_jwt/tools/tinypng/run.sh +15 -0
- package/templates/template_oa_jwt/versionPublish.sh +27 -0
- package/templates/template_oa_jwt/webpack.api.js +61 -0
- package/templates/template_offcial/public/src/mock/index.js +0 -2
- package/templates/template_admin/.gitignore +0 -6
- package/templates/template_app/.gitignore +0 -6
- package/templates/template_oa/.gitignore +0 -6
- package/templates/template_offcial/.gitignore +0 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CSS from './index.less';
|
|
3
|
+
|
|
4
|
+
const PageTitle = (props) => {
|
|
5
|
+
return (
|
|
6
|
+
<section className={CSS.title}>
|
|
7
|
+
<div className={CSS.rect}></div>
|
|
8
|
+
<h3 className={CSS.text}>{props.children}</h3>
|
|
9
|
+
</section>
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
export default PageTitle;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@import '~@/_variable.less';
|
|
2
|
+
|
|
3
|
+
.title{
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
border-bottom: 1px solid #ddd;
|
|
7
|
+
padding-bottom: var(--margin-small);
|
|
8
|
+
margin-bottom: var(--margin-default);
|
|
9
|
+
}
|
|
10
|
+
.rect {
|
|
11
|
+
background: var(--color-primary);
|
|
12
|
+
margin-right: 7px;
|
|
13
|
+
width: 4px;
|
|
14
|
+
height: 18px;
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
.text{
|
|
18
|
+
font-size: 16px;
|
|
19
|
+
color: #555;
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useDictionary } from '@/hooks';
|
|
2
|
+
// import { GET_PROJECT } from '@/services/dataset';
|
|
3
|
+
import { Select, Radio } from 'antd';
|
|
4
|
+
useDictionary.SetConfig({ SelectOption: Select.Option, RadioOption: Radio });
|
|
5
|
+
|
|
6
|
+
// export const useProjectList = useDictionary.createDictionary({
|
|
7
|
+
// api: async () => {
|
|
8
|
+
// const req = await GET_PROJECT();
|
|
9
|
+
// if (req?.code == 0) {
|
|
10
|
+
// const list = req.data.map(item => {
|
|
11
|
+
// const { app_id: id, name: label, _id: name } = item;
|
|
12
|
+
// return {
|
|
13
|
+
// id, label, name
|
|
14
|
+
// }
|
|
15
|
+
// });
|
|
16
|
+
// return { code: 0, data: { body: [{ id: '', label: '全部项目', name: 'all' }, ...list] } };
|
|
17
|
+
// }
|
|
18
|
+
// return null;
|
|
19
|
+
// }
|
|
20
|
+
// });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import useImageLoader from './useImageLoader';
|
|
4
|
+
import useDelay from './useDelay';
|
|
5
|
+
import usePreload from './usePreload';
|
|
6
|
+
import useSearch from './useSearch';
|
|
7
|
+
import useUpdate from './useUpdate';
|
|
8
|
+
import useLoading from './useLoading';
|
|
9
|
+
import {useDictionary, usePagination,usePaginationWithForm} from 'kn-hooks';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
useDictionary,
|
|
13
|
+
usePaginationWithForm,
|
|
14
|
+
usePagination,
|
|
15
|
+
useImageLoader,
|
|
16
|
+
useDelay,
|
|
17
|
+
usePreload,
|
|
18
|
+
useSearch,
|
|
19
|
+
useUpdate,
|
|
20
|
+
useLoading
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef,useState,useMemo, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useDelay=()=>{
|
|
4
|
+
const [loading,setLoading] = useState(false);
|
|
5
|
+
const refSet = useRef();
|
|
6
|
+
refSet.current = setLoading;
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
refSet.current = setLoading;
|
|
9
|
+
},[setLoading]);
|
|
10
|
+
|
|
11
|
+
const actions=useMemo(()=>{
|
|
12
|
+
const wait=(ms)=>{
|
|
13
|
+
refSet.current(true);
|
|
14
|
+
return new Promise(res=>{
|
|
15
|
+
setTimeout(()=>{
|
|
16
|
+
refSet.current(false);
|
|
17
|
+
res();
|
|
18
|
+
}, ms);
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
wait,
|
|
23
|
+
loading
|
|
24
|
+
};
|
|
25
|
+
},[loading]);
|
|
26
|
+
return actions;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default useDelay;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useEffect,useState,useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const useImageLoader=(img_src)=>{
|
|
6
|
+
const [src,setSrc] = useState('');
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if(img_src===src)return;
|
|
9
|
+
if(!img_src)return;
|
|
10
|
+
let img = new Image();
|
|
11
|
+
img.onload = () => {
|
|
12
|
+
setSrc(img_src);
|
|
13
|
+
};
|
|
14
|
+
img.onerror = () => {
|
|
15
|
+
setSrc('');
|
|
16
|
+
console.log(`图片加载失败:${img_src}`)
|
|
17
|
+
};
|
|
18
|
+
img.src = img_src;
|
|
19
|
+
}, [img_src]);
|
|
20
|
+
|
|
21
|
+
const actions=useMemo(()=>{
|
|
22
|
+
return src;
|
|
23
|
+
},[src]);
|
|
24
|
+
return actions;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default useImageLoader;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useRef,useState, useEffect } from 'react';
|
|
2
|
+
import {ShowPageLoading} from '@/components/Page/PageLoading';
|
|
3
|
+
|
|
4
|
+
const useLoading=(props={})=>{
|
|
5
|
+
const {canTouch=false} = props;
|
|
6
|
+
const [name] = useState(props?.name||'loading')
|
|
7
|
+
const [count,setCount] = useState(props?.loading?1:0);
|
|
8
|
+
const refPageLoading = useRef();
|
|
9
|
+
|
|
10
|
+
const setLoading=(state)=>{
|
|
11
|
+
if(state){
|
|
12
|
+
setCount(v=>v+1);
|
|
13
|
+
}else{
|
|
14
|
+
setCount(v=>v-1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const reset=()=>{
|
|
18
|
+
setCount(v=>0);
|
|
19
|
+
}
|
|
20
|
+
useEffect(()=>{
|
|
21
|
+
if(count > 0 ){
|
|
22
|
+
if(!refPageLoading.current){
|
|
23
|
+
refPageLoading.current = ShowPageLoading({canTouch:canTouch});
|
|
24
|
+
}
|
|
25
|
+
}else{
|
|
26
|
+
if(refPageLoading.current){
|
|
27
|
+
refPageLoading.current();//销毁
|
|
28
|
+
refPageLoading.current=null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},[count])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
name,
|
|
36
|
+
reset,
|
|
37
|
+
setLoading,
|
|
38
|
+
loading:count
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default useLoading;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
4
|
+
import {IS_LOGIN,SET_TOKEN,LOGIN} from '@/services/wish';
|
|
5
|
+
import ShowLogin from '@/pages/components/dialog/alert/login';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const useLogin=(props)=>{
|
|
9
|
+
const [isLogin,setLogin] = useState(IS_LOGIN());
|
|
10
|
+
|
|
11
|
+
const login=async ()=>{
|
|
12
|
+
if(IS_LOGIN()){
|
|
13
|
+
setLogin(true);
|
|
14
|
+
return true;
|
|
15
|
+
}else{
|
|
16
|
+
setLogin(false);
|
|
17
|
+
const phone = await ShowLogin();
|
|
18
|
+
if(phone){
|
|
19
|
+
const loginReq = await LOGIN({phone});
|
|
20
|
+
if(loginReq?.code==0){
|
|
21
|
+
SET_TOKEN(loginReq.data.api_token);
|
|
22
|
+
setLogin(IS_LOGIN());
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {login,isLogin}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default useLogin;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useEffect,useState,useMemo,useRef,useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
const usePreload=(files)=>{
|
|
4
|
+
const [list] = useState(files);
|
|
5
|
+
const [count,setCount] = useState(files.length);
|
|
6
|
+
const [state,setState]=useState('');
|
|
7
|
+
|
|
8
|
+
const load=useCallback((options)=>{
|
|
9
|
+
return new Promise(resolve=>{
|
|
10
|
+
if(count <= 0 ){
|
|
11
|
+
resolve(true);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if(state=='loading'){
|
|
15
|
+
resolve(false);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
setState('loading');
|
|
19
|
+
let per = files.length;
|
|
20
|
+
list.forEach((item, idx) => {
|
|
21
|
+
if (typeof item === 'string') {
|
|
22
|
+
let img = new Image();
|
|
23
|
+
img.onload = () => {
|
|
24
|
+
console.log('加载成功')
|
|
25
|
+
per--;
|
|
26
|
+
if(per<=0){
|
|
27
|
+
setCount(0);
|
|
28
|
+
if(options?.delay){
|
|
29
|
+
setTimeout(resolve, options.delay);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
resolve(true);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
img.onerror = () => {
|
|
36
|
+
per--;
|
|
37
|
+
if(per<=0){
|
|
38
|
+
setCount(0);
|
|
39
|
+
resolve(true);
|
|
40
|
+
}
|
|
41
|
+
console.log(`图片预加载失败`,item);
|
|
42
|
+
};
|
|
43
|
+
img.src = item;
|
|
44
|
+
} else {
|
|
45
|
+
console.log(`图片预加载失败异常图片`,item);
|
|
46
|
+
per--;
|
|
47
|
+
if(per<=0){
|
|
48
|
+
setCount(0);
|
|
49
|
+
resolve(true);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
},[state,setState,count]);
|
|
56
|
+
|
|
57
|
+
const actions=useMemo(()=>{
|
|
58
|
+
return {
|
|
59
|
+
count,
|
|
60
|
+
load,
|
|
61
|
+
};
|
|
62
|
+
},[count]);
|
|
63
|
+
return actions;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default usePreload;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState, useMemo, useEffect } from 'react'
|
|
2
|
+
import { createContainer } from 'unstated-next'
|
|
3
|
+
|
|
4
|
+
const useActivity = () => {
|
|
5
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
6
|
+
const [containerNode, setContainerNode] = useState();
|
|
7
|
+
const [clientHeight, setClientHeight] = useState(0);
|
|
8
|
+
const [titleRefs, setTitleRefs] = useState({});
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const node = document.getElementById('main-view');
|
|
12
|
+
setContainerNode(node);
|
|
13
|
+
setClientHeight(node.clientHeight)
|
|
14
|
+
node.addEventListener('scroll', (e) => {
|
|
15
|
+
setScrollTop(e.target.scrollTop);
|
|
16
|
+
})
|
|
17
|
+
}, [])
|
|
18
|
+
|
|
19
|
+
const action = useMemo(() => {
|
|
20
|
+
return {
|
|
21
|
+
scrollTop,
|
|
22
|
+
clientHeight,
|
|
23
|
+
titleRefs,
|
|
24
|
+
setTitleRefs,
|
|
25
|
+
containerNode,
|
|
26
|
+
setContainerNode,
|
|
27
|
+
}
|
|
28
|
+
}, [scrollTop, setScrollTop, clientHeight, titleRefs, setTitleRefs, containerNode, setContainerNode])
|
|
29
|
+
return action
|
|
30
|
+
}
|
|
31
|
+
const Activity = createContainer(useActivity);
|
|
32
|
+
export default Activity;
|
|
@@ -0,0 +1,137 @@
|
|
|
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;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import {HashRouter} from 'react-router-dom';
|
|
4
|
+
// import {createRoot} from 'react-dom/client';
|
|
5
|
+
// import { createHashRouter,RouterProvider } from 'react-router-dom';
|
|
6
|
+
import './_antd.less';
|
|
7
|
+
import './_reset.less';
|
|
8
|
+
import {RouteList} from './route';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if(MOCK){
|
|
12
|
+
let mock = require('@/mock');
|
|
13
|
+
mock;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
window.appLog=(txt)=>{
|
|
17
|
+
console.log(txt);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* eslint-disable */
|
|
21
|
+
if(BUILD_ENV!='prod' && window.knFeishu?.IS_FEISHU()){
|
|
22
|
+
let VConsole = require('vconsole');
|
|
23
|
+
const vConsole = new VConsole();
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
vConsole.setSwitchPosition(70, 10);
|
|
26
|
+
}, 2000);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if(BUILD_ENV){
|
|
30
|
+
window.appLog(`代码环境类型:${BUILD_ENV}`);
|
|
31
|
+
}
|
|
32
|
+
if (VERSION_HASH) {
|
|
33
|
+
window.appLog(`VERSION_HASH:${VERSION_HASH}`);
|
|
34
|
+
}
|
|
35
|
+
window.appLog(`log init`);
|
|
36
|
+
window.appLog(`${location.href}`);
|
|
37
|
+
window.appLog(`ua:${navigator.userAgent}`);
|
|
38
|
+
/* eslint-enable */
|
|
39
|
+
|
|
40
|
+
const BasicRoute = () => {
|
|
41
|
+
return (
|
|
42
|
+
<HashRouter>
|
|
43
|
+
{RouteList}
|
|
44
|
+
</HashRouter>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ReactDOM.render(<BasicRoute />, document.getElementById('main-view'));
|
|
49
|
+
|
|
50
|
+
// createRoot(document.getElementById('main-view')).render(<RouterProvider router={createHashRouter(router)} />);
|