@lark-apaas/client-toolkit 1.2.70-alpha.20260909115958 → 1.2.70
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/lib/components/AppContainer/Watermark.d.ts +13 -23
- package/lib/components/AppContainer/Watermark.js +150 -48
- package/lib/components/AppContainer/__test__/Watermark.test.js +41 -29
- package/lib/components/AppContainer/doubao-watermark-asset.d.ts +1 -0
- package/lib/components/AppContainer/doubao-watermark-asset.js +4 -3
- package/package.json +1 -1
|
@@ -1,51 +1,41 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
* 打开「投诉与举报」页:scene/entity_type 固定,entity_id 取当前妙搭 appId,域名按环境选,
|
|
4
|
-
* params 整体 encode。appId 为空(异常环境)时直接不跳转,避免带空 entity_id 打开举报中心
|
|
5
|
-
* (与 safety.tsx openReport 同口径)。
|
|
6
|
-
*/
|
|
7
|
-
export declare const openDoubaoReport: () => void;
|
|
2
|
+
export declare const openReport: () => void;
|
|
8
3
|
export declare const FeedbackIcon: React.FC;
|
|
9
4
|
export declare const CloseIcon: React.FC<{
|
|
10
5
|
size: number;
|
|
11
6
|
}>;
|
|
12
|
-
export declare const
|
|
7
|
+
export declare const DownloadIcon: React.FC;
|
|
8
|
+
export declare const EfficiencyIcon: React.FC;
|
|
9
|
+
type IconType = 'feedback' | 'close' | 'download' | 'efficiency';
|
|
10
|
+
export declare const BrandLogo: React.FC<{
|
|
11
|
+
src: string;
|
|
13
12
|
size: number;
|
|
14
13
|
}>;
|
|
15
14
|
export declare const Pill: React.FC<{
|
|
16
|
-
|
|
15
|
+
platform: 'desktop' | 'mobile';
|
|
16
|
+
brandText: string;
|
|
17
|
+
logoSrc: string;
|
|
17
18
|
onClose?: () => void;
|
|
18
19
|
showClose?: boolean;
|
|
19
20
|
}>;
|
|
20
21
|
export declare const MenuRow: React.FC<{
|
|
21
|
-
icon:
|
|
22
|
+
icon: IconType;
|
|
22
23
|
label: string;
|
|
23
24
|
fontSize: number;
|
|
24
25
|
onClick?: () => void;
|
|
25
26
|
}>;
|
|
26
27
|
type MenuItem = {
|
|
27
|
-
icon:
|
|
28
|
+
icon: IconType;
|
|
28
29
|
label: string;
|
|
29
30
|
onClick?: () => void;
|
|
30
31
|
};
|
|
31
32
|
export declare const MenuCard: React.FC<{
|
|
32
33
|
items: MenuItem[];
|
|
34
|
+
extraItems?: MenuItem[];
|
|
33
35
|
fontSize: number;
|
|
34
|
-
footerFontSize: number;
|
|
35
36
|
minWidth: number;
|
|
37
|
+
itemGap?: number;
|
|
36
38
|
style?: React.CSSProperties;
|
|
37
39
|
}>;
|
|
38
|
-
/**
|
|
39
|
-
* 豆包水印:在视口右下角展示收起态药丸(头像 +「豆包AI」)。
|
|
40
|
-
*
|
|
41
|
-
* 设计稿:Figma 1582:41560(桌面)/ 1582:41777(移动)。
|
|
42
|
-
* - 药丸 / 卡片本体用代码画(投影走 CSS box-shadow、图标用无滤镜小 SVG),高分屏清晰。
|
|
43
|
-
* - 桌面端点关闭叉 → 隐藏整个水印;hover 徽标 → 上方弹白色卡片(投诉与举报 + 由飞书妙搭提供支持)。
|
|
44
|
-
* - 移动端 tap 徽标 → 上方弹卡片(投诉与举报 / 不再展示 / 由飞书妙搭提供支持)。
|
|
45
|
-
* - 「投诉与举报」点击跳飞书风控举报中心(tns,域名随环境);后端链接未就绪时由 REPORT_ENABLED 整体隐藏。
|
|
46
|
-
* - 不加 NODE_ENV 判断——预览态与运行态都要展示。
|
|
47
|
-
* - show_badge=false(后端 get_published 接口返回)时不展示。
|
|
48
|
-
* - 用户点击关闭后 localStorage 记忆,刷新不再展示。
|
|
49
|
-
*/
|
|
50
40
|
declare const Watermark: React.FC;
|
|
51
41
|
export default Watermark;
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { Content, Portal, Root, Trigger } from "@radix-ui/react-popover";
|
|
4
|
-
import { DOUBAO_LOGO_SRC } from "./doubao-watermark-asset.js";
|
|
4
|
+
import { DOUBAO_LOGO_SRC, MIAODA_LOGO_SRC } from "./doubao-watermark-asset.js";
|
|
5
5
|
import { getAppId } from "../../utils/getAppId.js";
|
|
6
6
|
import { getEnv } from "../../utils/getParentOrigin.js";
|
|
7
7
|
import { getInitialInfo } from "../../utils/getInitialInfo.js";
|
|
8
8
|
import { useIsMobile } from "../../hooks/index.js";
|
|
9
|
+
const DOUBAO_SOURCE = '5';
|
|
10
|
+
const VARIANT = String(process.env.MIAODA_APP_SOURCE) === DOUBAO_SOURCE ? 'doubao' : 'miaoda';
|
|
11
|
+
const VARIANT_CONFIG = {
|
|
12
|
+
doubao: {
|
|
13
|
+
brandText: '豆包工作生成',
|
|
14
|
+
logoSrc: DOUBAO_LOGO_SRC,
|
|
15
|
+
downloadUrl: 'https://ugapk.com/FCtLH'
|
|
16
|
+
},
|
|
17
|
+
miaoda: {
|
|
18
|
+
brandText: '妙搭生成',
|
|
19
|
+
logoSrc: MIAODA_LOGO_SRC,
|
|
20
|
+
landingUrl: 'https://miaoda.feishu.cn/landing'
|
|
21
|
+
}
|
|
22
|
+
};
|
|
9
23
|
const REPORT_ENABLED = true;
|
|
10
|
-
const BRAND_TEXT = '豆包 AI 生成';
|
|
11
|
-
const POWERED_BY_TEXT = '由飞书妙搭提供支持';
|
|
12
24
|
const FONT_FAMILY = "'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif";
|
|
13
25
|
const PILL_SHADOW = '0px 8px 32px rgba(0,0,0,0.08), 0px 4px 16px rgba(0,0,0,0.04), 0px 2px 4px rgba(0,0,0,0.02)';
|
|
14
26
|
const CARD_SHADOW = '0px 4px 16px rgba(0,0,0,0.03), 0px 4px 10px rgba(0,0,0,0.03), 0px 2px 4px rgba(0,0,0,0.02)';
|
|
@@ -17,7 +29,7 @@ const REPORT_DOMAIN = {
|
|
|
17
29
|
PRE: 'tns.feishu-pre.cn',
|
|
18
30
|
ONLINE: 'tns.feishu.cn'
|
|
19
31
|
};
|
|
20
|
-
const
|
|
32
|
+
const openReport = ()=>{
|
|
21
33
|
const appId = getAppId();
|
|
22
34
|
if (!appId) return;
|
|
23
35
|
const params = JSON.stringify({
|
|
@@ -78,8 +90,56 @@ const CloseIcon = ({ size })=>/*#__PURE__*/ jsx("svg", {
|
|
|
78
90
|
fill: "currentColor"
|
|
79
91
|
})
|
|
80
92
|
});
|
|
81
|
-
const
|
|
82
|
-
|
|
93
|
+
const DownloadIcon = ()=>/*#__PURE__*/ jsx("svg", {
|
|
94
|
+
width: 16,
|
|
95
|
+
height: 16,
|
|
96
|
+
viewBox: "0 0 24 24",
|
|
97
|
+
fill: "none",
|
|
98
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
99
|
+
style: {
|
|
100
|
+
display: 'block',
|
|
101
|
+
flexShrink: 0
|
|
102
|
+
},
|
|
103
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
104
|
+
d: "M11.9922 1.99221C12.5445 1.98895 12.9958 2.43407 12.999 2.98634L13.0762 16.1943L14.6387 14.6328L17.8926 11.3789C18.2831 10.9884 18.9171 10.9885 19.3076 11.3789C19.6977 11.7695 19.6979 12.4026 19.3076 12.793L16.0527 16.0479L12.7979 19.3018C12.7111 19.3884 12.6098 19.4566 12.5 19.5059H20.375C20.9271 19.5059 21.3748 19.9538 21.375 20.5059C21.375 21.0581 20.9273 21.5059 20.375 21.5059H3.625C3.07272 21.5059 2.625 21.0581 2.625 20.5059C2.62523 19.9538 3.07286 19.5059 3.625 19.5059H11.6816C11.572 19.4566 11.4704 19.3884 11.3838 19.3018L4.87402 12.793C4.48372 12.4026 4.4839 11.7694 4.87402 11.3789C5.26452 10.9884 5.89756 10.9885 6.28809 11.3789L11.0762 16.166L10.999 2.99806C10.9958 2.44603 11.4402 1.99582 11.9922 1.99221Z",
|
|
105
|
+
fill: "currentColor"
|
|
106
|
+
})
|
|
107
|
+
});
|
|
108
|
+
const EfficiencyIcon = ()=>/*#__PURE__*/ jsxs("svg", {
|
|
109
|
+
width: 16,
|
|
110
|
+
height: 16,
|
|
111
|
+
viewBox: "0 0 16 16",
|
|
112
|
+
fill: "none",
|
|
113
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
114
|
+
style: {
|
|
115
|
+
display: 'block',
|
|
116
|
+
flexShrink: 0
|
|
117
|
+
},
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ jsx("path", {
|
|
120
|
+
d: "M2.0754 7.57153C2.23188 9.44922 3.49231 11.053 5.27982 11.6488C5.31351 11.6601 5.33994 11.6865 5.35117 11.7202L5.72076 12.8289C5.88752 13.3292 6.3557 13.6667 6.88304 13.6667H9.11696C9.6443 13.6667 10.1125 13.3292 10.2792 12.8289L10.6488 11.7202C10.6601 11.6865 10.6865 11.6601 10.7202 11.6488C12.5077 11.053 13.7681 9.44922 13.9246 7.57153L14 6.66667C14 3.35296 11.3137 0.666668 8 0.666668C4.68629 0.666668 2 3.35296 2 6.66667L2.0754 7.57153ZM9.38392 11.2985L9.03899 12.3333H6.96101L6.61608 11.2985C6.47214 10.8667 6.13328 10.5279 5.70146 10.3839C4.41995 9.95675 3.51631 8.80696 3.40413 7.4608L3.33362 6.61462C3.36152 4.06127 5.44004 2 8 2C10.56 2 12.6385 4.06127 12.6664 6.61462L12.5959 7.4608C12.4837 8.80696 11.5801 9.95675 10.2985 10.3839C9.86672 10.5279 9.52786 10.8667 9.38392 11.2985Z",
|
|
121
|
+
fill: "currentColor"
|
|
122
|
+
}),
|
|
123
|
+
/*#__PURE__*/ jsx("path", {
|
|
124
|
+
d: "M6.66667 14.3333C6.29848 14.3333 6 14.6318 6 15C6 15.3682 6.29848 15.6667 6.66667 15.6667H9.33333C9.70152 15.6667 10 15.3682 10 15C10 14.6318 9.70152 14.3333 9.33333 14.3333H6.66667Z",
|
|
125
|
+
fill: "currentColor"
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ jsx("path", {
|
|
128
|
+
d: "M8.00864 4.13208L5.44578 6.94049C5.20258 7.18228 5.37835 7.56531 5.74361 7.58951L7.2181 7.6872L7.21814 9.60852C7.21814 9.96788 7.72139 10.1366 7.99168 9.86792C8.26197 9.59921 10.5545 7.05951 10.5545 7.05951C10.7977 6.81772 10.622 6.43469 10.2567 6.41049L8.78222 6.3128L8.78219 4.39148C8.78218 4.03212 8.27893 3.86336 8.00864 4.13208Z",
|
|
129
|
+
fill: "currentColor"
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
const IconMap = {
|
|
134
|
+
feedback: FeedbackIcon,
|
|
135
|
+
close: ()=>/*#__PURE__*/ jsx(CloseIcon, {
|
|
136
|
+
size: 16
|
|
137
|
+
}),
|
|
138
|
+
download: DownloadIcon,
|
|
139
|
+
efficiency: EfficiencyIcon
|
|
140
|
+
};
|
|
141
|
+
const BrandLogo = ({ src, size })=>/*#__PURE__*/ jsx("img", {
|
|
142
|
+
src: src,
|
|
83
143
|
width: size,
|
|
84
144
|
height: size,
|
|
85
145
|
alt: "",
|
|
@@ -93,15 +153,15 @@ const Avatar = ({ size })=>/*#__PURE__*/ jsx("img", {
|
|
|
93
153
|
display: 'block'
|
|
94
154
|
}
|
|
95
155
|
});
|
|
96
|
-
const Pill = ({
|
|
97
|
-
const isDesktop = 'desktop' ===
|
|
156
|
+
const Pill = ({ platform, brandText, logoSrc, onClose, showClose = false })=>{
|
|
157
|
+
const isDesktop = 'desktop' === platform;
|
|
98
158
|
return /*#__PURE__*/ jsxs("div", {
|
|
99
159
|
style: {
|
|
100
160
|
boxSizing: 'border-box',
|
|
101
161
|
display: 'inline-flex',
|
|
102
162
|
alignItems: 'center',
|
|
103
|
-
gap:
|
|
104
|
-
padding: isDesktop ? '6px 12px 6px 8px' : '
|
|
163
|
+
gap: 4,
|
|
164
|
+
padding: isDesktop ? '6px 12px 6px 8px' : '5px 12px 5px 8px',
|
|
105
165
|
background: '#363636',
|
|
106
166
|
border: '0.5px solid rgba(255,255,255,0.1)',
|
|
107
167
|
borderRadius: 100,
|
|
@@ -109,8 +169,9 @@ const Pill = ({ variant, onClose, showClose = false })=>{
|
|
|
109
169
|
cursor: 'pointer'
|
|
110
170
|
},
|
|
111
171
|
children: [
|
|
112
|
-
/*#__PURE__*/ jsx(
|
|
113
|
-
|
|
172
|
+
/*#__PURE__*/ jsx(BrandLogo, {
|
|
173
|
+
src: logoSrc,
|
|
174
|
+
size: 16
|
|
114
175
|
}),
|
|
115
176
|
/*#__PURE__*/ jsx("span", {
|
|
116
177
|
style: {
|
|
@@ -120,7 +181,7 @@ const Pill = ({ variant, onClose, showClose = false })=>{
|
|
|
120
181
|
color: 'rgba(255,255,255,0.85)',
|
|
121
182
|
whiteSpace: 'nowrap'
|
|
122
183
|
},
|
|
123
|
-
children:
|
|
184
|
+
children: brandText
|
|
124
185
|
}),
|
|
125
186
|
isDesktop && onClose && showClose && /*#__PURE__*/ jsx("span", {
|
|
126
187
|
role: "button",
|
|
@@ -145,6 +206,7 @@ const Pill = ({ variant, onClose, showClose = false })=>{
|
|
|
145
206
|
};
|
|
146
207
|
const MenuRow = ({ icon, label, fontSize, onClick })=>{
|
|
147
208
|
const [hover, setHover] = useState(false);
|
|
209
|
+
const Icon = IconMap[icon];
|
|
148
210
|
return /*#__PURE__*/ jsxs("div", {
|
|
149
211
|
role: "menuitem",
|
|
150
212
|
"data-label": label,
|
|
@@ -156,6 +218,7 @@ const MenuRow = ({ icon, label, fontSize, onClick })=>{
|
|
|
156
218
|
display: 'flex',
|
|
157
219
|
alignItems: 'center',
|
|
158
220
|
gap: 8,
|
|
221
|
+
minHeight: 38,
|
|
159
222
|
padding: '4px 10px',
|
|
160
223
|
borderRadius: 6,
|
|
161
224
|
cursor: 'pointer',
|
|
@@ -171,9 +234,7 @@ const MenuRow = ({ icon, label, fontSize, onClick })=>{
|
|
|
171
234
|
flexShrink: 0,
|
|
172
235
|
color: '#000000'
|
|
173
236
|
},
|
|
174
|
-
children:
|
|
175
|
-
size: 16
|
|
176
|
-
})
|
|
237
|
+
children: /*#__PURE__*/ jsx(Icon, {})
|
|
177
238
|
}),
|
|
178
239
|
/*#__PURE__*/ jsx("span", {
|
|
179
240
|
style: {
|
|
@@ -188,7 +249,7 @@ const MenuRow = ({ icon, label, fontSize, onClick })=>{
|
|
|
188
249
|
]
|
|
189
250
|
});
|
|
190
251
|
};
|
|
191
|
-
const MenuCard = ({ items,
|
|
252
|
+
const MenuCard = ({ items, extraItems, fontSize, minWidth, itemGap = 0, style })=>/*#__PURE__*/ jsxs("div", {
|
|
192
253
|
style: {
|
|
193
254
|
boxSizing: 'border-box',
|
|
194
255
|
display: 'flex',
|
|
@@ -206,7 +267,10 @@ const MenuCard = ({ items, fontSize, footerFontSize, minWidth, style })=>/*#__PU
|
|
|
206
267
|
items.length > 0 && /*#__PURE__*/ jsx("div", {
|
|
207
268
|
style: {
|
|
208
269
|
boxSizing: 'border-box',
|
|
209
|
-
padding: 4
|
|
270
|
+
padding: 4,
|
|
271
|
+
display: 'flex',
|
|
272
|
+
flexDirection: 'column',
|
|
273
|
+
gap: itemGap
|
|
210
274
|
},
|
|
211
275
|
children: items.map((it)=>/*#__PURE__*/ jsx(MenuRow, {
|
|
212
276
|
icon: it.icon,
|
|
@@ -215,37 +279,60 @@ const MenuCard = ({ items, fontSize, footerFontSize, minWidth, style })=>/*#__PU
|
|
|
215
279
|
onClick: it.onClick
|
|
216
280
|
}, it.label))
|
|
217
281
|
}),
|
|
218
|
-
/*#__PURE__*/
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
282
|
+
extraItems && extraItems.length > 0 && /*#__PURE__*/ jsxs(Fragment, {
|
|
283
|
+
children: [
|
|
284
|
+
/*#__PURE__*/ jsx("div", {
|
|
285
|
+
style: {
|
|
286
|
+
height: 1,
|
|
287
|
+
background: 'rgba(0,0,0,0.08)',
|
|
288
|
+
margin: '0 10px'
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
/*#__PURE__*/ jsx("div", {
|
|
292
|
+
style: {
|
|
293
|
+
boxSizing: 'border-box',
|
|
294
|
+
padding: 4
|
|
295
|
+
},
|
|
296
|
+
children: extraItems.map((it)=>/*#__PURE__*/ jsx(MenuRow, {
|
|
297
|
+
icon: it.icon,
|
|
298
|
+
label: it.label,
|
|
299
|
+
fontSize: fontSize,
|
|
300
|
+
onClick: it.onClick
|
|
301
|
+
}, it.label))
|
|
302
|
+
})
|
|
303
|
+
]
|
|
230
304
|
})
|
|
231
305
|
]
|
|
232
306
|
});
|
|
233
307
|
const MobileWatermark = ({ onDontShow })=>{
|
|
234
308
|
const [open, setOpen] = useState(false);
|
|
309
|
+
const config = VARIANT_CONFIG[VARIANT];
|
|
235
310
|
const items = [];
|
|
311
|
+
if ('doubao' === VARIANT) items.push({
|
|
312
|
+
icon: 'download',
|
|
313
|
+
label: '下载豆包工作',
|
|
314
|
+
onClick: ()=>window.open(VARIANT_CONFIG.doubao.downloadUrl, '_blank', 'noopener,noreferrer')
|
|
315
|
+
});
|
|
316
|
+
else items.push({
|
|
317
|
+
icon: 'efficiency',
|
|
318
|
+
label: '了解妙搭',
|
|
319
|
+
onClick: ()=>window.open(VARIANT_CONFIG.miaoda.landingUrl, '_blank', 'noopener,noreferrer')
|
|
320
|
+
});
|
|
236
321
|
if (REPORT_ENABLED) items.push({
|
|
237
322
|
icon: 'feedback',
|
|
238
323
|
label: '投诉与举报',
|
|
239
|
-
onClick:
|
|
324
|
+
onClick: openReport
|
|
240
325
|
});
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
326
|
+
const extraItems = [
|
|
327
|
+
{
|
|
328
|
+
icon: 'close',
|
|
329
|
+
label: '不再展示',
|
|
330
|
+
onClick: ()=>{
|
|
331
|
+
setOpen(false);
|
|
332
|
+
onDontShow();
|
|
333
|
+
}
|
|
247
334
|
}
|
|
248
|
-
|
|
335
|
+
];
|
|
249
336
|
return /*#__PURE__*/ jsxs(Root, {
|
|
250
337
|
open: open,
|
|
251
338
|
onOpenChange: setOpen,
|
|
@@ -253,7 +340,7 @@ const MobileWatermark = ({ onDontShow })=>{
|
|
|
253
340
|
/*#__PURE__*/ jsx(Trigger, {
|
|
254
341
|
asChild: true,
|
|
255
342
|
children: /*#__PURE__*/ jsx("div", {
|
|
256
|
-
"data-custom-element":
|
|
343
|
+
"data-custom-element": `${VARIANT}-watermark-mobile`,
|
|
257
344
|
style: {
|
|
258
345
|
position: 'fixed',
|
|
259
346
|
right: 12,
|
|
@@ -262,7 +349,9 @@ const MobileWatermark = ({ onDontShow })=>{
|
|
|
262
349
|
cursor: 'pointer'
|
|
263
350
|
},
|
|
264
351
|
children: /*#__PURE__*/ jsx(Pill, {
|
|
265
|
-
|
|
352
|
+
platform: "mobile",
|
|
353
|
+
brandText: config.brandText,
|
|
354
|
+
logoSrc: config.logoSrc
|
|
266
355
|
})
|
|
267
356
|
})
|
|
268
357
|
}),
|
|
@@ -276,8 +365,8 @@ const MobileWatermark = ({ onDontShow })=>{
|
|
|
276
365
|
},
|
|
277
366
|
children: /*#__PURE__*/ jsx(MenuCard, {
|
|
278
367
|
items: items,
|
|
368
|
+
extraItems: extraItems,
|
|
279
369
|
fontSize: 16,
|
|
280
|
-
footerFontSize: 14,
|
|
281
370
|
minWidth: 160
|
|
282
371
|
})
|
|
283
372
|
})
|
|
@@ -300,6 +389,7 @@ const Watermark_Watermark = ()=>{
|
|
|
300
389
|
const [open, setOpen] = useState(false);
|
|
301
390
|
const timer = useRef(null);
|
|
302
391
|
const isMobile = useIsMobile();
|
|
392
|
+
const config = VARIANT_CONFIG[VARIANT];
|
|
303
393
|
useEffect(()=>{
|
|
304
394
|
getInitialInfo().then((info)=>{
|
|
305
395
|
const badge = info?.app_info?.show_badge;
|
|
@@ -330,13 +420,23 @@ const Watermark_Watermark = ()=>{
|
|
|
330
420
|
timer.current = setTimeout(()=>setOpen(false), 100);
|
|
331
421
|
};
|
|
332
422
|
const desktopItems = [];
|
|
423
|
+
if ('doubao' === VARIANT) desktopItems.push({
|
|
424
|
+
icon: 'download',
|
|
425
|
+
label: '下载豆包工作',
|
|
426
|
+
onClick: ()=>window.open(VARIANT_CONFIG.doubao.downloadUrl, '_blank', 'noopener,noreferrer')
|
|
427
|
+
});
|
|
428
|
+
else desktopItems.push({
|
|
429
|
+
icon: 'efficiency',
|
|
430
|
+
label: '了解妙搭',
|
|
431
|
+
onClick: ()=>window.open(VARIANT_CONFIG.miaoda.landingUrl, '_blank', 'noopener,noreferrer')
|
|
432
|
+
});
|
|
333
433
|
if (REPORT_ENABLED) desktopItems.push({
|
|
334
434
|
icon: 'feedback',
|
|
335
435
|
label: '投诉与举报',
|
|
336
|
-
onClick:
|
|
436
|
+
onClick: openReport
|
|
337
437
|
});
|
|
338
438
|
return /*#__PURE__*/ jsxs("div", {
|
|
339
|
-
"data-custom-element":
|
|
439
|
+
"data-custom-element": `${VARIANT}-watermark`,
|
|
340
440
|
onMouseEnter: enter,
|
|
341
441
|
onMouseLeave: leave,
|
|
342
442
|
style: {
|
|
@@ -353,11 +453,13 @@ const Watermark_Watermark = ()=>{
|
|
|
353
453
|
open && /*#__PURE__*/ jsx(MenuCard, {
|
|
354
454
|
items: desktopItems,
|
|
355
455
|
fontSize: 14,
|
|
356
|
-
|
|
357
|
-
|
|
456
|
+
minWidth: 160,
|
|
457
|
+
itemGap: 8
|
|
358
458
|
}),
|
|
359
459
|
/*#__PURE__*/ jsx(Pill, {
|
|
360
|
-
|
|
460
|
+
platform: "desktop",
|
|
461
|
+
brandText: config.brandText,
|
|
462
|
+
logoSrc: config.logoSrc,
|
|
361
463
|
onClose: handleClose,
|
|
362
464
|
showClose: open
|
|
363
465
|
})
|
|
@@ -365,4 +467,4 @@ const Watermark_Watermark = ()=>{
|
|
|
365
467
|
});
|
|
366
468
|
};
|
|
367
469
|
const Watermark = Watermark_Watermark;
|
|
368
|
-
export {
|
|
470
|
+
export { BrandLogo, CloseIcon, DownloadIcon, EfficiencyIcon, FeedbackIcon, MenuCard, MenuRow, Pill, Watermark as default, openReport };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import react from "react";
|
|
3
3
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
4
|
-
import Watermark, {
|
|
5
|
-
import { DOUBAO_LOGO_SRC } from "../doubao-watermark-asset.js";
|
|
4
|
+
import Watermark, { BrandLogo, CloseIcon, FeedbackIcon, MenuCard, Pill, openReport } from "../Watermark.js";
|
|
5
|
+
import { DOUBAO_LOGO_SRC, MIAODA_LOGO_SRC } from "../doubao-watermark-asset.js";
|
|
6
6
|
const html = ()=>renderToStaticMarkup(/*#__PURE__*/ react.createElement(Watermark));
|
|
7
7
|
const setViewportWidth = (w)=>Object.defineProperty(window, 'innerWidth', {
|
|
8
8
|
value: w,
|
|
@@ -15,55 +15,67 @@ afterEach(()=>{
|
|
|
15
15
|
delete window.appId;
|
|
16
16
|
setViewportWidth(1024);
|
|
17
17
|
});
|
|
18
|
-
describe('Watermark
|
|
19
|
-
it('
|
|
18
|
+
describe('Watermark(水印·变体拆分后)', ()=>{
|
|
19
|
+
it('默认(非豆包来源)渲染妙搭变体药丸', ()=>{
|
|
20
20
|
const out = html();
|
|
21
|
-
expect(out).toContain('data-custom-element="
|
|
22
|
-
expect(out).toContain('
|
|
23
|
-
expect(out).toContain(
|
|
21
|
+
expect(out).toContain('data-custom-element="miaoda-watermark"');
|
|
22
|
+
expect(out).toContain('妙搭生成');
|
|
23
|
+
expect(out).toContain(MIAODA_LOGO_SRC);
|
|
24
24
|
expect(out).not.toContain('aria-label="关闭"');
|
|
25
25
|
expect(out).not.toContain('投诉与举报');
|
|
26
|
-
expect(out).not.toContain('由飞书妙搭提供支持');
|
|
27
26
|
});
|
|
28
27
|
it('移动端视口(<768)时展示移动端药丸', ()=>{
|
|
29
28
|
setViewportWidth(375);
|
|
30
29
|
const out = html();
|
|
31
|
-
expect(out).toContain('data-custom-element="
|
|
32
|
-
expect(out).toContain(
|
|
33
|
-
expect(out).toContain('
|
|
30
|
+
expect(out).toContain('data-custom-element="miaoda-watermark-mobile"');
|
|
31
|
+
expect(out).toContain(MIAODA_LOGO_SRC);
|
|
32
|
+
expect(out).toContain('妙搭生成');
|
|
34
33
|
expect(out).not.toContain('aria-label="关闭"');
|
|
35
34
|
});
|
|
36
35
|
describe('展开态展示组件(SSR 覆盖)', ()=>{
|
|
37
|
-
it('Pill
|
|
36
|
+
it('Pill 桌面态:logo + 品牌文案;关闭叉仅 showClose 时显示', ()=>{
|
|
38
37
|
const out = renderToStaticMarkup(/*#__PURE__*/ react.createElement(Pill, {
|
|
39
|
-
|
|
38
|
+
platform: 'desktop',
|
|
39
|
+
brandText: '妙搭生成',
|
|
40
|
+
logoSrc: MIAODA_LOGO_SRC,
|
|
40
41
|
onClose: ()=>{}
|
|
41
42
|
}));
|
|
42
|
-
expect(out).toContain('
|
|
43
|
-
expect(out).toContain(
|
|
43
|
+
expect(out).toContain('妙搭生成');
|
|
44
|
+
expect(out).toContain(MIAODA_LOGO_SRC);
|
|
44
45
|
expect(out).not.toContain('aria-label="关闭"');
|
|
45
46
|
const hovered = renderToStaticMarkup(/*#__PURE__*/ react.createElement(Pill, {
|
|
46
|
-
|
|
47
|
+
platform: 'desktop',
|
|
48
|
+
brandText: '妙搭生成',
|
|
49
|
+
logoSrc: MIAODA_LOGO_SRC,
|
|
47
50
|
onClose: ()=>{},
|
|
48
51
|
showClose: true
|
|
49
52
|
}));
|
|
50
53
|
expect(hovered).toContain('aria-label="关闭"');
|
|
51
54
|
});
|
|
52
|
-
it('Pill
|
|
55
|
+
it('Pill 移动态:logo + 品牌文案,无关闭叉', ()=>{
|
|
53
56
|
const out = renderToStaticMarkup(/*#__PURE__*/ react.createElement(Pill, {
|
|
54
|
-
|
|
57
|
+
platform: 'mobile',
|
|
58
|
+
brandText: '豆包工作生成',
|
|
59
|
+
logoSrc: DOUBAO_LOGO_SRC
|
|
55
60
|
}));
|
|
56
|
-
expect(out).toContain('
|
|
61
|
+
expect(out).toContain('豆包工作生成');
|
|
57
62
|
expect(out).not.toContain('aria-label="关闭"');
|
|
58
63
|
});
|
|
59
|
-
it('MenuCard
|
|
64
|
+
it('MenuCard:items + extraItems 分隔线', ()=>{
|
|
60
65
|
const out = renderToStaticMarkup(/*#__PURE__*/ react.createElement(MenuCard, {
|
|
61
66
|
items: [
|
|
67
|
+
{
|
|
68
|
+
icon: 'efficiency',
|
|
69
|
+
label: '了解妙搭',
|
|
70
|
+
onClick: ()=>{}
|
|
71
|
+
},
|
|
62
72
|
{
|
|
63
73
|
icon: 'feedback',
|
|
64
74
|
label: '投诉与举报',
|
|
65
75
|
onClick: ()=>{}
|
|
66
|
-
}
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
extraItems: [
|
|
67
79
|
{
|
|
68
80
|
icon: 'close',
|
|
69
81
|
label: '不再展示',
|
|
@@ -71,29 +83,29 @@ describe('Watermark(豆包水印·统一改造后)', ()=>{
|
|
|
71
83
|
}
|
|
72
84
|
],
|
|
73
85
|
fontSize: 16,
|
|
74
|
-
footerFontSize: 14,
|
|
75
86
|
minWidth: 160
|
|
76
87
|
}));
|
|
88
|
+
expect(out).toContain('data-label="了解妙搭"');
|
|
77
89
|
expect(out).toContain('data-label="投诉与举报"');
|
|
78
90
|
expect(out).toContain('data-label="不再展示"');
|
|
79
|
-
expect(out).toContain('由飞书妙搭提供支持');
|
|
80
91
|
});
|
|
81
|
-
it('图标:FeedbackIcon / CloseIcon /
|
|
92
|
+
it('图标:FeedbackIcon / CloseIcon / BrandLogo 渲染', ()=>{
|
|
82
93
|
expect(renderToStaticMarkup(/*#__PURE__*/ react.createElement(FeedbackIcon))).toContain('<svg');
|
|
83
94
|
expect(renderToStaticMarkup(/*#__PURE__*/ react.createElement(CloseIcon, {
|
|
84
95
|
size: 16
|
|
85
96
|
}))).toContain('<svg');
|
|
86
|
-
expect(renderToStaticMarkup(/*#__PURE__*/ react.createElement(
|
|
97
|
+
expect(renderToStaticMarkup(/*#__PURE__*/ react.createElement(BrandLogo, {
|
|
98
|
+
src: MIAODA_LOGO_SRC,
|
|
87
99
|
size: 18
|
|
88
|
-
}))).toContain(
|
|
100
|
+
}))).toContain(MIAODA_LOGO_SRC);
|
|
89
101
|
});
|
|
90
102
|
});
|
|
91
|
-
describe('
|
|
103
|
+
describe('openReport(举报跳转)', ()=>{
|
|
92
104
|
it('按当前环境(getEnv)拼出飞书风控举报中心(tns) URL 并以新窗口打开', ()=>{
|
|
93
105
|
const openSpy = vi.spyOn(window, 'open').mockReturnValue(null);
|
|
94
106
|
window.appId = 'app_abc';
|
|
95
107
|
globalThis.ENVIRONMENT = 'staging';
|
|
96
|
-
|
|
108
|
+
openReport();
|
|
97
109
|
expect(openSpy).toHaveBeenCalledTimes(1);
|
|
98
110
|
const [url, target, features] = openSpy.mock.calls[0];
|
|
99
111
|
expect(String(url)).toContain('tns.feishu-boe.cn/cust/lark_report/');
|
|
@@ -105,7 +117,7 @@ describe('Watermark(豆包水印·统一改造后)', ()=>{
|
|
|
105
117
|
it('无 appId 时不跳转', ()=>{
|
|
106
118
|
const openSpy = vi.spyOn(window, 'open').mockReturnValue(null);
|
|
107
119
|
globalThis.ENVIRONMENT = 'online';
|
|
108
|
-
|
|
120
|
+
openReport();
|
|
109
121
|
expect(openSpy).not.toHaveBeenCalled();
|
|
110
122
|
});
|
|
111
123
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
const CDN = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp
|
|
2
|
-
const DOUBAO_LOGO_SRC = `${CDN}/doubao.svg`;
|
|
3
|
-
|
|
1
|
+
const CDN = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/LMfspH/ljhwZthlaukjlkulzlp';
|
|
2
|
+
const DOUBAO_LOGO_SRC = `${CDN}/miaoda-ui/doubao.svg`;
|
|
3
|
+
const MIAODA_LOGO_SRC = `${CDN}/logo/miaodalogo.svg`;
|
|
4
|
+
export { DOUBAO_LOGO_SRC, MIAODA_LOGO_SRC };
|