kn-cli 1.0.97 → 1.0.99

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.
Files changed (127) hide show
  1. package/package.json +1 -1
  2. package/templates/template_admin/cli.config.js +4 -1
  3. package/templates/template_admin/package.json +7 -1
  4. package/templates/template_admin/public/favicon.png +0 -0
  5. package/templates/template_admin/public/index.html +6 -4
  6. package/templates/template_admin/public/src/_antd.less +30 -3
  7. package/templates/template_admin/public/src/_mixin.less +41 -0
  8. package/templates/template_admin/public/src/_reset.less +28 -20
  9. package/templates/template_admin/public/src/_variable.less +11 -6
  10. package/templates/template_admin/public/src/assets/iconfont/iconfont.eot +0 -0
  11. package/templates/template_admin/public/src/assets/iconfont/iconfont.less +60 -8
  12. package/templates/template_admin/public/src/assets/iconfont/iconfont.svg +57 -18
  13. package/templates/template_admin/public/src/assets/iconfont/iconfont.ttf +0 -0
  14. package/templates/template_admin/public/src/assets/iconfont/iconfont.woff +0 -0
  15. package/templates/template_admin/public/src/assets/iconfont/iconfont.woff2 +0 -0
  16. package/templates/template_admin/public/src/assets/images/arrow.png +0 -0
  17. package/templates/template_admin/public/src/assets/images/icon-notice.png +0 -0
  18. package/templates/template_admin/public/src/assets/images/icon-user.png +0 -0
  19. package/templates/template_admin/public/src/assets/images/loadFail.png +0 -0
  20. package/templates/template_admin/public/src/assets/images/login/bg.png +0 -0
  21. package/templates/template_admin/public/src/assets/images/login/logo.png +0 -0
  22. package/templates/template_admin/public/src/assets/images/login/slogan.png +0 -0
  23. package/templates/template_admin/public/src/assets/images/nav/icon-dep-active.png +0 -0
  24. package/templates/template_admin/public/src/assets/images/nav/icon-dep.png +0 -0
  25. package/templates/template_admin/public/src/assets/images/nav/icon-log-active.png +0 -0
  26. package/templates/template_admin/public/src/assets/images/nav/icon-log.png +0 -0
  27. package/templates/template_admin/public/src/assets/images/nav/icon-loginlog-active.png +0 -0
  28. package/templates/template_admin/public/src/assets/images/nav/icon-loginlog.png +0 -0
  29. package/templates/template_admin/public/src/assets/images/nav/icon-role-active.png +0 -0
  30. package/templates/template_admin/public/src/assets/images/nav/icon-role.png +0 -0
  31. package/templates/template_admin/public/src/assets/images/nav/icon-user-active.png +0 -0
  32. package/templates/template_admin/public/src/assets/images/nav/icon-user.png +0 -0
  33. package/templates/template_admin/public/src/assets/images/nav/nav-toggle.png +0 -0
  34. package/templates/template_admin/public/src/assets/images/nav/slogan.png +0 -0
  35. package/templates/template_admin/public/src/assets/images/noData.png +0 -0
  36. package/templates/template_admin/public/src/assets/images/noSelect.png +0 -0
  37. package/templates/template_admin/public/src/components/auth/index.jsx +7 -3
  38. package/templates/template_admin/public/src/components/auth/index.less +7 -0
  39. package/templates/template_admin/public/src/components/badge/index.jsx +47 -0
  40. package/templates/template_admin/public/src/components/badge/index.less +44 -0
  41. package/templates/template_admin/public/src/components/debug/index.jsx +27 -0
  42. package/templates/template_admin/public/src/components/debug/index.less +9 -0
  43. package/templates/template_admin/public/src/components/empty/index.jsx +28 -0
  44. package/templates/template_admin/public/src/components/empty/index.less +20 -0
  45. package/templates/template_admin/public/src/components/image/index.jsx +73 -0
  46. package/templates/template_admin/public/src/components/image/index.less +117 -0
  47. package/templates/template_admin/public/src/components/image/preview.jsx +85 -0
  48. package/templates/template_admin/public/src/components/layout/basic/index.jsx +24 -11
  49. package/templates/template_admin/public/src/components/layout/basic/index.less +58 -19
  50. package/templates/template_admin/public/src/components/layout/index.jsx +20 -17
  51. package/templates/template_admin/public/src/components/layout/index.less +4 -4
  52. package/templates/template_admin/public/src/components/layout/provider/index.jsx +19 -6
  53. package/templates/template_admin/public/src/components/{menu → leftMenu}/index.jsx +20 -28
  54. package/templates/template_admin/public/src/components/leftMenu/index.less +42 -0
  55. package/templates/template_admin/public/src/components/popup/index.jsx +25 -0
  56. package/templates/template_admin/public/src/components/table/column.jsx +47 -0
  57. package/templates/template_admin/public/src/components/table/column.less +12 -0
  58. package/templates/template_admin/public/src/components/table/index.jsx +22 -13
  59. package/templates/template_admin/public/src/components/table/index.less +15 -0
  60. package/templates/template_admin/public/src/components/text/index.jsx +98 -0
  61. package/templates/template_admin/public/src/components/text/index.less +13 -0
  62. package/templates/template_admin/public/src/components/topMenu/index.jsx +97 -0
  63. package/templates/template_admin/public/src/components/topMenu/index.less +80 -0
  64. package/templates/template_admin/public/src/components/topMenu/topBar/index.jsx +76 -0
  65. package/templates/template_admin/public/src/components/topMenu/topBar/index.less +88 -0
  66. package/templates/template_admin/public/src/components/video/index.jsx +96 -0
  67. package/templates/template_admin/public/src/components/video/index.less +132 -0
  68. package/templates/template_admin/public/src/components/video/preview.jsx +38 -0
  69. package/templates/template_admin/public/src/dictionary/index.js +108 -39
  70. package/templates/template_admin/public/src/enum.js +41 -0
  71. package/templates/template_admin/public/src/hooks/index.jsx +8 -6
  72. package/templates/template_admin/public/src/hooks/useDebounceFn.jsx +33 -0
  73. package/templates/template_admin/public/src/hooks/useInToView.jsx +58 -0
  74. package/templates/template_admin/public/src/hooks/useRouteMenu.jsx +37 -28
  75. package/templates/template_admin/public/src/hooks/useTimer.jsx +42 -0
  76. package/templates/template_admin/public/src/index.jsx +10 -7
  77. package/templates/template_admin/public/src/mock/auth.js +33 -0
  78. package/templates/template_admin/public/src/mock/demo.js +12 -74
  79. package/templates/template_admin/public/src/mock/index.js +1 -0
  80. package/templates/template_admin/public/src/pages/auth/user/create/index.jsx +55 -0
  81. package/templates/template_admin/public/src/pages/auth/user/create/index.less +6 -0
  82. package/templates/template_admin/public/src/pages/auth/user/dialog/index.jsx +96 -0
  83. package/templates/template_admin/public/src/pages/auth/user/index.jsx +271 -0
  84. package/templates/template_admin/public/src/pages/components/layout/index.jsx +75 -0
  85. package/templates/template_admin/public/src/pages/components/layout/index.less +78 -0
  86. package/templates/template_admin/public/src/pages/components/layout/titleBar/index.jsx +28 -0
  87. package/templates/template_admin/public/src/pages/components/layout/titleBar/index.less +44 -0
  88. package/templates/template_admin/public/src/pages/components/select/account/index.jsx +114 -0
  89. package/templates/template_admin/public/src/pages/components/select/device/index.jsx +83 -0
  90. package/templates/template_admin/public/src/pages/components/select/groupUser/index.jsx +172 -0
  91. package/templates/template_admin/public/src/pages/components/select/user/index.jsx +119 -0
  92. package/templates/template_admin/public/src/pages/home.jsx +79 -0
  93. package/templates/template_admin/public/src/pages/home.less +6 -0
  94. package/templates/template_admin/public/src/pages/login/index.jsx +90 -6
  95. package/templates/template_admin/public/src/pages/login/index.less +133 -24
  96. package/templates/template_admin/public/src/provider/app.jsx +72 -66
  97. package/templates/template_admin/public/src/provider/loading.jsx +47 -0
  98. package/templates/template_admin/public/src/provider/menu.jsx +117 -83
  99. package/templates/template_admin/public/src/provider/menu.less +35 -0
  100. package/templates/template_admin/public/src/route.jsx +39 -41
  101. package/templates/template_admin/public/src/services/auth.js +39 -0
  102. package/templates/template_admin/public/src/services/demo.js +3 -37
  103. package/templates/template_admin/public/src/services/index.js +139 -13
  104. package/templates/template_admin/public/src/services/login.js +37 -0
  105. package/templates/template_admin/public/src/services/socket/index.jsx +100 -0
  106. package/templates/template_admin/public/src/type.js +36 -19
  107. package/templates/template_admin/public/src/utils/event.js +58 -0
  108. package/templates/template_admin/public/src/utils/format.js +84 -0
  109. package/templates/template_admin/public/src/utils/index.js +214 -2
  110. package/templates/template_admin/public/src/utils/rule.js +3 -0
  111. package/templates/template_admin/public/static/kssoLogin.html +1 -1
  112. package/templates/template_admin/webpack.api.js +11 -3
  113. package/templates/template_admin/public/favicon.ico +0 -0
  114. package/templates/template_admin/public/src/assets/images/avatars/1.png +0 -0
  115. package/templates/template_admin/public/src/assets/images/avatars/2.png +0 -0
  116. package/templates/template_admin/public/src/assets/images/avatars/3.png +0 -0
  117. package/templates/template_admin/public/src/components/layout/centerBody/index.jsx +0 -25
  118. package/templates/template_admin/public/src/components/layout/centerBody/index.less +0 -30
  119. package/templates/template_admin/public/src/components/menu/index.less +0 -19
  120. package/templates/template_admin/public/src/components/menu/topMenu/index.jsx +0 -132
  121. package/templates/template_admin/public/src/components/menu/topMenu/index.less +0 -105
  122. package/templates/template_admin/public/src/pages/demo/detail/index.jsx +0 -27
  123. package/templates/template_admin/public/src/pages/demo/edit/index.jsx +0 -109
  124. package/templates/template_admin/public/src/pages/demo/index.less +0 -9
  125. package/templates/template_admin/public/src/pages/demo/page1.jsx +0 -161
  126. package/templates/template_admin/public/src/pages/superAdminLogin/index.jsx +0 -64
  127. package/templates/template_admin/public/src/pages/superAdminLogin/index.less +0 -44
@@ -1,36 +1,39 @@
1
1
  // @ts-ignore
2
- import React from 'react';
2
+ import React, { useEffect } from 'react';
3
3
  // @ts-ignore
4
- import {Outlet} from 'react-router-dom';
5
- // @ts-ignore
6
- import { ConfigProvider } from 'antd';
7
- // @ts-ignore
8
- import zhCN from 'antd/lib/locale/zh_CN';
4
+ import {Outlet,useLocation} from 'react-router-dom';
9
5
 
10
6
  import ProviderApp from '@/provider/app';
11
7
  import LayoutBasic from './basic/index';
12
- import LayoutCenterBody from './centerBody/index';
8
+ import {LayoutLanguage} from './provider';
13
9
 
14
10
  // @ts-ignore
15
11
  import styles from './index.less';
16
12
 
13
+ import { popupList } from '@/components/popup';
14
+
17
15
  /**
18
16
  * 页面根框架,用于注入各类provider
19
- *
20
17
  * @returns {JSX.Element}
21
18
  */
22
- const Layout = () => {
19
+ const AbsoluteLayout = () => {
20
+ const curLocation =useLocation();
21
+
22
+ useEffect(() => {
23
+ popupList.destroyAll();
24
+ }, [curLocation]);
25
+
23
26
  return (
24
- <ProviderApp.Provider>
25
- <ConfigProvider locale={zhCN}>
26
- <section className={styles.layout} >
27
- <Outlet />
28
- </section>
29
- </ConfigProvider>
30
- </ProviderApp.Provider>
27
+ <LayoutLanguage>
28
+ <ProviderApp.Provider>
29
+ <section className={styles.absoluteLayout} >
30
+ <Outlet />
31
+ </section>
32
+ </ProviderApp.Provider>
33
+ </LayoutLanguage>
31
34
  );
32
35
  };
33
36
 
34
37
 
35
38
 
36
- export { Layout,LayoutCenterBody,LayoutBasic };
39
+ export { AbsoluteLayout,LayoutBasic };
@@ -1,6 +1,7 @@
1
1
  @import '~@/_variable.less';
2
+ @import '~@/_mixin.less';
2
3
 
3
- .layout {
4
+ .absoluteLayout {
4
5
  width: 100%;
5
6
  height:100%;
6
7
  left:0;
@@ -11,15 +12,14 @@
11
12
  background:white;
12
13
  display: flex;
13
14
  justify-content: center;
15
+ overflow: hidden;
14
16
 
15
17
  .app-scroll-body-pull-load-box{
16
18
  width:100%;
17
19
  height:100%;
18
20
  overflow: scroll;
19
21
  -webkit-overflow-scrolling: touch;
20
- &::-webkit-scrollbar {
21
- display: none;
22
- }
22
+ .hideScrollBar;
23
23
  }
24
24
 
25
25
  .app-scroll-body-pull-load{
@@ -1,19 +1,32 @@
1
1
  // @ts-ignore
2
2
  import React from 'react';
3
3
  // @ts-ignore
4
- import {Outlet} from 'react-router-dom';
4
+ import { ConfigProvider } from 'antd';
5
+ // @ts-ignore
6
+ import zhCN from 'antd/lib/locale/zh_CN';
5
7
 
6
8
  import ProviderApp from '@/provider/app';
7
9
 
8
10
  /**
9
11
  * 注入AppProvider
10
- * @returns {JSX.Element}
11
12
  */
12
- const LayoutProvider=()=>{
13
+ const LayoutProvider=(props)=>{
13
14
  return (
14
- <ProviderApp.Provider>
15
- <Outlet />
16
- </ProviderApp.Provider>
15
+ <ConfigProvider locale={zhCN}>
16
+ <ProviderApp.Provider>
17
+ {props.children}
18
+ </ProviderApp.Provider>
19
+ </ConfigProvider>
20
+ )
21
+ }
22
+
23
+ export const LayoutLanguage=(props)=>{
24
+ return (
25
+ <ConfigProvider locale={zhCN}>
26
+ {props.children}
27
+ </ConfigProvider>
17
28
  )
18
29
  }
30
+
31
+
19
32
  export default LayoutProvider;
@@ -1,10 +1,13 @@
1
1
  // @ts-ignore
2
- import React, { useEffect, useRef, useState } from 'react';
3
- // @ts-ignore
4
- import { Menu,Badge } from 'antd';
2
+ import React, { useEffect, useState } from 'react';
5
3
  // @ts-ignore
6
4
  import {useNavigate,} from 'react-router-dom';
7
5
 
6
+ // @ts-ignore
7
+ import { Menu } from 'antd';
8
+ import Badge from '@/components/badge'
9
+ // @ts-ignore
10
+ import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
8
11
 
9
12
  import {useLoading} from '@/hooks/index';
10
13
  import ProviderMenu from '@/provider/menu';
@@ -15,18 +18,17 @@ import styles from './index.less';
15
18
 
16
19
 
17
20
 
21
+
18
22
  /**
19
23
  * 左侧导航栏的demo组件
20
24
  *
21
25
  * @returns {JSX.Element}
22
26
  */
23
- const LeftMenu=()=>{
27
+ const LeftMenu=(props)=>{
24
28
 
25
-
26
29
  const providerMenu = ProviderMenu.useContainer();
27
30
  const loader = useLoading();
28
31
  const [menus,setMenus] = useState([]);
29
- const [subMenuOpen,setSubMenuOpen]= useState([]);
30
32
  const nav = useNavigate();
31
33
 
32
34
  const translateMenu=(list)=>{
@@ -38,7 +40,9 @@ const LeftMenu=()=>{
38
40
  key,label,icon,url
39
41
  }
40
42
  if(msgCount&&msgCount>0){
41
- item.label=<span>{label}<Badge size='small' count={msgCount} offset={[5,-5]} /></span>
43
+ item.label=<span className={styles.menuLabel}>{label}
44
+ <Badge count={msgCount}/>
45
+ </span>
42
46
  }
43
47
  if(menu.children){
44
48
  item.children = translateMenu(menu.children)
@@ -60,28 +64,16 @@ const LeftMenu=()=>{
60
64
  nav(menu.url);
61
65
  }
62
66
 
63
- const onOpenSubMenu=(keys)=>{
64
- setSubMenuOpen(keys)
65
- }
66
- useEffect(()=>{
67
- if(providerMenu.selectMenus.keys && providerMenu.selectMenus.keys.length>0){
68
- setSubMenuOpen([...subMenuOpen,...providerMenu.selectMenus.keys]);
69
- }
70
- },[providerMenu.selectMenus.keys])
71
67
  return (
72
- <section className={styles.nav}>
73
- {
74
- providerMenu.selectMenus.keys&&
75
- <Menu
76
- theme='dark'
77
- openKeys={subMenuOpen}
78
- onOpenChange={onOpenSubMenu}
79
- selectedKeys={providerMenu.selectMenus.keys}
80
- onClick={onClickMenuItem}
81
- mode="inline"
82
- items={loader.loading?[]:menus}
83
- />
84
- }
68
+ <section className={styles.nav} data-nav-hide={!menus||menus.length<=0}>
69
+ <Menu
70
+ selectedKeys={providerMenu.selectMenus.keys}
71
+ // openKeys={openKeys}
72
+ // onOpenChange={onOpenChange}
73
+ onClick={onClickMenuItem}
74
+ mode="inline"
75
+ items={loader.loading?[]:menus}
76
+ />
85
77
  </section>
86
78
  )
87
79
  }
@@ -0,0 +1,42 @@
1
+ @import '~@/_variable.less';
2
+
3
+ @import '~@/_mixin.less';
4
+
5
+
6
+ .nav{
7
+ max-width: var(--nav-width);
8
+ min-width: var(--nav-min-width);
9
+ height:100%;
10
+ background-color: white;
11
+ transition: all .2s;
12
+ z-index: var(--z-nav-mobile);
13
+ overflow-y: auto;
14
+ border-right: 1px solid #DEE0E3;
15
+ .scrollBar;
16
+ &[data-nav-hide='true']{
17
+ display: none;
18
+ }
19
+ &[data-nav-mode='mobile']{
20
+ position: fixed;
21
+ z-index: var(--z-nav-mobile);
22
+ box-shadow: 0 0 20px #444;
23
+ }
24
+
25
+ }
26
+ .iconUnread{
27
+ width: 6px;
28
+ height: 6px;
29
+ border-radius: 6px;
30
+ background-color: red;
31
+ position: absolute;
32
+ right: 0;
33
+ top: 0;
34
+ }
35
+ .menuLabel{
36
+ display: flex;
37
+ column-gap: 6px;
38
+ align-items: center;
39
+ font-size: inherit;
40
+ font-weight: inherit;
41
+ color:inherit;
42
+ }
@@ -7,26 +7,51 @@ import ReactDOM from 'react-dom';
7
7
  import styles from './index.less';
8
8
  styles;
9
9
 
10
+ export const popupList={
11
+ list:[],
12
+ remove:function(fn){
13
+ let list = popupList.list;
14
+ let idx = list.indexOf(fn);
15
+ if(idx>=0)list.splice(idx,1);
16
+ },
17
+ destroyAll:function(){
18
+ let list = popupList.list;
19
+
20
+ while(list.length>0){
21
+ let fn = list.shift();
22
+ fn(false);
23
+ }
24
+ },
25
+ add:function(fn){
26
+ popupList.list.push(fn);
27
+ }
28
+ }
29
+
10
30
  /**
11
31
  * 一个全屏置顶的遮罩层
12
32
  * @param {(result)=>void} reslove - 遮罩层的关闭回调
13
33
  * @param {Object} [options] - 参数
14
34
  * @param {boolean} [options.cantouch=false] - 是否允许被点击穿透
15
35
  * @param {boolean} [options.transparent=false] - 是否遮罩层完全透明
36
+ * @param {string} [options.className=''] - 扩展样式
37
+ *
16
38
  *
17
39
  * @returns { {dom:HTMLElement,destory:()=>void} }
18
40
  */
19
41
  const Popup = (reslove,options) => {
20
42
  let rootDom = document.createElement('div');
21
43
  rootDom.className='popup-box';
44
+ if(options&&options.className)rootDom.className += ` ${options.className}`
22
45
  if(options&&options.cantouch)rootDom.setAttribute('data-can-touch','1');
23
46
  if(options&&options.transparent)rootDom.setAttribute('data-transparent','1');
24
47
 
25
48
  let destory = (result) => {
49
+ popupList.remove(destory);
26
50
  ReactDOM.unmountComponentAtNode(rootDom);
27
51
  rootDom.parentNode.removeChild(rootDom);
28
52
  if (reslove) reslove(result);
29
53
  };
54
+ popupList.add(destory);
30
55
  document.body.appendChild(rootDom);
31
56
  return { dom: rootDom, destory };
32
57
  };
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+
3
+ // @ts-ignore
4
+ import styles from './column.less';
5
+ import {DebugTableItem} from '@/components/debug';
6
+
7
+
8
+ /**
9
+ * 用于Table组件内渲染列用
10
+ * 一旦设置了width/minWidth/maxWidth后,则会自动根据宽度显示,超出的显示省略号
11
+ * @param {object} props
12
+ * @param {string|number} [props.width] - 列宽限制,width和minWidth、maxWidth不要同时存在,2者取1
13
+ * @param {string|number} [props.minWidth] - 列宽限制范围
14
+ * @param {string|number} [props.maxWidth] - 列宽限制范围
15
+ * @param {boolean} [props.wrap=false] - 是否允许自动换行
16
+ * @param {number} [props.maxLine=3] - 最大限制换行数
17
+ * @param {object} [props.item] - 源数据对象
18
+ * @param {string|JSX.Element} [props.children] - 显示的列内容
19
+ *
20
+ *
21
+ * @returns {JSX.Element}
22
+ */
23
+ const Column=(props)=>{
24
+ const {width,minWidth,maxWidth,wrap=false,maxLine=3,item={}} = props;
25
+ const myStyle = {
26
+ };
27
+ if(minWidth){myStyle.minWidth=minWidth;}
28
+ if(maxWidth){myStyle.maxWidth=maxWidth;}
29
+ if(width){myStyle.width=width;}
30
+
31
+ if(width || minWidth || maxWidth){
32
+ if(wrap && maxLine){
33
+ myStyle.display='-webkit-box';
34
+ myStyle.webkitBoxOrient='vertical';
35
+ myStyle.webkitLineClamp=''+maxLine;
36
+ }
37
+ }
38
+ return (
39
+ <DebugTableItem item={item}>
40
+ <div className={styles.column} style={myStyle} data-wrap={wrap}>
41
+ {props.children??'-'}
42
+ </div>
43
+ </DebugTableItem>
44
+ )
45
+ }
46
+
47
+ export default Column;
@@ -0,0 +1,12 @@
1
+
2
+
3
+ .column{
4
+ flex-wrap: nowrap;
5
+ text-overflow: ellipsis;
6
+ overflow: hidden;
7
+ white-space: nowrap;
8
+ &[data-wrap='true']{
9
+ white-space: normal;
10
+ flex-wrap: wrap;
11
+ }
12
+ }
@@ -1,6 +1,11 @@
1
1
  import React,{useCallback} from 'react';
2
2
  // @ts-ignore
3
3
  import { Table } from 'antd';
4
+ // @ts-ignore
5
+ import styles from './index.less';
6
+ import Column from './column';
7
+
8
+ export const SCROLL_CONFIG={x:'max-content',y:550}
4
9
 
5
10
  /**
6
11
  * 页面公共Table组件
@@ -43,20 +48,24 @@ const PageTable = (props) => {
43
48
  }, [pagination, page]);
44
49
 
45
50
  return (
46
- <Table
47
- rowKey={rowKey ?? 'id'}
48
- bordered
49
- size="small"
50
- loading={loading ?? page?.loading?.state}
51
- columns={columns}
52
- dataSource={
53
- dataSource ?? (page?.data?.[page?.pagination?.current - 1] || [])
54
- }
55
- pagination={paginationFn()}
56
- scroll={scroll ?? { y: 500 }}
57
- {...others}
58
- />
51
+ <section className={styles.tableScrollWrap}>
52
+ <Table
53
+ rowKey={rowKey ?? 'id'}
54
+ bordered
55
+ size="small"
56
+ loading={loading ?? page?.loading?.state}
57
+ columns={columns}
58
+ dataSource={
59
+ dataSource ?? (page?.data?.[page?.pagination?.current - 1] || [])
60
+ }
61
+ pagination={paginationFn()}
62
+ scroll={scroll?{...SCROLL_CONFIG,...scroll}: SCROLL_CONFIG }
63
+ {...others}
64
+ />
65
+ </section>
59
66
  );
60
67
  };
61
68
 
69
+
70
+ PageTable.Column = Column;
62
71
  export default PageTable;
@@ -0,0 +1,15 @@
1
+
2
+
3
+ .tableScrollWrap{
4
+ flex:1;
5
+ width: 100%;
6
+ overflow: auto;
7
+ }
8
+
9
+ .tableWrap{
10
+ flex:1;
11
+ display: flex;
12
+ width: 100%;
13
+ flex-direction: column;
14
+ overflow: hidden;
15
+ }
@@ -0,0 +1,98 @@
1
+ import React, { useEffect, useState, useRef } from 'react';
2
+ // @ts-ignore
3
+ import { Tooltip } from 'antd';
4
+ import { getStrByteLen } from '@/utils';
5
+ // @ts-ignore
6
+ import styles from './index.less';
7
+
8
+ /**
9
+ * 获取字符串末尾字节数的字符串、所在位置
10
+ * @param {string} str - 必填项;要处理的字符串
11
+ * @param {number} bytes - 必填项;末尾字节数
12
+ * @returns {object}
13
+ */
14
+ const endBytesStr = (str, bytes) => {
15
+ if (!str) return { index: 0, text: '' };
16
+ let num = 0;
17
+ let result = '';
18
+ let index = 0;
19
+ for (let i = str.length - 1; i >=0; i--) {
20
+ num += str.charCodeAt(i) > 255 ? 3 : 1; // 中文三个字节,英文一个字节
21
+ if (num > bytes) {
22
+ break;
23
+ }
24
+ result = str.substring(i, str.length);
25
+ index = i;
26
+ }
27
+ return {
28
+ index,
29
+ text:result,
30
+ };
31
+ }
32
+
33
+ /**
34
+ * 字符串省略效果:末尾省略 | 中间省略
35
+ * @param {object} props
36
+ * @param {string} props.str - 必填项;要处理的字符
37
+ * @param {number} [props.endBytes] - 可选项;不传默认末尾省略,中间省略时,字符串末尾显示几个“字节”
38
+ * @param {string} [props.className] - 可选项;类名
39
+ * @returns {JSX.Element}
40
+ */
41
+ const Text = (props) => {
42
+ const { str, endBytes=null, className='' } = props;
43
+ const [strEnd, setStrEnd] = useState({
44
+ index: 0,
45
+ text: '',
46
+ });
47
+ const [isOverflow, setIsOverflow] = useState(false);
48
+ const prevRef = useRef(null);
49
+
50
+ useEffect(() => {
51
+ if(!str) return;
52
+ const strBytes = getStrByteLen(str);
53
+ if (endBytes && strBytes > endBytes) {
54
+ const { index, text } = endBytesStr(str, endBytes);
55
+ setStrEnd({
56
+ index,
57
+ text,
58
+ });
59
+ } else {
60
+ setStrEnd({
61
+ index: 0,
62
+ text: '',
63
+ });
64
+ }
65
+ }, [str, endBytes]);
66
+
67
+ useEffect(() => {
68
+ const checkOverflow = () => {
69
+ if (prevRef.current) {
70
+ const isOverflowing =
71
+ prevRef.current.scrollWidth > prevRef.current.clientWidth;
72
+ setIsOverflow(isOverflowing);
73
+ }
74
+ };
75
+
76
+ checkOverflow();
77
+ }, [strEnd]);
78
+
79
+ const ContentDom = (
80
+ <section className={`${styles.parent} ${className}`}>
81
+ {strEnd?.text ? (
82
+ <>
83
+ <div className={styles.prev} ref={prevRef}>
84
+ {str.slice(0, strEnd?.index)}
85
+ </div>
86
+ <div className={styles.next}>{strEnd?.text}</div>
87
+ </>
88
+ ) : (
89
+ <div className={styles.prev} ref={prevRef}>
90
+ {str}
91
+ </div>
92
+ )}
93
+ </section>
94
+ );
95
+ return isOverflow ? <Tooltip title={str}>{ContentDom}</Tooltip> : ContentDom;
96
+ };
97
+
98
+ export default React.memo(Text);
@@ -0,0 +1,13 @@
1
+ .parent {
2
+ display: flex;
3
+ overflow: hidden;
4
+ .prev {
5
+ overflow: hidden;
6
+ text-overflow: ellipsis;
7
+ white-space: nowrap;
8
+ word-break: keep-all;
9
+ }
10
+ .next {
11
+ white-space: nowrap;
12
+ }
13
+ }
@@ -0,0 +1,97 @@
1
+ // @ts-ignore
2
+ import React, { useState,useEffect } from 'react';
3
+ // @ts-ignore
4
+ import { useNavigate } from 'react-router-dom';
5
+
6
+ import ProviderMenu from '@/provider/menu';
7
+ // @ts-ignore
8
+ import imgSlogan from '@/assets/images/nav/slogan.png';
9
+
10
+ import TopBar from './topBar';
11
+
12
+ // @ts-ignore
13
+ import styles from './index.less';
14
+
15
+ const TopSlogan=()=>{
16
+ const navigate = useNavigate();
17
+ const onHome= ()=>{
18
+ navigate('/')
19
+ }
20
+ return (
21
+ <div className={styles.TopMenuSlogan} onClick={onHome}>
22
+ <img src={imgSlogan} />
23
+ </div>
24
+ )
25
+ }
26
+
27
+
28
+ const TopMenu=(props)=>{
29
+ const providerMenu = ProviderMenu.useContainer();
30
+
31
+ const [menus,setMenus]=useState([]);
32
+ const navigate = useNavigate();
33
+
34
+ const menuOpen= true;//app.nav.leftNavOpen;
35
+
36
+
37
+ // // 推出登录
38
+ // const onAvatarClick = (e)=>{
39
+ // if (e?.key === 'logout') {
40
+ // app.logout();
41
+ // }
42
+ // }
43
+
44
+ const onClickMenuItem=(menu,e)=>{
45
+ navigate(menu.url);
46
+ }
47
+ const reload= async ()=>{
48
+ providerMenu.reload();
49
+ }
50
+ useEffect(()=>{
51
+ setMenus(providerMenu.topMenu)
52
+ },[providerMenu.topMenu]);
53
+
54
+ useEffect(()=>{
55
+ reload();
56
+ },[])
57
+
58
+
59
+ // const getIcon=(iconName,active)=>{
60
+ // import(`@/assets/images/nav/${iconName}.png`).then(item=>{
61
+ // return item;
62
+ // })
63
+ // }
64
+ return (
65
+
66
+
67
+ <div className={styles.topMenu} data-open={menuOpen}>
68
+ <hgroup className={styles.leftGroup}>
69
+ <TopSlogan />
70
+ {
71
+ menus&&menus.length>1&&
72
+ menus.map((menu,idx)=>{
73
+ const {key,name:label,icon,msgCount}= menu;
74
+ const active = providerMenu.selectMenus.keys.includes(key);
75
+ return (
76
+ <div
77
+ key={key}
78
+ className={styles.menuItem}
79
+ data-checked={active}
80
+ onClick={onClickMenuItem.bind(this,menu)}
81
+ >
82
+ <span>{label}</span>
83
+ {/* 未读标记 */}
84
+ <div className={styles.messageWrap}>
85
+ {msgCount>0?<i className={styles.iconUnread}/>:''}
86
+ </div>
87
+ </div>
88
+ )
89
+ })
90
+ }
91
+ </hgroup>
92
+ <TopBar />
93
+ </div>
94
+ )
95
+ }
96
+
97
+ export default TopMenu;