diff --git a/apps/web-antdv-next/src/views/qqbot/account/components/AccountConfigPanel.tsx b/apps/web-antdv-next/src/views/qqbot/account/components/AccountConfigPanel.tsx index 6689074..ceb0769 100644 --- a/apps/web-antdv-next/src/views/qqbot/account/components/AccountConfigPanel.tsx +++ b/apps/web-antdv-next/src/views/qqbot/account/components/AccountConfigPanel.tsx @@ -32,6 +32,14 @@ const AKtTable = KtTable as any; const ASpin = Spin as any; const ATabs = Tabs as any; +const configTabItems = [ + { key: 'command', label: '在线命令' }, + { key: 'event', label: '事件触发' }, + { key: 'rule', label: '自动回复规则' }, +] as const; + +type ConfigTabKey = (typeof configTabItems)[number]['key']; + export default defineComponent({ name: 'QqBotAccountConfigPanel', props: { @@ -41,7 +49,7 @@ export default defineComponent({ }, }, setup(props) { - const activeTab = ref('command'); + const activeTab = ref('command'); const boundCommands = ref([]); const boundRules = ref([]); const commandTemplates = ref([]); @@ -167,6 +175,28 @@ export default defineComponent({ rowVisible: (row) => boundRuleIds.value.has(row.id), }, ]; + const activeColumns = computed(() => { + if (activeTab.value === 'event') return eventColumns; + if (activeTab.value === 'rule') return ruleColumns; + return commandColumns; + }); + const activeRows = computed(() => { + if (activeTab.value === 'event') return eventPlugins.value; + if (activeTab.value === 'rule') return mergedRuleTemplates.value; + return mergedCommandTemplates.value; + }); + const activeRowActions = computed(() => { + if (activeTab.value === 'event') return eventRowActions; + if (activeTab.value === 'rule') return ruleRowActions; + return commandRowActions; + }); + const activeRowKey = computed(() => { + if (activeTab.value === 'event') { + return (row: QqbotApi.EventPlugin) => + `${currentSelfId.value}:${row.key}`; + } + return 'id'; + }); watch( currentSelfId, @@ -319,149 +349,106 @@ export default defineComponent({ ); }; - const renderCommandTable = () => { + const renderTableTitle = () => { return ( -