@zw-team/react-lib 1.0.5-beta.5 → 1.0.5-beta.6
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/dist/components/ConfigProvider/ConfigContext.js +3 -0
- package/dist/components/ConfigProvider/ConfigProvider.js +24 -6
- package/dist/components/ConfigProvider/types.d.ts +21 -0
- package/dist/components/Form/Form.js +6 -2
- package/dist/components/FormItem/FormItem.js +6 -2
- package/dist/components/NavbarTool/NavbarTool.js +35 -16
- package/dist/components/NavbarTool/components/index.js +2 -2
- package/dist/components/NavbarTool/types.d.ts +13 -0
- package/dist/components/NoticeCenter/NoticeCenter.js +150 -84
- package/dist/components/NoticeCenter/noticeCenter.scss +48 -4
- package/dist/package.json +1 -1
- package/dist/utils/request/defaultRequest.js +6 -3
- package/dist/utils/request/index.d.ts +4 -0
- package/dist/utils/request/index.js +21 -1
- package/dist/utils/tools.d.ts +9 -0
- package/dist/utils/tools.js +15 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import js_cookie from "js-cookie";
|
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { initProdEnvWarning } from "../../utils/advisory.js";
|
|
6
6
|
import { loadIcon, loadSvg } from "../../utils/svgIcon/index.js";
|
|
7
|
+
import { isToolSystem, setToolCsrfToken } from "../../utils/tools.js";
|
|
7
8
|
import AccessReport from "../AccessReport/index.js";
|
|
8
9
|
import { ConfigContext, defaultConfig } from "./ConfigContext.js";
|
|
9
10
|
const ConfigProvider_ConfigProvider_ConfigProvider = ({ children, antdConfig, ...restProps })=>{
|
|
@@ -28,16 +29,23 @@ const ConfigProvider_ConfigProvider_ConfigProvider = ({ children, antdConfig, ..
|
|
|
28
29
|
...newConfig
|
|
29
30
|
}));
|
|
30
31
|
}, []);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const liveCsrfToken = restProps.csrfToken;
|
|
33
|
+
if (void 0 !== liveCsrfToken) setToolCsrfToken(liveCsrfToken);
|
|
34
|
+
if (contextValue.env) {
|
|
34
35
|
window.$BiEnv = contextValue.env;
|
|
35
|
-
window.$BiSystem = contextValue.system;
|
|
36
36
|
js_cookie.set('$BiEnv', contextValue.env);
|
|
37
|
+
}
|
|
38
|
+
if (contextValue.system) {
|
|
39
|
+
window.$BiSystem = contextValue.system;
|
|
37
40
|
js_cookie.set('$BiSystem', contextValue.system);
|
|
41
|
+
}
|
|
42
|
+
window.$BI = contextValue;
|
|
43
|
+
window.$AccessReport = contextValue.$AccessReport;
|
|
44
|
+
const install = ()=>{
|
|
38
45
|
initProdEnvWarning(contextValue.env || 'production', contextValue.showProdEnvWarning);
|
|
39
|
-
|
|
40
|
-
if (
|
|
46
|
+
const skipZqIcon = 'ark' === contextValue.system || isToolSystem();
|
|
47
|
+
if (!skipZqIcon) loadSvg(contextValue.system, contextValue.env || 'production', contextValue.mainOrigin);
|
|
48
|
+
if (contextValue.needIcon && !skipZqIcon) loadIcon(contextValue.env || 'production', (data)=>{
|
|
41
49
|
updateConfig({
|
|
42
50
|
iconList: data.data,
|
|
43
51
|
iconInit: true
|
|
@@ -47,6 +55,16 @@ const ConfigProvider_ConfigProvider_ConfigProvider = ({ children, antdConfig, ..
|
|
|
47
55
|
useEffect(()=>{
|
|
48
56
|
install();
|
|
49
57
|
}, []);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
if (void 0 === restProps.csrfToken) return;
|
|
60
|
+
setToolCsrfToken(restProps.csrfToken);
|
|
61
|
+
setContextValue((prev)=>prev.csrfToken === restProps.csrfToken ? prev : {
|
|
62
|
+
...prev,
|
|
63
|
+
csrfToken: restProps.csrfToken
|
|
64
|
+
});
|
|
65
|
+
}, [
|
|
66
|
+
restProps.csrfToken
|
|
67
|
+
]);
|
|
50
68
|
return /*#__PURE__*/ jsx(ConfigContext.Provider, {
|
|
51
69
|
value: {
|
|
52
70
|
contextValue,
|
|
@@ -5,7 +5,28 @@ export interface ContextValue {
|
|
|
5
5
|
system: string;
|
|
6
6
|
mainOrigin?: string;
|
|
7
7
|
request: any;
|
|
8
|
+
/**
|
|
9
|
+
* 小工具 BFF CSRF token,由宿主项目获取后注入;
|
|
10
|
+
* 组件库请求时自动放到 X-CSRF-Token,不负责向 /auth/csrf 获取。
|
|
11
|
+
*/
|
|
12
|
+
csrfToken?: string;
|
|
8
13
|
needIcon: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 是否显示下载中心,仅对 system="ark" 生效。
|
|
16
|
+
* 与 BiNavbarTool 同名 prop 任一为 true 即显示;非 ark 忽略该参数。
|
|
17
|
+
*/
|
|
18
|
+
downloadCenter?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 是否显示通知中心,仅对 system="ark" 生效。
|
|
21
|
+
* 与 BiNavbarTool 同名 prop 任一为 true 即显示;非 ark 忽略该参数。
|
|
22
|
+
* 通知中心展示时同步初始化其 WebSocket。
|
|
23
|
+
*/
|
|
24
|
+
noticeCenter?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 是否显示系统入口,仅对 system="ark" 生效(ark 默认不显示,可按需打开)。
|
|
27
|
+
* 与 BiNavbarTool 同名 prop 任一为 true 即显示;非 ark 忽略该参数。
|
|
28
|
+
*/
|
|
29
|
+
systemLink?: boolean;
|
|
9
30
|
iconInit: boolean;
|
|
10
31
|
iconList: Record<string, any>;
|
|
11
32
|
componentsKeys: string | number;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "./Form.css";
|
|
3
3
|
import { Form } from "antd";
|
|
4
|
+
import { classNames } from "../../utils/index.js";
|
|
4
5
|
const BaseForm = (props)=>{
|
|
5
|
-
const { form: externalForm, children, layout = 'inline', ...rest } = props;
|
|
6
|
+
const { form: externalForm, children, layout = 'inline', className, ...rest } = props;
|
|
6
7
|
const [internalForm] = Form.useForm();
|
|
7
8
|
const form = externalForm ?? internalForm;
|
|
8
9
|
return /*#__PURE__*/ jsx("div", {
|
|
9
|
-
className:
|
|
10
|
+
className: classNames([
|
|
11
|
+
'search-form',
|
|
12
|
+
className
|
|
13
|
+
]),
|
|
10
14
|
children: /*#__PURE__*/ jsx(Form, {
|
|
11
15
|
form: form,
|
|
12
16
|
layout: layout,
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { classNames } from "../../utils/index.js";
|
|
2
3
|
import "./FormItem.css";
|
|
3
4
|
import { Form } from "antd";
|
|
4
5
|
const FormItem = (props)=>{
|
|
5
|
-
const { children, label, button, ...rest } = props;
|
|
6
|
+
const { children, label, button, className, ...rest } = props;
|
|
6
7
|
return /*#__PURE__*/ jsxs("div", {
|
|
7
|
-
className:
|
|
8
|
+
className: classNames([
|
|
9
|
+
button ? 'search-item-button search-item' : 'search-item',
|
|
10
|
+
className
|
|
11
|
+
]),
|
|
8
12
|
children: [
|
|
9
13
|
label && !button && /*#__PURE__*/ jsx("div", {
|
|
10
14
|
className: 'string' == typeof label ? 'search-item-label' : 'search-item-label search-label-select',
|
|
@@ -2,13 +2,21 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { BiAvatar, BiNoticeCenter, BiSystemLink } from "../index.js";
|
|
4
4
|
import request from "../../utils/request/index.js";
|
|
5
|
+
import { useConfig } from "../ConfigProvider/ConfigContext.js";
|
|
5
6
|
import components from "./components/index.js";
|
|
6
7
|
import "./index.css";
|
|
7
8
|
import { getEnv, getSystem } from "../../utils/tools.js";
|
|
8
9
|
const avatar = 'https://zqingalioss.wozhangwan.com/zhangqing-test/uploads/9211/2025-10-21/1761024983_4SdTSjcJK8.png';
|
|
9
|
-
const BiNavbarTool = ({ downloadCenter
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const BiNavbarTool = ({ downloadCenter, noticeCenter, systemLink, avatarNode, ...restProps })=>{
|
|
11
|
+
const { contextValue } = useConfig();
|
|
12
|
+
const system = contextValue.system || getSystem() || '';
|
|
13
|
+
const env = contextValue.env || getEnv() || '';
|
|
14
|
+
const isArk = 'ark' === system;
|
|
15
|
+
const showDownloadCenter = isArk ? true === downloadCenter || true === contextValue.downloadCenter : false !== downloadCenter;
|
|
16
|
+
const showNoticeCenter = isArk ? true === noticeCenter || true === contextValue.noticeCenter : false !== noticeCenter;
|
|
17
|
+
const showSystemLink = isArk ? true === systemLink || true === contextValue.systemLink : false !== systemLink;
|
|
18
|
+
const enableNoticeWs = showNoticeCenter;
|
|
19
|
+
const toolCsrfReady = !isArk || Boolean(contextValue.csrfToken);
|
|
12
20
|
const wsRef = useRef(null);
|
|
13
21
|
const heartTimer = useRef(null);
|
|
14
22
|
const reconnectTimer = useRef(null);
|
|
@@ -18,15 +26,20 @@ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, systemLink =
|
|
|
18
26
|
const [downloadStatus, setDownloadStatus] = useState(false);
|
|
19
27
|
const isMounted = useRef(true);
|
|
20
28
|
const WebSocketInit = useCallback(async ()=>{
|
|
21
|
-
if (!isMounted.current ||
|
|
29
|
+
if (!isMounted.current || !enableNoticeWs || !toolCsrfReady) return;
|
|
22
30
|
try {
|
|
23
31
|
const res = await request({
|
|
24
32
|
env,
|
|
25
|
-
system: '
|
|
26
|
-
api: '/
|
|
33
|
+
system: 'service_center',
|
|
34
|
+
api: '/api/admin/message/getMCUrl',
|
|
35
|
+
data: {
|
|
36
|
+
system: system
|
|
37
|
+
}
|
|
27
38
|
});
|
|
28
39
|
if (!isMounted.current) return;
|
|
29
|
-
|
|
40
|
+
if (res?.status_code !== void 0 && 1 !== res.status_code) return void console.log('getMCUrl failed:', res?.msg);
|
|
41
|
+
const url = res?.data?.url ?? res?.url;
|
|
42
|
+
if (!url) return void console.log('getMCUrl: empty ws url');
|
|
30
43
|
const ws = new WebSocket(url);
|
|
31
44
|
wsRef.current = ws;
|
|
32
45
|
ws.onopen = wsOnopen;
|
|
@@ -39,7 +52,9 @@ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, systemLink =
|
|
|
39
52
|
}
|
|
40
53
|
}, [
|
|
41
54
|
env,
|
|
42
|
-
system
|
|
55
|
+
system,
|
|
56
|
+
enableNoticeWs,
|
|
57
|
+
toolCsrfReady
|
|
43
58
|
]);
|
|
44
59
|
const wsOnopen = ()=>{
|
|
45
60
|
console.log('WebSocket 连接成功');
|
|
@@ -87,7 +102,7 @@ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, systemLink =
|
|
|
87
102
|
useEffect(()=>{
|
|
88
103
|
isMounted.current = true;
|
|
89
104
|
reconnectCount.current = 0;
|
|
90
|
-
WebSocketInit();
|
|
105
|
+
if (enableNoticeWs && toolCsrfReady) WebSocketInit();
|
|
91
106
|
return ()=>{
|
|
92
107
|
console.log('%c 组件卸载,清除心跳定时器', 'color: white; background-color: #409EFF; padding: 2px 5px; border-radius: 2px;');
|
|
93
108
|
isMounted.current = false;
|
|
@@ -106,25 +121,29 @@ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, systemLink =
|
|
|
106
121
|
}
|
|
107
122
|
};
|
|
108
123
|
}, [
|
|
109
|
-
WebSocketInit
|
|
124
|
+
WebSocketInit,
|
|
125
|
+
enableNoticeWs,
|
|
126
|
+
toolCsrfReady
|
|
110
127
|
]);
|
|
111
128
|
return /*#__PURE__*/ jsxs("div", {
|
|
112
129
|
className: "bi-navbar-tool",
|
|
113
130
|
children: [
|
|
114
|
-
|
|
131
|
+
showDownloadCenter && /*#__PURE__*/ jsx(components, {
|
|
115
132
|
...restProps,
|
|
116
133
|
loading: downloadStatus,
|
|
117
134
|
system: system,
|
|
118
135
|
env: env,
|
|
119
|
-
requestFn: request
|
|
136
|
+
requestFn: request,
|
|
137
|
+
taskCenter: isArk ? true === restProps.taskCenter : false !== restProps.taskCenter,
|
|
138
|
+
downloadCenter: isArk ? false !== restProps.downloadCenter : false !== restProps.downloadCenter
|
|
120
139
|
}),
|
|
121
|
-
|
|
140
|
+
showNoticeCenter && /*#__PURE__*/ jsx(BiNoticeCenter, {
|
|
122
141
|
...restProps,
|
|
123
142
|
ref: noticeCenterRef,
|
|
124
143
|
system: system,
|
|
125
144
|
headerHeight: "64px"
|
|
126
145
|
}),
|
|
127
|
-
(
|
|
146
|
+
(showDownloadCenter || showNoticeCenter) && /*#__PURE__*/ jsx("div", {
|
|
128
147
|
className: "divider"
|
|
129
148
|
}),
|
|
130
149
|
avatarNode || /*#__PURE__*/ jsx(BiAvatar, {
|
|
@@ -132,10 +151,10 @@ const BiNavbarTool = ({ downloadCenter = true, noticeCenter = true, systemLink =
|
|
|
132
151
|
image: restProps.avatar || avatar,
|
|
133
152
|
logout: restProps.logout
|
|
134
153
|
}),
|
|
135
|
-
|
|
154
|
+
showSystemLink && /*#__PURE__*/ jsx("div", {
|
|
136
155
|
className: "divider"
|
|
137
156
|
}),
|
|
138
|
-
|
|
157
|
+
showSystemLink && /*#__PURE__*/ jsx(BiSystemLink, {})
|
|
139
158
|
]
|
|
140
159
|
});
|
|
141
160
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Badge, Button, Drawer, Tabs, Tooltip } from "antd";
|
|
3
|
-
import { classNames } from "../../../utils/classNames.js";
|
|
4
3
|
import { useCallback, useState } from "react";
|
|
5
4
|
import { BiDownloadCenter, BiTaskCenter } from "../../index.js";
|
|
5
|
+
import { classNames } from "../../../utils/classNames.js";
|
|
6
6
|
import "./index.css";
|
|
7
7
|
const DownloadCenter = (props)=>{
|
|
8
8
|
const { headerHeight = '50', loading = false, userId = '', system = '', taskCenter = true, downloadCenter = true, env, requestFn, className, style } = props;
|
|
@@ -82,7 +82,7 @@ const DownloadCenter = (props)=>{
|
|
|
82
82
|
},
|
|
83
83
|
onClose: handleDrawerClose,
|
|
84
84
|
children: [
|
|
85
|
-
'DownloadCenter' === tabsName && /*#__PURE__*/ jsx(BiDownloadCenter, {
|
|
85
|
+
'DownloadCenter' === tabsName && downloadCenter && /*#__PURE__*/ jsx(BiDownloadCenter, {
|
|
86
86
|
...props
|
|
87
87
|
}),
|
|
88
88
|
'TaskCenter' === tabsName && taskCenter && /*#__PURE__*/ jsx(BiTaskCenter, {
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
export interface BiNavbarToolProps {
|
|
2
2
|
token?: string;
|
|
3
|
+
/**
|
|
4
|
+
* 是否显示下载中心,默认 true。
|
|
5
|
+
* 非 ark 仅看该 prop;ark 下与 ConfigProvider.downloadCenter 任一为 true 即显示。
|
|
6
|
+
*/
|
|
3
7
|
downloadCenter?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 是否显示通知中心,默认 true。
|
|
10
|
+
* 非 ark 仅看该 prop;ark 下与 ConfigProvider.noticeCenter 任一为 true 即显示。
|
|
11
|
+
* 展示时同步初始化通知 WebSocket。
|
|
12
|
+
*/
|
|
4
13
|
noticeCenter?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 是否显示系统入口,默认 true(ark 默认不显示)。
|
|
16
|
+
* 非 ark 仅看该 prop;ark 下与 ConfigProvider.systemLink 任一为 true 即显示。
|
|
17
|
+
*/
|
|
5
18
|
systemLink?: boolean;
|
|
6
19
|
avatarNode?: React.ReactNode;
|
|
7
20
|
userId?: string;
|
|
@@ -8,6 +8,37 @@ import { diffTime } from "../../utils/time/index.js";
|
|
|
8
8
|
import { getEnv } from "../../utils/tools.js";
|
|
9
9
|
import "./noticeCenter.scss";
|
|
10
10
|
const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=>{
|
|
11
|
+
const NOTICE_TYPE_CLASS = {
|
|
12
|
+
1: {
|
|
13
|
+
name: '版本更新',
|
|
14
|
+
color: '#1890FF'
|
|
15
|
+
},
|
|
16
|
+
2: {
|
|
17
|
+
name: '系统维护',
|
|
18
|
+
color: '#FA8C16'
|
|
19
|
+
},
|
|
20
|
+
3: {
|
|
21
|
+
name: '故障通知',
|
|
22
|
+
color: '#F5222D'
|
|
23
|
+
},
|
|
24
|
+
4: {
|
|
25
|
+
name: '运营活动',
|
|
26
|
+
color: '#52C41A'
|
|
27
|
+
},
|
|
28
|
+
5: {
|
|
29
|
+
name: '业务通知',
|
|
30
|
+
color: '#722ED1'
|
|
31
|
+
},
|
|
32
|
+
6: {
|
|
33
|
+
name: '系统公告',
|
|
34
|
+
color: '#8C8C8C'
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const normalizeNoticeType = (noticeType)=>{
|
|
38
|
+
const type = String(noticeType || '1');
|
|
39
|
+
return NOTICE_TYPE_CLASS[type] ? type : '1';
|
|
40
|
+
};
|
|
41
|
+
const getNoticeTypeName = (noticeType)=>NOTICE_TYPE_CLASS[normalizeNoticeType(noticeType)].name;
|
|
11
42
|
const [detailData, setDetailData] = useState({
|
|
12
43
|
_id: {
|
|
13
44
|
oid: ''
|
|
@@ -25,10 +56,11 @@ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=
|
|
|
25
56
|
const [last_send_time, setLastSendTime] = useState('');
|
|
26
57
|
const [badgeNum, setBadgeNum] = useState(0);
|
|
27
58
|
const [detailVisible, setDetailVisible] = useState(false);
|
|
28
|
-
const dialogImg = 'https://
|
|
59
|
+
const dialogImg = (theme = 'light')=>`https://frontend-oss.zzwwiidd.com/bi-element-ui/NoticeCenter/notice-empty-${theme}.png`;
|
|
29
60
|
const [dialogVisible, setDialogVisible] = useState(false);
|
|
30
61
|
const [openNotice, setOpenNotice] = useState({
|
|
31
62
|
id: '',
|
|
63
|
+
notice_type: '1',
|
|
32
64
|
title: '',
|
|
33
65
|
content: "",
|
|
34
66
|
user_name: '',
|
|
@@ -78,6 +110,7 @@ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=
|
|
|
78
110
|
});
|
|
79
111
|
popupNotice({
|
|
80
112
|
id: item._id.oid,
|
|
113
|
+
notice_type: item.notice_type,
|
|
81
114
|
title: item.title,
|
|
82
115
|
content: item.content,
|
|
83
116
|
user_name: item.user_name,
|
|
@@ -91,6 +124,7 @@ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=
|
|
|
91
124
|
dialogSource.current = source;
|
|
92
125
|
setOpenNotice({
|
|
93
126
|
id: data.id,
|
|
127
|
+
notice_type: normalizeNoticeType(data.notice_type),
|
|
94
128
|
title: data.title,
|
|
95
129
|
content: data.content,
|
|
96
130
|
user_name: data.user_name,
|
|
@@ -104,6 +138,7 @@ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=
|
|
|
104
138
|
dialogSource.current = 'external';
|
|
105
139
|
setOpenNotice({
|
|
106
140
|
id: '',
|
|
141
|
+
notice_type: normalizeNoticeType(data.notice_type),
|
|
107
142
|
title: data.title || '',
|
|
108
143
|
content: data.content || '',
|
|
109
144
|
user_name: data.user_name || '',
|
|
@@ -211,31 +246,55 @@ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=
|
|
|
211
246
|
await request({
|
|
212
247
|
env: getEnv(),
|
|
213
248
|
system: 'zq',
|
|
214
|
-
api: '/api/system_notice/close',
|
|
249
|
+
api: '/api/admin/system_notice/close',
|
|
215
250
|
data: {
|
|
216
251
|
id
|
|
217
252
|
}
|
|
218
253
|
});
|
|
219
254
|
};
|
|
220
255
|
const NoticeModal = /*#__PURE__*/ jsxs(Modal, {
|
|
221
|
-
title:
|
|
256
|
+
title: null,
|
|
222
257
|
open: dialogVisible,
|
|
223
258
|
width: 680,
|
|
259
|
+
closable: false,
|
|
224
260
|
onCancel: ()=>noticeClose(openNotice.extra_id),
|
|
225
261
|
style: {
|
|
226
262
|
top: '38px'
|
|
227
263
|
},
|
|
228
264
|
footer: null,
|
|
229
265
|
wrapClassName: "notice-open-dialog",
|
|
266
|
+
styles: {
|
|
267
|
+
root: {
|
|
268
|
+
padding: 0,
|
|
269
|
+
background: 'transparent',
|
|
270
|
+
boxShadow: 'none',
|
|
271
|
+
borderRadius: 0,
|
|
272
|
+
overflow: 'hidden'
|
|
273
|
+
},
|
|
274
|
+
body: {
|
|
275
|
+
padding: 0
|
|
276
|
+
},
|
|
277
|
+
header: {
|
|
278
|
+
display: 'none',
|
|
279
|
+
padding: 0,
|
|
280
|
+
marginBottom: 0
|
|
281
|
+
}
|
|
282
|
+
},
|
|
230
283
|
children: [
|
|
231
284
|
/*#__PURE__*/ jsxs("div", {
|
|
232
285
|
className: "notice-open-container",
|
|
233
286
|
children: [
|
|
234
|
-
/*#__PURE__*/
|
|
287
|
+
/*#__PURE__*/ jsxs("div", {
|
|
235
288
|
className: "notice-bg",
|
|
236
|
-
children:
|
|
237
|
-
|
|
238
|
-
|
|
289
|
+
children: [
|
|
290
|
+
/*#__PURE__*/ jsx("img", {
|
|
291
|
+
src: dialogImg()
|
|
292
|
+
}),
|
|
293
|
+
/*#__PURE__*/ jsx("p", {
|
|
294
|
+
className: "notice-type",
|
|
295
|
+
children: getNoticeTypeName(openNotice.notice_type)
|
|
296
|
+
})
|
|
297
|
+
]
|
|
239
298
|
}),
|
|
240
299
|
/*#__PURE__*/ jsxs("div", {
|
|
241
300
|
className: "notice-open-box",
|
|
@@ -306,93 +365,100 @@ const BiNoticeCenter = /*#__PURE__*/ forwardRef(({ headerHeight, system }, ref)=
|
|
|
306
365
|
})
|
|
307
366
|
]
|
|
308
367
|
});
|
|
368
|
+
const noticeHeader = /*#__PURE__*/ jsxs("div", {
|
|
369
|
+
className: "notice-header",
|
|
370
|
+
children: [
|
|
371
|
+
/*#__PURE__*/ jsx("span", {
|
|
372
|
+
children: "系统通知"
|
|
373
|
+
}),
|
|
374
|
+
/*#__PURE__*/ jsx(Button, {
|
|
375
|
+
type: "text",
|
|
376
|
+
disabled: 0 === badgeNum && !currentUnreadNum(),
|
|
377
|
+
onClick: ()=>noticeAllRead(),
|
|
378
|
+
children: 0 !== badgeNum || currentUnreadNum() ? '全部标为已读' : '全部已读'
|
|
379
|
+
})
|
|
380
|
+
]
|
|
381
|
+
});
|
|
309
382
|
const prpoverContent = /*#__PURE__*/ jsx("div", {
|
|
310
383
|
className: "bi-notice-box",
|
|
311
|
-
children: /*#__PURE__*/
|
|
384
|
+
children: /*#__PURE__*/ jsx(Card, {
|
|
385
|
+
title: noticeHeader,
|
|
312
386
|
style: {
|
|
313
387
|
padding: 0
|
|
314
388
|
},
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
389
|
+
styles: {
|
|
390
|
+
body: {
|
|
391
|
+
padding: '0'
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
395
|
+
style: {
|
|
396
|
+
height: '400px',
|
|
397
|
+
overflowY: 'auto'
|
|
398
|
+
},
|
|
399
|
+
children: /*#__PURE__*/ jsxs(react_infinite_scroller, {
|
|
400
|
+
loadMore: loadMore,
|
|
401
|
+
hasMore: !noMore,
|
|
402
|
+
useWindow: false,
|
|
403
|
+
pageStart: 0,
|
|
404
|
+
className: "notice-list",
|
|
331
405
|
style: {
|
|
332
|
-
height: '400px'
|
|
333
|
-
overflowY: 'auto'
|
|
406
|
+
height: '400px'
|
|
334
407
|
},
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
hasMore: !noMore,
|
|
338
|
-
useWindow: false,
|
|
339
|
-
pageStart: 0,
|
|
340
|
-
className: "notice-list",
|
|
408
|
+
loader: /*#__PURE__*/ jsx("div", {
|
|
409
|
+
className: "loader",
|
|
341
410
|
style: {
|
|
342
|
-
|
|
411
|
+
textAlign: 'center'
|
|
343
412
|
},
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}) : ''
|
|
392
|
-
]
|
|
393
|
-
})
|
|
413
|
+
children: "Loading..."
|
|
414
|
+
}, 0),
|
|
415
|
+
children: [
|
|
416
|
+
noticeList.map((item, index)=>/*#__PURE__*/ jsxs("li", {
|
|
417
|
+
className: `notice-item ${!item.is_read ? 'unread' : ''}`,
|
|
418
|
+
onClick: ()=>detail(item),
|
|
419
|
+
children: [
|
|
420
|
+
/*#__PURE__*/ jsxs("div", {
|
|
421
|
+
className: "header",
|
|
422
|
+
children: [
|
|
423
|
+
/*#__PURE__*/ jsx("p", {
|
|
424
|
+
className: "title",
|
|
425
|
+
children: item.title
|
|
426
|
+
}),
|
|
427
|
+
/*#__PURE__*/ jsx("p", {
|
|
428
|
+
className: "time",
|
|
429
|
+
children: item.send_time
|
|
430
|
+
})
|
|
431
|
+
]
|
|
432
|
+
}),
|
|
433
|
+
/*#__PURE__*/ jsxs("div", {
|
|
434
|
+
className: "notice-content-box",
|
|
435
|
+
children: [
|
|
436
|
+
/*#__PURE__*/ jsx("div", {
|
|
437
|
+
className: "content",
|
|
438
|
+
children: item.describe
|
|
439
|
+
}),
|
|
440
|
+
/*#__PURE__*/ jsxs("div", {
|
|
441
|
+
className: "username",
|
|
442
|
+
children: [
|
|
443
|
+
"产品负责人: ",
|
|
444
|
+
item.user_name || '-'
|
|
445
|
+
]
|
|
446
|
+
})
|
|
447
|
+
]
|
|
448
|
+
})
|
|
449
|
+
]
|
|
450
|
+
}, `notice_${index}`)),
|
|
451
|
+
noMore ? /*#__PURE__*/ jsx("p", {
|
|
452
|
+
style: {
|
|
453
|
+
fontSize: '14px',
|
|
454
|
+
color: '#5e6d82',
|
|
455
|
+
textAlign: 'center'
|
|
456
|
+
},
|
|
457
|
+
children: "没有更多了"
|
|
458
|
+
}) : ''
|
|
459
|
+
]
|
|
394
460
|
})
|
|
395
|
-
|
|
461
|
+
})
|
|
396
462
|
})
|
|
397
463
|
});
|
|
398
464
|
const NoticePopover = /*#__PURE__*/ jsx(Popover, {
|
|
@@ -148,16 +148,60 @@
|
|
|
148
148
|
.notice-open-dialog {
|
|
149
149
|
background: none !important;
|
|
150
150
|
box-shadow: none !important;
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
|
|
152
|
+
// 对齐 bi-element-ui:去掉 dialog 边框/阴影/圆角/内边距,横幅通铺
|
|
153
|
+
.ant-modal,
|
|
154
|
+
.ant-modal-content,
|
|
155
|
+
.ant-modal-container,
|
|
156
|
+
.ant-modal-header,
|
|
157
|
+
.ant-modal-body {
|
|
158
|
+
background: none !important;
|
|
159
|
+
box-shadow: none !important;
|
|
160
|
+
border: none !important;
|
|
161
|
+
border-radius: 0 !important;
|
|
162
|
+
padding: 0 !important;
|
|
163
|
+
// margin: 0 !important;
|
|
153
164
|
}
|
|
154
|
-
.
|
|
155
|
-
padding: 0;
|
|
165
|
+
.ant-modal {
|
|
166
|
+
padding-bottom: 0 !important;
|
|
167
|
+
max-width: 100% !important;
|
|
168
|
+
}
|
|
169
|
+
.ant-modal-header,
|
|
170
|
+
.ant-modal-close {
|
|
171
|
+
display: none !important;
|
|
172
|
+
}
|
|
173
|
+
.notice-open-container {
|
|
174
|
+
overflow: hidden;
|
|
175
|
+
background: none;
|
|
176
|
+
border-radius: 0;
|
|
156
177
|
}
|
|
178
|
+
|
|
157
179
|
.notice-bg {
|
|
180
|
+
position: relative;
|
|
181
|
+
user-select: none;
|
|
182
|
+
-webkit-user-select: none;
|
|
158
183
|
img {
|
|
159
184
|
width: 100%;
|
|
160
185
|
display: block;
|
|
186
|
+
height: 180px;
|
|
187
|
+
}
|
|
188
|
+
.notice-type {
|
|
189
|
+
position: absolute;
|
|
190
|
+
left: 40px;
|
|
191
|
+
bottom: 56px;
|
|
192
|
+
z-index: 3;
|
|
193
|
+
max-width: none;
|
|
194
|
+
margin: 0;
|
|
195
|
+
transform: translateY(-50%);
|
|
196
|
+
color: #fff;
|
|
197
|
+
font-size: 38px;
|
|
198
|
+
line-height: 1.12;
|
|
199
|
+
font-weight: 800;
|
|
200
|
+
font-style: italic;
|
|
201
|
+
letter-spacing: 0;
|
|
202
|
+
text-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
overflow: visible;
|
|
161
205
|
}
|
|
162
206
|
}
|
|
163
207
|
.notice-open-box {
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { message } from "antd";
|
|
2
2
|
import axios from "axios";
|
|
3
|
-
import { getCSFToken } from "../tools.js";
|
|
3
|
+
import { getCSFToken, getToolCsrfToken, isToolSystem } from "../tools.js";
|
|
4
4
|
const service = axios.create({
|
|
5
5
|
baseURL: '',
|
|
6
6
|
withCredentials: true,
|
|
@@ -9,9 +9,12 @@ const service = axios.create({
|
|
|
9
9
|
service.interceptors.request.use((config)=>{
|
|
10
10
|
config.headers = {
|
|
11
11
|
...config.headers,
|
|
12
|
-
'Content-Type': 'application/json'
|
|
13
|
-
'zw-csrf-token': getCSFToken()
|
|
12
|
+
'Content-Type': 'application/json'
|
|
14
13
|
};
|
|
14
|
+
if (isToolSystem()) {
|
|
15
|
+
const token = getToolCsrfToken();
|
|
16
|
+
if (token) config.headers['X-CSRF-Token'] = token;
|
|
17
|
+
} else config.headers['zw-csrf-token'] = getCSFToken();
|
|
15
18
|
return config;
|
|
16
19
|
}, (error)=>{
|
|
17
20
|
console.error('请求配置错误:', error);
|
|
@@ -4,8 +4,12 @@ import { type EnvType } from '../../config/index';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare enum SystemType {
|
|
6
6
|
ZHANGQUAN = "zq",
|
|
7
|
+
/** 小工具:同域 /api + cookie 鉴权 */
|
|
8
|
+
ARK = "ark",
|
|
7
9
|
OTHER = "other"
|
|
8
10
|
}
|
|
11
|
+
/** 是否小工具请求模式(接口地址不变,仅切换同域 cookie 直连) */
|
|
12
|
+
export declare function isToolRequestMode(system?: string): system is SystemType.ARK;
|
|
9
13
|
/**
|
|
10
14
|
* 请求配置接口
|
|
11
15
|
*/
|
|
@@ -2,9 +2,18 @@ import { getServiceURL } from "../../config/index.js";
|
|
|
2
2
|
import defaultRequest from "./defaultRequest.js";
|
|
3
3
|
var request_SystemType = /*#__PURE__*/ function(SystemType) {
|
|
4
4
|
SystemType["ZHANGQUAN"] = "zq";
|
|
5
|
+
SystemType["ARK"] = "ark";
|
|
5
6
|
SystemType["OTHER"] = "other";
|
|
6
7
|
return SystemType;
|
|
7
8
|
}({});
|
|
9
|
+
function isToolRequestMode(system) {
|
|
10
|
+
return "ark" === system;
|
|
11
|
+
}
|
|
12
|
+
function getRuntimeSystem() {
|
|
13
|
+
if ('undefined' == typeof window) return '';
|
|
14
|
+
const runtimeWindow = window;
|
|
15
|
+
return runtimeWindow.$BI?.system || '';
|
|
16
|
+
}
|
|
8
17
|
function isAbsoluteUrl(url) {
|
|
9
18
|
return /^https?:\/\//i.test(url);
|
|
10
19
|
}
|
|
@@ -26,6 +35,17 @@ function request(config) {
|
|
|
26
35
|
const { env = 'production', system, api, data = {}, headers = {}, mainOrigin } = config;
|
|
27
36
|
const resolvedMainOrigin = mainOrigin || getRuntimeMainOrigin();
|
|
28
37
|
const baseUrl = resolveBaseUrl(getServiceURL(void 0, env), resolvedMainOrigin);
|
|
38
|
+
if (isToolRequestMode(system) || isToolRequestMode(getRuntimeSystem())) {
|
|
39
|
+
const url = resolvedMainOrigin ? joinUrl(resolvedMainOrigin, api) : api;
|
|
40
|
+
return defaultRequest({
|
|
41
|
+
url,
|
|
42
|
+
method: 'post',
|
|
43
|
+
headers: {
|
|
44
|
+
...headers
|
|
45
|
+
},
|
|
46
|
+
data
|
|
47
|
+
});
|
|
48
|
+
}
|
|
29
49
|
if ("zq" === system) {
|
|
30
50
|
const defaultHeaders = {
|
|
31
51
|
Authkey: 'authtpe84dzfl3iq62'
|
|
@@ -55,4 +75,4 @@ function request(config) {
|
|
|
55
75
|
}
|
|
56
76
|
});
|
|
57
77
|
}
|
|
58
|
-
export { request_SystemType as SystemType, request as default };
|
|
78
|
+
export { request_SystemType as SystemType, request as default, isToolRequestMode };
|
package/dist/utils/tools.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export declare function getCSFToken(key?: string): string;
|
|
|
22
22
|
* @returns 系统信息,如果不存在则返回undefined
|
|
23
23
|
*/
|
|
24
24
|
export declare function getSystem(key?: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* 是否小工具(ark)运行时:优先读 $BI.system,回退 cookie $BiSystem
|
|
27
|
+
*/
|
|
28
|
+
export declare function isToolSystem(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 小工具 CSRF token:由宿主项目获取后注入,组件库只负责携带到 X-CSRF-Token
|
|
31
|
+
*/
|
|
32
|
+
export declare function setToolCsrfToken(token: string): void;
|
|
33
|
+
export declare function getToolCsrfToken(): string;
|
|
25
34
|
/**
|
|
26
35
|
* 获取环境信息
|
|
27
36
|
* @param key Cookie键名,默认为'$BiEnv'
|
package/dist/utils/tools.js
CHANGED
|
@@ -15,6 +15,20 @@ function getCSFToken(key = 'zw-csrf-token') {
|
|
|
15
15
|
function getSystem(key = '$BiSystem') {
|
|
16
16
|
return js_cookie.get(key);
|
|
17
17
|
}
|
|
18
|
+
function isToolSystem() {
|
|
19
|
+
if ('undefined' != typeof window) {
|
|
20
|
+
const runtime = window.$BI?.system;
|
|
21
|
+
if ('ark' === runtime) return true;
|
|
22
|
+
}
|
|
23
|
+
return 'ark' === getSystem();
|
|
24
|
+
}
|
|
25
|
+
let toolCsrfToken = '';
|
|
26
|
+
function setToolCsrfToken(token) {
|
|
27
|
+
toolCsrfToken = token || '';
|
|
28
|
+
}
|
|
29
|
+
function getToolCsrfToken() {
|
|
30
|
+
return toolCsrfToken;
|
|
31
|
+
}
|
|
18
32
|
function getEnv(key = '$BiEnv') {
|
|
19
33
|
return js_cookie.get(key);
|
|
20
34
|
}
|
|
@@ -54,4 +68,4 @@ function isNumeric(value) {
|
|
|
54
68
|
return /^-?\d+(\.\d+)?$/.test(str);
|
|
55
69
|
}
|
|
56
70
|
const eventEmitter = new event_emitter();
|
|
57
|
-
export { eventEmitter, getCSFToken, getComponentsKeys, getEnv, getSystem, getToken, isNumeric, randomStr, removeAllCookies };
|
|
71
|
+
export { eventEmitter, getCSFToken, getComponentsKeys, getEnv, getSystem, getToken, getToolCsrfToken, isNumeric, isToolSystem, randomStr, removeAllCookies, setToolCsrfToken };
|