@lark-apaas/devtool-kits 1.2.5-alpha.3 → 1.2.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/error.html +197 -30
- package/dist/index.cjs +28597 -1311
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -11
- package/dist/index.d.ts +1 -11
- package/dist/index.js +28608 -1294
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/template/types.ts +0 -69
package/dist/error.html
CHANGED
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
body {
|
|
15
|
-
font-family:
|
|
15
|
+
font-family: -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
|
-
.
|
|
22
|
+
.container {
|
|
23
23
|
min-height: 100vh;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
26
26
|
justify-content: center;
|
|
27
|
-
background-color: #
|
|
27
|
+
background-color: #F3F4F6; /* bg-gray-100 */
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.
|
|
30
|
+
.content {
|
|
31
31
|
display: flex;
|
|
32
32
|
flex-direction: column;
|
|
33
33
|
justify-content: center;
|
|
@@ -35,37 +35,104 @@
|
|
|
35
35
|
text-align: center;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.
|
|
39
|
-
margin-bottom:
|
|
40
|
-
width:
|
|
38
|
+
.error-image {
|
|
39
|
+
margin-bottom: 16px; /* mb-4 */
|
|
40
|
+
width: 120px; /* w-[120px] */
|
|
41
41
|
height: auto;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.
|
|
44
|
+
.title {
|
|
45
|
+
font-size: 18px; /* text-l (推测为 text-lg) */
|
|
46
|
+
line-height: 22px;
|
|
45
47
|
color: #1F2329;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 */
|
|
51
106
|
}
|
|
52
107
|
</style>
|
|
53
108
|
|
|
54
109
|
<script>
|
|
55
110
|
// 全局错误对象
|
|
56
111
|
let clientBasePath = '{{.clientBasePath}}';
|
|
112
|
+
let errorData = {
|
|
113
|
+
message: `{{.errorData.message}}`,
|
|
114
|
+
};
|
|
115
|
+
|
|
57
116
|
// 探针配置
|
|
58
117
|
const PROBE_INTERVAL = 2000; // 探测间隔 2 秒
|
|
59
|
-
const PROBE_TIMEOUT =
|
|
118
|
+
const PROBE_TIMEOUT = 5000; // 单次请求超时 5 秒
|
|
60
119
|
let probeTimer = null;
|
|
61
120
|
|
|
62
121
|
// 初始化页面
|
|
63
122
|
function init() {
|
|
64
123
|
// 通知前端,渲染错误页面已准备就绪
|
|
65
124
|
sendPostMessage({
|
|
66
|
-
type: '
|
|
125
|
+
type: 'PreviewReady'
|
|
67
126
|
});
|
|
68
127
|
|
|
128
|
+
// 如果有错误对象,发送 postMessage
|
|
129
|
+
if (errorData) {
|
|
130
|
+
sendPostMessage({
|
|
131
|
+
type: 'RenderError',
|
|
132
|
+
data: errorData,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
69
136
|
// 启动服务恢复探针
|
|
70
137
|
startServiceProbe();
|
|
71
138
|
}
|
|
@@ -161,6 +228,52 @@
|
|
|
161
228
|
}
|
|
162
229
|
}
|
|
163
230
|
|
|
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
|
+
|
|
164
277
|
// 发送 postMessage
|
|
165
278
|
function sendPostMessage(message, targetOrigin) {
|
|
166
279
|
const origin = targetOrigin || getPreviewParentOrigin();
|
|
@@ -171,22 +284,69 @@
|
|
|
171
284
|
// 获取父窗口 origin
|
|
172
285
|
function getPreviewParentOrigin() {
|
|
173
286
|
const { origin } = window.location;
|
|
174
|
-
//
|
|
175
|
-
if (origin.includes('force.byted.org')) {
|
|
176
|
-
return 'https://force.feishu-boe.cn';
|
|
177
|
-
}
|
|
178
|
-
// MIAODA 线上环境
|
|
287
|
+
// 线上环境
|
|
179
288
|
if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) {
|
|
180
289
|
return 'https://miaoda.feishu.cn';
|
|
181
290
|
}
|
|
182
|
-
//
|
|
291
|
+
// PRE 环境
|
|
183
292
|
if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) {
|
|
184
293
|
return 'https://miaoda.feishu-pre.cn';
|
|
185
294
|
}
|
|
186
|
-
//
|
|
295
|
+
// BOE 环境
|
|
187
296
|
return 'https://miaoda.feishu-boe.cn';
|
|
188
297
|
}
|
|
189
298
|
|
|
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
|
+
|
|
190
350
|
// 页面加载完成后初始化
|
|
191
351
|
if (document.readyState === 'loading') {
|
|
192
352
|
document.addEventListener('DOMContentLoaded', init);
|
|
@@ -196,16 +356,23 @@
|
|
|
196
356
|
</script>
|
|
197
357
|
</head>
|
|
198
358
|
<body>
|
|
199
|
-
<div class="
|
|
200
|
-
<div class="
|
|
359
|
+
<div class="container">
|
|
360
|
+
<div class="content">
|
|
201
361
|
<img
|
|
202
|
-
src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylcylz_fsph_ryhs/ljhwZthlaukjlkulzlp/feisuda/template/
|
|
203
|
-
alt="
|
|
204
|
-
class="
|
|
205
|
-
width="100"
|
|
206
|
-
height="100"
|
|
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"
|
|
207
365
|
/>
|
|
208
|
-
<p class="
|
|
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>
|
|
209
376
|
</div>
|
|
210
377
|
</div>
|
|
211
378
|
</body>
|