Skip to content

Commit 419761f

Browse files
author
Taois
committed
feat:完善菜单选项动作的交互设计
1 parent 04ad326 commit 419761f

File tree

4 files changed

+166
-5
lines changed

4 files changed

+166
-5
lines changed

dashboard/src/components/actions/HelpAction.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export default {
424424
default: ''
425425
}
426426
},
427-
emits: ['close', 'link-click', 'toast', 'reset'],
427+
emits: ['close', 'link-click', 'toast', 'reset', 'special-action'],
428428
setup(props, { emit }) {
429429
const imageError = ref(false)
430430
const qrError = ref(false)

dashboard/src/components/actions/MenuAction.vue

Lines changed: 163 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,48 @@ export default {
569569
emit('close')
570570
return
571571
572+
case '__detail__':
573+
// 详情页跳转
574+
console.log('详情页跳转:', actionData)
575+
await handleDetailAction(actionData)
576+
emit('close')
577+
return
578+
579+
case '__copy__':
580+
// 复制到剪贴板
581+
await handleCopyAction(actionData, toastData)
582+
emit('close')
583+
return
584+
585+
case '__self_search__':
586+
// 源内搜索
587+
await handleSelfSearchAction(actionData)
588+
emit('close')
589+
return
590+
572591
case '__refresh_list__':
573592
// 刷新列表
574-
handleRefreshListAction(actionData)
593+
await handleRefreshListAction(actionData)
594+
emit('close')
595+
return
596+
597+
case '__ktvplayer__':
598+
// KTV播放
599+
await handleKtvPlayerAction(actionData)
575600
emit('close')
576601
return
577602
578603
default:
579-
console.warn('未知的专项动作:', actionData.actionId)
604+
// 检查是否为普通动作(包含type字段)
605+
if (actionData.type) {
606+
console.log('检测到普通动作,触发新的ActionRenderer:', actionData)
607+
// 通过action事件将新的动作数据传递给ActionRenderer
608+
emit('action', actionData)
609+
// 不要立即关闭弹窗,让ActionRenderer处理新动作配置
610+
return
611+
} else {
612+
console.warn('未知的专项动作:', actionData.actionId)
613+
}
580614
break
581615
}
582616
}
@@ -590,6 +624,85 @@ export default {
590624
emit('submit', result)
591625
}
592626
627+
// 处理详情页跳转动作
628+
const handleDetailAction = async (actionData) => {
629+
try {
630+
console.log('执行详情页跳转:', actionData)
631+
632+
if (actionData.url) {
633+
// 如果有URL,直接跳转
634+
await router.push(actionData.url)
635+
} else if (actionData.route) {
636+
// 如果有路由信息,使用路由跳转
637+
await router.push(actionData.route)
638+
} else {
639+
console.warn('详情页跳转缺少URL或路由信息')
640+
showToast('跳转失败:缺少目标地址', 'error')
641+
}
642+
643+
} catch (error) {
644+
console.error('详情页跳转失败:', error)
645+
showToast('跳转失败', 'error')
646+
}
647+
}
648+
649+
// 处理复制动作
650+
const handleCopyAction = async (actionData, toastData) => {
651+
try {
652+
const copyContent = actionData.content || actionData.text || actionData.value || ''
653+
654+
if (!copyContent) {
655+
console.warn('复制内容为空')
656+
showToast('复制失败:内容为空', 'error')
657+
return
658+
}
659+
660+
await navigator.clipboard.writeText(copyContent)
661+
console.log('复制成功:', copyContent)
662+
663+
const message = actionData.msg || toastData?.msg || '复制成功'
664+
showToast(message, 'success')
665+
666+
} catch (error) {
667+
console.error('复制失败:', error)
668+
showToast('复制失败', 'error')
669+
}
670+
}
671+
672+
// 处理源内搜索动作
673+
const handleSelfSearchAction = async (actionData) => {
674+
try {
675+
console.log('执行源内搜索:', actionData)
676+
677+
// 构建搜索参数
678+
const searchParams = {
679+
keyword: actionData.keyword || actionData.query || '',
680+
siteKey: actionData.skey || actionData.siteKey || '',
681+
...actionData.params
682+
}
683+
684+
// 如果指定了站点,先切换站点
685+
if (searchParams.siteKey) {
686+
// 触发站点切换事件
687+
window.dispatchEvent(new CustomEvent('switchSite', {
688+
detail: { siteKey: searchParams.siteKey }
689+
}))
690+
}
691+
692+
// 触发搜索事件
693+
emit('special-action', {
694+
type: 'self-search',
695+
data: searchParams
696+
})
697+
698+
showToast('开始搜索...', 'info')
699+
700+
} catch (error) {
701+
console.error('源内搜索失败:', error)
702+
showToast('搜索失败', 'error')
703+
}
704+
}
705+
593706
// 处理刷新列表动作
594707
const handleRefreshListAction = async (actionData) => {
595708
try {
@@ -624,6 +737,54 @@ export default {
624737
}
625738
}
626739
740+
// 处理KTV播放动作
741+
const handleKtvPlayerAction = async (actionData) => {
742+
try {
743+
console.log('执行KTV播放:', actionData)
744+
745+
const playUrl = actionData.url || actionData.playUrl || ''
746+
const title = actionData.title || actionData.name || 'KTV播放'
747+
748+
if (!playUrl) {
749+
console.warn('KTV播放缺少播放地址')
750+
showToast('播放失败:缺少播放地址', 'error')
751+
return
752+
}
753+
754+
// 构建KTV播放器路由参数
755+
const routeParams = {
756+
name: 'KtvPlayer',
757+
query: {
758+
url: playUrl,
759+
title: title,
760+
...actionData.params
761+
}
762+
}
763+
764+
// 如果没有KTV播放器路由,使用通用视频播放器
765+
try {
766+
await router.push(routeParams)
767+
} catch (routeError) {
768+
console.log('KTV播放器路由不存在,使用通用播放器')
769+
await router.push({
770+
name: 'VideoPlayer',
771+
query: {
772+
url: playUrl,
773+
title: title,
774+
type: 'ktv',
775+
...actionData.params
776+
}
777+
})
778+
}
779+
780+
showToast('正在打开KTV播放器...', 'info')
781+
782+
} catch (error) {
783+
console.error('KTV播放失败:', error)
784+
showToast('播放失败', 'error')
785+
}
786+
}
787+
627788
const handleCancel = () => {
628789
emit('cancel')
629790
emit('close')

dashboard/src/components/actions/MsgBoxAction.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export default {
241241
default: ''
242242
}
243243
},
244-
emits: ['submit', 'cancel', 'close', 'action', 'toast', 'reset'],
244+
emits: ['submit', 'cancel', 'close', 'action', 'toast', 'reset', 'special-action'],
245245
setup(props, { emit }) {
246246
const timeLeft = ref(0)
247247
const timer = ref(null)

dashboard/src/components/actions/WebViewAction.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export default {
246246
default: ''
247247
}
248248
},
249-
emits: ['submit', 'cancel', 'close', 'action', 'toast', 'reset'],
249+
emits: ['submit', 'cancel', 'close', 'action', 'toast', 'reset', 'special-action'],
250250
setup(props, { emit }) {
251251
const webviewFrame = ref(null)
252252
const currentUrl = ref('')

0 commit comments

Comments
 (0)