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:
DEV_DSW
2026-04-16 15:13:30 +08:00
parent 7bd5a1aa20
commit 411f4f3421
15 changed files with 668 additions and 214 deletions

View File

@@ -150,7 +150,7 @@ import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark';
import type { AutomationScript, ScriptSaveInput } from '@lib/script-types';
import { useScriptStore } from '@src/stores/script';
import { channels } from '@constant/channel';
import { channelDictionary } from '@constant/channel';
const { t } = useI18n();
const store = useScriptStore();
@@ -197,16 +197,15 @@ watch(() => props.script, (script) => {
watch(() => form.value.channel, (newUrl) => {
if (!newUrl) return;
channels.forEach((c: any) => {
if (form.value.code.includes(c.channelUrl)) {
form.value.code = form.value.code.split(c.channelUrl).join(newUrl);
Object.values(channelDictionary).forEach((url) => {
if (form.value.code.includes(url)) {
form.value.code = form.value.code.split(url).join(newUrl);
}
});
});
function getChannelUrl(channel: string): string | undefined {
const item = channels.find((c) => c.channelName === channel);
return item?.channelUrl;
return channelDictionary[channel];
}
async function handleStartRecording() {