kn-cli 1.0.56 → 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.
- package/package.json +3 -1
- package/templates/template_oa/.DS_Store +0 -0
- package/templates/template_oa/build.sh +2 -0
- package/templates/template_oa/cli.config.js +24 -0
- package/templates/template_oa/dev.sh +89 -0
- package/templates/template_oa/frontend_build.sh +83 -0
- package/templates/template_oa/init/prepare-commit-msg +5 -0
- package/templates/template_oa/init.sh +33 -0
- package/templates/template_oa/jsconfig.json +10 -0
- package/templates/template_oa/package-lock.json +1925 -0
- package/templates/template_oa/package.json +24 -0
- package/templates/template_oa/public/.DS_Store +0 -0
- package/templates/template_oa/public/404.html +26 -0
- package/templates/template_oa/public/favicon.ico +0 -0
- package/templates/template_oa/public/favicon.png +0 -0
- package/templates/template_oa/public/index.html +43 -0
- package/templates/template_oa/public/pluginjs/.DS_Store +0 -0
- package/templates/template_oa/public/src/.DS_Store +0 -0
- package/templates/template_oa/public/src/_antd.less +237 -0
- package/templates/template_oa/public/src/_reset.less +131 -0
- package/templates/template_oa/public/src/_variable.less +84 -0
- package/templates/template_oa/public/src/assets/.DS_Store +0 -0
- package/templates/template_oa/public/src/assets/iconfont/.DS_Store +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_oa/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_oa/public/src/assets/images/.DS_Store +0 -0
- package/templates/template_oa/public/src/assets/images/avatar.png +0 -0
- package/templates/template_oa/public/src/assets/images/loading.svg +40 -0
- package/templates/template_oa/public/src/components/.DS_Store +0 -0
- package/templates/template_oa/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_oa/public/src/components/Alert/index.less +0 -0
- package/templates/template_oa/public/src/components/Auth/index.jsx +44 -0
- package/templates/template_oa/public/src/components/Footer/index.jsx +17 -0
- package/templates/template_oa/public/src/components/Footer/index.less +28 -0
- package/templates/template_oa/public/src/components/IFrame/index.jsx +37 -0
- package/templates/template_oa/public/src/components/IFrame/index.less +4 -0
- package/templates/template_oa/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_oa/public/src/components/IconFont/index.less +5 -0
- package/templates/template_oa/public/src/components/Layout/.DS_Store +0 -0
- package/templates/template_oa/public/src/components/Layout/Basic/index.jsx +31 -0
- package/templates/template_oa/public/src/components/Layout/Basic/index.less +74 -0
- package/templates/template_oa/public/src/components/Layout/CenterBody/index.jsx +15 -0
- package/templates/template_oa/public/src/components/Layout/CenterBody/index.less +36 -0
- package/templates/template_oa/public/src/components/Layout/FormBlock/index.jsx +23 -0
- package/templates/template_oa/public/src/components/Layout/FormBlock/index.less +34 -0
- package/templates/template_oa/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_oa/public/src/components/Layout/index.jsx +26 -0
- package/templates/template_oa/public/src/components/Layout/index.less +8 -0
- package/templates/template_oa/public/src/components/Link/index.jsx +24 -0
- package/templates/template_oa/public/src/components/Link/index.less +11 -0
- package/templates/template_oa/public/src/components/Loading/index.jsx +14 -0
- package/templates/template_oa/public/src/components/Loading/index.less +85 -0
- package/templates/template_oa/public/src/components/Nav/index.jsx +121 -0
- package/templates/template_oa/public/src/components/Nav/index.less +38 -0
- package/templates/template_oa/public/src/components/Page/.DS_Store +0 -0
- package/templates/template_oa/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_oa/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_oa/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_oa/public/src/components/Popup/index.less +18 -0
- package/templates/template_oa/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_oa/public/src/components/Toast/index.less +43 -0
- package/templates/template_oa/public/src/components/mask/index.jsx +47 -0
- package/templates/template_oa/public/src/components/mask/index.less +32 -0
- package/templates/template_oa/public/src/dictionary/index.js +39 -0
- package/templates/template_oa/public/src/hooks/.DS_Store +0 -0
- package/templates/template_oa/public/src/hooks/index.jsx +20 -0
- package/templates/template_oa/public/src/hooks/useDelay.jsx +29 -0
- package/templates/template_oa/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_oa/public/src/hooks/useLoading.jsx +42 -0
- package/templates/template_oa/public/src/hooks/useLogin.jsx +33 -0
- package/templates/template_oa/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_oa/public/src/hooks/useScrollTop.jsx +32 -0
- package/templates/template_oa/public/src/hooks/useSearch.jsx +137 -0
- package/templates/template_oa/public/src/hooks/useUpdate.jsx +11 -0
- package/templates/template_oa/public/src/index.jsx +50 -0
- package/templates/template_oa/public/src/mock/auth.js +91 -0
- package/templates/template_oa/public/src/mock/index.js +63 -0
- package/templates/template_oa/public/src/mock/user.js +70 -0
- package/templates/template_oa/public/src/mock/utils.js +33 -0
- package/templates/template_oa/public/src/pages/.DS_Store +0 -0
- package/templates/template_oa/public/src/pages/components/pageTitle/index.jsx +13 -0
- package/templates/template_oa/public/src/pages/components/pageTitle/index.less +20 -0
- package/templates/template_oa/public/src/pages/login/index.jsx +27 -0
- package/templates/template_oa/public/src/pages/login/index.less +44 -0
- package/templates/template_oa/public/src/pages/video/index.jsx +91 -0
- package/templates/template_oa/public/src/pages/video/index.less +12 -0
- package/templates/template_oa/public/src/provider/app.jsx +119 -0
- package/templates/template_oa/public/src/provider/menu.jsx +20 -0
- package/templates/template_oa/public/src/route.jsx +43 -0
- package/templates/template_oa/public/src/services/.DS_Store +0 -0
- package/templates/template_oa/public/src/services/auth.js +121 -0
- package/templates/template_oa/public/src/services/index.js +181 -0
- package/templates/template_oa/public/src/services/user.js +26 -0
- package/templates/template_oa/public/src/services/video.js +33 -0
- package/templates/template_oa/public/src/utils/.DS_Store +0 -0
- package/templates/template_oa/public/src/utils/index.js +66 -0
- package/templates/template_oa/public/static/.DS_Store +0 -0
- package/templates/template_oa/public/static/about.html +1 -0
- package/templates/template_oa/public/static/kssoLogin.html +22 -0
- package/templates/template_oa/readme.md +60 -0
- package/templates/template_oa/release/.DS_Store +0 -0
- package/templates/template_oa/report.sh +68 -0
- package/templates/template_oa/tools/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/dist/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_oa/tools/iconfont/package.json +20 -0
- package/templates/template_oa/tools/iconfont/run.sh +39 -0
- package/templates/template_oa/tools/iconfont/svg/.DS_Store +0 -0
- package/templates/template_oa/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_oa/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_oa/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_oa/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_oa/tools/iconfont/templates/index.html +56 -0
- package/templates/template_oa/tools/tinypng/.DS_Store +0 -0
- package/templates/template_oa/tools/tinypng/img/.DS_Store +0 -0
- package/templates/template_oa/tools/tinypng/package.json +11 -0
- package/templates/template_oa/tools/tinypng/run.sh +15 -0
- package/templates/template_oa/versionPublish.sh +27 -0
- package/templates/template_oa/webpack.api.js +62 -0
- package/templates/template_offcial/.gitignore +6 -0
- package/templates/template_offcial/build.sh +2 -0
- package/templates/template_offcial/cli.config.js +25 -0
- package/templates/template_offcial/dev.sh +89 -0
- package/templates/template_offcial/frontend_build.sh +83 -0
- package/templates/template_offcial/init/prepare-commit-msg +5 -0
- package/templates/template_offcial/init.sh +33 -0
- package/templates/template_offcial/jsconfig.json +10 -0
- package/templates/template_offcial/package.json +23 -0
- package/templates/template_offcial/public/404.html +26 -0
- package/templates/template_offcial/public/favicon.ico +0 -0
- package/templates/template_offcial/public/favicon.png +0 -0
- package/templates/template_offcial/public/index.html +52 -0
- package/templates/template_offcial/public/src/_antd.less +4 -0
- package/templates/template_offcial/public/src/_reset.less +130 -0
- package/templates/template_offcial/public/src/_variable.less +78 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_offcial/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_offcial/public/src/assets/images/avatar.png +0 -0
- package/templates/template_offcial/public/src/assets/images/loading.svg +40 -0
- package/templates/template_offcial/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_offcial/public/src/components/Alert/index.less +0 -0
- package/templates/template_offcial/public/src/components/Footer/index.jsx +32 -0
- package/templates/template_offcial/public/src/components/Footer/index.less +8 -0
- package/templates/template_offcial/public/src/components/Header/index.jsx +68 -0
- package/templates/template_offcial/public/src/components/Header/index.less +76 -0
- package/templates/template_offcial/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_offcial/public/src/components/IconFont/index.less +5 -0
- package/templates/template_offcial/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_offcial/public/src/components/Layout/index.jsx +20 -0
- package/templates/template_offcial/public/src/components/Layout/index.less +20 -0
- package/templates/template_offcial/public/src/components/Link/index.jsx +24 -0
- package/templates/template_offcial/public/src/components/Link/index.less +11 -0
- package/templates/template_offcial/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_offcial/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_offcial/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_offcial/public/src/components/Popup/index.less +18 -0
- package/templates/template_offcial/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_offcial/public/src/components/Toast/index.less +43 -0
- package/templates/template_offcial/public/src/hooks/index.jsx +12 -0
- package/templates/template_offcial/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_offcial/public/src/hooks/useInToView.jsx +55 -0
- package/templates/template_offcial/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_offcial/public/src/hooks/useScroll.jsx +66 -0
- package/templates/template_offcial/public/src/index.jsx +50 -0
- package/templates/template_offcial/public/src/mock/index.js +63 -0
- package/templates/template_offcial/public/src/mock/user.js +70 -0
- package/templates/template_offcial/public/src/mock/utils.js +33 -0
- package/templates/template_offcial/public/src/pages/index.jsx +23 -0
- package/templates/template_offcial/public/src/pages/index.less +0 -0
- package/templates/template_offcial/public/src/pages/mobile/index.jsx +11 -0
- package/templates/template_offcial/public/src/pages/mobile/index.less +0 -0
- package/templates/template_offcial/public/src/pages/pc/index.jsx +45 -0
- package/templates/template_offcial/public/src/pages/pc/index.less +42 -0
- package/templates/template_offcial/public/src/provider/app.jsx +26 -0
- package/templates/template_offcial/public/src/route.jsx +26 -0
- package/templates/template_offcial/public/src/services/index.js +182 -0
- package/templates/template_offcial/public/src/services/user.js +26 -0
- package/templates/template_offcial/public/src/utils/index.js +109 -0
- package/templates/template_offcial/public/static/about.html +1 -0
- package/templates/template_offcial/readme.md +59 -0
- package/templates/template_offcial/report.sh +68 -0
- package/templates/template_offcial/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_offcial/tools/iconfont/package.json +20 -0
- package/templates/template_offcial/tools/iconfont/run.sh +39 -0
- package/templates/template_offcial/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_offcial/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_offcial/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_offcial/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_offcial/tools/iconfont/templates/index.html +56 -0
- package/templates/template_offcial/tools/tinypng/package.json +11 -0
- package/templates/template_offcial/tools/tinypng/run.sh +15 -0
- package/templates/template_offcial/versionPublish.sh +27 -0
- package/templates/template_offcial/webpack.api.js +36 -0
|
@@ -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,66 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const useScroll=(targetDom='#appLayout')=>{
|
|
5
|
+
|
|
6
|
+
const [isScroll,setIsScroll] = useState(false);
|
|
7
|
+
const [listener,setListener]= useState({
|
|
8
|
+
scroll:[]
|
|
9
|
+
});
|
|
10
|
+
const [height,setHeight]= useState(0);
|
|
11
|
+
|
|
12
|
+
const refScrollDom = useRef();
|
|
13
|
+
const refSetIsScroll = useRef();
|
|
14
|
+
const refIsScroll = useRef();
|
|
15
|
+
refIsScroll.current= isScroll;
|
|
16
|
+
refSetIsScroll.current= setIsScroll;
|
|
17
|
+
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
if(typeof targetDom == 'string'){
|
|
20
|
+
refScrollDom.current = document.querySelector(targetDom);
|
|
21
|
+
}else{
|
|
22
|
+
refScrollDom.current = targetDom;
|
|
23
|
+
}
|
|
24
|
+
let dom = refScrollDom.current;
|
|
25
|
+
setHeight(dom.clientHeight)
|
|
26
|
+
|
|
27
|
+
const fn=(e)=>{
|
|
28
|
+
if(e.target.scrollTop>0){
|
|
29
|
+
if(!refIsScroll.current){
|
|
30
|
+
refSetIsScroll.current(true);
|
|
31
|
+
}
|
|
32
|
+
}else{
|
|
33
|
+
if(refIsScroll.current){
|
|
34
|
+
refSetIsScroll.current(false);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
listener.scroll.forEach(fn=>{
|
|
38
|
+
fn(e.target.scrollTop);
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
dom.addEventListener('scroll',fn);
|
|
42
|
+
return ()=>{
|
|
43
|
+
dom.removeEventListener('scroll',fn);
|
|
44
|
+
}
|
|
45
|
+
},[]);
|
|
46
|
+
|
|
47
|
+
const addEventListener=(type,callback)=>{
|
|
48
|
+
listener[type].push(callback);
|
|
49
|
+
setListener({...listener})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const removeEventListener=(type,callback)=>{
|
|
53
|
+
let list = listener[type];
|
|
54
|
+
for(let i=0;i<list.length;i++){
|
|
55
|
+
if(list[i]==callback){
|
|
56
|
+
list.splice(i,1);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
setListener({...listener})
|
|
61
|
+
}
|
|
62
|
+
return {isScroll,height,addEventListener,removeEventListener}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default useScroll;
|
|
@@ -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'){
|
|
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)} />);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import mock from 'mockjs-async';
|
|
2
|
+
|
|
3
|
+
import user from './user.js';
|
|
4
|
+
function regMock(list){
|
|
5
|
+
if(list){
|
|
6
|
+
let keys = Object.keys(list)
|
|
7
|
+
keys.map(key=>{
|
|
8
|
+
let pattern;
|
|
9
|
+
if(typeof key === 'string'){
|
|
10
|
+
pattern = new RegExp(key)
|
|
11
|
+
}else{
|
|
12
|
+
pattern=key;
|
|
13
|
+
}
|
|
14
|
+
let config = list[key];
|
|
15
|
+
if(typeof config == 'function'){
|
|
16
|
+
console.log(`[mock]注册 ()${pattern}`)
|
|
17
|
+
mock.mock(pattern,(options)=>{
|
|
18
|
+
return new Promise(reslove=>{
|
|
19
|
+
if(config){
|
|
20
|
+
config(options).then(ret=>{
|
|
21
|
+
console.log(`[mock]response ()${pattern}`,options,ret)
|
|
22
|
+
reslove(ret);
|
|
23
|
+
});
|
|
24
|
+
}else{
|
|
25
|
+
reslove();
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
i
|
|
29
|
+
});
|
|
30
|
+
}else{
|
|
31
|
+
let methods = Object.keys(config);
|
|
32
|
+
methods.forEach(method=>{
|
|
33
|
+
console.log(`[mock]注册 (${method})${pattern}`)
|
|
34
|
+
mock.mock(pattern,method,(options)=>{
|
|
35
|
+
return new Promise(reslove=>{
|
|
36
|
+
if(config[method]){
|
|
37
|
+
config[method](options).then(ret=>{
|
|
38
|
+
console.log(`[mock]response (${method})${pattern}`,options,ret)
|
|
39
|
+
reslove(ret);
|
|
40
|
+
});
|
|
41
|
+
}else{
|
|
42
|
+
reslove();
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
i
|
|
46
|
+
});
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/* eslint-disable */
|
|
54
|
+
if(MOCK){
|
|
55
|
+
console.log(`=========MOCK OPEN=======`)
|
|
56
|
+
regMock(user);
|
|
57
|
+
}else{
|
|
58
|
+
console.log(`=========MOCK CLOSE=======`)
|
|
59
|
+
}
|
|
60
|
+
/* eslint-enable */
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export default {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {waitTime,REP_SUCCESS} from './utils.js';
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import {GET_REQUEST} from './utils';
|
|
4
|
+
async function GET_USER(req,res){
|
|
5
|
+
const query = qs.parse(req.url.split('?')[1]);
|
|
6
|
+
const {name} = query;
|
|
7
|
+
await waitTime();
|
|
8
|
+
return {code:0,data:{name}}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function SET_USER(req,res){
|
|
12
|
+
const query = JSON.parse(req.body);
|
|
13
|
+
const {name,age}= query;
|
|
14
|
+
await waitTime();
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
"code": 0,
|
|
18
|
+
"data":{name,age}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function GET_USER_LIST(req,res){
|
|
23
|
+
const {current,pageSize} = GET_REQUEST(req,res);
|
|
24
|
+
const MAX_TOTAL=98;
|
|
25
|
+
let data=[];
|
|
26
|
+
let idx=(current-1)*pageSize;
|
|
27
|
+
|
|
28
|
+
for(let i=0;i<pageSize;i++){
|
|
29
|
+
if(idx>=MAX_TOTAL)break;
|
|
30
|
+
data.push({
|
|
31
|
+
name:`${idx++}小朋友`
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
code:0,
|
|
36
|
+
data:{
|
|
37
|
+
list:data,
|
|
38
|
+
page:{
|
|
39
|
+
pageNum:current,
|
|
40
|
+
pageSize:pageSize,
|
|
41
|
+
total:MAX_TOTAL
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function GET_USER_TYPE(req,res){
|
|
48
|
+
let data=[];
|
|
49
|
+
for(let i=0;i<10;i++){
|
|
50
|
+
data.push({
|
|
51
|
+
label:`标题${i}`,
|
|
52
|
+
value:i,
|
|
53
|
+
key:`title${i}`
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
code:0,
|
|
58
|
+
data:data
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
'/userType':{get:GET_USER_TYPE},
|
|
67
|
+
'/userList':{get:GET_USER_LIST},
|
|
68
|
+
'/user':{get:GET_USER,post:SET_USER},
|
|
69
|
+
|
|
70
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import qs from 'qs';
|
|
2
|
+
|
|
3
|
+
export const waitTime = (time = 500) => {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
resolve(true);
|
|
7
|
+
}, time);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const REP_SUCCESS=async (req,res)=>{
|
|
13
|
+
await waitTime();
|
|
14
|
+
return res.json({code:0,data:{}})
|
|
15
|
+
}
|
|
16
|
+
export const REP_FAIL=async (req,res)=>{
|
|
17
|
+
await waitTime();
|
|
18
|
+
return res.json({code:1,message:'mock失败',data:{}})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const REP_500=async (req,res)=>{
|
|
22
|
+
await waitTime();
|
|
23
|
+
// console.log(res);
|
|
24
|
+
return res.status(500).send({})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export const GET_REQUEST=(req)=>{
|
|
29
|
+
if(req.type=='GET'){
|
|
30
|
+
return qs.parse(req.url.split('?')[1]);
|
|
31
|
+
}
|
|
32
|
+
return JSON.parse(req.body);
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { isMobile } from '@/utils';
|
|
3
|
+
import { useNavigate } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const Home = () => {
|
|
9
|
+
console.log('🌹🌹🌹 Home 🌹🌹🌹')
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const flag = isMobile();
|
|
13
|
+
if(flag){
|
|
14
|
+
navigate('/mobile')
|
|
15
|
+
}else{
|
|
16
|
+
navigate('/pc');
|
|
17
|
+
}
|
|
18
|
+
}, [])
|
|
19
|
+
|
|
20
|
+
return <span>home</span>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default Home;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import Header from '@/components/Header';
|
|
4
|
+
import styles from './index.less';
|
|
5
|
+
import Footer from '@/components/Footer';
|
|
6
|
+
import useInToView from '@/hooks/useInToView';
|
|
7
|
+
|
|
8
|
+
const PcHome=()=>{
|
|
9
|
+
console.log('🌹🌹🌹 PC 🌹🌹🌹')
|
|
10
|
+
const intoViewBlock4= useInToView();
|
|
11
|
+
const intoViewBlock3= useInToView();
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
console.log('pc home effect');
|
|
16
|
+
intoViewBlock4.watch('#block4');
|
|
17
|
+
intoViewBlock3.watch('#block3');
|
|
18
|
+
},[])
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Header />
|
|
24
|
+
<section className={styles.bodyWrap}>
|
|
25
|
+
|
|
26
|
+
<section className={styles.contentWrap}>
|
|
27
|
+
|
|
28
|
+
<div className={styles.blockWrap} id='block1'>
|
|
29
|
+
模块
|
|
30
|
+
</div>
|
|
31
|
+
<div className={styles.stickyHeader}>粘顶模块</div>
|
|
32
|
+
|
|
33
|
+
<div className={styles.blockWrap} id='block2'>模块2</div>
|
|
34
|
+
<div className={`${styles.blockWrap} ${styles.animationIn}`} id='block3' data-visible={intoViewBlock3.visibled}>模块3</div>
|
|
35
|
+
<div className={`${styles.blockWrap} ${styles.animationIn}`} id='block4' data-visible={intoViewBlock4.visibled}>模块4</div>
|
|
36
|
+
</section>
|
|
37
|
+
<Footer />
|
|
38
|
+
</section>
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
</>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default PcHome;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
@import '~@/_variable.less';
|
|
2
|
+
|
|
3
|
+
.bodyWrap{
|
|
4
|
+
width: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: center;
|
|
8
|
+
background-color: #fcfcfc;
|
|
9
|
+
.contentWrap{
|
|
10
|
+
background-color: #f2f2f2;
|
|
11
|
+
min-width: var(--body-min-width);
|
|
12
|
+
max-width: var(--body-max-width);
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
padding-top:var(--height-header);
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
.blockWrap{
|
|
21
|
+
width: 1100px;
|
|
22
|
+
min-height:800px;
|
|
23
|
+
border:1px solid #ccc;
|
|
24
|
+
}
|
|
25
|
+
.stickyHeader{
|
|
26
|
+
width: 1100px;
|
|
27
|
+
height:60px;
|
|
28
|
+
box-shadow: 0 0 4px 0 #e89c55;
|
|
29
|
+
position: sticky;
|
|
30
|
+
top:var(--height-header);
|
|
31
|
+
backdrop-filter: blur(4px);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.animationIn{
|
|
35
|
+
transition: all .5s ease-in-out;
|
|
36
|
+
margin-top:100px;
|
|
37
|
+
opacity: 0;
|
|
38
|
+
&[data-visible='true']{
|
|
39
|
+
margin-top:0;
|
|
40
|
+
opacity: 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState,useMemo, useEffect } from 'react';
|
|
2
|
+
import { useSearchParams,useNavigate } from 'react-router-dom';
|
|
3
|
+
import { createContainer } from "unstated-next"
|
|
4
|
+
|
|
5
|
+
const useApp=() =>{
|
|
6
|
+
const navigate= useNavigate();
|
|
7
|
+
const [loading,setLoading] = useState(true);
|
|
8
|
+
const [nav,setNavConfig] = useState({visible:true,syncDocumentTitle:false});
|
|
9
|
+
const setNav=(config)=>{
|
|
10
|
+
setNavConfig({...nav,...config});
|
|
11
|
+
}
|
|
12
|
+
const action=useMemo(()=>{
|
|
13
|
+
return {
|
|
14
|
+
loading,
|
|
15
|
+
setLoading,
|
|
16
|
+
nav,
|
|
17
|
+
setNav,
|
|
18
|
+
}
|
|
19
|
+
},[loading,nav,setNav]);
|
|
20
|
+
|
|
21
|
+
return action
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const App = createContainer(useApp);
|
|
25
|
+
|
|
26
|
+
export default App;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React,{Suspense} from 'react';
|
|
2
|
+
import { Routes, Route } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import {Layout} from '@/components/Layout';
|
|
5
|
+
import PageLoading from '@/components/Page/PageLoading';
|
|
6
|
+
|
|
7
|
+
import Home from '@/pages/index.jsx';
|
|
8
|
+
|
|
9
|
+
const Pc = React.lazy(()=>import('@/pages/pc'));
|
|
10
|
+
const Mobile = React.lazy(()=>import('@/pages/mobile'));
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export const RouteList = (
|
|
14
|
+
<Routes>
|
|
15
|
+
<Route path='/' element={<Home />} />
|
|
16
|
+
<Route path='/' element={
|
|
17
|
+
<Suspense fallback={<PageLoading />}>
|
|
18
|
+
<Layout />
|
|
19
|
+
</Suspense>
|
|
20
|
+
}>
|
|
21
|
+
<Route path='/pc' element={<Pc />} />
|
|
22
|
+
<Route path='/mobile' element={<Mobile />} />
|
|
23
|
+
</Route>
|
|
24
|
+
</Routes>
|
|
25
|
+
);
|
|
26
|
+
|