kn-cli 1.0.90 → 1.0.91
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 +1 -1
- package/readme.md +4 -0
- package/src/create.js +22 -2
- package/src/utils/index.js +1 -1
- package/templates/template_admin/cli.config.js +1 -1
- package/templates/template_admin/jsconfig.json +5 -1
- package/templates/template_admin/package.json +1 -1
- package/templates/template_admin/public/index.html +2 -2
- package/templates/template_admin/public/src/components/{Auth → auth}/index.jsx +21 -3
- package/templates/template_admin/public/src/components/{IconFont → iconFont}/index.jsx +10 -0
- package/templates/template_admin/public/src/components/{Layout/Basic → layout/basic}/index.jsx +13 -3
- package/templates/template_admin/public/src/components/layout/centerBody/index.jsx +25 -0
- package/templates/template_admin/public/src/components/{Layout → layout}/index.jsx +15 -6
- package/templates/{template_offcial/public/src/components/Layout/Provider → template_admin/public/src/components/layout/provider}/index.jsx +8 -1
- package/templates/{template_app/public/src/components/Link → template_admin/public/src/components/link}/index.jsx +15 -0
- package/templates/template_admin/public/src/components/{Menu → menu}/index.jsx +15 -8
- package/templates/template_admin/public/src/components/{Page/PageLoading → page/pageLoading}/index.jsx +25 -4
- package/templates/template_admin/public/src/components/{Popup → popup}/index.jsx +13 -0
- package/templates/{template_app/public/src/components/Toast → template_admin/public/src/components/toast}/index.jsx +20 -1
- package/templates/template_admin/public/src/components/{TopMenu → topMenu}/index.jsx +13 -8
- package/templates/template_admin/public/src/dictionary/index.js +8 -3
- package/templates/template_admin/public/src/hooks/index.jsx +1 -0
- package/templates/template_admin/public/src/hooks/useDelay.jsx +5 -0
- package/templates/template_admin/public/src/hooks/useImageLoader.jsx +1 -2
- package/templates/template_admin/public/src/hooks/useLoading.jsx +5 -1
- package/templates/template_admin/public/src/hooks/usePreload.jsx +2 -1
- package/templates/template_admin/public/src/hooks/useScrollTop.jsx +12 -0
- package/templates/template_admin/public/src/hooks/useSearch.jsx +28 -2
- package/templates/template_admin/public/src/hooks/useUpdate.jsx +5 -0
- package/templates/template_admin/public/src/index.jsx +16 -2
- package/templates/template_admin/public/src/pages/material/index.jsx +2 -1
- package/templates/template_admin/public/src/pages/user/index.jsx +7 -2
- package/templates/template_admin/public/src/provider/app.jsx +39 -4
- package/templates/template_admin/public/src/provider/menu.jsx +4 -1
- package/templates/template_admin/public/src/route.jsx +8 -5
- package/templates/template_admin/public/src/services/index.js +38 -4
- package/templates/template_admin/public/src/services/user.js +3 -3
- package/templates/template_admin/public/src/type.js +48 -0
- package/templates/template_admin/public/src/utils/index.js +34 -18
- package/templates/template_app/cli.config.js +1 -1
- package/templates/template_app/jsconfig.json +5 -1
- package/templates/template_app/package.json +1 -1
- package/templates/template_app/public/src/components/{Auth → auth}/index.jsx +20 -2
- package/templates/template_app/public/src/components/{Header → header}/index.jsx +25 -1
- package/templates/template_app/public/src/components/{IconFont → iconFont}/index.jsx +10 -0
- package/templates/template_app/public/src/components/{Layout/App → layout/app}/index.jsx +12 -2
- package/templates/template_app/public/src/components/layout/index.jsx +6 -0
- package/templates/{template_admin/public/src/components/Layout/Provider → template_app/public/src/components/layout/provider}/index.jsx +3 -0
- package/templates/template_app/public/src/components/link/index.jsx +39 -0
- package/templates/template_app/public/src/components/{Marquee → marquee}/index.jsx +11 -2
- package/templates/template_app/public/src/components/{Page/PageLoading → page/pageLoading}/index.jsx +23 -3
- package/templates/template_app/public/src/components/{Popup → popup}/index.jsx +13 -0
- package/templates/{template_offcial/public/src/components/Toast → template_app/public/src/components/toast}/index.jsx +21 -1
- package/templates/template_app/public/src/dictionary/index.js +7 -3
- package/templates/template_app/public/src/hooks/index.jsx +1 -0
- package/templates/template_app/public/src/hooks/useDelay.jsx +5 -0
- package/templates/template_app/public/src/hooks/useImageLoader.jsx +1 -2
- package/templates/template_app/public/src/hooks/useLoading.jsx +5 -1
- package/templates/template_app/public/src/hooks/usePreload.jsx +2 -1
- package/templates/template_app/public/src/hooks/useScrollTop.jsx +12 -0
- package/templates/template_app/public/src/index.jsx +22 -5
- package/templates/template_app/public/src/pages/dictionary/index.jsx +9 -1
- package/templates/template_app/public/src/pages/index.jsx +16 -4
- package/templates/template_app/public/src/pages/list/index.jsx +7 -1
- package/templates/template_app/public/src/pages/login/index.jsx +10 -4
- package/templates/template_app/public/src/pages/user/index.jsx +7 -2
- package/templates/template_app/public/src/provider/app.jsx +5 -3
- package/templates/template_app/public/src/route.jsx +5 -2
- package/templates/template_app/public/src/services/index.js +10 -8
- package/templates/template_app/public/src/services/user.js +4 -4
- package/templates/template_app/public/src/type.js +27 -0
- package/templates/template_app/public/src/utils/index.js +6 -0
- package/templates/template_oa/cli.config.js +1 -1
- package/templates/template_oa/package.json +1 -1
- package/templates/template_oa_jwt/cli.config.js +1 -1
- package/templates/template_oa_jwt/package.json +1 -1
- package/templates/template_offcial/cli.config.js +1 -1
- package/templates/template_offcial/jsconfig.json +5 -1
- package/templates/template_offcial/package.json +1 -1
- package/templates/template_offcial/public/src/components/{Footer → footer}/index.jsx +15 -1
- package/templates/template_offcial/public/src/components/{Header → header}/index.jsx +14 -0
- package/templates/template_offcial/public/src/components/{IconFont → iconFont}/index.jsx +10 -0
- package/templates/template_offcial/public/src/components/{Layout → layout}/index.jsx +10 -3
- package/templates/{template_app/public/src/components/Layout/Provider → template_offcial/public/src/components/layout/provider}/index.jsx +7 -0
- package/templates/template_offcial/public/src/components/link/index.jsx +39 -0
- package/templates/template_offcial/public/src/components/{Page/PageLoading → page/pageLoading}/index.jsx +25 -4
- package/templates/template_offcial/public/src/components/{Popup → popup}/index.jsx +13 -0
- package/templates/{template_admin/public/src/components/Toast → template_offcial/public/src/components/toast}/index.jsx +20 -1
- package/templates/template_offcial/public/src/hooks/index.jsx +1 -0
- package/templates/template_offcial/public/src/hooks/useImageLoader.jsx +1 -0
- package/templates/template_offcial/public/src/hooks/useInToView.jsx +3 -0
- package/templates/template_offcial/public/src/hooks/usePreload.jsx +1 -0
- package/templates/template_offcial/public/src/hooks/useScroll.jsx +8 -0
- package/templates/template_offcial/public/src/index.jsx +15 -2
- package/templates/template_offcial/public/src/pages/index.jsx +8 -1
- package/templates/template_offcial/public/src/pages/pc/index.jsx +4 -2
- package/templates/template_offcial/public/src/provider/app.jsx +28 -2
- package/templates/template_offcial/public/src/route.jsx +4 -2
- package/templates/template_offcial/public/src/services/index.js +38 -2
- package/templates/template_offcial/public/src/services/user.js +3 -3
- package/templates/template_offcial/public/src/type.js +47 -0
- package/src/.DS_Store +0 -0
- package/templates/template_admin/.gitignore +0 -6
- 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/Header/index.jsx +0 -57
- package/templates/template_admin/public/src/components/Layout/CenterBody/index.jsx +0 -15
- package/templates/template_admin/public/src/components/Link/index.jsx +0 -24
- package/templates/template_admin/public/src/components/Loading/index.jsx +0 -14
- package/templates/template_admin/public/src/components/Loading/index.less +0 -85
- package/templates/template_admin/public/src/components/mask/index.jsx +0 -47
- package/templates/template_admin/public/src/components/mask/index.less +0 -32
- package/templates/template_admin/public/src/hooks/useLogin.jsx +0 -33
- package/templates/template_app/.gitignore +0 -6
- package/templates/template_app/public/src/components/Header/index.less +0 -57
- package/templates/template_app/public/src/components/Layout/index.jsx +0 -4
- package/templates/template_app/public/src/hooks/useLogin.jsx +0 -33
- package/templates/template_oa/.gitignore +0 -6
- package/templates/template_oa_jwt/.gitignore +0 -6
- package/templates/template_offcial/.gitignore +0 -6
- 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/Link/index.jsx +0 -24
- /package/templates/template_admin/public/src/components/{IconFont → iconFont}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Layout/Basic → layout/basic}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Layout/CenterBody → layout/centerBody}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Layout → layout}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Link → link}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Menu → menu}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Popup → popup}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{Toast → toast}/index.less +0 -0
- /package/templates/template_admin/public/src/components/{TopMenu → topMenu}/index.less +0 -0
- /package/templates/{template_admin/public/src/components/Header → template_app/public/src/components/header}/index.less +0 -0
- /package/templates/template_app/public/src/components/{IconFont → iconFont}/index.less +0 -0
- /package/templates/template_app/public/src/components/{Layout/App → layout/app}/index.less +0 -0
- /package/templates/template_app/public/src/components/{Link → link}/index.less +0 -0
- /package/templates/template_app/public/src/components/{Marquee → marquee}/index.less +0 -0
- /package/templates/template_app/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
- /package/templates/template_app/public/src/components/{Popup → popup}/index.less +0 -0
- /package/templates/template_app/public/src/components/{Toast → toast}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Footer → footer}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Header → header}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{IconFont → iconFont}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Layout → layout}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Link → link}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Popup → popup}/index.less +0 -0
- /package/templates/template_offcial/public/src/components/{Toast → toast}/index.less +0 -0
package/package.json
CHANGED
package/readme.md
CHANGED
package/src/create.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const chalk= require("chalk");
|
|
3
3
|
const path= require( "path");
|
|
4
4
|
const {Listr} = require('listr2');
|
|
5
|
-
const {TaskNodeVersion,copyDir}= require('./utils');
|
|
5
|
+
const {TaskNodeVersion,copyDir,replaceFileData}= require('./utils');
|
|
6
6
|
const inquirer = require('inquirer');
|
|
7
7
|
const ROOT=path.resolve(__dirname,"../");
|
|
8
8
|
|
|
@@ -13,6 +13,7 @@ const ROOT=path.resolve(__dirname,"../");
|
|
|
13
13
|
*/
|
|
14
14
|
module.exports=async ()=> {
|
|
15
15
|
const sourceDir = process.cwd();
|
|
16
|
+
const project_name = path.parse(sourceDir).base;//新建的项目名称以当前文件夹名为名
|
|
16
17
|
const templatesDir = path.resolve(ROOT,"templates");
|
|
17
18
|
let templateName='';
|
|
18
19
|
const answer = await inquirer.prompt([
|
|
@@ -51,7 +52,26 @@ module.exports=async ()=> {
|
|
|
51
52
|
},
|
|
52
53
|
{
|
|
53
54
|
title: "项目创建中",
|
|
54
|
-
task: () =>
|
|
55
|
+
task: async () => {
|
|
56
|
+
const project_dir = path.resolve(templatesDir,templateName);
|
|
57
|
+
// 将模版复制到目标目录
|
|
58
|
+
const req= await copyDir(project_dir,sourceDir);
|
|
59
|
+
if(req){
|
|
60
|
+
// 替换工程名称
|
|
61
|
+
const cliConfigName = path.resolve(sourceDir,'cli.config.js');
|
|
62
|
+
const packageConfigName = path.resolve(sourceDir,'package.json');
|
|
63
|
+
await replaceFileData(cliConfigName,function(data){
|
|
64
|
+
data = data.replace(/projectName/ig,project_name);
|
|
65
|
+
return data;
|
|
66
|
+
});
|
|
67
|
+
await replaceFileData(packageConfigName,function(data){
|
|
68
|
+
data = data.replace(/projectName/ig,project_name);
|
|
69
|
+
return data;
|
|
70
|
+
});
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
55
75
|
},
|
|
56
76
|
]);
|
|
57
77
|
try{
|
package/src/utils/index.js
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
var docEl = document.documentElement;
|
|
22
22
|
function setRemUnit(type) {
|
|
23
23
|
let w = Math.max(window.innerWidth, docEl.clientWidth, docEl.offsetWidth);
|
|
24
|
-
let defaultWidth =
|
|
25
|
-
w = w > defaultWidth ? defaultWidth : w;
|
|
24
|
+
let defaultWidth = 1200;//填入设计稿上的宽度
|
|
25
|
+
// w = w > defaultWidth ? defaultWidth : w;
|
|
26
26
|
var rem = w / defaultWidth * 100;
|
|
27
27
|
docEl.style.fontSize = rem + 'px'
|
|
28
28
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
+
// @ts-ignore
|
|
3
4
|
import { useNavigate } from 'react-router-dom';
|
|
4
|
-
import {useLoading} from '@/hooks';
|
|
5
5
|
|
|
6
|
+
import ProviderApp from '@/provider/app';
|
|
7
|
+
import {useLoading} from '@/hooks/index';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 检查用户是否带有某个权限
|
|
11
|
+
* @param {object} props
|
|
12
|
+
* @param {string} [props.name] - 权限的名称
|
|
13
|
+
* @param {JSX.Element} [props.children] - 子组件
|
|
14
|
+
*
|
|
15
|
+
* @returns {JSX.Element}
|
|
16
|
+
*/
|
|
6
17
|
export const AuthShow=(props)=>{
|
|
7
18
|
const {name} = props;
|
|
8
19
|
const app = ProviderApp.useContainer();
|
|
@@ -12,6 +23,13 @@ export const AuthShow=(props)=>{
|
|
|
12
23
|
return <></>
|
|
13
24
|
}
|
|
14
25
|
|
|
26
|
+
/**
|
|
27
|
+
* 用户登录态校验
|
|
28
|
+
* @param {object} props
|
|
29
|
+
* @param {JSX.Element} [props.children] - 当登录校验合法后显示的子组件
|
|
30
|
+
*
|
|
31
|
+
* @returns {JSX.Element}
|
|
32
|
+
*/
|
|
15
33
|
export const AuthLogin=(props)=>{
|
|
16
34
|
const navigate = useNavigate();
|
|
17
35
|
const [pass,setPass] = useState(false)
|
|
@@ -32,7 +50,7 @@ export const AuthLogin=(props)=>{
|
|
|
32
50
|
navigate('/superAdminLogin');
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
|
-
useEffect(check,[]);
|
|
53
|
+
useEffect(()=>{check()},[]);
|
|
36
54
|
|
|
37
55
|
if(pass){
|
|
38
56
|
return props.children;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React from "react";
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import styles from'./index.less';
|
|
3
5
|
|
|
6
|
+
/**
|
|
7
|
+
* iconFont图标
|
|
8
|
+
* @param {object} props
|
|
9
|
+
* @param {string} [props.icon] - 图标名称
|
|
10
|
+
* @param {string} [props.className] - 扩展类名
|
|
11
|
+
*
|
|
12
|
+
* @returns {JSX.Element}
|
|
13
|
+
*/
|
|
4
14
|
const IconFont=(props)=>{
|
|
5
15
|
const {icon,className,...others} = props;
|
|
6
16
|
return (
|
package/templates/template_admin/public/src/components/{Layout/Basic → layout/basic}/index.jsx
RENAMED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import {Outlet} from 'react-router-dom';
|
|
3
|
-
import {LayoutCenterBody} from '@/components/Layout';
|
|
4
5
|
|
|
6
|
+
import {LayoutCenterBody} from '@/components/layout';
|
|
5
7
|
|
|
8
|
+
// @ts-ignore
|
|
6
9
|
import styles from './index.less';
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 基础页面框架
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @param {JSX.Element} [props.nav] - 左侧导航栏组件
|
|
15
|
+
* @param {JSX.Element} [props.topMenu] - 顶部导航栏组件
|
|
16
|
+
*
|
|
17
|
+
* @returns {JSX.Element}
|
|
18
|
+
*/
|
|
9
19
|
const LayoutBasic=(props)=>{
|
|
10
|
-
const {
|
|
20
|
+
const {nav="",topMenu=""} = props;
|
|
11
21
|
return (
|
|
12
22
|
<LayoutCenterBody layout='x-center'>
|
|
13
23
|
<section className={styles.wrap} >
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import styles from './index.less';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 居中定位的layout
|
|
9
|
+
* @param {object} props
|
|
10
|
+
* @param {string} [props.className] - 扩展类样式
|
|
11
|
+
* @param {string} [props.layout='normal'] - 布局样式,xy-center|x-center|y-center
|
|
12
|
+
* @param {JSX.Element|string} [props.children] - 容器内的子组件
|
|
13
|
+
*
|
|
14
|
+
* @returns {JSX.Element}
|
|
15
|
+
*/
|
|
16
|
+
const LayoutCenterBody=(props)=>{
|
|
17
|
+
const {className,layout='normal'} = props;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<section data-layout={layout} className={ className?`${styles.contentBody} ${className}`:styles.contentBody }>
|
|
21
|
+
{props.children}
|
|
22
|
+
</section>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
export default LayoutCenterBody;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
// @ts-ignore
|
|
4
4
|
import {Outlet} from 'react-router-dom';
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
import { ConfigProvider } from 'antd';
|
|
6
|
-
|
|
7
|
-
import LayoutCenterBody from './CenterBody';
|
|
7
|
+
// @ts-ignore
|
|
8
8
|
import zhCN from 'antd/lib/locale/zh_CN';
|
|
9
9
|
|
|
10
|
+
import ProviderApp from '@/provider/app';
|
|
11
|
+
import LayoutBasic from './basic/index';
|
|
12
|
+
import LayoutCenterBody from './centerBody/index';
|
|
13
|
+
|
|
14
|
+
// @ts-ignore
|
|
10
15
|
import styles from './index.less';
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
/**
|
|
18
|
+
* 页面根框架,用于注入各类provider
|
|
19
|
+
*
|
|
20
|
+
* @returns {JSX.Element}
|
|
21
|
+
*/
|
|
22
|
+
const Layout = () => {
|
|
14
23
|
return (
|
|
15
24
|
<ProviderApp.Provider>
|
|
16
25
|
<ConfigProvider locale={zhCN}>
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import {Outlet} from 'react-router-dom';
|
|
5
|
+
|
|
3
6
|
import ProviderApp from '@/provider/app';
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* 注入AppProvider
|
|
10
|
+
* @returns {JSX.Element}
|
|
11
|
+
*/
|
|
12
|
+
const LayoutProvider=()=>{
|
|
6
13
|
return (
|
|
7
14
|
<ProviderApp.Provider>
|
|
8
15
|
<Outlet />
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React from 'react';
|
|
3
|
+
|
|
2
4
|
import { openLink } from '@/utils';
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
3
7
|
import styles from './index.less';
|
|
4
8
|
|
|
9
|
+
/**
|
|
10
|
+
* 超链接组件
|
|
11
|
+
* @param {object} [props]
|
|
12
|
+
* @param {JSX.Element|string} [props.children] - 子组件
|
|
13
|
+
* @param {string} [props.className] - 扩展类样式名称
|
|
14
|
+
* @param {Function} [props.onClick] - 点击链接的回调
|
|
15
|
+
* @param {string} [props.href] - 跳转链接
|
|
16
|
+
* @param {string} [props.target] - 当target='_blank'时代表新窗口打开
|
|
17
|
+
*
|
|
18
|
+
* @returns {JSX.Element}
|
|
19
|
+
*/
|
|
5
20
|
const Link=(props)=>{
|
|
6
21
|
const {children,className='',onClick,href='',target=''} = props;
|
|
7
22
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import { Menu } from 'antd';
|
|
1
|
+
// @ts-ignore
|
|
3
2
|
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { Menu } from 'antd';
|
|
5
|
+
// @ts-ignore
|
|
4
6
|
import {matchPath,useLocation,useNavigate,} from 'react-router-dom';
|
|
7
|
+
// @ts-ignore
|
|
5
8
|
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
|
|
6
|
-
import {useDelay,useLoading} from '@/hooks';
|
|
7
|
-
import ProviderMenu from '@/provider/menu';
|
|
8
9
|
|
|
10
|
+
import {useLoading} from '@/hooks/index';
|
|
11
|
+
import ProviderMenu from '@/provider/menu';
|
|
9
12
|
|
|
13
|
+
// @ts-ignore
|
|
10
14
|
import styles from './index.less';
|
|
11
15
|
|
|
12
16
|
const ICON_NAME={
|
|
@@ -17,11 +21,14 @@ const ICON_NAME={
|
|
|
17
21
|
|
|
18
22
|
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
/**
|
|
25
|
+
* 左侧导航栏的demo组件
|
|
26
|
+
*
|
|
27
|
+
* @returns {JSX.Element}
|
|
28
|
+
*/
|
|
29
|
+
const LeftMenu=()=>{
|
|
22
30
|
|
|
23
31
|
const providerMenu = ProviderMenu.useContainer();
|
|
24
|
-
const delay = useDelay();
|
|
25
32
|
const loader = useLoading();
|
|
26
33
|
const [menus,setMenus] = useState([]);
|
|
27
34
|
const [openKeys,setOpenKeys] = useState([]);
|
|
@@ -54,7 +61,7 @@ const LeftMenu=(props)=>{
|
|
|
54
61
|
return item;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
|
|
64
|
+
// @ts-ignore
|
|
58
65
|
window.matchPath=matchPath;
|
|
59
66
|
|
|
60
67
|
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import ReactDOM from 'react-dom';
|
|
3
|
-
|
|
4
|
-
import Popup from '@/components/
|
|
5
|
+
|
|
6
|
+
import Popup from '@/components/popup';
|
|
7
|
+
|
|
8
|
+
// @ts-ignore
|
|
5
9
|
import imgLoading from '@/assets/images/loading.svg';
|
|
6
10
|
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
import CSS from './index.less';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 页面Loading状态
|
|
16
|
+
* @param {object} [props]
|
|
17
|
+
* @param {boolean} [props.visible=true] - 是否显示状态
|
|
18
|
+
*
|
|
19
|
+
* @returns {JSX.Element}
|
|
20
|
+
*/
|
|
7
21
|
const PageLoading = (props) => {
|
|
8
22
|
const {visible=true} = props;
|
|
9
23
|
if(!visible){
|
|
10
|
-
return
|
|
24
|
+
return <></>;
|
|
11
25
|
}
|
|
12
26
|
return (
|
|
13
27
|
<div className={CSS.wrap } >
|
|
@@ -18,6 +32,13 @@ const PageLoading = (props) => {
|
|
|
18
32
|
);
|
|
19
33
|
};
|
|
20
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 全屏置顶显示一个页面loading组件
|
|
37
|
+
* @param {object} [props]
|
|
38
|
+
* @param {boolean} [props.canTouch=false] - 是否允许用户点击屏幕穿透到下面的组件
|
|
39
|
+
*
|
|
40
|
+
* @returns {(string)=>void}
|
|
41
|
+
*/
|
|
21
42
|
export const ShowPageLoading=(props={canTouch:false})=>{
|
|
22
43
|
let popup = Popup(()=>{},{cantouch:props.canTouch});
|
|
23
44
|
ReactDOM.render(
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React from 'react';
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import ReactDOM from 'react-dom';
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
3
7
|
import styles from './index.less';
|
|
4
8
|
styles;
|
|
5
9
|
|
|
10
|
+
/**
|
|
11
|
+
* 一个全屏置顶的遮罩层
|
|
12
|
+
* @param {(result)=>void} reslove - 遮罩层的关闭回调
|
|
13
|
+
* @param {Object} [options] - 参数
|
|
14
|
+
* @param {boolean} [options.cantouch=false] - 是否允许被点击穿透
|
|
15
|
+
* @param {boolean} [options.transparent=false] - 是否遮罩层完全透明
|
|
16
|
+
*
|
|
17
|
+
* @returns { {dom:HTMLElement,destory:()=>void} }
|
|
18
|
+
*/
|
|
6
19
|
const Popup = (reslove,options) => {
|
|
7
20
|
let rootDom = document.createElement('div');
|
|
8
21
|
rootDom.className='popup-box';
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React,{useEffect} from 'react';
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import ReactDOM from 'react-dom';
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import Popup from '@/components/popup';
|
|
8
|
+
|
|
9
|
+
// @ts-ignore
|
|
3
10
|
import styles from './index.less';
|
|
4
|
-
import Popup from '@/components/Popup/index.jsx';
|
|
5
11
|
|
|
6
12
|
const toastList=[];
|
|
7
13
|
const runNext=()=>{
|
|
@@ -43,12 +49,25 @@ const Toast=props=>{
|
|
|
43
49
|
)
|
|
44
50
|
}
|
|
45
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @typedef {object} ToastOptions
|
|
54
|
+
* @property {string} message - 吐司文案内容
|
|
55
|
+
* @property {number} [delay=2000] - 持续时间,毫秒
|
|
56
|
+
* @property {string} [position] - 显示位置,center|top|bottom
|
|
57
|
+
* @property {Function} [resolve] - 显示完毕的回调
|
|
58
|
+
*/
|
|
46
59
|
|
|
60
|
+
/**
|
|
61
|
+
* 显示一个吐司信息
|
|
62
|
+
* @param {ToastOptions|string} [props] - 文案内容或一个配置参数
|
|
63
|
+
* @returns { Promise }
|
|
64
|
+
*/
|
|
47
65
|
const ShowToast=props=>{
|
|
48
66
|
if(typeof props === 'string'){
|
|
49
67
|
props = {message:props}
|
|
50
68
|
}
|
|
51
69
|
return new Promise((resolve) => {
|
|
70
|
+
// @ts-ignore
|
|
52
71
|
props.resolve = resolve;
|
|
53
72
|
toastList.push(props);
|
|
54
73
|
if(toastList.length===1){
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import React, { useState,useEffect, useRef} from 'react';
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import { matchPath,useLocation,useNavigate } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
import { LogoutOutlined, UserOutlined } from '@ant-design/icons';
|
|
6
|
-
|
|
7
|
-
import { Menu,Dropdown } from 'antd'
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
import { Menu,Dropdown } from 'antd';
|
|
9
|
+
|
|
8
10
|
import ProviderApp from '@/provider/app';
|
|
9
11
|
import ProviderMenu from '@/provider/menu';
|
|
10
|
-
import styles from './index.less';
|
|
11
12
|
import {GET_MENU} from '@/services/auth';
|
|
12
13
|
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
import imgAvatar from '@/assets/images/avatar.png';
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
import styles from './index.less';
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* 菜单下的隐藏子路由集
|
|
@@ -53,9 +58,9 @@ const SUB_MENU_CONFIG=[
|
|
|
53
58
|
左侧导航栏数据为顶部导航栏数据的menus内子项{label,icon,children}组成
|
|
54
59
|
routeTemplate用来识别动态参数的路由,同前端本地路由配置同步即可
|
|
55
60
|
当顶部导航栏只有一项时,将自动隐藏顶部导航菜单
|
|
56
|
-
* @returns
|
|
61
|
+
* @returns {JSX.Element}
|
|
57
62
|
*/
|
|
58
|
-
const TopMenu=(
|
|
63
|
+
const TopMenu=()=>{
|
|
59
64
|
const app = ProviderApp.useContainer();
|
|
60
65
|
const providerMenu = ProviderMenu.useContainer();
|
|
61
66
|
const curRoute = useLocation();
|
|
@@ -187,7 +192,7 @@ const TopMenu=(props)=>{
|
|
|
187
192
|
setSelectedKeys([]);
|
|
188
193
|
providerMenu.setMenus([]);
|
|
189
194
|
}
|
|
190
|
-
useEffect(loadMenu,[]);
|
|
195
|
+
useEffect(()=>{loadMenu()},[]);
|
|
191
196
|
|
|
192
197
|
useEffect(()=>{
|
|
193
198
|
reloadOpenMenu();
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import React from 'react';
|
|
4
|
+
// @ts-ignore
|
|
4
5
|
import {useDictionary} from 'kn-hooks';
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
import {GET_USER_TYPE} from '@/services/user';
|
|
8
|
+
import ShowToast from '@/components/toast';
|
|
9
|
+
|
|
6
10
|
export const SelectOption=(props)=>{
|
|
7
11
|
const {value}=props;
|
|
8
12
|
const name = props['data-keyname'];
|
|
@@ -10,6 +14,7 @@ export const SelectOption=(props)=>{
|
|
|
10
14
|
ShowToast(`点击option name=${name},value=${value},label=${props.children}`)
|
|
11
15
|
if(props.onClick)props.onClick();
|
|
12
16
|
}
|
|
17
|
+
// @ts-ignore
|
|
13
18
|
return <hgroup onClick={onClick} key={value} name={name} value={value}>{props.children}</hgroup>
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import { useRef,useState,useMemo, useEffect } from 'react';
|
|
2
3
|
|
|
3
4
|
const useDelay=()=>{
|
|
4
5
|
const [loading,setLoading] = useState(false);
|
|
5
6
|
const refSet = useRef();
|
|
7
|
+
// @ts-ignore
|
|
6
8
|
refSet.current = setLoading;
|
|
7
9
|
useEffect(()=>{
|
|
10
|
+
// @ts-ignore
|
|
8
11
|
refSet.current = setLoading;
|
|
9
12
|
},[setLoading]);
|
|
10
13
|
|
|
11
14
|
const actions=useMemo(()=>{
|
|
12
15
|
const wait=(ms)=>{
|
|
16
|
+
// @ts-ignore
|
|
13
17
|
refSet.current(true);
|
|
14
18
|
return new Promise(res=>{
|
|
15
19
|
setTimeout(()=>{
|
|
20
|
+
// @ts-ignore
|
|
16
21
|
refSet.current(false);
|
|
17
22
|
res();
|
|
18
23
|
}, ms);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import { useRef,useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
+
|
|
4
|
+
import {ShowPageLoading} from '@/components/page/pageLoading';
|
|
3
5
|
|
|
4
6
|
const useLoading=(props={})=>{
|
|
5
7
|
const {canTouch=false} = props;
|
|
@@ -20,10 +22,12 @@ const useLoading=(props={})=>{
|
|
|
20
22
|
useEffect(()=>{
|
|
21
23
|
if(count > 0 ){
|
|
22
24
|
if(!refPageLoading.current){
|
|
25
|
+
// @ts-ignore
|
|
23
26
|
refPageLoading.current = ShowPageLoading({canTouch:canTouch});
|
|
24
27
|
}
|
|
25
28
|
}else{
|
|
26
29
|
if(refPageLoading.current){
|
|
30
|
+
// @ts-ignore
|
|
27
31
|
refPageLoading.current();//销毁
|
|
28
32
|
refPageLoading.current=null;
|
|
29
33
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
// @ts-ignore
|
|
1
2
|
import { useState, useMemo, useEffect } from 'react'
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import { createContainer } from 'unstated-next'
|
|
3
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {[HTMLElement,Function]} UseStateElement
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
4
11
|
const useActivity = () => {
|
|
5
12
|
const [scrollTop, setScrollTop] = useState(0);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type UseStateElement
|
|
16
|
+
*/
|
|
6
17
|
const [containerNode, setContainerNode] = useState();
|
|
7
18
|
const [clientHeight, setClientHeight] = useState(0);
|
|
8
19
|
const [titleRefs, setTitleRefs] = useState({});
|
|
@@ -12,6 +23,7 @@ const useActivity = () => {
|
|
|
12
23
|
setContainerNode(node);
|
|
13
24
|
setClientHeight(node.clientHeight)
|
|
14
25
|
node.addEventListener('scroll', (e) => {
|
|
26
|
+
// @ts-ignore
|
|
15
27
|
setScrollTop(e.target.scrollTop);
|
|
16
28
|
})
|
|
17
29
|
}, [])
|