feat: Refactor channel management and UI components
- Removed hardcoded channel data from `channel.ts` and replaced it with a dynamic channel dictionary. - Introduced a new Pinia store `channel.ts` to manage selected and available channels. - Reworked `AddChannelDialog.vue` to allow users to search and select channels dynamically. - Updated `TaskCenter.vue` to utilize the new channel store and handle empty channel selections gracefully. - Enhanced IPC communication for loading and saving selected channels in the configuration. - Adjusted `runTaskOperationService.ts` to ensure proper handling of channel data. - Improved styling and structure of UI components for better user experience.
This commit is contained in:
@@ -205,14 +205,20 @@ export function runTaskOperationService() {
|
||||
|
||||
openedTabIndexByChannelName.clear()
|
||||
|
||||
if (Array.isArray(channels)) {
|
||||
for (let i = 0; i < channels.length; i++) {
|
||||
const name = channels[i]?.channelName
|
||||
if (name) openedTabIndexByChannelName.set(String(name), i)
|
||||
}
|
||||
const validChannels = Array.isArray(channels)
|
||||
? channels.filter((c) => c && typeof c === 'object' && c.channelUrl)
|
||||
: []
|
||||
|
||||
if (validChannels.length === 0) {
|
||||
return { success: false, error: '没有可用的渠道配置' }
|
||||
}
|
||||
|
||||
const result = await executeScriptServiceInstance.executeScript(scriptPath, { channels })
|
||||
for (let i = 0; i < validChannels.length; i++) {
|
||||
const name = validChannels[i]?.channelName
|
||||
if (name) openedTabIndexByChannelName.set(String(name), i)
|
||||
}
|
||||
|
||||
const result = await executeScriptServiceInstance.executeScript(scriptPath, { channels: validChannels })
|
||||
return { success: true, result }
|
||||
} catch (error) {
|
||||
return { success: false, error: (error as any)?.message || 'open channel failed' }
|
||||
|
||||
Reference in New Issue
Block a user