-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathActionDebugTest.vue
More file actions
354 lines (305 loc) · 11.1 KB
/
ActionDebugTest.vue
File metadata and controls
354 lines (305 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<template>
<div class="action-debug-test">
<div class="debug-header">
<h1>Action数据解析调试工具</h1>
<p>用于排查T4 API返回的action数据解析问题</p>
</div>
<div class="debug-sections">
<!-- 原始数据输入 -->
<div class="debug-section">
<h2>1. 原始数据输入</h2>
<p>请粘贴T4 API返回的vod_id字段内容:</p>
<textarea
v-model="rawData"
class="debug-textarea"
placeholder="粘贴vod_id字段的JSON字符串..."
rows="8"
></textarea>
<button @click="parseData" class="debug-button">解析数据</button>
</div>
<!-- 解析结果 -->
<div class="debug-section" v-if="parseResult">
<h2>2. 解析结果</h2>
<div class="debug-result">
<h3>解析状态:<span :class="parseResult.success ? 'success' : 'error'">
{{ parseResult.success ? '成功' : '失败' }}
</span></h3>
<div v-if="parseResult.success">
<h4>解析后的配置对象:</h4>
<pre class="debug-json">{{ JSON.stringify(parseResult.config, null, 2) }}</pre>
<h4>关键字段检查:</h4>
<ul class="debug-fields">
<li>actionId: <code>{{ parseResult.config.actionId || 'undefined' }}</code></li>
<li>type: <code>{{ parseResult.config.type || 'undefined' }}</code></li>
<li>title: <code>{{ parseResult.config.title || 'undefined' }}</code></li>
<li>id: <code>{{ parseResult.config.id || 'undefined' }}</code></li>
</ul>
<h4>类型验证:</h4>
<ul class="debug-validation">
<li>type字段存在: <span :class="parseResult.config.type ? 'success' : 'error'">
{{ parseResult.config.type ? '是' : '否' }}
</span></li>
<li>type值有效: <span :class="isValidType(parseResult.config.type) ? 'success' : 'error'">
{{ isValidType(parseResult.config.type) ? '是' : '否' }}
</span></li>
<li>actionId存在: <span :class="parseResult.config.actionId ? 'success' : 'error'">
{{ parseResult.config.actionId ? '是' : '否' }}
</span></li>
</ul>
</div>
<div v-else>
<h4>错误信息:</h4>
<pre class="debug-error">{{ parseResult.error }}</pre>
</div>
</div>
</div>
<!-- ActionRenderer测试 -->
<div class="debug-section" v-if="parseResult && parseResult.success">
<h2>3. ActionRenderer组件测试</h2>
<button @click="testActionRenderer" class="debug-button">测试ActionRenderer</button>
<div v-if="rendererError" class="debug-error-box">
<h4>ActionRenderer错误:</h4>
<pre>{{ rendererError }}</pre>
</div>
</div>
<!-- 预设测试数据 -->
<div class="debug-section">
<h2>4. 预设测试数据</h2>
<p>使用你提供的真实T4 API数据进行测试:</p>
<div class="preset-buttons">
<button @click="loadPresetData('push_video')" class="debug-button">推送视频播放</button>
<button @click="loadPresetData('push_novel')" class="debug-button">推送番茄小说</button>
</div>
</div>
</div>
<!-- ActionRenderer组件 -->
<ActionRenderer
v-if="showActionRenderer"
ref="actionRendererRef"
:action-data="currentActionData"
@close="handleActionClose"
@submit="handleActionSubmit"
@error="handleActionError"
/>
</div>
</template>
<script setup>
import { ref } from 'vue'
import ActionRenderer from '@/components/actions/ActionRenderer.vue'
import { ActionType, parseActionConfig, validateActionConfig } from '@/components/actions/types.js'
const rawData = ref('')
const parseResult = ref(null)
const showActionRenderer = ref(false)
const currentActionData = ref(null)
const actionRendererRef = ref(null)
const rendererError = ref(null)
// 预设测试数据
const presetData = {
push_video: `{"actionId":"推送视频播放","id":"push","type":"input","title":"推送视频地址进行播放","tip":"支持网盘、官链、直链、待嗅探链接","value":"","msg":"请输入待推送的视频地址","imageUrl":"http://127.0.0.1:5757/public/images/lives.jpg","imageHeight":200,"imageType":"card_pic_3","keep":true,"button":4,"width":640,"selectData":"123:=\`https://www.123684.com/s/oec7Vv-DggWh?ZY4K,腾讯:=https://v.qq.com/x/cover/mzc00200vkqr54u/u4100l66fas.html,爱奇艺:=http://www.iqiyi.com/v_1b0tk1b8tl8.html,夸克:=https://pan.quark.cn/s/6c8158e258f3,UC:=https://drive.uc.cn/s/59023f57d3ce4?public=1,阿里:=https://www.alipan.com/s/vgXMcowK8pQ,天翼:=https://cloud.189.cn/web/share?code=INJbU3NbqyUj,百度:=https://pan.baidu.com/s/1L0UIv4p0X0QrbbKErJuc_w?pwd=2pwj,移动1:=https://yun.139.com/shareweb/#/w/i/0i5CLQ7BpV7Ai,移动2:=https://caiyun.139.com/m/i?2jexC1gcjeN7q,移动3:=https://yun.139.com/shareweb/#/w/i/2i2MoE9ZHn9p1,直链1:=https://vdse.bdstatic.com//628ca08719cef5987ea2ae3c6f0d2386.mp4,嗅探1:=https://www.6080kk.cc/haokanplay/178120-1-1.html,嗅探2:=https://www.hahads.com/play/537106-3-1.html,多集:=https://v.qq.com/x/cover/m441e3rjq9kwpsc/m00253deqqo.html@https://pan.quark.cn/s/6c8158e258f3@https://pan.baidu.com/s/1TdbgcwaMG1dK7B5pQ1LbBg?pwd=1234,海阔二级单线路:=H4sIAAAAAAAAA52Uy27TQBSGXwUZlsT2GefadZ+AN3ATk7qKL7guUoKQXAQFeoEG6oKaVBUFlBZFbdQ0TXAIeRjPTJwVr8AYCsNyijQbnzPfPz72p3kk6WXf8aQFibzszFsb0l2p7Ni+YfusFAe78/W383C6eC8OmnEQsEVal7NxiEebeLQ/i75oKvl6iccfZwdPWY0OhnR8+uPbdnJ2kUx7ONrAo094skMOD+ZHHbL1nIbHbCf53KdBh7RPaP+Yfm8n5x+S3gWr016TtCb03VUa2Brh6A0Nm8ngVRysk7Nt+mI3aYfk9fs0YfMERxENn+FoKw6e3KJ7V8lgyF6+YnrG9UAPTLu6ZNgrpu4ZNlJRlrXve47FWrNomgzPEdJYydYtIx1/Z0rbXTzps9zrza5ZZo1l33dXFxSFPWlyvdGom5ZeNVblsmMpa27N0SvKQ6eipEwGIINAgYKGIA+lYg7kFbfKkta8Wnpqt6sC+8Z3/kQuyXm1qDZ+RbEMt6bXFVBBQ6UMy5KXfat2O4WQMIQ4pAlDGoeywlCWQzlhKMehvDCU51BBGCpwqCgMFTlUEoZKfyFQxX+uyqkbKMGdAHEnAP0Xxa0AcZWAawHiLgH3AsRlAi4GiNsE3AwQ1wm4GiDuE/zjhrhQiLuBxI1C3A0kbhTibqAb3DK/3ZAe/wSSQMKkPgYAAA==\`"}`,
push_novel: `{"actionId":"推送番茄小说","id":"push","type":"input","title":"推送番茄小说网页目录链接进行解析","tip":"支持番茄小说网页版链接","value":"\`https://fanqienovel.com/page/7421167583522458648\`","msg":"请输入待推送的番茄小说网页版链接","imageUrl":"http://127.0.0.1:5757/public/images/icon_cookie/%E9%98%85%E8%AF%BB.png","imageHeight":200,"imageType":"card_pic_3","keep":false,"selectData":"大一实习:=\`https://fanqienovel.com/page/7421167583522458648,十日终焉:=https://fanqienovel.com/page/7143038691944959011,斩神:=https://fanqienovel.com/page/6982529841564224526\`"}`
}
// 检查type是否有效
const isValidType = (type) => {
return Object.values(ActionType).includes(type)
}
// 解析数据
const parseData = () => {
if (!rawData.value.trim()) {
parseResult.value = {
success: false,
error: '请输入数据'
}
return
}
try {
console.log('原始数据:', rawData.value)
// 使用ActionRenderer相同的解析逻辑
const config = parseActionConfig(rawData.value)
console.log('解析后的配置:', config)
// 验证配置
validateActionConfig(config)
parseResult.value = {
success: true,
config: config
}
} catch (error) {
console.error('解析错误:', error)
parseResult.value = {
success: false,
error: error.message || error.toString()
}
}
}
// 测试ActionRenderer
const testActionRenderer = () => {
if (!parseResult.value || !parseResult.value.success) {
return
}
try {
rendererError.value = null
currentActionData.value = parseResult.value.config
showActionRenderer.value = true
} catch (error) {
rendererError.value = error.message || error.toString()
}
}
// 加载预设数据
const loadPresetData = (type) => {
rawData.value = presetData[type]
parseData()
}
// ActionRenderer事件处理
const handleActionClose = () => {
showActionRenderer.value = false
currentActionData.value = null
}
const handleActionSubmit = (result) => {
console.log('Action提交结果:', result)
showActionRenderer.value = false
currentActionData.value = null
}
const handleActionError = (error) => {
console.error('ActionRenderer错误:', error)
rendererError.value = error.message || error.toString()
}
</script>
<style scoped>
.action-debug-test {
padding: 20px;
max-width: 1200px;
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.debug-header {
text-align: center;
margin-bottom: 40px;
}
.debug-header h1 {
color: var(--color-text-1);
margin-bottom: 10px;
}
.debug-header p {
color: var(--color-text-3);
font-size: 16px;
}
.debug-sections {
display: flex;
flex-direction: column;
gap: 30px;
}
.debug-section {
border: 1px solid var(--color-border-2);
border-radius: 8px;
padding: 20px;
background: var(--color-bg-2);
}
.debug-section h2 {
color: var(--color-text-1);
margin-bottom: 15px;
font-size: 18px;
}
.debug-section p {
color: var(--color-text-3);
margin-bottom: 15px;
}
.debug-textarea {
width: 100%;
min-height: 120px;
padding: 12px;
border: 1px solid var(--color-border-2);
border-radius: 6px;
background: var(--color-bg-1);
color: var(--color-text-1);
font-family: 'Courier New', monospace;
font-size: 12px;
resize: vertical;
margin-bottom: 15px;
}
.debug-button {
background: var(--color-primary);
color: white;
border: none;
padding: 10px 20px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
margin-right: 10px;
margin-bottom: 10px;
}
.debug-button:hover {
background: var(--color-primary-hover);
}
.debug-result {
margin-top: 15px;
}
.debug-result h3 {
color: var(--color-text-1);
margin-bottom: 15px;
}
.debug-result h4 {
color: var(--color-text-2);
margin: 20px 0 10px 0;
font-size: 16px;
}
.debug-json {
background: var(--color-bg-1);
border: 1px solid var(--color-border-2);
border-radius: 6px;
padding: 15px;
font-family: 'Courier New', monospace;
font-size: 12px;
overflow-x: auto;
color: var(--color-text-1);
}
.debug-fields, .debug-validation {
list-style: none;
padding: 0;
margin: 0;
}
.debug-fields li, .debug-validation li {
padding: 8px 0;
border-bottom: 1px solid var(--color-border-3);
color: var(--color-text-2);
}
.debug-fields code {
background: var(--color-bg-1);
padding: 2px 6px;
border-radius: 3px;
font-family: 'Courier New', monospace;
color: var(--color-text-1);
}
.success {
color: #52c41a;
font-weight: bold;
}
.error {
color: #f5222d;
font-weight: bold;
}
.debug-error {
background: #fff2f0;
border: 1px solid #ffccc7;
border-radius: 6px;
padding: 15px;
color: #f5222d;
font-family: 'Courier New', monospace;
font-size: 12px;
overflow-x: auto;
}
.debug-error-box {
margin-top: 15px;
padding: 15px;
background: #fff2f0;
border: 1px solid #ffccc7;
border-radius: 6px;
}
.debug-error-box h4 {
color: #f5222d;
margin-bottom: 10px;
}
.preset-buttons {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
</style>