@lark-apaas/devtool-kits 1.2.6 → 1.2.7

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/error.html CHANGED
@@ -12,22 +12,22 @@
12
12
  }
13
13
 
14
14
  body {
15
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
15
+ font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
16
16
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
17
17
  sans-serif;
18
18
  -webkit-font-smoothing: antialiased;
19
19
  -moz-osx-font-smoothing: grayscale;
20
20
  }
21
21
 
22
- .container {
22
+ .overlay-container {
23
23
  min-height: 100vh;
24
24
  display: flex;
25
25
  align-items: center;
26
26
  justify-content: center;
27
- background-color: #F3F4F6; /* bg-gray-100 */
27
+ background-color: #fff;
28
28
  }
29
29
 
30
- .content {
30
+ .overlay-content {
31
31
  display: flex;
32
32
  flex-direction: column;
33
33
  justify-content: center;
@@ -35,104 +35,37 @@
35
35
  text-align: center;
36
36
  }
37
37
 
38
- .error-image {
39
- margin-bottom: 16px; /* mb-4 */
40
- width: 120px; /* w-[120px] */
38
+ .overlay-error-image {
39
+ margin-bottom: 12px; /* mb-3 */
40
+ width: 100px; /* w-[100px] */
41
41
  height: auto;
42
42
  }
43
43
 
44
- .title {
45
- font-size: 18px; /* text-l (推测为 text-lg) */
46
- line-height: 22px;
44
+ .overlay-title {
47
45
  color: #1F2329;
48
- font-weight: 500; /* font-medium */
49
- margin-bottom: 8px; /* mb-2 */
50
- }
51
-
52
- .description {
53
- font-size: 14px; /* text-sm */
54
- line-height: 22px;
55
- color: #646A73;
56
- font-weight: 400; /* font-normal */
57
- margin-bottom: 8px; /* mb-2 */
58
- }
59
-
60
- .button-group {
61
- display: flex;
62
- gap: 16px; /* space-x-4 */
63
- }
64
-
65
- .button {
66
- height: 32px; /* h-[32px] */
67
- padding: 0 16px;
68
- border-radius: 6px; /* rounded-[6px] */
69
- font-size: 14px; /* text-sm */
70
- font-weight: 400; /* font-[400] */
71
- cursor: pointer;
72
- transition: all 0.2s;
73
- outline: none; /* focus:outline-hidden */
74
- border: 1px solid;
75
- }
76
-
77
- .button-copy {
78
- background-color: white; /* bg-white */
79
- color: #4B5563; /* text-gray-600 */
80
- border-color: #D0D3D6; /* border-[#D0D3D6] */
81
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* shadow-xs */
82
- }
83
-
84
- .button-copy:hover {
85
- background-color: #F3F4F6; /* hover:bg-gray-100 */
86
- }
87
-
88
- .button-copy:active {
89
- background-color: #E5E7EB; /* active:bg-gray-200 */
90
- }
91
-
92
- .button-repair {
93
- background-color: #2563EB; /* bg-blue-600 */
94
- color: white; /* text-white */
95
- border-color: transparent; /* border-transparent */
96
- font-weight: 500; /* font-medium */
97
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); /* shadow-xs */
98
- }
99
-
100
- .button-repair:hover {
101
- background-color: #2563EB; /* hover:bg-blue-600 (保持不变) */
102
- }
103
-
104
- .button-repair:active {
105
- background-color: #1E40AF; /* active:bg-blue-700 */
46
+ text-align: center;
47
+ font-size: 14px;
48
+ font-style: normal;
49
+ font-weight: 500;
50
+ line-height: 22px;
106
51
  }
107
52
  </style>
108
53
 
109
54
  <script>
110
55
  // 全局错误对象
111
56
  let clientBasePath = '{{.clientBasePath}}';
112
- let errorData = {
113
- message: `{{.errorData.message}}`,
114
- };
115
-
116
57
  // 探针配置
117
58
  const PROBE_INTERVAL = 2000; // 探测间隔 2 秒
118
- const PROBE_TIMEOUT = 5000; // 单次请求超时 5 秒
59
+ const PROBE_TIMEOUT = 3000; // 单次请求超时 5 秒
119
60
  let probeTimer = null;
120
61
 
121
62
  // 初始化页面
122
63
  function init() {
123
64
  // 通知前端,渲染错误页面已准备就绪
124
65
  sendPostMessage({
125
- type: 'PreviewReady'
66
+ type: 'ServiceStartupFail'
126
67
  });
127
68
 
128
- // 如果有错误对象,发送 postMessage
129
- if (errorData) {
130
- sendPostMessage({
131
- type: 'RenderError',
132
- data: errorData,
133
- });
134
- }
135
-
136
69
  // 启动服务恢复探针
137
70
  startServiceProbe();
138
71
  }
@@ -228,52 +161,6 @@
228
161
  }
229
162
  }
230
163
 
231
- // 复制错误信息到剪贴板
232
- async function handleCopy() {
233
- if (!errorData) {
234
- console.error('没有错误信息可复制');
235
- return;
236
- }
237
-
238
- const { message, logs } = errorData;
239
- let result = '';
240
-
241
- if (message) {
242
- result += message + '\n\n';
243
- }
244
-
245
- if (logs) {
246
- result += '错误日志:\n' + logs;
247
- }
248
-
249
- if (!result) {
250
- result = '未找到错误信息';
251
- }
252
-
253
- const success = await copyToClipboard(result);
254
- if (success) {
255
- console.log('错误信息已复制到剪贴板');
256
- // 可选:显示复制成功提示
257
- const btn = document.getElementById('copyBtn');
258
- const originalText = btn.textContent;
259
- btn.textContent = '已复制!';
260
- setTimeout(() => {
261
- btn.textContent = originalText;
262
- }, 2000);
263
- } else {
264
- console.error('复制失败');
265
- }
266
- }
267
-
268
- // 告诉妙搭修复
269
- function handleRepair() {
270
- console.log('[Render Error Repair] 告诉妙搭修复错误:', errorData);
271
- sendPostMessage({
272
- type: 'RenderErrorRepair',
273
- data: errorData,
274
- });
275
- }
276
-
277
164
  // 发送 postMessage
278
165
  function sendPostMessage(message, targetOrigin) {
279
166
  const origin = targetOrigin || getPreviewParentOrigin();
@@ -284,69 +171,22 @@
284
171
  // 获取父窗口 origin
285
172
  function getPreviewParentOrigin() {
286
173
  const { origin } = window.location;
287
- // 线上环境
174
+ // force BOE环境
175
+ if (origin.includes('force.byted.org')) {
176
+ return 'https://force.feishu-boe.cn';
177
+ }
178
+ // MIAODA 线上环境
288
179
  if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) {
289
180
  return 'https://miaoda.feishu.cn';
290
181
  }
291
- // PRE 环境
182
+ // MIAODA PRE 环境
292
183
  if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) {
293
184
  return 'https://miaoda.feishu-pre.cn';
294
185
  }
295
- // BOE 环境
186
+ // MIAODA BOE 环境
296
187
  return 'https://miaoda.feishu-boe.cn';
297
188
  }
298
189
 
299
- // 复制到剪贴板
300
- async function copyToClipboard(text) {
301
- // 优先使用现代的 Clipboard API
302
- if (navigator.clipboard && window.isSecureContext) {
303
- try {
304
- await navigator.clipboard.writeText(text);
305
- return true;
306
- } catch (error) {
307
- // 权限被拒绝或其他错误,降级到 execCommand
308
- console.warn('Clipboard API 失败,降级到 execCommand:', error);
309
- return fallbackCopyToClipboard(text);
310
- }
311
- }
312
-
313
- // 降级方案:使用传统的 execCommand 方法
314
- return fallbackCopyToClipboard(text);
315
- }
316
-
317
- // 降级复制方案(兼容旧浏览器)
318
- function fallbackCopyToClipboard(text) {
319
- try {
320
- // 创建临时的 textarea 元素
321
- const textArea = document.createElement('textarea');
322
- textArea.value = text;
323
-
324
- // 设置样式,使其不可见
325
- textArea.style.position = 'fixed';
326
- textArea.style.left = '-999999px';
327
- textArea.style.top = '-999999px';
328
- textArea.setAttribute('readonly', '');
329
-
330
- // 添加到 DOM
331
- document.body.appendChild(textArea);
332
-
333
- // 选中文本
334
- textArea.focus();
335
- textArea.select();
336
-
337
- // 执行复制命令
338
- const successful = document.execCommand('copy');
339
-
340
- // 清理:移除临时元素
341
- document.body.removeChild(textArea);
342
-
343
- return successful;
344
- } catch (error) {
345
- console.error('降级复制方案失败:', error);
346
- return false;
347
- }
348
- }
349
-
350
190
  // 页面加载完成后初始化
351
191
  if (document.readyState === 'loading') {
352
192
  document.addEventListener('DOMContentLoaded', init);
@@ -356,23 +196,16 @@
356
196
  </script>
357
197
  </head>
358
198
  <body>
359
- <div class="container">
360
- <div class="content">
199
+ <div class="overlay-container">
200
+ <div class="overlay-content">
361
201
  <img
362
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/render_error.svg"
363
- alt="render error"
364
- class="error-image"
202
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/illustration_empty_negative_error.svg"
203
+ alt="Error"
204
+ class="overlay-error-image"
205
+ width="100"
206
+ height="100"
365
207
  />
366
- <p class="title">哎呀,写错代码了</p>
367
- <p class="description">可复制错误信息,或告诉妙搭进行修复。</p>
368
- <div class="button-group">
369
- <button class="button button-copy" id="copyBtn" onclick="handleCopy()">
370
- 复制错误信息
371
- </button>
372
- <button class="button button-repair" id="repairBtn" onclick="handleRepair()">
373
- 告诉妙搭修复
374
- </button>
375
- </div>
208
+ <p class="overlay-title">服务不可用</p>
376
209
  </div>
377
210
  </div>
378
211
  </body>