diff --git a/frontend/src/components/queue/QueueItemManager.vue b/frontend/src/components/queue/QueueItemManager.vue index 88651d6..13397ab 100644 --- a/frontend/src/components/queue/QueueItemManager.vue +++ b/frontend/src/components/queue/QueueItemManager.vue @@ -11,46 +11,59 @@ - - - - - - - - - + + @@ -77,6 +95,7 @@ import { ref, watch } from 'vue' import { message } from 'ant-design-vue' import { DeleteOutlined, PlusOutlined } from '@ant-design/icons-vue' +import draggable from 'vuedraggable' import { Service } from '@/api' import dayjs from 'dayjs' @@ -159,7 +178,7 @@ const timeSets = ref([...props.timeSets]) const processTimeSets = (rawTimeSets: any[]) => { return rawTimeSets.map(item => ({ ...item, - timeValue: parseTimeString(item.time) + timeValue: parseTimeString(item.time), })) } @@ -221,7 +240,7 @@ const addTimeSet = async () => { const updateTimeSetTime = async (timeSet: any) => { try { const timeString = formatTimeValue(timeSet.timeValue) - + const response = await Service.updateTimeSetApiQueueTimeUpdatePost({ queueId: props.queueId, timeSetId: timeSet.id, @@ -297,6 +316,44 @@ const deleteTimeSet = async (timeSetId: string) => { message.error('删除定时项失败: ' + (error?.message || '网络错误')) } } + +// 拖拽结束处理函数 +const onDragEnd = async (evt: any) => { + // 如果位置没有变化,直接返回 + if (evt.oldIndex === evt.newIndex) { + return + } + + try { + loading.value = true + + // 构造排序后的ID列表 + const sortedIds = timeSets.value.map(item => item.id) + + // 调用排序API + const response = await Service.reorderTimeSetApiQueueTimeOrderPost({ + queueId: props.queueId, + indexList: sortedIds, + }) + + if (response.code === 200) { + message.success('定时顺序已更新') + // 刷新数据以确保与服务器同步 + emit('refresh') + } else { + message.error('更新定时顺序失败: ' + (response.message || '未知错误')) + // 如果失败,刷新数据恢复原状态 + emit('refresh') + } + } catch (error: any) { + console.error('拖拽排序失败:', error) + message.error('更新定时顺序失败: ' + (error?.message || '网络错误')) + // 如果失败,刷新数据恢复原状态 + emit('refresh') + } finally { + loading.value = false + } +} @@ -831,7 +1054,9 @@ const deleteTimeSet = async (timeSetId: string) => { transition: background 0.2s ease; } -[data-theme='dark'] .ant-picker-dropdown .ant-picker-time-panel-column::-webkit-scrollbar-thumb:hover { +[data-theme='dark'] + .ant-picker-dropdown + .ant-picker-time-panel-column::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.45); } diff --git a/frontend/src/views/setting/TabFunction.vue b/frontend/src/views/setting/TabFunction.vue index e6dd1cf..8ff5bfb 100644 --- a/frontend/src/views/setting/TabFunction.vue +++ b/frontend/src/views/setting/TabFunction.vue @@ -2,14 +2,65 @@ import { QuestionCircleOutlined } from '@ant-design/icons-vue' import type { SettingsData } from '@/types/settings' -const { settings, historyRetentionOptions, handleSettingChange } = defineProps<{ +const { settings, historyRetentionOptions, updateSourceOptions, voiceTypeOptions, handleSettingChange, checkUpdate } = defineProps<{ settings: SettingsData historyRetentionOptions: { label: string; value: number }[] + updateSourceOptions: { label: string; value: string }[] + voiceTypeOptions: { label: string; value: string }[] handleSettingChange: (category: keyof SettingsData, key: string, value: any) => Promise + checkUpdate: () => Promise }>() diff --git a/frontend/src/views/setting/TabStart.vue b/frontend/src/views/setting/TabStart.vue deleted file mode 100644 index 2f995f8..0000000 --- a/frontend/src/views/setting/TabStart.vue +++ /dev/null @@ -1,58 +0,0 @@ - - diff --git a/frontend/src/views/setting/TabUpdate.vue b/frontend/src/views/setting/TabUpdate.vue deleted file mode 100644 index debdcf0..0000000 --- a/frontend/src/views/setting/TabUpdate.vue +++ /dev/null @@ -1,108 +0,0 @@ - - diff --git a/frontend/src/views/setting/TabVoice.vue b/frontend/src/views/setting/TabVoice.vue deleted file mode 100644 index 70f2372..0000000 --- a/frontend/src/views/setting/TabVoice.vue +++ /dev/null @@ -1,58 +0,0 @@ - - diff --git a/frontend/src/views/setting/index.vue b/frontend/src/views/setting/index.vue index 8cde780..d08e9e5 100644 --- a/frontend/src/views/setting/index.vue +++ b/frontend/src/views/setting/index.vue @@ -16,9 +16,6 @@ import { mirrorManager } from '@/utils/mirrorManager' import TabBasic from './TabBasic.vue' import TabFunction from './TabFunction.vue' import TabNotify from './TabNotify.vue' -import TabUpdate from './TabUpdate.vue' -import TabStart from './TabStart.vue' -import TabVoice from './TabVoice.vue' import TabAdvanced from './TabAdvanced.vue' import TabOthers from './TabOthers.vue' @@ -193,7 +190,10 @@ const openDevTools = () => (window as any).electronAPI?.openDevTools?.() // 更新检查 const checkUpdate = async () => { try { - const response = await Service.checkUpdateApiUpdateCheckPost({ current_version: version, if_force: true }) + const response = await Service.checkUpdateApiUpdateCheckPost({ + current_version: version, + if_force: true, + }) if (response.code === 200) { if (response.if_need_update) { updateData.value = response.update_info @@ -232,7 +232,9 @@ const refreshMirrorConfig = async () => { } catch (e) { console.error('刷新镜像配置失败', e) message.error('刷新镜像配置失败') - } finally { refreshingConfig.value = false } + } finally { + refreshingConfig.value = false + } } const goToMirrorTest = () => router.push('/mirror-test') @@ -247,7 +249,9 @@ const testNotify = async () => { } catch (e) { console.error('测试通知发送失败', e) message.error('测试通知发送失败') - } finally { testingNotify.value = false } + } finally { + testingNotify.value = false + } } onMounted(() => { @@ -278,7 +282,10 @@ onMounted(() => { @@ -290,23 +297,9 @@ onMounted(() => { :testing-notify="testingNotify" /> - - - - - - - - - - { :go-to-mirror-test="goToMirrorTest" /> - + - +