Skip to content

Commit 48d548c

Browse files
author
Taois
committed
feat:专项动作处理
1 parent ae5863d commit 48d548c

File tree

7 files changed

+1357
-292
lines changed

7 files changed

+1357
-292
lines changed

dashboard/src/components/actions/ActionDialog.vue

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,19 @@ export default {
144144
style.width = '95vw'
145145
style.maxWidth = '95vw'
146146
style.margin = '0 auto'
147-
if (props.height && props.height !== 'auto') {
148-
style.maxHeight = '85vh'
149-
}
147+
// 移除移动端的高度限制,让CSS控制
150148
} else {
151149
// 桌面端样式
152150
if (props.width) {
153151
style.width = typeof props.width === 'number' ? `${props.width}px` : props.width
154152
style.maxWidth = '90vw'
155153
}
156154
155+
// 只有明确设置了固定高度时才应用
157156
if (props.height && props.height !== 'auto') {
158157
style.height = typeof props.height === 'number' ? `${props.height}px` : props.height
159-
style.maxHeight = '90vh'
160158
}
159+
// 移除桌面端的maxHeight限制,让CSS控制
161160
}
162161
163162
if (props.bottom > 0) {
@@ -171,11 +170,12 @@ export default {
171170
const contentStyle = computed(() => {
172171
const style = {}
173172
173+
// 只有在明确设置了固定高度时才应用内容区域的高度限制
174174
if (props.height && props.height !== 'auto') {
175-
// 如果设置了固定高度,内容区域需要减去头部和底部的高度
176175
style.maxHeight = 'calc(100% - 120px)' // 预留头部和底部空间
177176
style.overflowY = 'auto'
178177
}
178+
// 其他情况让CSS的max-height规则控制
179179
180180
return style
181181
})
@@ -264,20 +264,21 @@ export default {
264264
left: 0;
265265
right: 0;
266266
bottom: 0;
267-
z-index: 10000;
267+
z-index: 20000;
268268
display: flex;
269269
align-items: center;
270270
justify-content: center;
271271
padding: 1rem;
272272
background: rgba(0, 0, 0, calc(var(--dim-amount, 0.45)));
273273
backdrop-filter: blur(8px);
274274
-webkit-backdrop-filter: blur(8px);
275+
overflow: hidden;
275276
}
276277
277278
/* 现代化弹窗容器 */
278279
.action-dialog {
279280
position: relative;
280-
z-index: 10001;
281+
z-index: 20001;
281282
background: rgba(255, 255, 255, 0.95);
282283
backdrop-filter: blur(20px);
283284
-webkit-backdrop-filter: blur(20px);
@@ -289,6 +290,10 @@ export default {
289290
overflow: hidden;
290291
transform-origin: center;
291292
transition: all var(--ds-duration-normal) cubic-bezier(0.34, 1.56, 0.64, 1);
293+
max-height: calc(100vh - 2rem);
294+
max-width: 90vw;
295+
display: flex;
296+
flex-direction: column;
292297
}
293298
294299
/* 装饰性背景 */
@@ -342,6 +347,7 @@ export default {
342347
padding: 2rem 2rem 1rem;
343348
background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
344349
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
350+
flex-shrink: 0;
345351
}
346352
347353
.action-dialog-title {
@@ -358,29 +364,13 @@ export default {
358364
position: relative;
359365
z-index: 1;
360366
padding: 1.5rem 2rem;
361-
max-height: calc(85vh - 200px);
362-
overflow-y: auto;
363-
overflow-x: hidden;
364-
}
365-
366-
/* 自定义滚动条 */
367-
.action-dialog-content::-webkit-scrollbar {
368-
width: 6px;
367+
flex: 1 1 auto;
368+
overflow: visible; /* 移除滚动条,让子元素处理滚动 */
369+
min-height: 0; /* 重要:允许flex子项收缩 */
370+
max-height: 100%; /* 确保不超出父容器 */
369371
}
370372
371-
.action-dialog-content::-webkit-scrollbar-track {
372-
background: rgba(0, 0, 0, 0.05);
373-
border-radius: 3px;
374-
}
375-
376-
.action-dialog-content::-webkit-scrollbar-thumb {
377-
background: rgba(0, 0, 0, 0.2);
378-
border-radius: 3px;
379-
}
380-
381-
.action-dialog-content::-webkit-scrollbar-thumb:hover {
382-
background: rgba(0, 0, 0, 0.3);
383-
}
373+
/* action-dialog-content 不再需要滚动条样式,因为滚动由子元素处理 */
384374
385375
/* 底部样式 */
386376
.action-dialog-footer {
@@ -392,6 +382,7 @@ export default {
392382
display: flex;
393383
justify-content: flex-end;
394384
gap: 0.75rem;
385+
flex-shrink: 0;
395386
}
396387
397388
/* 移动端适配 */
@@ -406,7 +397,7 @@ export default {
406397
407398
.action-dialog-mobile .action-dialog-content {
408399
padding: 1rem 1.5rem;
409-
max-height: calc(85vh - 150px);
400+
/* 移除max-height,使用flex布局控制 */
410401
}
411402
412403
.action-dialog-mobile .action-dialog-footer {

dashboard/src/components/actions/ActionRenderer.vue

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ import {
6262
validateActionConfig,
6363
ActionType,
6464
ActionErrorType,
65-
createActionError
65+
createActionError,
66+
isSpecialAction
6667
} from './types.js'
6768
import { executeAction } from '@/api/modules/module.js'
6869
import { showToast } from '@/stores/toast.js'
@@ -155,7 +156,7 @@ export default {
155156
})
156157
157158
// 解析Action配置
158-
const parseConfig = (data) => {
159+
const parseConfig = async (data) => {
159160
try {
160161
console.log('ActionRenderer parseConfig 开始解析:', data)
161162
if (!data) {
@@ -167,8 +168,12 @@ export default {
167168
console.log('ActionRenderer parseConfig 解析后的配置:', config)
168169
validateActionConfig(config)
169170
170-
// 处理特殊动作
171-
handleSpecialActions(config)
171+
// 检查是否为特殊动作,如果是则立即执行
172+
if (isSpecialAction(config)) {
173+
console.log('检测到特殊动作,立即执行:', config)
174+
await handleSpecialAction(config)
175+
return // 特殊动作执行完毕后直接返回,不需要显示UI
176+
}
172177
173178
parsedConfig.value = config
174179
error.value = null
@@ -187,32 +192,7 @@ export default {
187192
}
188193
}
189194
190-
// 处理特殊动作
191-
const handleSpecialActions = (config) => {
192-
const { actionId } = config
193195
194-
// 专项动作处理
195-
switch (actionId) {
196-
case '源内搜索':
197-
// 可以在这里添加特殊处理逻辑
198-
break
199-
case '详情页跳转':
200-
// 可以在这里添加特殊处理逻辑
201-
break
202-
case 'KTV播放':
203-
// 可以在这里添加特殊处理逻辑
204-
break
205-
case '刷新列表':
206-
// 可以在这里添加特殊处理逻辑
207-
break
208-
case '放入剪贴板':
209-
// 可以在这里添加特殊处理逻辑
210-
break
211-
case '保持窗口':
212-
// 可以在这里添加特殊处理逻辑
213-
break
214-
}
215-
}
216196
217197
// 处理专项动作(动态动作)
218198
const handleSpecialAction = async (actionData) => {
@@ -278,7 +258,7 @@ export default {
278258
if (actionData.content) {
279259
try {
280260
await navigator.clipboard.writeText(actionData.content)
281-
showToast('已复制到剪贴板', 'success')
261+
showToast('已复制到剪切板', 'success')
282262
} catch (err) {
283263
showToast('复制失败', 'error')
284264
}
@@ -386,7 +366,7 @@ export default {
386366
// 处理新的action(动态action)
387367
if (result.action) {
388368
console.log('检测到动态action,重新解析:', result.action)
389-
parseConfig(result.action)
369+
await parseConfig(result.action)
390370
return
391371
}
392372
@@ -409,7 +389,7 @@ export default {
409389
if (dataResult.action || dataResult.actionId) {
410390
console.log('在data字段中检测到action:', dataResult)
411391
if (dataResult.action) {
412-
parseConfig(dataResult.action)
392+
await parseConfig(dataResult.action)
413393
return
414394
}
415395
if (dataResult.actionId) {
@@ -465,7 +445,7 @@ export default {
465445
// 等待一个短暂的时间让当前弹窗完全关闭
466446
await new Promise(resolve => setTimeout(resolve, 100))
467447
// 然后解析新的配置
468-
parseConfig(action)
448+
await parseConfig(action)
469449
return
470450
}
471451
@@ -495,8 +475,8 @@ export default {
495475
496476
497477
// 监听actionData变化
498-
watch(() => props.actionData, (newData) => {
499-
parseConfig(newData)
478+
watch(() => props.actionData, async (newData) => {
479+
await parseConfig(newData)
500480
}, { immediate: true })
501481
502482
// 监听visible变化
@@ -505,9 +485,9 @@ export default {
505485
})
506486
507487
// 公开方法
508-
const show = (actionData) => {
488+
const show = async (actionData) => {
509489
if (actionData) {
510-
parseConfig(actionData)
490+
await parseConfig(actionData)
511491
}
512492
isVisible.value = true
513493
}

dashboard/src/components/actions/InputAction.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ export default {
586586
587587
await navigator.clipboard.writeText(content)
588588
if(!toastData){
589-
showToast('已复制到剪贴板', 'success')
589+
showToast('已复制到剪切板', 'success')
590590
}
591591
592592
} catch (error) {

0 commit comments

Comments
 (0)