@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
@@ -1,13 +1,13 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { BellOutlined } from "@ant-design/icons";
3
- import { Badge, Button, Card, Drawer, Modal, Popover, Space } from "antd";
4
- import { useState } from "react";
3
+ import { Badge, Button, Card, Drawer, Image, Modal, Popover, Space } from "antd";
4
+ import { forwardRef, useImperativeHandle, useRef, useState } from "react";
5
5
  import react_infinite_scroller from "react-infinite-scroller";
6
6
  import request from "../../utils/request/index.js";
7
7
  import { diffTime } from "../../utils/time/index.js";
8
8
  import { getEnv } from "../../utils/tools.js";
9
9
  import "./noticeCenter.scss";
10
- const BiNoticeCenter = ({ headerHeight, system })=>{
10
+ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=>{
11
11
  const [detailData, setDetailData] = useState({
12
12
  _id: {
13
13
  oid: ''
@@ -36,6 +36,8 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
36
36
  extra_id: ''
37
37
  });
38
38
  const [noMore, setNoMore] = useState(false);
39
+ const dialogSource = useRef('');
40
+ const [previewUrl, setPreviewUrl] = useState('');
39
41
  const handleNoticeRead = async (msg_id)=>{
40
42
  const res = await request({
41
43
  env: getEnv(),
@@ -81,10 +83,12 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
81
83
  user_name: item.user_name,
82
84
  send_time: item.send_time,
83
85
  extra_id: item.extra_id
84
- }, true);
86
+ }, true, 'list');
85
87
  handleNoticeRead(item._id.oid);
86
88
  };
87
- const popupNotice = (data, onlyRead = false)=>{
89
+ const popupNotice = (data, onlyRead = false, source = 'websocket')=>{
90
+ if ('external' === dialogSource.current && dialogVisible) return;
91
+ dialogSource.current = source;
88
92
  setOpenNotice({
89
93
  id: data.id,
90
94
  title: data.title,
@@ -94,7 +98,19 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
94
98
  extra_id: data.extra_id
95
99
  });
96
100
  setDialogVisible(true);
97
- true !== onlyRead && noticePoped(openNotice.id);
101
+ true !== onlyRead && noticePoped(data.id);
102
+ };
103
+ const openExternalNoticeDialog = (data)=>{
104
+ dialogSource.current = 'external';
105
+ setOpenNotice({
106
+ id: '',
107
+ title: data.title || '',
108
+ content: data.content || '',
109
+ user_name: data.user_name || '',
110
+ send_time: data.send_time || '',
111
+ extra_id: ''
112
+ });
113
+ setDialogVisible(true);
98
114
  };
99
115
  const noticePoped = async (msg_id)=>{
100
116
  await request({
@@ -121,6 +137,11 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
121
137
  const setUnreadNum = (unread_num)=>{
122
138
  setBadgeNum(Number(unread_num));
123
139
  };
140
+ useImperativeHandle(ref, ()=>({
141
+ setUnreadNum,
142
+ popupNotice,
143
+ openExternalNoticeDialog
144
+ }));
124
145
  const fetchData = async ()=>{
125
146
  try {
126
147
  if (noMore) return;
@@ -174,7 +195,17 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
174
195
  };
175
196
  const noticeClose = (id)=>{
176
197
  setDialogVisible(false);
177
- noticeRead(id);
198
+ const source = dialogSource.current;
199
+ dialogSource.current = '';
200
+ if (('websocket' === source || 'list' === source) && id) noticeRead(id);
201
+ };
202
+ const handleContentClick = (event)=>{
203
+ const target = event.target;
204
+ if ('IMG' === target.tagName) setPreviewUrl(target.src);
205
+ };
206
+ const handleContentMouseOver = (event)=>{
207
+ const target = event.target;
208
+ if ('IMG' === target.tagName) target.title = '点击预览';
178
209
  };
179
210
  const noticeRead = async (id)=>{
180
211
  await request({
@@ -186,80 +217,94 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
186
217
  }
187
218
  });
188
219
  };
189
- const NoticeModal = /*#__PURE__*/ jsx(Modal, {
220
+ const NoticeModal = /*#__PURE__*/ jsxs(Modal, {
190
221
  title: "提示",
191
222
  open: dialogVisible,
192
223
  width: 680,
193
- onCancel: ()=>setDialogVisible(false),
224
+ onCancel: ()=>noticeClose(openNotice.extra_id),
194
225
  style: {
195
226
  top: '38px'
196
227
  },
197
228
  footer: null,
198
229
  wrapClassName: "notice-open-dialog",
199
- children: /*#__PURE__*/ jsxs("div", {
200
- className: "notice-open-container",
201
- children: [
202
- /*#__PURE__*/ jsx("div", {
203
- className: "notice-bg",
204
- children: /*#__PURE__*/ jsx("img", {
205
- src: dialogImg
206
- })
207
- }),
208
- /*#__PURE__*/ jsxs("div", {
209
- className: "notice-open-box",
210
- children: [
211
- /*#__PURE__*/ jsx("p", {
212
- className: "notice-open-tile",
213
- children: openNotice.title
214
- }),
215
- /*#__PURE__*/ jsx("div", {
216
- className: "notice-open-box-scrollbar",
217
- children: /*#__PURE__*/ jsxs("div", {
218
- className: "notice-open-content",
219
- children: [
220
- /*#__PURE__*/ jsxs("div", {
221
- className: "notice-open-content-info",
222
- children: [
223
- /*#__PURE__*/ jsxs("div", {
224
- children: [
225
- "产品负责人: ",
226
- /*#__PURE__*/ jsx("span", {
227
- children: openNotice.user_name || '-'
228
- })
229
- ]
230
- }),
231
- /*#__PURE__*/ jsxs("div", {
232
- children: [
233
- "发送时间: ",
234
- /*#__PURE__*/ jsx("span", {
235
- children: openNotice.send_time
236
- })
237
- ]
238
- })
239
- ]
240
- }),
241
- /*#__PURE__*/ jsx("div", {
242
- dangerouslySetInnerHTML: {
243
- __html: openNotice.content
244
- }
245
- })
246
- ]
247
- })
248
- }),
249
- /*#__PURE__*/ jsx("div", {
250
- className: "notice-open-button",
251
- children: /*#__PURE__*/ jsx(Button, {
252
- type: "primary",
253
- onClick: ()=>{
254
- noticeClose(openNotice.extra_id);
255
- },
256
- children: "知道了"
257
- })
230
+ children: [
231
+ /*#__PURE__*/ jsxs("div", {
232
+ className: "notice-open-container",
233
+ children: [
234
+ /*#__PURE__*/ jsx("div", {
235
+ className: "notice-bg",
236
+ children: /*#__PURE__*/ jsx("img", {
237
+ src: dialogImg
258
238
  })
259
- ]
260
- })
261
- ]
262
- })
239
+ }),
240
+ /*#__PURE__*/ jsxs("div", {
241
+ className: "notice-open-box",
242
+ children: [
243
+ /*#__PURE__*/ jsx("p", {
244
+ className: "notice-open-tile",
245
+ children: openNotice.title
246
+ }),
247
+ /*#__PURE__*/ jsx("div", {
248
+ className: "notice-open-box-scrollbar",
249
+ children: /*#__PURE__*/ jsxs("div", {
250
+ className: "notice-open-content",
251
+ onClick: handleContentClick,
252
+ onMouseOver: handleContentMouseOver,
253
+ children: [
254
+ /*#__PURE__*/ jsxs("div", {
255
+ className: "notice-open-content-info",
256
+ children: [
257
+ /*#__PURE__*/ jsxs("div", {
258
+ children: [
259
+ "产品负责人: ",
260
+ /*#__PURE__*/ jsx("span", {
261
+ children: openNotice.user_name || '-'
262
+ })
263
+ ]
264
+ }),
265
+ /*#__PURE__*/ jsxs("div", {
266
+ children: [
267
+ "发送时间: ",
268
+ /*#__PURE__*/ jsx("span", {
269
+ children: openNotice.send_time
270
+ })
271
+ ]
272
+ })
273
+ ]
274
+ }),
275
+ /*#__PURE__*/ jsx("div", {
276
+ dangerouslySetInnerHTML: {
277
+ __html: openNotice.content
278
+ }
279
+ })
280
+ ]
281
+ })
282
+ }),
283
+ /*#__PURE__*/ jsx("div", {
284
+ className: "notice-open-button",
285
+ children: /*#__PURE__*/ jsx(Button, {
286
+ type: "primary",
287
+ onClick: ()=>{
288
+ noticeClose(openNotice.extra_id);
289
+ },
290
+ children: "知道了"
291
+ })
292
+ })
293
+ ]
294
+ })
295
+ ]
296
+ }),
297
+ /*#__PURE__*/ jsx(Image, {
298
+ src: previewUrl,
299
+ style: {
300
+ display: 'none'
301
+ },
302
+ preview: {
303
+ visible: Boolean(previewUrl),
304
+ onVisibleChange: (visible)=>!visible && setPreviewUrl('')
305
+ }
306
+ })
307
+ ]
263
308
  });
264
309
  const prpoverContent = /*#__PURE__*/ jsx("div", {
265
310
  className: "bi-notice-box",
@@ -421,6 +466,6 @@ const BiNoticeCenter = ({ headerHeight, system })=>{
421
466
  NoticeDrawer
422
467
  ]
423
468
  });
424
- };
469
+ });
425
470
  const NoticeCenter = BiNoticeCenter;
426
471
  export { NoticeCenter as default };
@@ -176,7 +176,16 @@
176
176
  color: #323335;
177
177
  line-height: 30px;
178
178
  }
179
- .notice-open-content {
179
+ .notice-open-content {
180
+ * {
181
+ line-height: normal;
182
+ }
183
+
184
+ img {
185
+ max-width: 100%;
186
+ border-radius: 4px;
187
+ cursor: pointer;
188
+ }
180
189
  font-size: 14px;
181
190
  font-weight: 400;
182
191
  color: #333333;
@@ -1,6 +1,4 @@
1
- import type { RefObject } from 'react';
2
1
  export interface NoticeCenterProps {
3
- headerHeight: string;
2
+ headerHeight?: string;
4
3
  system: string;
5
- ref?: RefObject<any>;
6
4
  }
@@ -1,11 +1,14 @@
1
1
  import { useCallback, useEffect, useState } from "react";
2
2
  import request from "../../utils/request/index.js";
3
3
  import { getEnv, getSystem } from "../../utils/tools.js";
4
+ import { useConfig } from "../ConfigProvider/ConfigContext.js";
4
5
  const useHeaderPopper = (moduleName)=>{
5
6
  const [popperData, setPopperData] = useState([]);
6
7
  const [editEnabled, setEditEnabled] = useState(false);
8
+ const { contextValue } = useConfig();
7
9
  const system = getSystem() || '';
8
10
  const $BiEnv = getEnv() || '';
11
+ const mainOrigin = contextValue.mainOrigin;
9
12
  const getPopperList = useCallback(async ()=>{
10
13
  if (!moduleName) return;
11
14
  {
@@ -19,7 +22,8 @@ const useHeaderPopper = (moduleName)=>{
19
22
  headers: {
20
23
  System: system,
21
24
  Authkey: ''
22
- }
25
+ },
26
+ mainOrigin
23
27
  });
24
28
  if (1 === res.status_code) {
25
29
  setEditEnabled(res.data.super);
@@ -29,7 +33,8 @@ const useHeaderPopper = (moduleName)=>{
29
33
  }, [
30
34
  moduleName,
31
35
  $BiEnv,
32
- system
36
+ system,
37
+ mainOrigin
33
38
  ]);
34
39
  useEffect(()=>{
35
40
  if (moduleName) getPopperList();
@@ -54,7 +59,8 @@ const useHeaderPopper = (moduleName)=>{
54
59
  headers: {
55
60
  System: system,
56
61
  Authkey: ''
57
- }
62
+ },
63
+ mainOrigin
58
64
  });
59
65
  if (1 === res.status_code) await getPopperList();
60
66
  return res;
@@ -63,6 +69,7 @@ const useHeaderPopper = (moduleName)=>{
63
69
  moduleName,
64
70
  $BiEnv,
65
71
  system,
72
+ mainOrigin,
66
73
  getPopperList
67
74
  ]);
68
75
  const delPopperItem = useCallback(async (id)=>{
@@ -76,12 +83,13 @@ const useHeaderPopper = (moduleName)=>{
76
83
  headers: {
77
84
  System: system,
78
85
  Authkey: ''
79
- }
86
+ },
87
+ mainOrigin
80
88
  });
81
89
  }, [
82
90
  $BiEnv,
83
91
  system,
84
- getPopperList
92
+ mainOrigin
85
93
  ]);
86
94
  const findPopperData = useCallback((prop)=>popperData.find((item)=>item.prop === prop), [
87
95
  popperData
@@ -1,9 +1,15 @@
1
1
  import { useCallback } from "react";
2
2
  import { useConfig } from "../components/ConfigProvider/ConfigContext.js";
3
+ function getRuntimeAccessReport() {
4
+ if ('undefined' == typeof window) return;
5
+ const runtimeWindow = window;
6
+ return runtimeWindow.$AccessReport;
7
+ }
3
8
  const useAccessReport_useAccessReport = ()=>{
4
9
  const { contextValue } = useConfig();
5
10
  const accessReport = useCallback((router, page)=>{
6
- contextValue.$AccessReport?.report(router, page);
11
+ const report = contextValue.$AccessReport || getRuntimeAccessReport();
12
+ report?.report(router, page);
7
13
  }, [
8
14
  contextValue.$AccessReport
9
15
  ]);
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@zw-team/react-lib",
3
+ "version": "1.0.5-beta.4",
4
+ "description": "zw-team 业务组件库,基于 React + Ant Design,提供通用组件、Hooks 与工具函数",
5
+ "keywords": [
6
+ "react",
7
+ "antd",
8
+ "components",
9
+ "hooks",
10
+ "utils",
11
+ "zw-team"
12
+ ],
13
+ "author": "zw-team",
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "http://git.wozhangwan.com/frontend/react-components.git"
18
+ },
19
+ "homepage": "http://git.wozhangwan.com/frontend/react-components",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./index.d.ts",
24
+ "import": "./index.js"
25
+ },
26
+ "./components": {
27
+ "types": "./components/index.d.ts",
28
+ "import": "./components/index.js"
29
+ },
30
+ "./hooks": {
31
+ "types": "./hooks/index.d.ts",
32
+ "import": "./hooks/index.js"
33
+ },
34
+ "./utils": {
35
+ "types": "./utils/index.d.ts",
36
+ "import": "./utils/index.js"
37
+ },
38
+ "./config": {
39
+ "types": "./config/index.d.ts",
40
+ "import": "./config/index.js"
41
+ }
42
+ },
43
+ "types": "./index.d.ts",
44
+ "engines": {
45
+ "node": ">=20.0.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public",
49
+ "registry": "https://registry.npmjs.org"
50
+ },
51
+ "sideEffects": [
52
+ "**/*.css",
53
+ "**/*.scss"
54
+ ],
55
+ "dependencies": {
56
+ "@braintree/event-emitter": "2.0.2",
57
+ "ali-oss": "^6.23.0",
58
+ "js-cookie": "^3.0.5",
59
+ "md5": "^2.3.0",
60
+ "react-infinite-scroller": "^1.2.6",
61
+ "react-quill-new": "^3.7.0",
62
+ "react-resizable": "^3.0.5",
63
+ "sortablejs": "^1.15.6"
64
+ },
65
+ "peerDependencies": {
66
+ "@ant-design/icons": ">=6.1.0",
67
+ "antd": ">=6.0.0",
68
+ "axios": ">=1.0.0",
69
+ "dayjs": ">=1.11.0",
70
+ "react": ">=18.0.0",
71
+ "react-dom": ">=18.0.0",
72
+ "zustand": ">=5.0.0"
73
+ }
74
+ }
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * 根据环境和 cookie 判断是否需要显示正式环境警告,满足条件时自动创建悬浮提示
3
- * 条件:zw-warning cookie === '1' 且 env 为 prod / production / development
3
+ * 条件:zw-warning cookie === '1' 且 env 为 prod / production
4
4
  */
5
- export declare function initProdEnvWarning(env: string): void;
5
+ export declare function initProdEnvWarning(env: string, showProdEnvWarning?: boolean): void;
6
6
  /**
7
7
  * 创建正式环境悬浮提示框
8
8
  * 带有打砖块式物理碰撞算法的悬浮提示,会在窗口内自由运动并反射
@@ -1,12 +1,17 @@
1
1
  import js_cookie from "js-cookie";
2
- function initProdEnvWarning(env) {
2
+ function initProdEnvWarning(env, showProdEnvWarning = true) {
3
3
  if ('undefined' == typeof window) return;
4
+ if (isWujieMicroApp()) return;
4
5
  const isZwWarning = js_cookie.get('zw-warning') || '0';
5
- if ('1' === isZwWarning && ('prod' === env || 'production' === env)) setTimeout(()=>{
6
+ if ('1' === isZwWarning && ('prod' === env || 'production' === env) && showProdEnvWarning) setTimeout(()=>{
6
7
  const indicator = createProdEnvIndicator();
7
8
  if (indicator) window.$BIProdIndicator = indicator;
8
9
  }, 100);
9
10
  }
11
+ function isWujieMicroApp() {
12
+ const runtimeWindow = window;
13
+ return Boolean(runtimeWindow.__POWERED_BY_WUJIE__ || runtimeWindow.$wujie);
14
+ }
10
15
  function createProdEnvIndicator() {
11
16
  if ('undefined' == typeof window) return;
12
17
  if (document.getElementById('bi-prod-env-indicator')) return;
@@ -17,9 +17,15 @@ function resolveBaseUrl(baseUrl, mainOrigin) {
17
17
  if (!mainOrigin || isAbsoluteUrl(baseUrl)) return baseUrl;
18
18
  return joinUrl(mainOrigin, baseUrl);
19
19
  }
20
+ function getRuntimeMainOrigin() {
21
+ if ('undefined' == typeof window) return;
22
+ const runtimeWindow = window;
23
+ return runtimeWindow.$BI?.mainOrigin;
24
+ }
20
25
  function request(config) {
21
26
  const { env = 'production', system, api, data = {}, headers = {}, mainOrigin } = config;
22
- const baseUrl = resolveBaseUrl(getServiceURL(void 0, env), mainOrigin);
27
+ const resolvedMainOrigin = mainOrigin || getRuntimeMainOrigin();
28
+ const baseUrl = resolveBaseUrl(getServiceURL(void 0, env), resolvedMainOrigin);
23
29
  if ("zq" === system) {
24
30
  const defaultHeaders = {
25
31
  Authkey: 'authtpe84dzfl3iq62'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zw-team/react-lib",
3
- "version": "1.0.5-beta.2",
3
+ "version": "1.0.5-beta.4",
4
4
  "description": "zw-team 业务组件库,基于 React + Ant Design,提供通用组件、Hooks 与工具函数",
5
5
  "keywords": [
6
6
  "react",
@@ -56,7 +56,7 @@
56
56
  "**/*.scss"
57
57
  ],
58
58
  "scripts": {
59
- "build": "rslib build",
59
+ "build": "rslib build && node scripts/write-dist-package.mjs",
60
60
  "build:storybook": "storybook build",
61
61
  "check": "biome check --write",
62
62
  "dev": "rslib build --watch",