feat: 账号配置表格头部接入KtTable
This commit is contained in:
parent
01743cfc18
commit
5af4b4d297
@ -32,6 +32,14 @@ const AKtTable = KtTable as any;
|
|||||||
const ASpin = Spin as any;
|
const ASpin = Spin as any;
|
||||||
const ATabs = Tabs 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({
|
export default defineComponent({
|
||||||
name: 'QqBotAccountConfigPanel',
|
name: 'QqBotAccountConfigPanel',
|
||||||
props: {
|
props: {
|
||||||
@ -41,7 +49,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const activeTab = ref('command');
|
const activeTab = ref<ConfigTabKey>('command');
|
||||||
const boundCommands = ref<QqbotApi.Command[]>([]);
|
const boundCommands = ref<QqbotApi.Command[]>([]);
|
||||||
const boundRules = ref<QqbotApi.Rule[]>([]);
|
const boundRules = ref<QqbotApi.Rule[]>([]);
|
||||||
const commandTemplates = ref<QqbotApi.Command[]>([]);
|
const commandTemplates = ref<QqbotApi.Command[]>([]);
|
||||||
@ -167,6 +175,28 @@ export default defineComponent({
|
|||||||
rowVisible: (row) => boundRuleIds.value.has(row.id),
|
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(
|
watch(
|
||||||
currentSelfId,
|
currentSelfId,
|
||||||
@ -319,96 +349,41 @@ export default defineComponent({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCommandTable = () => {
|
const renderTableTitle = () => {
|
||||||
return (
|
return (
|
||||||
<AKtTable
|
<div class="qqbot-account-config-panel__table-title">
|
||||||
class="qqbot-account-config-panel__table"
|
<span>账号功能配置</span>
|
||||||
columns={commandColumns}
|
<Tag color="processing">{`Self ID:${currentSelfId.value || '-'}`}</Tag>
|
||||||
dataSource={mergedCommandTemplates.value}
|
{props.account?.name ? <Tag>{props.account.name}</Tag> : null}
|
||||||
rowActions={commandRowActions}
|
</div>
|
||||||
rowKey="id"
|
|
||||||
showDefaultButtons={false}
|
|
||||||
showFooter={false}
|
|
||||||
showHeader={false}
|
|
||||||
showIndex={false}
|
|
||||||
showPagination={false}
|
|
||||||
showTableSetting={false}
|
|
||||||
size="small"
|
|
||||||
v-slots={{
|
|
||||||
bodyCell: ({ column, record }: any) => {
|
|
||||||
const row = record as QqbotApi.Command;
|
|
||||||
const bound = boundCommandIds.value.has(row.id);
|
|
||||||
if (column.key === 'aliases') {
|
|
||||||
return row.aliases?.join(' / ') || '-';
|
|
||||||
}
|
|
||||||
if (column.key === 'targetType') {
|
|
||||||
return getOptionLabel(qqbotRuleTargetOptions, row.targetType);
|
|
||||||
}
|
|
||||||
if (column.key === 'enabled') {
|
|
||||||
return renderEnabledTag(row.enabled);
|
|
||||||
}
|
|
||||||
if (column.key === 'bound') {
|
|
||||||
return renderBoundTag(bound);
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderEventTable = () => {
|
const renderHeaderControls = () => {
|
||||||
return (
|
return (
|
||||||
<AKtTable
|
<div class="kt-table__header-control-group">
|
||||||
class="qqbot-account-config-panel__table"
|
<ATabs
|
||||||
columns={eventColumns}
|
class="kt-table__header-tabs"
|
||||||
dataSource={eventPlugins.value}
|
items={[...configTabItems]}
|
||||||
rowActions={eventRowActions}
|
v-model:activeKey={activeTab.value}
|
||||||
rowKey={(row: QqbotApi.EventPlugin) =>
|
/>
|
||||||
`${currentSelfId.value}:${row.key}`
|
</div>
|
||||||
}
|
);
|
||||||
showDefaultButtons={false}
|
};
|
||||||
showFooter={false}
|
|
||||||
showHeader={false}
|
const renderBodyCell = ({ column, record }: any) => {
|
||||||
showIndex={false}
|
if (activeTab.value === 'event') {
|
||||||
showPagination={false}
|
|
||||||
showTableSetting={false}
|
|
||||||
size="small"
|
|
||||||
v-slots={{
|
|
||||||
bodyCell: ({ column, record }: any) => {
|
|
||||||
const row = record as QqbotApi.EventPlugin;
|
const row = record as QqbotApi.EventPlugin;
|
||||||
if (column.key === 'triggerType') {
|
if (column.key === 'triggerType') {
|
||||||
return row.triggerType === 'message'
|
return row.triggerType === 'message' ? '消息事件' : row.triggerType;
|
||||||
? '消息事件'
|
|
||||||
: row.triggerType;
|
|
||||||
}
|
}
|
||||||
if (column.key === 'bound') {
|
if (column.key === 'bound') {
|
||||||
return renderBoundTag(row.bound);
|
return renderBoundTag(row.bound);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
}
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderRuleTable = () => {
|
if (activeTab.value === 'rule') {
|
||||||
return (
|
|
||||||
<AKtTable
|
|
||||||
class="qqbot-account-config-panel__table"
|
|
||||||
columns={ruleColumns}
|
|
||||||
dataSource={mergedRuleTemplates.value}
|
|
||||||
rowActions={ruleRowActions}
|
|
||||||
rowKey="id"
|
|
||||||
showDefaultButtons={false}
|
|
||||||
showFooter={false}
|
|
||||||
showHeader={false}
|
|
||||||
showIndex={false}
|
|
||||||
showPagination={false}
|
|
||||||
showTableSetting={false}
|
|
||||||
size="small"
|
|
||||||
v-slots={{
|
|
||||||
bodyCell: ({ column, record }: any) => {
|
|
||||||
const row = record as QqbotApi.Rule;
|
const row = record as QqbotApi.Rule;
|
||||||
const bound = boundRuleIds.value.has(row.id);
|
const bound = boundRuleIds.value.has(row.id);
|
||||||
if (column.key === 'matchType') {
|
if (column.key === 'matchType') {
|
||||||
@ -431,38 +406,50 @@ export default defineComponent({
|
|||||||
return renderBoundTag(bound);
|
return renderBoundTag(bound);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
}
|
||||||
}}
|
|
||||||
/>
|
const row = record as QqbotApi.Command;
|
||||||
);
|
const bound = boundCommandIds.value.has(row.id);
|
||||||
|
if (column.key === 'aliases') {
|
||||||
|
return row.aliases?.join(' / ') || '-';
|
||||||
|
}
|
||||||
|
if (column.key === 'targetType') {
|
||||||
|
return getOptionLabel(qqbotRuleTargetOptions, row.targetType);
|
||||||
|
}
|
||||||
|
if (column.key === 'enabled') {
|
||||||
|
return renderEnabledTag(row.enabled);
|
||||||
|
}
|
||||||
|
if (column.key === 'bound') {
|
||||||
|
return renderBoundTag(bound);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<div class="qqbot-account-config-panel">
|
<div class="qqbot-account-config-panel">
|
||||||
<div class="qqbot-account-config-panel__account">
|
<div class="qqbot-account-config-panel__spin">
|
||||||
<Tag color="processing">Self ID:{currentSelfId.value || '-'}</Tag>
|
<ASpin spinning={loading.value}>
|
||||||
{props.account?.name ? <Tag>{props.account.name}</Tag> : null}
|
<AKtTable
|
||||||
</div>
|
class="qqbot-account-config-panel__table"
|
||||||
<ATabs
|
columns={activeColumns.value}
|
||||||
class="qqbot-account-config-panel__tabs"
|
dataSource={activeRows.value}
|
||||||
items={[
|
rowActions={activeRowActions.value}
|
||||||
{ key: 'command', label: '在线命令' },
|
rowKey={activeRowKey.value}
|
||||||
{ key: 'event', label: '事件触发' },
|
showDefaultButtons={false}
|
||||||
{ key: 'rule', label: '自动回复规则' },
|
showFooter={false}
|
||||||
]}
|
showIndex={false}
|
||||||
v-model:activeKey={activeTab.value}
|
showPagination={false}
|
||||||
|
showTableSetting={false}
|
||||||
|
size="small"
|
||||||
|
v-slots={{
|
||||||
|
bodyCell: renderBodyCell,
|
||||||
|
headerControls: renderHeaderControls,
|
||||||
|
title: renderTableTitle,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<ASpin
|
|
||||||
class="qqbot-account-config-panel__spin"
|
|
||||||
spinning={loading.value}
|
|
||||||
>
|
|
||||||
<div class="qqbot-account-config-panel__content">
|
|
||||||
{activeTab.value === 'command' ? renderCommandTable() : null}
|
|
||||||
{activeTab.value === 'event' ? renderEventTable() : null}
|
|
||||||
{activeTab.value === 'rule' ? renderRuleTable() : null}
|
|
||||||
</div>
|
|
||||||
</ASpin>
|
</ASpin>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -33,24 +33,14 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card {
|
&__content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__card,
|
&__content,
|
||||||
&__card > .ant-card-body {
|
&__content > .ant-spin-nested-loading,
|
||||||
display: flex;
|
&__content > .ant-spin-nested-loading > .ant-spin-container {
|
||||||
flex-direction: column;
|
|
||||||
min-height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__card > .ant-card-body {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__card .ant-spin-nested-loading,
|
|
||||||
&__card .ant-spin-container {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -65,19 +55,9 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
|
||||||
&__account {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__tabs {
|
|
||||||
flex: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__spin,
|
&__spin,
|
||||||
&__spin > .ant-spin-container {
|
&__spin > .ant-spin-nested-loading,
|
||||||
|
&__spin > .ant-spin-nested-loading > .ant-spin-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -85,19 +65,19 @@
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__content {
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
min-height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__table {
|
&__table {
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
|
||||||
|
.kt-table__header {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.kt-table__main-content {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__ellipsis {
|
&__ellipsis {
|
||||||
@ -108,4 +88,12 @@
|
|||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__table-title {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useRoute, useRouter } from 'vue-router';
|
|||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { ArrowLeft } from '@vben/icons';
|
import { ArrowLeft } from '@vben/icons';
|
||||||
|
|
||||||
import { Alert, Button, Card, Spin, Tag } from 'antdv-next';
|
import { Alert, Button, Spin, Tag } from 'antdv-next';
|
||||||
|
|
||||||
import { getQqbotAccountList } from '#/api/qqbot';
|
import { getQqbotAccountList } from '#/api/qqbot';
|
||||||
|
|
||||||
@ -15,7 +15,6 @@ import AccountConfigPanel from './components/AccountConfigPanel';
|
|||||||
import './config.scss';
|
import './config.scss';
|
||||||
|
|
||||||
const AButton = Button as any;
|
const AButton = Button as any;
|
||||||
const ACard = Card as any;
|
|
||||||
const ASpin = Spin as any;
|
const ASpin = Spin as any;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@ -112,7 +111,7 @@ export default defineComponent({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ACard class="qqbot-account-config__card" variant="borderless">
|
<div class="qqbot-account-config__content">
|
||||||
<ASpin spinning={loading.value}>
|
<ASpin spinning={loading.value}>
|
||||||
{errorMessage.value ? (
|
{errorMessage.value ? (
|
||||||
<Alert message={errorMessage.value} showIcon type="warning" />
|
<Alert message={errorMessage.value} showIcon type="warning" />
|
||||||
@ -120,7 +119,7 @@ export default defineComponent({
|
|||||||
<AccountConfigPanel account={account.value} />
|
<AccountConfigPanel account={account.value} />
|
||||||
)}
|
)}
|
||||||
</ASpin>
|
</ASpin>
|
||||||
</ACard>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user