@zw-team/react-lib 1.0.5-beta.2 → 1.0.5-beta.4

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 (34) hide show
  1. package/dist/components/AccessReport/index.d.ts +7 -5
  2. package/dist/components/AccessReport/index.js +14 -2
  3. package/dist/components/ConfigProvider/ConfigProvider.js +15 -12
  4. package/dist/components/ConfigProvider/types.d.ts +1 -0
  5. package/dist/components/FormItem/FormItem.css +26 -0
  6. package/dist/components/Log/src/Detail.js +8 -6
  7. package/dist/components/Log/src/Detail.scss +2 -1
  8. package/dist/components/Log/src/Log.d.ts +1 -2
  9. package/dist/components/Log/src/Log.js +267 -227
  10. package/dist/components/Log/src/Log.scss +8 -3
  11. package/dist/components/Log/src/useLogTableColumns.d.ts +4 -1
  12. package/dist/components/Log/src/useLogTableColumns.js +21 -7
  13. package/dist/components/Log/types.d.ts +1 -0
  14. package/dist/components/LogButton/LogButton.js +5 -4
  15. package/dist/components/LogButton/logbutton.css +0 -1
  16. package/dist/components/LogButton/types.d.ts +3 -2
  17. package/dist/components/LogDialog/BiLogManager.d.ts +6 -4
  18. package/dist/components/LogDialog/BiLogManager.js +11 -5
  19. package/dist/components/LogDialog/LogDialog.js +133 -74
  20. package/dist/components/LogDialog/LogDialog.scss +10 -1
  21. package/dist/components/LogDialog/types.d.ts +3 -1
  22. package/dist/components/NavbarTool/NavbarTool.js +4 -4
  23. package/dist/components/NavbarTool/types.d.ts +2 -0
  24. package/dist/components/NoticeCenter/NoticeCenter.d.ts +1 -1
  25. package/dist/components/NoticeCenter/NoticeCenter.js +118 -73
  26. package/dist/components/NoticeCenter/noticeCenter.scss +10 -1
  27. package/dist/components/NoticeCenter/types.d.ts +1 -3
  28. package/dist/components/Table/useHeaderPopper.js +13 -5
  29. package/dist/hooks/useAccessReport.js +7 -1
  30. package/dist/package.json +74 -0
  31. package/dist/utils/advisory.d.ts +2 -2
  32. package/dist/utils/advisory.js +7 -2
  33. package/dist/utils/request/index.js +7 -1
  34. package/package.json +2 -2
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Button } from "antd";
3
3
  import { useMemo } from "react";
4
4
  import Detail from "./Detail.js";
5
- const useLogTableColumns = (showMoreFn, fomartOperates)=>{
5
+ const useLogTableColumns = (showMoreFn, fomartOperates, modelOptions = [])=>{
6
6
  const drawerTableColums = useMemo(()=>[
7
7
  {
8
8
  dataIndex: 'operator',
@@ -38,7 +38,7 @@ const useLogTableColumns = (showMoreFn, fomartOperates)=>{
38
38
  /*#__PURE__*/ jsx("div", {
39
39
  className: 'log-more',
40
40
  children: /*#__PURE__*/ jsxs(Button, {
41
- type: 'text',
41
+ type: 'link',
42
42
  onClick: ()=>{
43
43
  showMoreFn(row);
44
44
  },
@@ -52,9 +52,15 @@ const useLogTableColumns = (showMoreFn, fomartOperates)=>{
52
52
  })
53
53
  ]
54
54
  });
55
+ return /*#__PURE__*/ jsx(Detail, {
56
+ data: row
57
+ });
55
58
  }
56
59
  }
57
- ], []);
60
+ ], [
61
+ fomartOperates,
62
+ showMoreFn
63
+ ]);
58
64
  const defaultTableColums = useMemo(()=>[
59
65
  {
60
66
  dataIndex: 'operator',
@@ -79,9 +85,10 @@ const useLogTableColumns = (showMoreFn, fomartOperates)=>{
79
85
  width: 80
80
86
  },
81
87
  {
82
- dataIndex: 'model_name',
88
+ dataIndex: 'model',
83
89
  title: '模块',
84
- width: 100
90
+ width: 100,
91
+ render: (value)=>modelOptions.find((item)=>item.id === value)?.label || '-'
85
92
  },
86
93
  {
87
94
  dataIndex: 'objectName',
@@ -116,7 +123,7 @@ const useLogTableColumns = (showMoreFn, fomartOperates)=>{
116
123
  /*#__PURE__*/ jsx("div", {
117
124
  className: 'log-more',
118
125
  children: /*#__PURE__*/ jsxs(Button, {
119
- type: 'text',
126
+ type: 'link',
120
127
  onClick: ()=>{
121
128
  showMoreFn(row);
122
129
  },
@@ -130,9 +137,16 @@ const useLogTableColumns = (showMoreFn, fomartOperates)=>{
130
137
  })
131
138
  ]
132
139
  });
140
+ return /*#__PURE__*/ jsx(Detail, {
141
+ data: row
142
+ });
133
143
  }
134
144
  }
135
- ], []);
145
+ ], [
146
+ fomartOperates,
147
+ modelOptions,
148
+ showMoreFn
149
+ ]);
136
150
  return {
137
151
  drawerTableColums,
138
152
  defaultTableColums
@@ -1,5 +1,6 @@
1
1
  export interface LogProps {
2
2
  logId?: string | number;
3
3
  logModel?: string;
4
+ className?: string;
4
5
  [key: string]: any;
5
6
  }
@@ -1,13 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import "./logbutton.css";
3
3
  import { Button } from "antd";
4
+ import { useBiLog } from "../LogDialog/index.js";
4
5
  const LogButton = ({ type = 'text', logId = '', logModel = '', className, onLog })=>{
6
+ const { openDrawer } = useBiLog();
5
7
  const handleLog = ()=>{
6
8
  const payload = {
7
9
  id: logId,
8
10
  model: logModel
9
11
  };
10
- if (onLog) onLog(payload);
12
+ openDrawer(payload);
13
+ onLog?.(payload);
11
14
  };
12
15
  return /*#__PURE__*/ jsx("div", {
13
16
  className: [
@@ -15,10 +18,8 @@ const LogButton = ({ type = 'text', logId = '', logModel = '', className, onLog
15
18
  className
16
19
  ].filter(Boolean).join(' '),
17
20
  children: 'button' === type ? /*#__PURE__*/ jsx(Button, {
18
- type: "text",
19
- className: "a-button",
21
+ type: "link",
20
22
  onClick: handleLog,
21
- block: true,
22
23
  children: "日志"
23
24
  }) : /*#__PURE__*/ jsx("span", {
24
25
  onClick: handleLog,
@@ -2,7 +2,6 @@
2
2
  display: block;
3
3
  }
4
4
 
5
- .bi-log-button .a-button,
6
5
  .bi-log-button span {
7
6
  width: 100%;
8
7
  text-align: left;
@@ -1,10 +1,11 @@
1
1
  export interface LogButtonProps {
2
2
  type?: 'button' | 'text';
3
- logId?: string;
3
+ logId?: string | number;
4
4
  logModel?: string;
5
5
  className?: string;
6
+ /** 日志 Drawer 打开后的附加回调。 */
6
7
  onLog?: (payload: {
7
- id: string;
8
+ id: string | number;
8
9
  model: string;
9
10
  }) => void;
10
11
  }
@@ -1,3 +1,4 @@
1
+ import type { BiLogDialogConfig } from './types';
1
2
  interface BiLogReturn {
2
3
  close: () => void;
3
4
  }
@@ -5,9 +6,10 @@ declare class BiLogManager {
5
6
  private static instance;
6
7
  private constructor();
7
8
  static getInstance(): BiLogManager;
8
- openDrawer({ logId, logModel, }: {
9
- logId?: string;
9
+ openDrawer({ logId, logModel, configContext, }: {
10
+ logId?: string | number;
10
11
  logModel?: string;
12
+ configContext?: BiLogDialogConfig['configContext'];
11
13
  }): BiLogReturn;
12
14
  openRichText({ newContent, oldContent, }: {
13
15
  newContent?: string;
@@ -16,8 +18,8 @@ declare class BiLogManager {
16
18
  closeAll(): void;
17
19
  }
18
20
  export declare const useBiLog: () => {
19
- openDrawer: ({ id, model }: {
20
- id?: string;
21
+ openDrawer: ({ id, model, }: {
22
+ id?: string | number;
21
23
  model?: string;
22
24
  }) => BiLogReturn;
23
25
  openRichText: ({ newContent, oldContent, }: {
@@ -1,5 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { createRoot } from "react-dom/client";
3
+ import { useConfig } from "../ConfigProvider/ConfigContext.js";
3
4
  import LogDialog from "./LogDialog.js";
4
5
  const activeInstances = [];
5
6
  const createPopupInstance = (config)=>{
@@ -32,10 +33,11 @@ class BiLogManager {
32
33
  if (!BiLogManager.instance) BiLogManager.instance = new BiLogManager();
33
34
  return BiLogManager.instance;
34
35
  }
35
- openDrawer({ logId = '', logModel = '' }) {
36
+ openDrawer({ logId = '', logModel = '', configContext }) {
36
37
  const config = {
37
38
  logId,
38
- logModel
39
+ logModel,
40
+ configContext
39
41
  };
40
42
  return createPopupInstance(config);
41
43
  }
@@ -61,10 +63,13 @@ class BiLogManager {
61
63
  }
62
64
  }
63
65
  const biLogManager = BiLogManager.getInstance();
64
- const useBiLog = ()=>({
66
+ const useBiLog = ()=>{
67
+ const configContext = useConfig();
68
+ return {
65
69
  openDrawer: ({ id = '', model = '' })=>biLogManager.openDrawer({
66
70
  logId: id,
67
- logModel: model
71
+ logModel: model,
72
+ configContext
68
73
  }),
69
74
  openRichText: ({ newContent = '', oldContent = '' })=>biLogManager.openRichText({
70
75
  newContent,
@@ -73,6 +78,7 @@ const useBiLog = ()=>({
73
78
  closeAll: ()=>{
74
79
  biLogManager.closeAll();
75
80
  }
76
- });
81
+ };
82
+ };
77
83
  const LogDialog_BiLogManager = BiLogManager;
78
84
  export { LogDialog_BiLogManager as default, useBiLog };
@@ -1,19 +1,64 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { ConfigProvider, Drawer, Modal } from "antd";
3
- import { useRef, useState } from "react";
3
+ import { useEffect, useRef, useState } from "react";
4
4
  import { theme } from "../../config/theme/index.js";
5
+ import { ConfigContext, defaultConfig } from "../ConfigProvider/ConfigContext.js";
5
6
  import { BiLog } from "../Log/index.js";
6
7
  import "./LogDialog.scss";
8
+ const bodyScrollLocks = new WeakMap();
9
+ const getOutermostAccessibleBody = ()=>{
10
+ let currentWindow = window;
11
+ try {
12
+ while(currentWindow.parent !== currentWindow){
13
+ currentWindow.parent.document.body;
14
+ currentWindow = currentWindow.parent;
15
+ }
16
+ } catch {}
17
+ return currentWindow.document.body;
18
+ };
19
+ const lockBodyScroll = (body)=>{
20
+ const currentLock = bodyScrollLocks.get(body);
21
+ if (currentLock) {
22
+ currentLock.count += 1;
23
+ return;
24
+ }
25
+ bodyScrollLocks.set(body, {
26
+ count: 1,
27
+ overflow: body.style.overflow
28
+ });
29
+ body.style.overflow = 'hidden';
30
+ };
31
+ const unlockBodyScroll = (body)=>{
32
+ const currentLock = bodyScrollLocks.get(body);
33
+ if (!currentLock) return;
34
+ currentLock.count -= 1;
35
+ if (currentLock.count > 0) return;
36
+ body.style.overflow = currentLock.overflow;
37
+ bodyScrollLocks.delete(body);
38
+ };
7
39
  const BiLogDialog = ({ config, onClose })=>{
8
- const { logId = '', logModel = '', richTextData = '' } = config;
40
+ const { logId = '', logModel = '', richTextData = '', configContext = defaultConfig } = config;
9
41
  const [drawerVisible, setDrawerVisible] = useState(!!logId);
10
42
  const [dialogVisible, setDialogVisible] = useState(!!richTextData);
11
- const [dialogData, setDialogData] = useState(config.richTextData || {
43
+ const [dialogData] = useState(config.richTextData || {
12
44
  new: '',
13
45
  old: ''
14
46
  });
15
47
  const [arrowImg] = useState('https://wanxiaomeng-1255977238.file.myqcloud.com/bi-element-ui/Log/arrow.png');
16
48
  const biLogRef = useRef(null);
49
+ useEffect(()=>{
50
+ if (!drawerVisible) return;
51
+ const bodies = Array.from(new Set([
52
+ document.body,
53
+ getOutermostAccessibleBody()
54
+ ]));
55
+ bodies.forEach(lockBodyScroll);
56
+ return ()=>{
57
+ bodies.forEach(unlockBodyScroll);
58
+ };
59
+ }, [
60
+ drawerVisible
61
+ ]);
17
62
  const onCloseDrawer = ()=>{
18
63
  setDrawerVisible(false);
19
64
  onClose();
@@ -25,81 +70,95 @@ const BiLogDialog = ({ config, onClose })=>{
25
70
  setDialogVisible(false);
26
71
  onClose();
27
72
  };
28
- return /*#__PURE__*/ jsxs(ConfigProvider, {
29
- theme: theme,
30
- children: [
31
- /*#__PURE__*/ jsx(Drawer, {
32
- title: "日志",
33
- size: 900,
34
- className: "bi-log-drawer",
35
- closable: {
36
- disabled: true,
37
- placement: 'end'
38
- },
39
- onClose: onCloseDrawer,
40
- afterOpenChange: onOpenDrawer,
41
- open: drawerVisible,
42
- children: /*#__PURE__*/ jsx(BiLog, {
43
- ref: biLogRef,
44
- logId: logId,
45
- logModel: logModel,
46
- BiLogDialog: 1
47
- })
48
- }),
49
- /*#__PURE__*/ jsxs(Modal, {
50
- title: "详情",
51
- width: 1354,
52
- footer: null,
53
- onCancel: handleDialogClose,
54
- open: dialogVisible,
55
- styles: {
56
- container: {
57
- height: 'calc(100vh - 160px)',
58
- maxWidth: '80%'
73
+ return /*#__PURE__*/ jsx(ConfigContext.Provider, {
74
+ value: configContext,
75
+ children: /*#__PURE__*/ jsxs(ConfigProvider, {
76
+ theme: theme,
77
+ children: [
78
+ /*#__PURE__*/ jsx(Drawer, {
79
+ title: "日志",
80
+ size: 900,
81
+ className: "bi-log-drawer",
82
+ closable: {
83
+ disabled: true,
84
+ placement: 'end'
59
85
  },
60
- body: {
61
- height: 'calc(100vh - 160px - 56px)',
62
- padding: '0'
63
- }
64
- },
65
- children: [
66
- /*#__PURE__*/ jsxs("div", {
67
- className: "bi-log-rich-text-box",
68
- children: [
69
- /*#__PURE__*/ jsx("div", {
70
- style: {
71
- display: dialogData.old ? 'block' : 'none'
72
- },
73
- className: "bi-log-rich-text-item old",
74
- children: /*#__PURE__*/ jsx("div", {
75
- dangerouslySetInnerHTML: {
76
- __html: dialogData.old || ''
77
- }
78
- })
79
- }),
80
- /*#__PURE__*/ jsx("div", {
81
- className: "bi-log-rich-text-item new",
82
- children: /*#__PURE__*/ jsx("div", {
83
- dangerouslySetInnerHTML: {
84
- __html: dialogData.new || ''
85
- }
86
+ onClose: onCloseDrawer,
87
+ afterOpenChange: onOpenDrawer,
88
+ open: drawerVisible,
89
+ styles: {
90
+ header: {
91
+ boxSizing: 'border-box',
92
+ flex: '0 0 50px',
93
+ height: 50,
94
+ padding: '0 20px'
95
+ },
96
+ body: {
97
+ padding: 0
98
+ }
99
+ },
100
+ children: /*#__PURE__*/ jsx(BiLog, {
101
+ ref: biLogRef,
102
+ logId: logId,
103
+ logModel: logModel,
104
+ BiLogDialog: 1
105
+ })
106
+ }),
107
+ /*#__PURE__*/ jsxs(Modal, {
108
+ title: "详情",
109
+ width: 1354,
110
+ footer: null,
111
+ onCancel: handleDialogClose,
112
+ open: dialogVisible,
113
+ styles: {
114
+ container: {
115
+ height: 'calc(100vh - 160px)',
116
+ maxWidth: '80%'
117
+ },
118
+ body: {
119
+ height: 'calc(100vh - 160px - 56px)',
120
+ padding: '0'
121
+ }
122
+ },
123
+ children: [
124
+ /*#__PURE__*/ jsxs("div", {
125
+ className: "bi-log-rich-text-box",
126
+ children: [
127
+ /*#__PURE__*/ jsx("div", {
128
+ style: {
129
+ display: dialogData.old ? 'block' : 'none'
130
+ },
131
+ className: "bi-log-rich-text-item old",
132
+ children: /*#__PURE__*/ jsx("div", {
133
+ dangerouslySetInnerHTML: {
134
+ __html: dialogData.old || ''
135
+ }
136
+ })
137
+ }),
138
+ /*#__PURE__*/ jsx("div", {
139
+ className: "bi-log-rich-text-item new",
140
+ children: /*#__PURE__*/ jsx("div", {
141
+ dangerouslySetInnerHTML: {
142
+ __html: dialogData.new || ''
143
+ }
144
+ })
86
145
  })
146
+ ]
147
+ }),
148
+ /*#__PURE__*/ jsx("div", {
149
+ style: {
150
+ display: dialogData.old ? 'block' : 'none'
151
+ },
152
+ className: "arrow",
153
+ children: /*#__PURE__*/ jsx("img", {
154
+ src: arrowImg,
155
+ alt: ''
87
156
  })
88
- ]
89
- }),
90
- /*#__PURE__*/ jsx("div", {
91
- style: {
92
- display: dialogData.old ? 'block' : 'none'
93
- },
94
- className: "arrow",
95
- children: /*#__PURE__*/ jsx("img", {
96
- src: arrowImg,
97
- alt: ''
98
157
  })
99
- })
100
- ]
101
- })
102
- ]
158
+ ]
159
+ })
160
+ ]
161
+ })
103
162
  });
104
163
  };
105
164
  const LogDialog = BiLogDialog;
@@ -1,3 +1,12 @@
1
+ .bi-log-drawer {
2
+ .ant-drawer-header {
3
+ box-sizing: border-box;
4
+ flex: 0 0 50px;
5
+ height: 50px;
6
+ padding: 0 20px;
7
+ }
8
+ }
9
+
1
10
  .bi-log-rich-text-box {
2
11
  height: calc(100vh - 160px - 56px);
3
12
  display: flex;
@@ -26,4 +35,4 @@
26
35
  width: 100%;
27
36
  height: 100%;
28
37
  }
29
- }
38
+ }
@@ -1,6 +1,8 @@
1
+ import type { ConfigProviderValue } from '../ConfigProvider';
1
2
  export interface BiLogDialogConfig {
2
- logId?: string;
3
+ logId?: string | number;
3
4
  logModel?: string;
5
+ configContext?: ConfigProviderValue;
4
6
  richTextData?: {
5
7
  new: string;
6
8
  old: string;
@@ -6,7 +6,7 @@ import components from "./components/index.js";
6
6
  import "./index.css";
7
7
  import { getEnv, getSystem } from "../../utils/tools.js";
8
8
  const avatar = 'https://zqingalioss.wozhangwan.com/zhangqing-test/uploads/9211/2025-10-21/1761024983_4SdTSjcJK8.png';
9
- const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, ...restProps })=>{
9
+ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, systemLink = true, avatarNode, ...restProps })=>{
10
10
  const system = getSystem() ?? '';
11
11
  const env = getEnv() ?? '';
12
12
  const wsRef = useRef(null);
@@ -127,15 +127,15 @@ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, ...restProps
127
127
  (downloadCenter || noticeCenter) && /*#__PURE__*/ jsx("div", {
128
128
  className: "divider"
129
129
  }),
130
- /*#__PURE__*/ jsx(BiAvatar, {
130
+ avatarNode || /*#__PURE__*/ jsx(BiAvatar, {
131
131
  ...restProps,
132
132
  image: restProps.avatar || avatar,
133
133
  logout: restProps.logout
134
134
  }),
135
- /*#__PURE__*/ jsx("div", {
135
+ systemLink && /*#__PURE__*/ jsx("div", {
136
136
  className: "divider"
137
137
  }),
138
- /*#__PURE__*/ jsx(BiSystemLink, {})
138
+ systemLink && /*#__PURE__*/ jsx(BiSystemLink, {})
139
139
  ]
140
140
  });
141
141
  };
@@ -2,6 +2,8 @@ export interface BiNavbarToolProps {
2
2
  token?: string;
3
3
  downloadCenter?: boolean;
4
4
  noticeCenter?: boolean;
5
+ systemLink?: boolean;
6
+ avatarNode?: React.ReactNode;
5
7
  userId?: string;
6
8
  [key: string]: any;
7
9
  }
@@ -1,4 +1,4 @@
1
1
  import './noticeCenter.scss';
2
2
  import type { NoticeCenterProps } from './types';
3
- declare const BiNoticeCenter: React.FC<NoticeCenterProps>;
3
+ declare const BiNoticeCenter: import("react").ForwardRefExoticComponent<NoticeCenterProps & import("react").RefAttributes<any>>;
4
4
  export default BiNoticeCenter;