mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 17:47:06 +08:00
move mcp management to plugin managemanet page * feat: 新增命令配置数据库模型 * feat: 实现核心命令管理系统 * feat: 将命令管理集成到 Star 框架 * feat: 新增命令管理后台 API * feat: 新增命令管理界面页面 * feat: 新增命令管理国际化支持 * test: 新增命令管理相关测试 * refactor(command): 移除指令重命名时的别名功能 * fix(command): 修正指令冲突检测逻辑 * fix(command): 排除已禁用指令的冲突检测 - 只有 `effective_command` 存在且 `enabled` 为 `True` 的指令才会被纳入冲突检测范围。 * feat(command): 优化指令冲突显示与提示 - 【功能】新增指令冲突警告提示,当检测到冲突时显示详细信息及解决方案。 - 【优化】调整指令列表排序逻辑,将冲突指令优先显示并分组。 - 【样式】为冲突指令行添加专属高亮样式,提升视觉识别度。 - 【国际化】更新英文和中文多语言文件,增加指令冲突警告相关的翻译文本。 * chore(command-page): 禁用命令表格部分列的排序功能 * style(command-page): 调整命令页面表格样式和图标大小 * refactor(command): 优化指令页面布局并更新冲突警告 - 【布局优化】重新组织指令管理页面布局,将筛选器移至顶部独立行 - 【信息展示】将搜索栏与总指令数、已禁用指令数合并显示,提升页面空间利用率 - 【视觉更新】更新指令冲突警告样式 * style: UI 细节 * refactor(command): 调整指令管理中的成员权限显示与筛选 - 更新指令筛选逻辑,当选择“所有人”权限筛选时,将同时包含 `everyone` 和 `member` 权限的指令。 * feat(command-management): 新增指令层级管理与UI展示 - 【后端】 - `CommandDescriptor` 新增 `parent_group_handler` 和 `sub_commands` 字段,支持指令层级结构定义。 - `list_commands` 函数重构,实现指令的层级收集与构建,将子指令正确挂载到其父指令组下。 - 新增 `_collect_all_descriptors` 和 `_find_parent_group_handler` 辅助函数,用于全面收集指令并定位父指令组。 - `_build_descriptor` 优化指令类型判断逻辑,明确区分普通指令、指令组和子指令。 - `_descriptor_to_dict` 递归处理子指令,确保 API 返回完整的指令层级数据。 - 【前端】 - 指令管理页面 (`CommandPage.vue`) 增加指令类型筛选器,并支持指令组的展开/折叠功能。 - 表格展示优化,为指令组和子指令添加不同的样式和缩进,提升层级结构的视觉可读性。 - 指令详情对话框新增指令类型、所属指令组和子指令列表的展示。 - 更新 `CommandItem` 接口,以适配后端提供的层级数据结构。 - 【i18n】 - 新增指令类型(指令、指令组、子指令)的国际化文本。 - 更新指令管理相关 UI 文本,包括表格头部、详情对话框字段和筛选器选项。 * style(command): 优化指令组子指令数量显示UI * refactor(command): 修改指令列表排序逻辑 * style(command-page): 优化命令列表UI * feat(command): 添加系统插件指令过滤与冲突处理 * refactor(command): 更新指令数展示逻辑 * style(command): 更新空状态描述 * feat(extension): 添加插件指令冲突检测与提示 - 在插件安装或启用后,自动检测并提示指令冲突。 - 当检测到指令冲突时,显示警告对话框,告知用户冲突数量及可能的影响。 * refactor(command): 移除指令表格内部加载指示器 * style(extension): 文案修改 * refactor(command): 模块化指令管理面板前端代码 * refactor(commandPanel): 重命名指令模块目录为 commandPanel * style(commandPanel): 微调指令面板UI * fix(command): 确保新命令配置的事务提交 * fix(sidebar): 补全新增侧边栏项后的侧边栏位追加逻辑 * refactor(commands): 重构/help指令以动态显示实际命令并补充部分命令描述 * style(builtin_commands): 补充命令描述 * refactor(commandPanel): 移除未使用的 filterState 常量 * perf(dashboard): 删除多余的CommandPage.vue文件(已被模块化引用) * perf(command): 优化命令冲突计数逻辑 * perf(command): 优化指令管理辅助函数和配置绑定逻辑 * perf(db): 优化重构command相关数据库操作 * refactor(sidebar): 提取侧边栏项目解析逻辑到工具函数复用 * refactor: move mcp and command page to extension page * refactor: remove unused imports in component panel * fix: update terminology for handler management in extension localization --------- Co-authored-by: Soulter <905617992@qq.com>
269 lines
7.5 KiB
Vue
269 lines
7.5 KiB
Vue
<template>
|
|
<div style="margin-top: 16px;">
|
|
<v-btn
|
|
color="primary"
|
|
variant="outlined"
|
|
size="small"
|
|
@click="openDialog"
|
|
style="margin-bottom: 8px;"
|
|
>
|
|
{{ t('features.settings.sidebar.customize.title') }}
|
|
</v-btn>
|
|
|
|
<v-dialog v-model="dialog" max-width="700px">
|
|
<v-card>
|
|
<v-card-title class="d-flex justify-space-between align-center">
|
|
<span>{{ t('features.settings.sidebar.customize.title') }}</span>
|
|
<v-btn
|
|
icon="mdi-close"
|
|
variant="text"
|
|
@click="dialog = false"
|
|
></v-btn>
|
|
</v-card-title>
|
|
|
|
<v-card-text>
|
|
<p class="text-body-2 mb-4">{{ t('features.settings.sidebar.customize.subtitle') }}</p>
|
|
|
|
<v-row>
|
|
<v-col cols="12" md="6">
|
|
<div class="mb-2 font-weight-medium">{{ t('features.settings.sidebar.customize.mainItems') }}</div>
|
|
<v-list
|
|
density="compact"
|
|
class="custom-list"
|
|
@dragover.prevent
|
|
@drop="handleDropToList($event, 'main')"
|
|
>
|
|
<v-list-item
|
|
v-for="(item, index) in mainItems"
|
|
:key="item.title"
|
|
class="mb-1 draggable-item"
|
|
draggable="true"
|
|
@dragstart="handleDragStart($event, 'main', index)"
|
|
@dragover.prevent
|
|
@drop.stop="handleDrop($event, 'main', index)"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-icon :icon="item.icon" size="small" class="mr-2"></v-icon>
|
|
</template>
|
|
<v-list-item-title>{{ t(item.title) }}</v-list-item-title>
|
|
<template v-slot:append>
|
|
<v-btn
|
|
icon="mdi-arrow-right"
|
|
variant="text"
|
|
size="x-small"
|
|
@click="moveToMore(index)"
|
|
></v-btn>
|
|
</template>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-col>
|
|
|
|
<v-col cols="12" md="6">
|
|
<div class="mb-2 font-weight-medium">{{ t('features.settings.sidebar.customize.moreItems') }}</div>
|
|
<v-list
|
|
density="compact"
|
|
class="custom-list"
|
|
@dragover.prevent
|
|
@drop="handleDropToList($event, 'more')"
|
|
>
|
|
<v-list-item
|
|
v-for="(item, index) in moreItems"
|
|
:key="item.title"
|
|
class="mb-1 draggable-item"
|
|
draggable="true"
|
|
@dragstart="handleDragStart($event, 'more', index)"
|
|
@dragover.prevent
|
|
@drop.stop="handleDrop($event, 'more', index)"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-icon :icon="item.icon" size="small" class="mr-2"></v-icon>
|
|
</template>
|
|
<v-list-item-title>{{ t(item.title) }}</v-list-item-title>
|
|
<template v-slot:append>
|
|
<v-btn
|
|
icon="mdi-arrow-left"
|
|
variant="text"
|
|
size="x-small"
|
|
@click="moveToMain(index)"
|
|
></v-btn>
|
|
</template>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-col>
|
|
</v-row>
|
|
</v-card-text>
|
|
|
|
<v-card-actions>
|
|
<v-btn
|
|
color="error"
|
|
variant="text"
|
|
@click="resetToDefault"
|
|
>
|
|
{{ t('features.settings.sidebar.customize.reset') }}
|
|
</v-btn>
|
|
<v-spacer></v-spacer>
|
|
<v-btn
|
|
color="primary"
|
|
@click="saveCustomization"
|
|
>
|
|
{{ t('core.actions.save') }}
|
|
</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted } from 'vue';
|
|
import { useI18n } from '@/i18n/composables';
|
|
import sidebarItems from '@/layouts/full/vertical-sidebar/sidebarItem';
|
|
import {
|
|
getSidebarCustomization,
|
|
setSidebarCustomization,
|
|
clearSidebarCustomization,
|
|
resolveSidebarItems
|
|
} from '@/utils/sidebarCustomization';
|
|
|
|
const { t } = useI18n();
|
|
|
|
const dialog = ref(false);
|
|
const mainItems = ref([]);
|
|
const moreItems = ref([]);
|
|
const draggedItem = ref(null);
|
|
|
|
function initializeItems() {
|
|
const customization = getSidebarCustomization();
|
|
const { mainItems: resolvedMain, moreItems: resolvedMore } = resolveSidebarItems(
|
|
sidebarItems,
|
|
customization
|
|
);
|
|
mainItems.value = resolvedMain;
|
|
moreItems.value = resolvedMore;
|
|
}
|
|
|
|
function openDialog() {
|
|
initializeItems();
|
|
dialog.value = true;
|
|
}
|
|
|
|
function handleDragStart(event, listType, index) {
|
|
draggedItem.value = {
|
|
type: listType,
|
|
index: index,
|
|
item: listType === 'main' ? mainItems.value[index] : moreItems.value[index]
|
|
};
|
|
event.dataTransfer.effectAllowed = 'move';
|
|
}
|
|
|
|
function handleDrop(event, targetListType, targetIndex) {
|
|
event.preventDefault();
|
|
|
|
if (!draggedItem.value) return;
|
|
|
|
const sourceListType = draggedItem.value.type;
|
|
const sourceIndex = draggedItem.value.index;
|
|
const item = draggedItem.value.item;
|
|
|
|
// Remove from source
|
|
if (sourceListType === 'main') {
|
|
mainItems.value.splice(sourceIndex, 1);
|
|
} else {
|
|
moreItems.value.splice(sourceIndex, 1);
|
|
}
|
|
|
|
// Add to target
|
|
if (targetListType === 'main') {
|
|
mainItems.value.splice(targetIndex, 0, item);
|
|
} else {
|
|
moreItems.value.splice(targetIndex, 0, item);
|
|
}
|
|
|
|
draggedItem.value = null;
|
|
}
|
|
|
|
function handleDropToList(event, targetListType) {
|
|
event.preventDefault();
|
|
|
|
if (!draggedItem.value) return;
|
|
|
|
const sourceListType = draggedItem.value.type;
|
|
const sourceIndex = draggedItem.value.index;
|
|
const item = draggedItem.value.item;
|
|
|
|
// Remove from source
|
|
if (sourceListType === 'main') {
|
|
mainItems.value.splice(sourceIndex, 1);
|
|
} else {
|
|
moreItems.value.splice(sourceIndex, 1);
|
|
}
|
|
|
|
// Add to target list at the end
|
|
if (targetListType === 'main') {
|
|
mainItems.value.push(item);
|
|
} else {
|
|
moreItems.value.push(item);
|
|
}
|
|
|
|
draggedItem.value = null;
|
|
}
|
|
|
|
function moveToMore(index) {
|
|
const item = mainItems.value.splice(index, 1)[0];
|
|
moreItems.value.push(item);
|
|
}
|
|
|
|
function moveToMain(index) {
|
|
const item = moreItems.value.splice(index, 1)[0];
|
|
mainItems.value.push(item);
|
|
}
|
|
|
|
function saveCustomization() {
|
|
const config = {
|
|
mainItems: mainItems.value.map(item => item.title),
|
|
moreItems: moreItems.value.map(item => item.title)
|
|
};
|
|
|
|
setSidebarCustomization(config);
|
|
|
|
// Notify the sidebar to reload
|
|
window.dispatchEvent(new CustomEvent('sidebar-customization-changed'));
|
|
|
|
dialog.value = false;
|
|
}
|
|
|
|
function resetToDefault() {
|
|
clearSidebarCustomization();
|
|
initializeItems();
|
|
|
|
// Notify the sidebar to reload
|
|
window.dispatchEvent(new CustomEvent('sidebar-customization-changed'));
|
|
}
|
|
|
|
onMounted(() => {
|
|
initializeItems();
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.draggable-item {
|
|
cursor: move;
|
|
border: 1px solid rgba(var(--v-border-color), var(--v-border-opacity));
|
|
border-radius: 4px;
|
|
background-color: rgba(var(--v-theme-surface));
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.draggable-item:hover {
|
|
background-color: rgba(var(--v-theme-primary), 0.1);
|
|
border-color: rgba(var(--v-theme-primary), 0.3);
|
|
}
|
|
|
|
.custom-list {
|
|
min-height: 200px;
|
|
border: 1px dashed rgba(var(--v-border-color), var(--v-border-opacity));
|
|
border-radius: 4px;
|
|
padding: 8px;
|
|
}
|
|
</style>
|