kn-cli 1.0.43 → 1.0.45
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/utils/index.js +1 -1
- package/templates/template_admin/.gitignore +6 -0
- package/templates/template_admin/build.sh +2 -0
- package/templates/template_admin/cli.config.js +21 -0
- package/templates/template_admin/dev.sh +89 -0
- package/templates/template_admin/frontend_build.sh +83 -0
- package/templates/template_admin/init/prepare-commit-msg +5 -0
- package/templates/template_admin/init.sh +33 -0
- package/templates/template_admin/package.json +23 -0
- package/templates/template_admin/public/404.html +26 -0
- package/templates/template_admin/public/favicon.ico +0 -0
- package/templates/template_admin/public/favicon.png +0 -0
- package/templates/template_admin/public/index.html +43 -0
- package/templates/template_admin/public/src/_antd.less +4 -0
- package/templates/template_admin/public/src/_reset.less +128 -0
- package/templates/template_admin/public/src/_variable.less +80 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.eot +0 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.less +57 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.svg +36 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.ttf +0 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.woff +0 -0
- package/templates/template_admin/public/src/assets/iconfont/iconfont.woff2 +0 -0
- package/templates/template_admin/public/src/assets/images/avatar.png +0 -0
- package/templates/template_admin/public/src/assets/images/loading.svg +40 -0
- package/templates/template_admin/public/src/components/Alert/index.jsx +0 -0
- package/templates/template_admin/public/src/components/Alert/index.less +0 -0
- package/templates/template_admin/public/src/components/Auth/index.jsx +44 -0
- package/templates/template_admin/public/src/components/Header/index.jsx +57 -0
- package/templates/template_admin/public/src/components/Header/index.less +57 -0
- package/templates/template_admin/public/src/components/IconFont/index.jsx +10 -0
- package/templates/template_admin/public/src/components/IconFont/index.less +5 -0
- package/templates/template_admin/public/src/components/Layout/Basic/index.jsx +26 -0
- package/templates/template_admin/public/src/components/Layout/Basic/index.less +37 -0
- package/templates/template_admin/public/src/components/Layout/CenterBody/index.jsx +15 -0
- package/templates/template_admin/public/src/components/Layout/CenterBody/index.less +30 -0
- package/templates/template_admin/public/src/components/Layout/Provider/index.jsx +12 -0
- package/templates/template_admin/public/src/components/Layout/index.jsx +27 -0
- package/templates/template_admin/public/src/components/Layout/index.less +63 -0
- package/templates/template_admin/public/src/components/Link/index.jsx +24 -0
- package/templates/template_admin/public/src/components/Link/index.less +11 -0
- package/templates/template_admin/public/src/components/Loading/index.jsx +14 -0
- package/templates/template_admin/public/src/components/Loading/index.less +85 -0
- package/templates/template_admin/public/src/components/Menu/index.jsx +126 -0
- package/templates/template_admin/public/src/components/Menu/index.less +19 -0
- package/templates/template_admin/public/src/components/Page/PageLoading/index.jsx +30 -0
- package/templates/template_admin/public/src/components/Page/PageLoading/index.less +29 -0
- package/templates/template_admin/public/src/components/Popup/index.jsx +22 -0
- package/templates/template_admin/public/src/components/Popup/index.less +18 -0
- package/templates/template_admin/public/src/components/Toast/index.jsx +60 -0
- package/templates/template_admin/public/src/components/Toast/index.less +43 -0
- package/templates/template_admin/public/src/components/TopMenu/index.jsx +228 -0
- package/templates/template_admin/public/src/components/TopMenu/index.less +105 -0
- package/templates/template_admin/public/src/components/mask/index.jsx +47 -0
- package/templates/template_admin/public/src/components/mask/index.less +32 -0
- package/templates/template_admin/public/src/dictionary/index.js +103 -0
- package/templates/template_admin/public/src/hooks/index.jsx +18 -0
- package/templates/template_admin/public/src/hooks/useDelay.jsx +29 -0
- package/templates/template_admin/public/src/hooks/useImageLoader.jsx +27 -0
- package/templates/template_admin/public/src/hooks/useLoading.jsx +42 -0
- package/templates/template_admin/public/src/hooks/useLogin.jsx +33 -0
- package/templates/template_admin/public/src/hooks/useNextPage.jsx +89 -0
- package/templates/template_admin/public/src/hooks/usePreload.jsx +66 -0
- package/templates/template_admin/public/src/hooks/useScrollTop.jsx +32 -0
- package/templates/template_admin/public/src/hooks/useSearch.jsx +137 -0
- package/templates/template_admin/public/src/hooks/useUpdate.jsx +11 -0
- package/templates/template_admin/public/src/index.jsx +50 -0
- package/templates/template_admin/public/src/mock/auth.js +91 -0
- package/templates/template_admin/public/src/mock/index.js +63 -0
- package/templates/template_admin/public/src/mock/user.js +70 -0
- package/templates/template_admin/public/src/mock/utils.js +33 -0
- package/templates/template_admin/public/src/pages/checkLogin/index.jsx +13 -0
- package/templates/template_admin/public/src/pages/index.jsx +23 -0
- package/templates/template_admin/public/src/pages/index.less +22 -0
- package/templates/template_admin/public/src/pages/login/index.jsx +27 -0
- package/templates/template_admin/public/src/pages/login/index.less +44 -0
- package/templates/template_admin/public/src/pages/material/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/order/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/permission/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/subHome/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/subHome2/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/subHome3/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/suggest/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/superAdminLogin/index.jsx +57 -0
- package/templates/template_admin/public/src/pages/superAdminLogin/index.less +44 -0
- package/templates/template_admin/public/src/pages/user/index.jsx +13 -0
- package/templates/template_admin/public/src/pages/userData/index.jsx +12 -0
- package/templates/template_admin/public/src/pages/video/index.jsx +12 -0
- package/templates/template_admin/public/src/provider/app.jsx +119 -0
- package/templates/template_admin/public/src/provider/menu.jsx +20 -0
- package/templates/template_admin/public/src/route.jsx +77 -0
- package/templates/template_admin/public/src/services/auth.js +28 -0
- package/templates/template_admin/public/src/services/index.js +181 -0
- package/templates/template_admin/public/src/services/user.js +26 -0
- package/templates/template_admin/public/src/utils/index.js +38 -0
- package/templates/template_admin/public/static/about.html +1 -0
- package/templates/template_admin/public/static/kssoLogin.html +22 -0
- package/templates/template_admin/readme.md +55 -0
- package/templates/template_admin/report.sh +68 -0
- package/templates/template_admin/tools/iconfont/gulpfile.js +70 -0
- package/templates/template_admin/tools/iconfont/package.json +20 -0
- package/templates/template_admin/tools/iconfont/run.sh +39 -0
- package/templates/template_admin/tools/iconfont/svg/arrowBack.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/check.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/close.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/down.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/image.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/play.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/refresh.svg +1 -0
- package/templates/template_admin/tools/iconfont/svg/warn.svg +1 -0
- package/templates/template_admin/tools/iconfont/templates/_icons.css +26 -0
- package/templates/template_admin/tools/iconfont/templates/_icons.less +29 -0
- package/templates/template_admin/tools/iconfont/templates/index.html +56 -0
- package/templates/template_admin/tools/tinypng/package.json +11 -0
- package/templates/template_admin/tools/tinypng/run.sh +15 -0
- package/templates/template_admin/webpack.api.js +33 -0
- package/templates/template_app/.gitignore +6 -0
|
@@ -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('/login');
|
|
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,77 @@
|
|
|
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 Login from '@/pages/login';
|
|
8
|
+
import {AuthLogin} from '@/components/Auth';
|
|
9
|
+
import LeftMenu from '@/components/Menu';
|
|
10
|
+
import TopMenu from '@/components/TopMenu';
|
|
11
|
+
|
|
12
|
+
import ProviderMenu from '@/provider/menu';
|
|
13
|
+
|
|
14
|
+
const delayLoader=(loader)=>{
|
|
15
|
+
return new Promise(resolve=>{
|
|
16
|
+
loader.then(req=>{
|
|
17
|
+
setTimeout(()=>{
|
|
18
|
+
resolve(req);
|
|
19
|
+
},5000)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// /*webpackChunkName:'subGroup'*/
|
|
25
|
+
const Home = React.lazy(()=>import('@/pages/index.jsx'));
|
|
26
|
+
const SubHome = React.lazy(()=>import('@/pages/subHome'));
|
|
27
|
+
const SubHome2 = React.lazy(()=>import('@/pages/subHome2'));
|
|
28
|
+
const SubHome3 = React.lazy(()=>import('@/pages/subHome3'));
|
|
29
|
+
const CheckLogin = React.lazy(()=>import('@/pages/checkLogin'));
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const Video = React.lazy(()=>import('@/pages/video'));
|
|
33
|
+
const Suggest = React.lazy(()=>import('@/pages/suggest'));
|
|
34
|
+
const Order = React.lazy(()=>import('@/pages/order'));
|
|
35
|
+
const Permission = React.lazy(()=>import('@/pages/permission'));
|
|
36
|
+
const Material = React.lazy(()=>import('@/pages/material'));
|
|
37
|
+
|
|
38
|
+
const User = React.lazy(()=>import('@/pages/user'));
|
|
39
|
+
const UserData = React.lazy(()=>import('@/pages/userData'));
|
|
40
|
+
|
|
41
|
+
import SuperAdminLogin from '@/pages/superAdminLogin';
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export const RouteList = (
|
|
47
|
+
<Routes>
|
|
48
|
+
<Route path='/' element={<Suspense fallback={<PageLoading />}><Layout /></Suspense>}>
|
|
49
|
+
<Route path='login' element={<Login />} />
|
|
50
|
+
<Route path='superAdminLogin' element={<SuperAdminLogin />} />
|
|
51
|
+
|
|
52
|
+
<Route
|
|
53
|
+
path='/'
|
|
54
|
+
element={
|
|
55
|
+
<ProviderMenu.Provider>
|
|
56
|
+
<LayoutBasic nav={<LeftMenu />}topMenu={<TopMenu />} />
|
|
57
|
+
</ProviderMenu.Provider>
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<Route path='/' element={<Navigate to="/video"></Navigate> } />
|
|
61
|
+
<Route path='/video' element={<Video />} />
|
|
62
|
+
<Route path='/suggest' element={<Suggest />} />
|
|
63
|
+
<Route path='/order' element={<Order />} />
|
|
64
|
+
<Route path='/permission' element={<Permission />} />
|
|
65
|
+
<Route path='/material' element={<Material />} />
|
|
66
|
+
<Route path='/user' element={<User />} />
|
|
67
|
+
<Route path='/userData' element={<UserData />} />
|
|
68
|
+
|
|
69
|
+
{/* <Route path='/home/sub' element={<SubHome />} />
|
|
70
|
+
<Route path='/home/sub/:id' element={<Suspense fallback={<PageLoading />}><SubHome2 /></Suspense>} />
|
|
71
|
+
<Route path='/home/sub3/:id' element={<SubHome3 />} />
|
|
72
|
+
<Route path='/checkLogin' element={<AuthLogin><CheckLogin /></AuthLogin>} /> */}
|
|
73
|
+
</Route>
|
|
74
|
+
</Route>
|
|
75
|
+
</Routes>
|
|
76
|
+
);
|
|
77
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {GET_DEFAULT,API_ROOT,POST_DEFAULT} from './index.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export function GET_MENU(){
|
|
6
|
+
return GET_DEFAULT(`${API_ROOT}/api/menu/nav`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export function KSSO_LOGIN(params={
|
|
12
|
+
code:'',
|
|
13
|
+
redirectUri:'',
|
|
14
|
+
}){
|
|
15
|
+
return POST_DEFAULT(`${API_ROOT}/api/ksso/auth`,params)
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function LOGIN(params={
|
|
20
|
+
username:'',
|
|
21
|
+
password:'',
|
|
22
|
+
}){
|
|
23
|
+
return POST_DEFAULT(`${API_ROOT}/api/login`,params)
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
export function LOGOUT(){
|
|
27
|
+
return POST_DEFAULT(`${API_ROOT}/api/logout`)
|
|
28
|
+
}
|
|
@@ -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,38 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export const openLink = (link, target = '_blank') => {
|
|
4
|
+
let domLink = document.createElement('a');
|
|
5
|
+
domLink.href = link;
|
|
6
|
+
domLink.setAttribute('target', target);
|
|
7
|
+
domLink.style.opacity = 0;
|
|
8
|
+
domLink.style.zIndex = -999;
|
|
9
|
+
document.body.appendChild(domLink);
|
|
10
|
+
domLink.click();
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
document.body.removeChild(domLink);
|
|
13
|
+
}, 200);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const isMobile = () => {
|
|
17
|
+
return navigator.userAgent.match(
|
|
18
|
+
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const jumpUrl=(url,options={})=>{
|
|
23
|
+
const {replace,newWindow,reload}= options;
|
|
24
|
+
if(reload){
|
|
25
|
+
location.reload();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if(replace){
|
|
29
|
+
location.replace(url);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if(newWindow){
|
|
33
|
+
window.open(url);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
location.href=url;
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport"
|
|
7
|
+
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no,viewport-fit=cover" />
|
|
8
|
+
<meta name="format-detection" content="telephone=no,email=no,adress=no">
|
|
9
|
+
<meta name="apple-touch-fullscreen" content="yes">
|
|
10
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
11
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
12
|
+
<title></title>
|
|
13
|
+
<script>
|
|
14
|
+
var url = location.protocol + '//' + location.host+'/#/login';
|
|
15
|
+
location.replace('https://ksso.kingnet.com/oauth2/auth?client_id=30000655&response_type=code&redirect_uri=' + encodeURIComponent(url));
|
|
16
|
+
</script>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
</body>
|
|
21
|
+
|
|
22
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# oa-app
|
|
2
|
+
|
|
3
|
+
### 初始化项目
|
|
4
|
+
git仓库建立完毕后,执行`sh init.sh`
|
|
5
|
+
|
|
6
|
+
### 本地调试
|
|
7
|
+
kn-cli --dev
|
|
8
|
+
|
|
9
|
+
### 生产环境部署
|
|
10
|
+
1. 向运维申请CICD环境,申请模板如下:
|
|
11
|
+
```
|
|
12
|
+
标题:应用申请
|
|
13
|
+
|
|
14
|
+
内容:
|
|
15
|
+
应用名称: 自定义名称
|
|
16
|
+
域名:自定义域名
|
|
17
|
+
用途:说明文本
|
|
18
|
+
|
|
19
|
+
仓库地址:项目仓库地址
|
|
20
|
+
环境要求:node 16.18.0
|
|
21
|
+
构建方式:执行仓库下 sh frontend_build.sh
|
|
22
|
+
部署方式:将构建完成的文件夹下的 `release` 内的内容部署到目标服务器
|
|
23
|
+
参考应用:oa-app
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
2. 进入CICD,构建相应环境
|
|
27
|
+
3. 快速发布
|
|
28
|
+
4. 进入域名访问
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### 目录介绍
|
|
32
|
+
|
|
33
|
+
* static: 不参与打包,会在打包后将整个文件夹复制到站点根目录下
|
|
34
|
+
* src: 所有源码放在这个下面
|
|
35
|
+
* assets: 站点内用到的静态资源文件
|
|
36
|
+
* components: 通用性组件
|
|
37
|
+
* dictionary: 字典
|
|
38
|
+
* hooks: 所用的hooks
|
|
39
|
+
* mock: 接口mock配置
|
|
40
|
+
* pages: 所有页面源代码
|
|
41
|
+
* pageName: 每个页面自己名称的文件夹
|
|
42
|
+
* components: 页面自己的组件
|
|
43
|
+
* components: 跨页面使用的组件
|
|
44
|
+
* provider: 全局的provider通信组件
|
|
45
|
+
* services: 所有接口服务
|
|
46
|
+
* utils: 全局通用的工具类
|
|
47
|
+
* _variable.less: 全局通用less变量
|
|
48
|
+
* _reset.less: 站点初始化less配置
|
|
49
|
+
* index.jsx: 站点入口
|
|
50
|
+
* route.jsx: 站点路由配置
|
|
51
|
+
* pluginjs: 第三方静态引入的js库
|
|
52
|
+
* tools: 构建工具
|
|
53
|
+
* iconfont: 构建Iconfont工具
|
|
54
|
+
* tinypng: 压缩png工具
|
|
55
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
if [ -d "${HOME}/.nvm/" ]
|
|
2
|
+
then
|
|
3
|
+
. ${HOME}/.nvm/nvm.sh
|
|
4
|
+
fi
|
|
5
|
+
|
|
6
|
+
node_version="v16.18.0"
|
|
7
|
+
|
|
8
|
+
checkNode(){
|
|
9
|
+
for line in `node -v`
|
|
10
|
+
do
|
|
11
|
+
if [ $line != $node_version ]
|
|
12
|
+
then
|
|
13
|
+
echo "change Node from $line to $node_version"
|
|
14
|
+
nvm use $node_version
|
|
15
|
+
ret=$?
|
|
16
|
+
if [ $ret != 0 ]
|
|
17
|
+
then
|
|
18
|
+
echo "Please run nvm install $node_version"
|
|
19
|
+
exit 3
|
|
20
|
+
else
|
|
21
|
+
return 0
|
|
22
|
+
fi
|
|
23
|
+
else
|
|
24
|
+
return 0
|
|
25
|
+
fi
|
|
26
|
+
done
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
checkResult(){
|
|
30
|
+
ret=$?
|
|
31
|
+
if [ $ret != 0 ]
|
|
32
|
+
then
|
|
33
|
+
echo "[$1]执行失败"
|
|
34
|
+
exit 2
|
|
35
|
+
return 0
|
|
36
|
+
else
|
|
37
|
+
echo "[$1]执行成功"
|
|
38
|
+
return 0
|
|
39
|
+
fi
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
checkKnCli(){
|
|
44
|
+
if ! [ -x "$(command -v kn-cli)" ]
|
|
45
|
+
then
|
|
46
|
+
npm i kn-cli -g
|
|
47
|
+
return 0
|
|
48
|
+
fi
|
|
49
|
+
return 0
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
build(){
|
|
54
|
+
npm config delete registry -g
|
|
55
|
+
npm config delete registry
|
|
56
|
+
|
|
57
|
+
checkKnCli
|
|
58
|
+
checkResult "检查kn-cli"
|
|
59
|
+
|
|
60
|
+
kn-cli --report
|
|
61
|
+
checkResult "kn-cli --report"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
checkNode
|
|
65
|
+
checkResult "检查node"
|
|
66
|
+
|
|
67
|
+
build
|
|
68
|
+
checkResult "build"
|