@zw-team/react-lib 1.0.1 → 1.0.3

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.
@@ -1,369 +1,12 @@
1
1
  const theme = {
2
+ token: {
3
+ colorPrimary: "#00bf8a",
4
+ colorInfo: "#00bf8a"
5
+ },
2
6
  components: {
3
- Button: {
4
- algorithm: true,
5
- defaultBorderColor: 'rgb(214,217,224)',
6
- defaultActiveColor: 'rgb(0,153,115)',
7
- defaultHoverBorderColor: 'rgb(33,204,150)',
8
- defaultHoverColor: 'rgb(33,204,150)',
9
- groupBorderColor: 'rgb(33,204,150)',
10
- blue1: '#e6fff4',
11
- blue2: '#9bf2ce',
12
- blue3: '#6ee6b8',
13
- blue5: '#21cc96',
14
- blue6: '#00bf8a',
15
- blue7: '#009973',
16
- borderColorDisabled: 'rgb(229,230,235)',
17
- defaultActiveBorderColor: 'rgb(0,153,115)',
18
- textHoverBg: 'rgb(247,248,250)',
19
- textTextActiveColor: 'rgb(50,51,53)',
20
- textTextColor: 'rgb(50,51,53)',
21
- textTextHoverColor: 'rgb(50,51,53)',
22
- colorBgContainerDisabled: 'rgb(247,248,250)',
23
- colorBorder: 'rgb(229,230,235)',
24
- defaultColor: 'rgb(50,51,53)',
25
- colorBgSolid: 'rgb(0,191,138)',
26
- colorBgSolidActive: 'rgba(0,191,137,0.95)',
27
- colorBgSolidHover: 'rgba(0,191,137,0.75)',
28
- colorBgTextActive: 'rgb(229,230,235)',
29
- contentFontSizeSM: 12,
30
- paddingInlineSM: 8,
31
- paddingInlineLG: 16,
32
- paddingInline: 16
33
- },
34
- Layout: {
35
- headerHeight: 50,
36
- headerPadding: '0 20px',
37
- triggerHeight: 50,
38
- zeroTriggerHeight: 42,
39
- zeroTriggerWidth: 42,
40
- footerPadding: '15px 50px',
41
- bodyBg: 'rgb(238,239,245)',
42
- footerBg: 'rgb(238,239,245)',
43
- lightTriggerColor: 'rgb(50,51,53)',
44
- headerColor: 'rgb(50,51,53)'
45
- },
46
- Breadcrumb: {
47
- iconFontSize: 16,
48
- lastItemColor: 'rgb(50,51,53)',
49
- linkColor: 'rgb(134,144,156)',
50
- separatorColor: 'rgb(134,144,156)',
51
- linkHoverColor: 'rgb(50,51,53)',
52
- separatorMargin: 10,
53
- fontHeight: 22,
54
- colorBgTextHover: 'rgb(247,248,250)',
55
- itemColor: 'rgb(134,144,156)'
56
- },
57
- Dropdown: {
58
- controlPaddingHorizontal: 20,
59
- controlItemBgHover: 'rgb(247,248,250)',
60
- paddingBlock: 6
61
- },
62
- Menu: {
63
- iconSize: 16,
64
- itemHeight: 50,
65
- itemMarginBlock: 0,
66
- itemMarginInline: 0,
67
- controlHeightLG: 50,
68
- darkItemSelectedBg: 'rgb(0,191,138)',
69
- horizontalItemHoverColor: 'rgb(0,191,138)',
70
- horizontalItemSelectedColor: 'rgb(0,191,138)',
71
- itemActiveBg: 'rgb(230,255,244)',
72
- itemColor: 'rgb(50,51,53)',
73
- itemHoverColor: 'rgb(50,51,53)',
74
- itemDisabledColor: 'rgb(201,205,212)',
75
- itemHoverBg: 'rgb(247,248,250)',
76
- itemSelectedBg: 'rgb(230,255,244)',
77
- itemSelectedColor: 'rgb(0,191,138)',
78
- subMenuItemSelectedColor: 'rgb(0,191,138)',
79
- subMenuItemBg: 'rgb(255,255,255)',
80
- groupTitleColor: 'rgb(78,89,105)',
81
- colorSplit: 'rgb(242,243,245)'
82
- },
83
- Cascader: {
84
- optionSelectedBg: 'rgb(230,255,244)',
85
- optionSelectedColor: 'rgb(50,51,53)',
86
- colorBgContainerDisabled: 'rgb(247,248,250)',
87
- colorBorder: 'rgb(229,230,235)',
88
- controlItemBgHover: 'rgb(247,248,250)'
89
- },
90
- Transfer: {
91
- colorBgContainerDisabled: 'rgb(247,248,250)',
92
- colorBorder: 'rgb(214,217,224)',
93
- controlItemBgHover: 'rgb(247,248,250)',
94
- itemPaddingBlock: 6,
95
- listHeight: 300,
96
- listWidth: 280,
97
- listWidthLG: 350
98
- },
99
- Table: {
100
- headerBorderRadius: 0,
101
- headerColor: 'rgb(50,51,53)',
102
- rowSelectedBg: 'rgb(230,255,244)',
103
- rowSelectedHoverBg: 'rgb(155,242,206)',
104
- bodySortBg: 'rgb(247,248,250)',
105
- borderColor: 'rgb(242,243,245)',
106
- footerColor: 'rgb(50,51,53)',
107
- headerBg: 'rgb(242,243,245)',
108
- headerFilterHoverBg: 'rgb(229,230,235)',
109
- footerBg: 'rgb(242,243,245)',
110
- fixedHeaderSortActiveBg: 'rgb(242,243,245)',
111
- headerSortActiveBg: 'rgb(242,243,245)',
112
- headerSortHoverBg: 'rgb(242,243,245)',
113
- headerSplitColor: 'rgb(242,243,245)',
114
- rowExpandedBg: 'rgb(247,248,250)',
115
- rowHoverBg: 'rgb(247,248,250)',
116
- controlItemBgHover: 'rgb(247,248,250)'
117
- },
118
- Alert: {
119
- marginXS: 6,
120
- marginSM: 10,
121
- defaultPadding: '6px 12px'
122
- },
123
- Notification: {
124
- paddingContentHorizontalLG: 16,
125
- paddingLG: 16,
126
- paddingMD: 16,
127
- colorBgTextHover: 'rgb(242,243,245)',
128
- colorBgTextActive: 'rgb(229,230,235)'
129
- },
130
- Divider: {
131
- colorSplit: 'rgb(242,243,245)'
132
- },
133
- Pagination: {
134
- itemActiveBgDisabled: 'rgb(247,248,250)',
135
- itemActiveColorDisabled: 'rgb(201,205,212)',
136
- itemActiveBg: 'rgb(234,247,243)',
137
- colorBgTextHover: 'rgb(247,248,250)',
138
- marginXS: 6,
139
- marginXXS: 2,
140
- paddingXS: 6,
141
- paddingXXS: 2,
142
- marginSM: 10,
143
- colorBgContainerDisabled: 'rgb(247,248,250)',
144
- colorBgTextActive: 'rgb(229,230,235)',
145
- colorBorder: 'rgb(229,230,235)'
146
- },
147
- Steps: {
148
- marginXXS: 4,
149
- marginXS: 6,
150
- marginSM: 10,
151
- marginLG: 22,
152
- paddingXXS: 4,
153
- paddingXS: 6,
154
- paddingSM: 10,
155
- paddingLG: 22,
156
- controlItemBgHover: 'rgb(247,248,250)'
157
- },
158
- DatePicker: {
159
- activeBorderColor: 'rgb(0,191,138)',
160
- cellActiveWithRangeBg: 'rgb(230,255,244)',
161
- hoverBorderColor: 'rgb(33,204,150)',
162
- cellRangeBorderColor: 'rgb(33,204,150)',
163
- cellHoverWithRangeBg: 'rgb(155,242,206)',
164
- multipleItemColorDisabled: 'rgb(201,205,212)',
165
- multipleSelectorBgDisabled: 'rgb(229,230,235)',
166
- cellBgDisabled: 'rgb(247,248,250)',
167
- cellHoverBg: 'rgb(247,248,250)',
168
- colorBgContainerDisabled: 'rgb(247,248,250)',
169
- colorBorder: 'rgb(229,230,235)'
170
- },
171
- Form: {
172
- labelColor: 'rgb(50,51,53)',
173
- colorBorder: 'rgb(229,230,235)',
174
- labelColonMarginInlineEnd: 12
175
- },
176
- Input: {
177
- activeBorderColor: 'rgb(0,191,138)',
178
- hoverBorderColor: 'rgb(33,204,150)',
179
- colorBgContainerDisabled: 'rgb(247,248,250)',
180
- colorBorder: 'rgb(229,230,235)'
181
- },
182
- InputNumber: {
183
- activeBorderColor: 'rgb(0,191,138)',
184
- handleHoverColor: 'rgb(0,191,138)',
185
- hoverBorderColor: 'rgb(33,204,150)',
186
- handleBorderColor: 'rgb(214,217,224)',
187
- colorBgContainerDisabled: 'rgb(247,248,250)',
188
- colorBorder: 'rgb(229,230,235)'
189
- },
190
- Mentions: {
191
- activeBorderColor: 'rgb(0,191,138)',
192
- hoverBorderColor: 'rgb(33,204,150)',
193
- colorBgContainerDisabled: 'rgb(247,248,250)',
194
- controlItemBgHover: 'rgb(247,248,250)'
195
- },
196
- Radio: {
197
- buttonSolidCheckedActiveBg: 'rgb(0,153,115)',
198
- buttonSolidCheckedBg: 'rgb(0,191,138)',
199
- buttonSolidCheckedHoverBg: 'rgb(33,204,150)',
200
- buttonColor: 'rgb(50,51,53)',
201
- colorBgContainerDisabled: 'rgb(247,248,250)'
202
- },
203
- Select: {
204
- activeBorderColor: 'rgb(0,191,138)',
205
- hoverBorderColor: 'rgb(33,204,150)',
206
- optionSelectedBg: 'rgb(230,255,244)',
207
- activeOutlineColor: 'rgba(0,153,115,0.1)',
208
- optionSelectedColor: 'rgb(50,51,53)',
209
- colorFillSecondary: 'rgb(242,243,245)',
210
- paddingXXS: 4,
211
- paddingXS: 6,
212
- paddingSM: 10,
213
- colorBgContainerDisabled: 'rgb(247,248,250)',
214
- multipleItemBg: 'rgb(242,243,245)',
215
- multipleItemColorDisabled: 'rgb(134,144,156)',
216
- optionActiveBg: 'rgb(247,248,250)',
217
- multipleSelectorBgDisabled: 'rgb(247,248,250)',
218
- colorBorder: 'rgb(214,217,224)'
219
- },
220
- Calendar: {
221
- itemActiveBg: 'rgb(230,255,244)',
222
- controlItemBgHover: 'rgb(247,248,250)'
223
- },
224
- Card: {
225
- extraColor: 'rgb(50,51,53)',
226
- colorBorderSecondary: 'rgb(229,230,235)'
227
- },
228
- Descriptions: {
229
- contentColor: 'rgb(50,51,53)',
230
- extraColor: 'rgb(50,51,53)',
231
- titleColor: 'rgb(50,51,53)',
232
- labelColor: 'rgb(134,144,156)',
233
- colorSplit: 'rgb(214,217,224)'
234
- },
235
- Segmented: {
236
- itemHoverColor: 'rgb(50,51,53)',
237
- itemSelectedColor: 'rgb(50,51,53)',
238
- trackBg: 'rgb(242,243,245)',
239
- itemHoverBg: 'rgb(229,230,235)',
240
- itemActiveBg: 'rgb(201,205,212)',
241
- itemColor: 'rgb(50,51,53)'
242
- },
243
- Tabs: {
244
- inkBarColor: 'rgb(0,191,138)',
245
- itemSelectedColor: 'rgb(0,191,138)',
246
- itemActiveColor: 'rgb(0,153,115)',
247
- itemHoverColor: 'rgb(33,204,150)',
248
- itemColor: 'rgb(50,51,53)',
249
- cardBg: 'rgb(247,248,250)',
250
- colorBorderSecondary: 'rgb(214,217,224)',
251
- controlItemBgHover: 'rgb(247,248,250)'
252
- },
253
- Tag: {
254
- defaultColor: 'rgb(50,51,53)',
255
- defaultBg: 'rgb(247,248,250)',
256
- colorFillSecondary: 'rgb(242,243,245)'
257
- },
258
- Tree: {
259
- directoryNodeSelectedBg: 'rgb(0,191,138)',
260
- nodeSelectedBg: 'rgb(230,255,244)',
261
- nodeHoverBg: 'rgb(247,248,250)',
262
- nodeHoverColor: 'rgb(50,51,53)',
263
- controlItemBgHover: 'rgb(247,248,250)',
264
- controlItemBgActiveDisabled: 'rgb(242,243,245)',
265
- nodeSelectedColor: 'rgb(50,51,53)'
266
- },
267
- Modal: {
268
- titleColor: 'rgb(50,51,53)',
269
- colorBgMask: 'rgba(0,0,0,0.6)',
270
- colorBgTextHover: 'rgb(242,243,245)',
271
- colorBgTextActive: 'rgb(229,230,235)',
272
- fontHeight: 24
273
- },
274
- Progress: {
275
- defaultColor: 'rgb(0,191,138)',
276
- circleTextColor: 'rgb(50,51,53)'
277
- },
278
- Checkbox: {
279
- colorBgContainerDisabled: 'rgb(247,248,250)',
280
- colorBorder: 'rgb(229,230,235)'
281
- },
282
- Slider: {
283
- dotActiveBorderColor: 'rgb(110,230,184)',
284
- handleColor: 'rgb(110,230,184)',
285
- trackBg: 'rgb(110,230,184)',
286
- handleActiveColor: 'rgb(0,191,138)',
287
- handleActiveOutlineColor: 'rgba(0,191,137,0.2)',
288
- trackHoverBg: 'rgb(69,217,165)'
289
- },
290
- TreeSelect: {
291
- nodeHoverBg: 'rgb(247,248,250)',
292
- nodeHoverColor: 'rgb(50,51,53)',
293
- nodeSelectedBg: 'rgb(230,255,244)',
294
- nodeSelectedColor: 'rgb(50,51,53)',
295
- colorBgContainerDisabled: 'rgb(247,248,250)',
296
- colorBgTextHover: 'rgb(242,243,245)',
297
- controlItemBgHover: 'rgb(247,248,250)',
298
- controlItemBgActiveDisabled: 'rgb(229,230,235)'
299
- },
300
- Upload: {
301
- actionsColor: 'rgb(134,144,156)',
302
- controlItemBgHover: 'rgb(247,248,250)'
303
- },
304
- Image: {
305
- colorBgContainerDisabled: 'rgb(247,248,250)',
306
- colorBgMask: 'rgba(0,0,0,0.7)'
307
- },
308
- Tooltip: {
309
- colorBgSpotlight: 'rgba(0,0,0,0.75)',
310
- paddingXS: 8,
311
- paddingSM: 12
312
- },
313
7
  Drawer: {
314
- colorBgMask: 'rgba(0,0,0,0.6)',
315
- colorBgTextActive: 'rgb(229,230,235)',
316
- colorBgTextHover: 'rgb(242,243,245)'
317
- },
318
- Spin: {
319
- colorBgMask: 'rgba(0,0,0,0.6)'
320
- },
321
- Popconfirm: {
322
- marginXS: 8,
323
- marginXXS: 6
324
- },
325
- Message: {
326
- marginXS: 6,
327
- paddingXS: 6,
328
- contentPadding: '6px 12px'
8
+ paddingLG: 20
329
9
  }
330
- },
331
- token: {
332
- colorPrimary: '#00bf8a',
333
- colorInfo: '#00bf8a',
334
- colorBgLayout: '#eeeff5',
335
- colorText: '#323335',
336
- colorTextSecondary: '#4e5969',
337
- colorTextTertiary: '#86909c',
338
- colorTextQuaternary: '#c9cdd4',
339
- colorTextBase: '#323335',
340
- paddingXXS: 2,
341
- paddingLG: 20,
342
- paddingMD: 16,
343
- padding: 12,
344
- paddingSM: 8,
345
- paddingXS: 4,
346
- marginXXS: 2,
347
- marginXS: 4,
348
- marginSM: 8,
349
- margin: 12,
350
- marginMD: 16,
351
- marginLG: 20,
352
- marginXL: 24,
353
- marginXXL: 32,
354
- paddingXL: 24,
355
- borderRadius: 4,
356
- borderRadiusLG: 6,
357
- borderRadiusSM: 4,
358
- borderRadiusXS: 2,
359
- colorBorderSecondary: '#f2f3f5',
360
- colorBorder: '#d6d9e0',
361
- colorFill: '#c9cdd4',
362
- colorFillSecondary: '#e5e6eb',
363
- colorFillTertiary: '#f2f3f5',
364
- colorFillQuaternary: '#f7f8fa',
365
- colorBgSpotlight: '#4e5969',
366
- colorBgMask: '#86909c'
367
10
  }
368
11
  };
369
12
  export { theme };
@@ -1,5 +1,6 @@
1
1
  export { default as createAlive } from './createAlive';
2
2
  export { createGlobalState } from './createGlobalState';
3
+ export { default as useAccessReport } from './useAccessReport';
3
4
  export { default as useAsync } from './useAsync';
4
5
  export { default as useClickOther } from './useClickOther';
5
6
  export { default as useCopyToClipboard } from './useCopyToClipboard';
@@ -1,5 +1,6 @@
1
1
  import createAlive from "./createAlive.js";
2
2
  import { createGlobalState } from "./createGlobalState.js";
3
+ import useAccessReport from "./useAccessReport.js";
3
4
  import useAsync from "./useAsync.js";
4
5
  import useClickOther from "./useClickOther.js";
5
6
  import useCopyToClipboard from "./useCopyToClipboard.js";
@@ -22,4 +23,4 @@ import useUnmount from "./useUnmount.js";
22
23
  import useUpdateEffect from "./useUpdateEffect.js";
23
24
  import useWindowSize from "./useWindowSize.js";
24
25
  import { isObject, resolveHookState } from "./util.js";
25
- export { createAlive, createGlobalState, isObject, resolveHookState, useAsync, useClickOther, useCopyToClipboard, useCreate, useEventListener, useHistoryStore, useIntersectionObserver, useInterval, useLatest, useLockAsyncFn, useLockFn, useMergedState, useMountedState, usePermission, usePersistFn, useReactive, useRefresh, useToggle, useUnmount, useUpdateEffect, useWindowSize };
26
+ export { createAlive, createGlobalState, isObject, resolveHookState, useAccessReport, useAsync, useClickOther, useCopyToClipboard, useCreate, useEventListener, useHistoryStore, useIntersectionObserver, useInterval, useLatest, useLockAsyncFn, useLockFn, useMergedState, useMountedState, usePermission, usePersistFn, useReactive, useRefresh, useToggle, useUnmount, useUpdateEffect, useWindowSize };
@@ -0,0 +1,4 @@
1
+ export declare const useAccessReport: () => {
2
+ accessReport: (router: string, page: string | string[]) => void;
3
+ };
4
+ export default useAccessReport;
@@ -0,0 +1,15 @@
1
+ import { useCallback } from "react";
2
+ import { useConfig } from "../components/ConfigProvider/ConfigContext.js";
3
+ const useAccessReport_useAccessReport = ()=>{
4
+ const { contextValue } = useConfig();
5
+ const accessReport = useCallback((router, page)=>{
6
+ contextValue.$AccessReport?.report(router, page);
7
+ }, [
8
+ contextValue.$AccessReport
9
+ ]);
10
+ return {
11
+ accessReport
12
+ };
13
+ };
14
+ const useAccessReport = useAccessReport_useAccessReport;
15
+ export { useAccessReport as default, useAccessReport_useAccessReport as useAccessReport };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 根据环境和 cookie 判断是否需要显示正式环境警告,满足条件时自动创建悬浮提示
3
+ * 条件:zw-warning cookie === '1' 且 env 为 prod / production / development
4
+ */
5
+ export declare function initProdEnvWarning(env: string): void;
6
+ /**
7
+ * 创建正式环境悬浮提示框
8
+ * 带有打砖块式物理碰撞算法的悬浮提示,会在窗口内自由运动并反射
9
+ * @returns {Object} 控制方法对象 { pause, resume, destroy }
10
+ */
11
+ export declare function createProdEnvIndicator(): {
12
+ pause: () => void;
13
+ resume: () => void;
14
+ destroy: () => void;
15
+ } | undefined;
@@ -0,0 +1,240 @@
1
+ import js_cookie from "js-cookie";
2
+ function initProdEnvWarning(env) {
3
+ if ('undefined' == typeof window) return;
4
+ const isZwWarning = js_cookie.get('zw-warning') || '0';
5
+ if ('1' === isZwWarning && ('prod' === env || 'production' === env || 'development' === env)) setTimeout(()=>{
6
+ const indicator = createProdEnvIndicator();
7
+ if (indicator) window.$BIProdIndicator = indicator;
8
+ }, 100);
9
+ }
10
+ function createProdEnvIndicator() {
11
+ if ('undefined' == typeof window) return;
12
+ if (document.getElementById('bi-prod-env-indicator')) return;
13
+ const indicator = document.createElement('div');
14
+ indicator.id = 'bi-prod-env-indicator';
15
+ indicator.textContent = '这是正式环境';
16
+ const colorStyle = document.createElement('style');
17
+ colorStyle.textContent = `
18
+ @keyframes rainbow {
19
+ 0% {
20
+ color: #ff4757;
21
+ border-color: #ff4757;
22
+ }
23
+ 8.33% {
24
+ color: #ff6348;
25
+ border-color: #ff6348;
26
+ }
27
+ 16.66% {
28
+ color: #ffa502;
29
+ border-color: #ffa502;
30
+ }
31
+ 25% {
32
+ color: #ffd32a;
33
+ border-color: #ffd32a;
34
+ }
35
+ 33.33% {
36
+ color: #7bed9f;
37
+ border-color: #7bed9f;
38
+ }
39
+ 41.66% {
40
+ color: #2ed573;
41
+ border-color: #2ed573;
42
+ }
43
+ 50% {
44
+ color: #00d2d3;
45
+ border-color: #00d2d3;
46
+ }
47
+ 58.33% {
48
+ color: #1e90ff;
49
+ border-color: #1e90ff;
50
+ }
51
+ 66.66% {
52
+ color: #3742fa;
53
+ border-color: #3742fa;
54
+ }
55
+ 75% {
56
+ color: #5352ed;
57
+ border-color: #5352ed;
58
+ }
59
+ 83.33% {
60
+ color: #a55eea;
61
+ border-color: #a55eea;
62
+ }
63
+ 91.66% {
64
+ color: #ff6b9d;
65
+ border-color: #ff6b9d;
66
+ }
67
+ 100% {
68
+ color: #ff4757;
69
+ border-color: #ff4757;
70
+ }
71
+ }
72
+ // #bi-prod-env-indicator {
73
+ // animation: rainbow 3s linear infinite;
74
+ // }
75
+ `;
76
+ document.head.appendChild(colorStyle);
77
+ indicator.style.cssText = `
78
+ position: fixed;
79
+ top: 0;
80
+ left: 0;
81
+ // background: linear-gradient(135deg, #ff4757 0%, #ff6348 100%);
82
+ color: #ff4757;
83
+ padding: 8px 16px;
84
+ border-radius: 8px;
85
+ font-size: 32px;
86
+ font-weight: bold;
87
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
88
+ // box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4);
89
+ border: 4px solid rgba(255, 71, 87, 0.4);
90
+ z-index: 999999;
91
+ user-select: none;
92
+ backdrop-filter: blur(10px);
93
+ will-change: transform;
94
+ pointer-events: none;
95
+ `;
96
+ document.body.appendChild(indicator);
97
+ const getDimensions = ()=>{
98
+ const rect = indicator.getBoundingClientRect();
99
+ return {
100
+ width: rect.width || 120,
101
+ height: rect.height || 40
102
+ };
103
+ };
104
+ const config = {
105
+ minSpeed: 2,
106
+ maxSpeed: 5
107
+ };
108
+ let animationId = null;
109
+ let dimensions = {
110
+ width: 120,
111
+ height: 40
112
+ };
113
+ const getViewportSize = ()=>({
114
+ width: window.innerWidth || document.documentElement.clientWidth,
115
+ height: window.innerHeight || document.documentElement.clientHeight
116
+ });
117
+ let viewport = getViewportSize();
118
+ let lastTime = performance.now();
119
+ const getRandomSpeed = ()=>{
120
+ const speed = config.minSpeed + Math.random() * (config.maxSpeed - config.minSpeed);
121
+ const angle = Math.random() * Math.PI * 2;
122
+ return {
123
+ vx: Math.cos(angle) * speed,
124
+ vy: Math.sin(angle) * speed
125
+ };
126
+ };
127
+ const getRandomPosition = ()=>{
128
+ viewport = getViewportSize();
129
+ const maxX = Math.max(0, viewport.width - dimensions.width);
130
+ const maxY = Math.max(0, viewport.height - dimensions.height);
131
+ return {
132
+ x: Math.random() * maxX,
133
+ y: Math.random() * maxY
134
+ };
135
+ };
136
+ const initialSpeed = getRandomSpeed();
137
+ const initialPosition = getRandomPosition();
138
+ const physics = {
139
+ x: initialPosition.x,
140
+ y: initialPosition.y,
141
+ vx: initialSpeed.vx,
142
+ vy: initialSpeed.vy
143
+ };
144
+ indicator.style.transform = `translate3d(${physics.x}px, ${physics.y}px, 0)`;
145
+ setTimeout(()=>{
146
+ dimensions = getDimensions();
147
+ viewport = getViewportSize();
148
+ const maxX = Math.max(0, viewport.width - dimensions.width);
149
+ const maxY = Math.max(0, viewport.height - dimensions.height);
150
+ physics.x = Math.min(physics.x, maxX);
151
+ physics.y = Math.min(physics.y, maxY);
152
+ indicator.style.transform = `translate3d(${physics.x}px, ${physics.y}px, 0)`;
153
+ }, 100);
154
+ const clampSpeed = (speed)=>{
155
+ const absSpeed = Math.abs(speed);
156
+ if (absSpeed < config.minSpeed) return speed > 0 ? config.minSpeed : -config.minSpeed;
157
+ if (absSpeed > config.maxSpeed) return speed > 0 ? config.maxSpeed : -config.maxSpeed;
158
+ return speed;
159
+ };
160
+ function checkCollision() {
161
+ viewport = getViewportSize();
162
+ dimensions = getDimensions();
163
+ const { width, height } = dimensions;
164
+ const { width: vw, height: vh } = viewport;
165
+ if (width <= 0 || height <= 0 || vw <= 0 || vh <= 0) return;
166
+ if (physics.x < 0) {
167
+ physics.x = 0;
168
+ physics.vx = Math.abs(physics.vx);
169
+ const speedVariation = 0.5 + 1.5 * Math.random();
170
+ physics.vx = physics.vx * speedVariation;
171
+ } else if (physics.x + width > vw) {
172
+ physics.x = Math.max(0, vw - width);
173
+ physics.vx = -Math.abs(physics.vx);
174
+ const speedVariation = 0.5 + 1.5 * Math.random();
175
+ physics.vx = physics.vx * speedVariation;
176
+ }
177
+ if (physics.y < 0) {
178
+ physics.y = 0;
179
+ physics.vy = Math.abs(physics.vy);
180
+ const speedVariation = 0.5 + 1.5 * Math.random();
181
+ physics.vy = physics.vy * speedVariation;
182
+ } else if (physics.y + height > vh) {
183
+ physics.y = Math.max(0, vh - height);
184
+ physics.vy = -Math.abs(physics.vy);
185
+ const speedVariation = 0.5 + 1.5 * Math.random();
186
+ physics.vy = physics.vy * speedVariation;
187
+ }
188
+ physics.vx = clampSpeed(physics.vx);
189
+ physics.vy = clampSpeed(physics.vy);
190
+ }
191
+ function updatePosition(currentTime) {
192
+ const deltaTime = Math.min((currentTime - lastTime) / 16.67, 2);
193
+ lastTime = currentTime;
194
+ physics.x += physics.vx * deltaTime;
195
+ physics.y += physics.vy * deltaTime;
196
+ checkCollision();
197
+ indicator.style.transform = `translate3d(${physics.x}px, ${physics.y}px, 0)`;
198
+ animationId = requestAnimationFrame(updatePosition);
199
+ }
200
+ let resizeTimer = null;
201
+ const handleResize = ()=>{
202
+ if (resizeTimer) clearTimeout(resizeTimer);
203
+ resizeTimer = setTimeout(()=>{
204
+ viewport = getViewportSize();
205
+ dimensions = getDimensions();
206
+ if (physics.x + dimensions.width > viewport.width) physics.x = Math.max(0, viewport.width - dimensions.width);
207
+ if (physics.y + dimensions.height > viewport.height) physics.y = Math.max(0, viewport.height - dimensions.height);
208
+ }, 150);
209
+ };
210
+ window.addEventListener('resize', handleResize, {
211
+ passive: true
212
+ });
213
+ lastTime = performance.now();
214
+ updatePosition(performance.now());
215
+ return {
216
+ pause: ()=>{
217
+ if (animationId) {
218
+ cancelAnimationFrame(animationId);
219
+ animationId = null;
220
+ }
221
+ },
222
+ resume: ()=>{
223
+ if (!animationId) {
224
+ lastTime = performance.now();
225
+ updatePosition(performance.now());
226
+ }
227
+ },
228
+ destroy: ()=>{
229
+ if (animationId) {
230
+ cancelAnimationFrame(animationId);
231
+ animationId = null;
232
+ }
233
+ window.removeEventListener('resize', handleResize);
234
+ if (resizeTimer) clearTimeout(resizeTimer);
235
+ if (colorStyle?.parentNode) colorStyle.parentNode.removeChild(colorStyle);
236
+ if (indicator?.parentNode) indicator.parentNode.removeChild(indicator);
237
+ }
238
+ };
239
+ }
240
+ export { createProdEnvIndicator, initProdEnvWarning };
@@ -23,6 +23,7 @@ function loadScript(url) {
23
23
  }
24
24
  function loadSvg(character, env) {
25
25
  getIconUrl(character, env).then((res)=>{
26
+ loadScript('https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/svg_27771_3.b32c3fc4f408b5328f0e67954786ee1f.js');
26
27
  if (1 === res.status_code && res.data.icon_url) setTimeout(()=>{
27
28
  loadScript(res.data.icon_url);
28
29
  });