Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

refactor(frontend): remove unused components and share tag selection logic

wizardchenbfa7f0ed6967
diff --git a/docs/code-slimming-audit.md b/docs/code-slimming-audit.md
new file mode 100644
index 000000000..bbb4a5185
--- /dev/null
+++ b/docs/code-slimming-audit.md
@@ -0,0 +1,113 @@
+# 代码瘦身审计与第一批改动
+
+审计日期:2026-09-16。基线:`d5efe5ced`。目标:保留现有功能,减少重复维护和理解成本。
+
+## 扫描范围与口径
+
+- 统计 Git 跟踪的源码物理行数,包含注释、空行;分开统计测试、生成文件、翻译与 i18n 辅助代码。行数用于定位,不作为质量评分。
+- 对 `frontend/src` 的 TypeScript 和 Vue script 建立静态 import、re-export、字面量动态 import 依赖图,从 `main.ts`、`embed-main.ts` 两个实际入口遍历;额外检查模板名称、路由、全局组件注册、glob 和构建入口。
+- 对 `internal` 下 Go 文件进行 AST 扫描,统计函数长度,寻找包内没有其他标识符引用的非导出自由函数;计入测试文件引用。另对重复代码块、相同函数体进行候选扫描并抽查调用方。
+- 检查最近 200 个非 merge commit 的文件变更频率,结合重复程度和状态复杂度排序。
+- `cli`、`client`、`docreader`、`mcp-server`、`packages`、`miniprogram` 做体量与结构初筛;本轮没有完成这些子项目的逐函数调用审计。
+- 依赖图不是运行时覆盖证明;后端候选未经过所有平台、构建标签和集成测试验证,不等同于可直接删除的清单。
+
+基线体量:
+
+| 范围 | 生产源码行数 | 测试行数 |
+| --- | ---: | ---: |
+| `frontend/src` | 189,597 | 13,930 |
+| `internal` | 319,317 | 181,900 |
+
+前端另有 39,411 行翻译/i18n 辅助代码、693 行生成代码。整个仓库的测试和生成代码不应被当作优先削减对象。
+
+## 第一批已实施
+
+### 删除 10 个不可达组件
+
+两个应用入口均无法到达以下组件;仓库内没有引用其文件路径的测试、脚本或注册入口。Vite 未配置组件自动注册,发现的资源 glob 用于 provider SVG,不会加载这些 Vue 文件。
+
+| 文件(相对 `frontend/src`) | 行数 | 核查结果 |
+| --- | ---: | --- |
+| `views/settings/StorageEngineSettings.vue` | 1,687 | `Settings.vue` 实际导入 `StorageBackendSettings.vue`;同步修正了旧组件别名 |
+| `views/organization/OrganizationEditorModal.vue` | 914 | 组织列表实际使用 `OrganizationSettingsModal.vue` |
+| `views/settings/components/McpTestResultBody.vue` | 434 | 没有 import、注册或动态加载入口 |
+| `components/SourceSwitcherDropdown.vue` | 163 | 没有 import、注册或动态加载入口 |
+| `components/settings/SettingCard.vue` | 152 | 仅剩过时注释提及,注释一并清理 |
+| `views/organization/JoinOrganization.vue` | 127 | `/join` 已重定向到组织列表,通过 `invite_code` 处理加入 |
+| `components/SessionGroupByDropdown.vue` | 123 | 没有 import、注册或动态加载入口 |
+| `views/knowledge/settings/KBIndexingStrategy.vue` | 109 | 没有 import、注册或动态加载入口 |
+| `views/chat/components/sendMsg.vue` | 22 | 与仍在使用的 `sendMsg` 函数同名,但组件本身没有入口 |
+| `views/platform/RoutePlaceholder.vue` | 7 | 没有路由或组件引用 |
+
+共删除 3,738 行失效组件。它们原本不在应用入口依赖链中,因此这是源码维护收益,不能换算为构建产物缩小比例。
+
+### 合并标签选择与创建逻辑
+
+`TagEditDialog.vue`、`BatchTagDialog.vue` 共享新的 `composables/useKnowledgeTagSelection.ts`:
+
+- 选择集合、名称映射、搜索过滤、切换与清空。
+- 打开时恢复父组件选中值,重新打开时清空草稿。
+- 创建标签的加载状态、结果处理、错误回调;手动输入沿用精确同名复用规则。
+- 接口调用和通知通过参数提供,两个组件保留各自提交、关闭和 loading 行为。
+
+两个弹窗的 template 和 style 与基线逐字节一致。新增 7 项行为测试,覆盖父数据更新、缺失标签 ID、搜索、创建响应、失败重试和实例隔离。
+
+第一批生产源码净减少 **3,819 行**,已计入新增共享逻辑,未把新增测试和本文档计入生产源码。
+
+## 后续优先级
+
+| 优先级 | 证据 | 建议边界 | 验证重点 |
+| --- | --- | --- | --- |
+| P1 | `SandboxSkillsPanel.vue:1240` 与 `SkillSettings.vue:891` 重复安装模型读取、持久化、错误处理;面板最近 200 个非 merge commit 中变更 10 次 | 提取安装模型配置 composable;先统一这一块,再让面板复用已有 `useConfigSkillInstallProgress` | 默认模型回退、保存失败、同 skill 重试、卸载进度、配置切换与取消订阅 |
+| P1 | `useChatCitationPopover.ts` 与 `useEmbedCitationPopover.ts` 重复浮层状态、定位、计时和事件绑定 | 共享交互状态;通过参数提供内容加载、缓存作用域和点击行为 | 普通/嵌入鉴权、缓存隔离、根节点替换、悬停竞争与卸载 |
+| P2 | `AgentEditorModal.vue` 6,756 行,其中 script 3,023 行;近期变更 9 次 | 按提示词编辑、知识库选择、工具配置分离状态和表单序列化责任 | 编辑回填、模式切换、保存 payload 保持兼容 |
+| P2 | `WikiBrowser.vue` 6,592 行,其中 script 4,086 行;`FAQEntryManager.vue` 5,650 行,其中 style 2,780 行 | 分开文档导航/编辑状态、批量动作与可复用展示区域 | 页面切换后的异步结果、选中项、保存与批量操作 |
+| P2 | `knowledge_process.go` 4,091 行;`processChunks` 470 行、`ProcessDocument` 441 行 | 先划分分块入库、摘要、问题生成、重解析阶段的输入与输出,再抽函数 | 任务归属、取消、失败回写、重试与索引状态 |
+| P2 | `wiki_ingest_batch.go` 的 `ProcessWikiIngest` 718 行、`mapOneDocument` 446 行、`reduceSlugUpdates` 422 行 | 分离任务协调、单文档处理、页面归并;保留现有检查点 | 删除 KB、重复投递、部分失败、并发归并 |
+| P2 | `internal/im/service.go` 3,493 行,`handleMessageStream` 450 行 | 按通道生命周期、请求准备、流式回复拆责任 | completion/error 顺序、取消、最终持久化与平台发送失败 |
+
+这些条目的行号、长度和变更频率是本次基线快照。仅按长度分文件不会自动降低复杂度,验收应检查状态归属和业务规则是否集中。
+
+### 后端重复的具体判断
+
+- Qdrant 与 Weaviate 的 `tokenizeQuery` 函数体相同,但只有 Qdrant 的关键字检索调用它;Weaviate 使用 `WithQuery(params.Query)`。后续应验证并删除 Weaviate 的失效函数,而非为了它增加共享分词层。
+- IMA、语雀的 `sanitizeFileName` 函数体相同,可以共享;RSS 的近似实现另外处理首尾空白和换行,合并时必须保留这些差异。
+- Milvus/Qdrant/Weaviate 的结果映射体相似,但接收不同后端类型。当前各约 17 行,为此引入通用接口或泛型转换层未必减少维护成本。
+- 终端和桌面 WebSocket ticket handler 重复检查会话、用户、租户和 token,但签发方式不同。后续可共享前置身份校验,保留 ticket 和连接生命周期各自的契约。
+- 资源权限已经有 `internal/application/access`;继续沿已有授权边界收敛,避免新建与其并行的权限工具层。
+
+### 未引用 Go 私有自由函数候选
+
+扫描发现 16 个,第一批暂未改动后端。后续逐包确认调用、构建入口和测试后处理:
+
+| 文件(相对 `internal`) | 函数 |
+| --- | --- |
+| `application/repository/retriever/weaviate/repository.go` | `tokenizeQuery` |
+| `im/wechat/crypto.go` | `encryptAES128ECB` |
+| `application/repository/retriever/milvus/filter.go` | `formatValue` |
+| `agent/tools/todo_write.go` | `getStringArrayField`、`getStringField` |
+| `agent/prompts.go` | `formatFileSize` |
+| `utils/inject.go` | `extractTableAliasMap` |
+| `application/service/wiki_ingest_dedup.go` | `countEntityConceptPages` |
+| `agent/tools/sandbox_ls.go` | `relativeSkillFileFromImagePath` |
+| `infrastructure/docparser/json_converter.go` | `indentJSON` |
+| `handler/knowledge.go` | `mimeTypeByExt` |
+| `application/service/tenant_skill_source.go` | `normalizeFetchedSkillArchive` |
+| `sandbox/gateway_transport.go` | `newGatewayDataTransport` |
+| `application/service/knowledge_process.go` | `buildSplitterConfig` |
+| `im/service.go` | `imLocalStorageBaseDir` |
+| `handler/session/helpers.go` | `getRequestID` |
+
+## 测试维护与验证结果
+
+抽查发现,标签弹窗、安装进度的部分测试通过正则检查源码文本;IM 部分流式测试使用镜像状态结构,同时也存在直接调用生产路径的退出/投递测试。重构时应逐步补真实行为覆盖,不应只调整正则或同时修改两份镜像逻辑来获得通过。
+
+第一批验证:
+
+- 修改前 `npm run type-check` 通过,作为类型检查基线。
+- 11 项定向测试通过,其中 7 项是新增行为测试。
+- `scripts/verify_frontend_pr.sh` 完整通过:907 项测试、`vue-tsc --build`、Vite 生产构建。
+- 构建仍报告大 chunk 提示;本轮未以 bundle 体积为目标,也没有测量构建前后的体积差异。
+- 未修改后端,未运行后端测试;未做浏览器视觉验收。
+
+下一批优先处理 Skill 安装模型配置与进度重复。涉及聊天、任务重试、权限或共享状态的改动应单独成批,以可验证的行为等价为边界。
diff --git a/frontend/src/components/SessionGroupByDropdown.vue b/frontend/src/components/SessionGroupByDropdown.vue
deleted file mode 100644
index 79ccbe05d..000000000
--- a/frontend/src/components/SessionGroupByDropdown.vue
+++ /dev/null
@@ -1,123 +0,0 @@
-<template>
- <t-popup
- v-model:visible="visible"
- trigger="click"
- placement="bottom-left"
- :overlay-style="{ padding: 0 }"
- :overlay-inner-style="{ padding: 0 }"
- >
- <template #content>
- <div class="session-group-card">
- <div class="session-group-header">{{ headerLabel }}</div>
- <div class="session-group-list">
- <button
- v-for="item in modes"
- :key="item.value"
- type="button"
- class="session-group-row"
- :class="{ active: item.value === current }"
- @click="handleSelect(item.value)"
- >
- <span class="session-group-row-name">{{ item.label }}</span>
- <t-icon
- v-if="item.value === current"
- name="check"
- class="session-group-row-check"
- size="14px"
- />
- </button>
- </div>
- </div>
- </template>
- <slot />
- </t-popup>
-</template>
-
-<script setup lang="ts">
-import { ref } from 'vue'
-import type { SessionGroupMode } from './sessionGrouping'
-
-interface GroupModeItem {
- value: SessionGroupMode
- label: string
-}
-
-defineProps<{
- modes: GroupModeItem[]
- current: SessionGroupMode
- headerLabel: string
-}>()
-
-const emit = defineEmits<{
- (e: 'select', value: SessionGroupMode): void
-}>()
-
-const visible = ref(false)
-
-const handleSelect = (value: SessionGroupMode): void => {
- visible.value = false
- emit('select', value)
-}
-</script>
-
-<style scoped lang="less">
-.session-group-card {
- min-width: 180px;
- max-width: 240px;
- display: flex;
- flex-direction: column;
- padding: 0;
- overflow: hidden;
-}
-
-.session-group-header {
- padding: 8px 12px 6px;
- font-size: 11px;
- font-weight: 600;
- color: var(--td-text-color-placeholder);
- border-bottom: 1px solid var(--td-component-border);
- user-select: none;
-}
-
-.session-group-list {
- padding: 6px;
- display: flex;
- flex-direction: column;
- gap: 1px;
-}
-
-.session-group-row {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 6px 10px;
- border: none;
- border-radius: 6px;
- background: transparent;
- color: var(--td-text-color-primary);
- font-size: 13px;
- line-height: 1.4;
- cursor: pointer;
- transition: background 0.15s ease, color 0.15s ease;
- text-align: left;
- width: 100%;
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- }
-
- &.active {
- color: var(--td-brand-color);
- font-weight: 500;
- }
-}
-
-.session-group-row-name {
- flex: 1 1 auto;
-}
-
-.session-group-row-check {
- flex: 0 0 auto;
- color: var(--td-brand-color);
-}
-</style>
diff --git a/frontend/src/components/SourceSwitcherDropdown.vue b/frontend/src/components/SourceSwitcherDropdown.vue
deleted file mode 100644
index adda03932..000000000
--- a/frontend/src/components/SourceSwitcherDropdown.vue
+++ /dev/null
@@ -1,163 +0,0 @@
-<template>
- <t-popup
- v-model:visible="visible"
- trigger="click"
- placement="bottom-left"
- :overlay-style="{ padding: 0 }"
- :overlay-inner-style="{ padding: 0 }"
- >
- <template #content>
- <div class="source-switcher-card">
- <div class="source-switcher-list">
- <button
- v-for="item in sortedList"
- :key="item.value"
- type="button"
- class="source-switcher-row"
- :class="{ active: item.value === current }"
- @click="handleSelect(item.value)"
- >
- <img
- v-if="item.logo"
- :src="item.logo"
- :alt="item.label"
- class="source-switcher-row-logo"
- />
- <t-icon
- v-else
- name="user"
- class="source-switcher-row-icon"
- size="16px"
- />
- <span class="source-switcher-row-name" :title="item.label">{{ item.label }}</span>
- <t-icon
- v-if="item.value === current"
- name="check"
- class="source-switcher-row-check"
- size="14px"
- />
- </button>
- </div>
- </div>
- </template>
- <slot />
- </t-popup>
-</template>
-
-<script setup lang="ts">
-import { computed, ref } from 'vue'
-
-// A dumb scope switcher mirroring KBSwitcherDropdown's visual grammar. Logos are
-// pre-resolved by the caller; web (no logo) falls back to a generic icon.
-interface SourceItem {
- value: string
- label: string
- logo?: string
-}
-
-const props = defineProps<{
- sources: SourceItem[]
- current: string
-}>()
-
-const emit = defineEmits<{
- (e: 'select', value: string): void
-}>()
-
-// t-popup only closes on outside click; selecting an item must close it
-// explicitly, otherwise the panel lingers and overlays the list below
-// (switching source reloads in place, so nothing else dismisses it).
-const visible = ref(false)
-
-// Pin the current source to the top so users always see "where they are" without
-// scrolling — same as KBSwitcherDropdown. The rest keeps the caller's order
-// (web first, then configured platforms).
-const sortedList = computed<SourceItem[]>(() => {
- const all = props.sources || []
- const current = all.find((s) => s.value === props.current)
- if (!current) return all
- return [current, ...all.filter((s) => s.value !== props.current)]
-})
-
-const handleSelect = (value: string): void => {
- visible.value = false
- if (value === props.current) return
- emit('select', value)
-}
-</script>
-
-<style scoped lang="less">
-/* Mirrors KBSwitcherDropdown so both scope switchers stay visually identical. */
-.source-switcher-card {
- min-width: 200px;
- max-width: 300px;
- max-height: min(60vh, 420px);
- display: flex;
- flex-direction: column;
- padding: 6px;
- overflow: hidden;
-}
-
-.source-switcher-list {
- flex: 1 1 auto;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: 1px;
-}
-
-.source-switcher-row {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 6px 10px;
- border: none;
- border-radius: 6px;
- background: transparent;
- color: var(--td-text-color-primary);
- font-size: 13px;
- line-height: 1.4;
- cursor: pointer;
- transition: background 0.15s ease, color 0.15s ease;
- text-align: left;
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- }
-
- &.active {
- background: var(--td-brand-color-light, rgba(0, 82, 217, 0.08));
- color: var(--td-brand-color);
- font-weight: 500;
- }
-}
-
-.source-switcher-row-logo {
- flex: 0 0 auto;
- width: 16px;
- height: 16px;
- border-radius: 3px;
- object-fit: contain;
-}
-
-.source-switcher-row-icon {
- flex: 0 0 auto;
- color: var(--td-text-color-placeholder);
-
- .source-switcher-row.active & {
- color: var(--td-brand-color);
- }
-}
-
-.source-switcher-row-name {
- flex: 1 1 auto;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.source-switcher-row-check {
- flex: 0 0 auto;
- color: var(--td-brand-color);
-}
-</style>
diff --git a/frontend/src/components/settings/SettingCard.vue b/frontend/src/components/settings/SettingCard.vue
deleted file mode 100644
index 7a349964b..000000000
--- a/frontend/src/components/settings/SettingCard.vue
+++ /dev/null
@@ -1,152 +0,0 @@
-<template>
- <div class="setting-card" :class="{ 'setting-card--disabled': disabled }">
- <div class="setting-card__header">
- <h3 class="setting-card__title" :title="title">{{ title }}</h3>
- <div class="setting-card__header-right">
- <slot name="controls" />
- <t-dropdown
- v-if="actions && actions.length > 0"
- :options="actions"
- placement="bottom-right"
- attach="body"
- @click="(data: any) => emit('action', data.value)"
- >
- <t-button variant="text" shape="square" size="small" class="setting-card__more">
- <t-icon name="more" />
- </t-button>
- </t-dropdown>
- </div>
- </div>
- <div v-if="$slots.tags" class="setting-card__tags">
- <slot name="tags" />
- </div>
- <p v-if="description" class="setting-card__desc">{{ description }}</p>
- <div v-if="$slots.meta" class="setting-card__meta">
- <slot name="meta" />
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-interface DropdownOption {
- content: string
- value: string
- theme?: 'default' | 'success' | 'warning' | 'error' | 'primary'
-}
-
-interface Props {
- title: string
- description?: string
- disabled?: boolean
- actions?: DropdownOption[]
-}
-
-withDefaults(defineProps<Props>(), {
- description: '',
- disabled: false,
- actions: () => []
-})
-
-const emit = defineEmits<{
- (e: 'action', value: string): void
-}>()
-</script>
-
-<style lang="less" scoped>
-.setting-card {
- display: flex;
- flex-direction: column;
- gap: 8px;
- padding: 16px;
- border: 1px solid var(--td-component-stroke);
- border-radius: 8px;
- background: var(--td-bg-color-container);
- transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
- min-width: 0;
-
- &:hover {
- border-color: var(--td-brand-color);
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
- }
-
- &--disabled {
- background: var(--td-bg-color-secondarycontainer);
-
- .setting-card__title {
- color: var(--td-text-color-secondary);
- }
-
- &:hover {
- border-color: var(--td-brand-color-light);
- box-shadow: none;
- }
- }
-}
-
-.setting-card__header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- min-width: 0;
-}
-
-.setting-card__title {
- flex: 1;
- min-width: 0;
- margin: 0;
- font-size: 15px;
- font-weight: 600;
- line-height: 1.4;
- color: var(--td-text-color-primary);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.setting-card__header-right {
- display: flex;
- align-items: center;
- gap: 4px;
- flex-shrink: 0;
-}
-
-.setting-card__more {
- color: var(--td-text-color-placeholder);
- padding: 4px;
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
- }
-}
-
-.setting-card__tags {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 6px;
- min-height: 20px;
-}
-
-.setting-card__desc {
- margin: 0;
- font-size: 13px;
- line-height: 1.5;
- color: var(--td-text-color-secondary);
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
- word-break: break-all;
-}
-
-.setting-card__meta {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 12px;
- font-size: 12px;
- color: var(--td-text-color-placeholder);
-}
-</style>
diff --git a/frontend/src/composables/useKnowledgeTagSelection.test.ts b/frontend/src/composables/useKnowledgeTagSelection.test.ts
new file mode 100644
index 000000000..ef9f152ec
--- /dev/null
+++ b/frontend/src/composables/useKnowledgeTagSelection.test.ts
@@ -0,0 +1,149 @@
+import assert from 'node:assert/strict'
+import test from 'node:test'
+import { effectScope, nextTick, ref } from 'vue'
+import { useKnowledgeTagSelection, type KnowledgeTag } from './useKnowledgeTagSelection.ts'
+
+function harness(createTag: Parameters<typeof useKnowledgeTagSelection>[0]['createTag'] = async () => {
+ throw new Error('unexpected creation')
+}) {
+ const visible = ref(false)
+ const kbId = ref('kb-a')
+ const tags = ref<KnowledgeTag[]>([{ id: 'a', name: 'Alpha' }, { id: 'b', name: 'Beta' }])
+ const selectedIds = ref(['a'])
+ const errors: unknown[] = []
+ let created = 0
+ const scope = effectScope()
+ const selection = scope.run(() => useKnowledgeTagSelection({
+ visible: () => visible.value,
+ kbId: () => kbId.value,
+ tags: () => tags.value,
+ selectedIds: () => selectedIds.value,
+ createTag,
+ onCreated: () => { created++ },
+ onError: error => errors.push(error),
+ }))!
+ return { selection, visible, kbId, tags, selectedIds, errors, created: () => created, stop: () => scope.stop() }
+}
+
+test('opening hydrates selection and reopening discards edits using the latest parent values', async (t) => {
+ const h = harness()
+ t.after(h.stop)
+ h.visible.value = true
+ await nextTick()
+ assert.deepEqual([...h.selection.selectedSet.value], ['a'])
+ h.selection.toggleTag('b')
+ h.selection.searchQuery.value = 'draft search'
+ h.selection.newTagName.value = 'draft tag'
+ h.selectedIds.value = ['b']
+ await nextTick()
+ assert.deepEqual([...h.selection.selectedSet.value], ['a', 'b'], 'parent refresh must not overwrite an open draft')
+ h.visible.value = false
+ await nextTick()
+ h.visible.value = true
+ await nextTick()
+ assert.deepEqual([...h.selection.selectedSet.value], ['b'])
+ assert.equal(h.selection.searchQuery.value, '')
+ assert.equal(h.selection.newTagName.value, '')
+})
+
+test('search excludes selected tags, tracks refreshed names, and preserves IDs absent from the current list', async (t) => {
+ const h = harness()
+ t.after(h.stop)
+ h.selectedIds.value = ['a', 'not-loaded']
+ h.visible.value = true
+ await nextTick()
+ assert.deepEqual(h.selection.selectedTagsList.value.map(tag => tag.id), ['a'])
+ assert.deepEqual([...h.selection.selectedSet.value], ['a', 'not-loaded'])
+ h.selection.searchQuery.value = ' BETA '
+ assert.deepEqual(h.selection.availableTagsList.value.map(tag => tag.id), ['b'])
+ h.selection.toggleTag('b')
+ assert.deepEqual(h.selection.availableTagsList.value, [])
+ h.selection.toggleTag('b')
+ h.tags.value = [{ id: 'a', name: 'Renamed' }, { id: 'b', name: 'Gamma' }]
+ assert.equal(h.selection.selectedTagsList.value[0]?.name, 'Renamed')
+ assert.deepEqual(h.selection.availableTagsList.value, [])
+ h.selection.searchQuery.value = ''
+ h.selection.clearAll()
+ assert.equal(h.selection.selectedSet.value.size, 0)
+ assert.equal(h.selection.availableTagsList.value.length, 2)
+})
+
+test('search creation uses the current KB, selects the returned tag and clears only the search input', async (t) => {
+ const requests: [string, { name: string }][] = []
+ const h = harness(async (kbId, data) => {
+ requests.push([kbId, data])
+ return { data: { id: 'new', name: data.name } }
+ })
+ t.after(h.stop)
+ h.kbId.value = 'kb-b'
+ h.selection.searchQuery.value = ' New tag '
+ h.selection.newTagName.value = 'separate draft'
+ await h.selection.handleCreateTag()
+ assert.deepEqual(requests, [['kb-b', { name: 'New tag' }]])
+ assert.deepEqual([...h.selection.selectedSet.value], ['new'])
+ assert.equal(h.selection.searchQuery.value, '')
+ assert.equal(h.selection.newTagName.value, 'separate draft')
+ assert.equal(h.created(), 1)
+ assert.equal(h.selection.creatingTag.value, false)
+ h.tags.value.push({ id: 'new', name: 'New tag' })
+ assert.equal(h.selection.selectedTagsList.value[0]?.name, 'New tag')
+})
+
+test('manual entry reuses an exact existing name without creating or announcing a new tag', async (t) => {
+ const h = harness()
+ t.after(h.stop)
+ h.selection.newTagName.value = ' Alpha '
+ await h.selection.handleAddNewTag()
+ assert.deepEqual([...h.selection.selectedSet.value], ['a'])
+ assert.equal(h.selection.newTagName.value, '')
+ assert.equal(h.created(), 0)
+ assert.deepEqual(h.errors, [])
+})
+
+test('manual creation accepts an unwrapped response without clearing a separate search', async (t) => {
+ const h = harness(async (_, data) => ({ id: 'new', name: data.name }))
+ t.after(h.stop)
+ h.selection.newTagName.value = 'New'
+ h.selection.searchQuery.value = 'retained search'
+ await h.selection.handleAddNewTag()
+ assert.deepEqual([...h.selection.selectedSet.value], ['new'])
+ assert.equal(h.selection.newTagName.value, '')
+ assert.equal(h.selection.searchQuery.value, 'retained search')
+ assert.equal(h.created(), 1)
+})
+
+test('failed creation preserves the draft and selection, releases loading and permits retry', async (t) => {
+ let reject!: (error: Error) => void
+ const h = harness(() => new Promise((_, rejectRequest) => { reject = rejectRequest }))
+ t.after(h.stop)
+ h.selection.toggleTag('a')
+ h.selection.newTagName.value = 'retry me'
+ const pending = h.selection.handleAddNewTag()
+ assert.equal(h.selection.creatingTag.value, true)
+ const failure = new Error('denied')
+ reject(failure)
+ await pending
+ assert.equal(h.selection.creatingTag.value, false)
+ assert.equal(h.selection.newTagName.value, 'retry me')
+ assert.deepEqual([...h.selection.selectedSet.value], ['a'])
+ assert.deepEqual(h.errors, [failure])
+ assert.equal(h.created(), 0)
+ const retry = h.selection.handleAddNewTag()
+ assert.equal(h.selection.creatingTag.value, true)
+ reject(failure)
+ await retry
+ assert.equal(h.errors.length, 2)
+})
+
+test('empty inputs do not create tags and dialogs keep independent selection state', async (t) => {
+ const first = harness(), second = harness()
+ t.after(first.stop)
+ t.after(second.stop)
+ first.selection.searchQuery.value = ' '
+ first.selection.newTagName.value = ' '
+ await first.selection.handleCreateTag()
+ await first.selection.handleAddNewTag()
+ assert.deepEqual(first.errors, [])
+ first.selection.toggleTag('a')
+ assert.equal(second.selection.selectedSet.value.size, 0)
+})
diff --git a/frontend/src/composables/useKnowledgeTagSelection.ts b/frontend/src/composables/useKnowledgeTagSelection.ts
new file mode 100644
index 000000000..05f532536
--- /dev/null
+++ b/frontend/src/composables/useKnowledgeTagSelection.ts
@@ -0,0 +1,89 @@
+import { computed, ref, watch, type Ref } from 'vue'
+
+export interface KnowledgeTag {
+ id: string
+ name: string
+ color?: string
+ knowledge_count?: number
+}
+
+interface TagSelectionOptions {
+ visible: () => boolean
+ kbId: () => string
+ tags: () => KnowledgeTag[]
+ selectedIds: () => string[]
+ createTag: (kbId: string, data: { name: string }) => Promise<KnowledgeTag | { data: KnowledgeTag }>
+ onCreated: () => void
+ onError: (error: unknown) => void
+}
+
+/** Shared selection and creation state; each dialog owns its submit/close behavior. */
+export function useKnowledgeTagSelection(options: TagSelectionOptions) {
+ const searchQuery = ref('')
+ const newTagName = ref('')
+ const selectedSet = ref(new Set<string>())
+ const creatingTag = ref(false)
+
+ watch(options.visible, (visible) => {
+ if (visible) {
+ selectedSet.value = new Set(options.selectedIds())
+ searchQuery.value = ''
+ newTagName.value = ''
+ }
+ })
+
+ const tagMap = computed(() => new Map(options.tags().map(tag => [tag.id, tag])))
+ const selectedTagsList = computed(() => Array.from(selectedSet.value)
+ .map(id => tagMap.value.get(id))
+ .filter((tag): tag is KnowledgeTag => Boolean(tag)))
+ const availableTagsList = computed(() => {
+ const query = searchQuery.value.trim().toLowerCase()
+ return options.tags().filter(tag => !selectedSet.value.has(tag.id)
+ && (!query || (tag.name || '').toLowerCase().includes(query)))
+ })
+
+ function selectTag(id: string) {
+ selectedSet.value = new Set([...selectedSet.value, id])
+ }
+
+ function toggleTag(id: string) {
+ const next = new Set(selectedSet.value)
+ if (next.has(id)) next.delete(id)
+ else next.add(id)
+ selectedSet.value = next
+ }
+
+ function clearAll() {
+ selectedSet.value = new Set()
+ }
+
+ async function createFrom(input: Ref<string>, reuseExisting: boolean) {
+ const name = input.value.trim()
+ if (!name) return
+ const existing = reuseExisting && options.tags().find(tag => tag.name === name)
+ if (existing) {
+ selectTag(existing.id)
+ input.value = ''
+ return
+ }
+ creatingTag.value = true
+ try {
+ const response = await options.createTag(options.kbId(), { name })
+ const tag = 'data' in response ? response.data : response
+ selectTag(tag.id)
+ input.value = ''
+ options.onCreated()
+ } catch (error) {
+ options.onError(error)
+ } finally {
+ creatingTag.value = false
+ }
+ }
+
+ return {
+ searchQuery, newTagName, selectedSet, creatingTag, selectedTagsList, availableTagsList,
+ toggleTag, clearAll,
+ handleCreateTag: () => createFrom(searchQuery, false),
+ handleAddNewTag: () => createFrom(newTagName, true),
+ }
+}
diff --git a/frontend/src/views/chat/components/sendMsg.vue b/frontend/src/views/chat/components/sendMsg.vue
deleted file mode 100644
index 259bf3943..000000000
--- a/frontend/src/views/chat/components/sendMsg.vue
+++ /dev/null
@@ -1,22 +0,0 @@
-<template>
- <div>
- <t-textarea resize="none" :autosize="false" v-model="value" :placeholder="$t('chat.enterDescription')" name="description" @change="onChange" />
- </div>
-</template>
-<script setup>
-import { onMounted, watch, computed, ref, reactive } from 'vue';
-import { useI18n } from 'vue-i18n';
-
-const value = ref('');
-const { t } = useI18n();
-const onChange = (value,e) => {
- console.log(value)
-}
-</script>
-<style lang="less">
-.chat {
- width: 800px;
- font-size: 20px;
- margin: 0px auto
-}
-</style>
\ No newline at end of file
diff --git a/frontend/src/views/knowledge/components/BatchTagDialog.vue b/frontend/src/views/knowledge/components/BatchTagDialog.vue
index dde15cb2d..ae6e5b083 100644
--- a/frontend/src/views/knowledge/components/BatchTagDialog.vue
+++ b/frontend/src/views/knowledge/components/BatchTagDialog.vue
@@ -87,17 +87,11 @@
</template>
<script setup lang="ts">
-import { ref, computed, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { MessagePlugin } from 'tdesign-vue-next';
import { createKnowledgeBaseTag } from '@/api/knowledge-base';
-interface Tag {
- id: string;
- name: string;
- color?: string;
- knowledge_count?: number;
-}
+import { useKnowledgeTagSelection, type KnowledgeTag as Tag } from '@/composables/useKnowledgeTagSelection';
const props = defineProps<{
visible: boolean;
@@ -118,100 +112,21 @@ const emit = defineEmits<{
const { t } = useI18n();
-const searchQuery = ref('');
-const selectedSet = ref<Set<string>>(new Set());
-const creatingTag = ref(false);
-const newTagName = ref('');
-
-watch(
- () => props.visible,
- (val) => {
- if (val) {
- selectedSet.value = new Set(props.preSelectedTagIds ?? []);
- searchQuery.value = '';
- newTagName.value = '';
- }
- },
-);
-
-const tagMap = computed(() => new Map(props.tagList.map((tag) => [tag.id, tag])));
-
-const selectedTagsList = computed(() => {
- return Array.from(selectedSet.value)
- .map((id) => tagMap.value.get(id))
- .filter((tag): tag is Tag => Boolean(tag));
-});
-
-const availableTagsList = computed(() => {
- const query = searchQuery.value.trim().toLowerCase();
- return props.tagList.filter((tag) => {
- if (selectedSet.value.has(tag.id)) return false;
- if (query && !(tag.name || '').toLowerCase().includes(query)) return false;
- return true;
- });
-});
-
-function toggleTag(tagId: string) {
- const next = new Set(selectedSet.value);
- if (next.has(tagId)) {
- next.delete(tagId);
- } else {
- next.add(tagId);
- }
- selectedSet.value = next;
-}
-
-function clearAll() {
- selectedSet.value = new Set();
-}
-
-async function handleCreateTag() {
- const name = searchQuery.value.trim();
- if (!name) return;
- creatingTag.value = true;
- try {
- const res: any = await createKnowledgeBaseTag(props.kbId, { name });
- const newTag = res?.data || res;
- const next = new Set(selectedSet.value);
- next.add(newTag.id);
- selectedSet.value = next;
- searchQuery.value = '';
+const {
+ searchQuery, newTagName, selectedSet, creatingTag, selectedTagsList, availableTagsList,
+ toggleTag, clearAll, handleCreateTag, handleAddNewTag,
+} = useKnowledgeTagSelection({
+ visible: () => props.visible,
+ kbId: () => props.kbId,
+ tags: () => props.tagList,
+ selectedIds: () => props.preSelectedTagIds ?? [],
+ createTag: createKnowledgeBaseTag,
+ onCreated: () => {
emit('tag-created');
MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('common.operationFailed'));
- } finally {
- creatingTag.value = false;
- }
-}
-
-async function handleAddNewTag() {
- const name = newTagName.value.trim();
- if (!name) return;
- const exists = props.tagList.find((t) => t.name === name);
- if (exists) {
- const next = new Set(selectedSet.value);
- next.add(exists.id);
- selectedSet.value = next;
- newTagName.value = '';
- return;
- }
- creatingTag.value = true;
- try {
- const res: any = await createKnowledgeBaseTag(props.kbId, { name });
- const newTag = res?.data || res;
- const next = new Set(selectedSet.value);
- next.add(newTag.id);
- selectedSet.value = next;
- newTagName.value = '';
- emit('tag-created');
- MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('common.operationFailed'));
- } finally {
- creatingTag.value = false;
- }
-}
+ },
+ onError: (error: any) => MessagePlugin.error(error?.message || t('common.operationFailed')),
+});
function handleConfirm() {
if (props.confirmLoading) return;
diff --git a/frontend/src/views/knowledge/components/TagEditDialog.vue b/frontend/src/views/knowledge/components/TagEditDialog.vue
index 9127b181a..07b4e7887 100644
--- a/frontend/src/views/knowledge/components/TagEditDialog.vue
+++ b/frontend/src/views/knowledge/components/TagEditDialog.vue
@@ -87,17 +87,12 @@
</template>
<script setup lang="ts">
-import { ref, computed, watch } from 'vue';
+import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { MessagePlugin } from 'tdesign-vue-next';
import { createKnowledgeBaseTag } from '@/api/knowledge-base';
-interface Tag {
- id: string;
- name: string;
- color?: string;
- knowledge_count?: number;
-}
+import { useKnowledgeTagSelection, type KnowledgeTag as Tag } from '@/composables/useKnowledgeTagSelection';
const props = defineProps<{
visible: boolean;
@@ -117,101 +112,23 @@ const emit = defineEmits<{
const { t } = useI18n();
-const searchQuery = ref('');
-const selectedSet = ref<Set<string>>(new Set());
-const creatingTag = ref(false);
-const saving = ref(false);
-const newTagName = ref('');
-
-watch(
- () => props.visible,
- (val) => {
- if (val) {
- selectedSet.value = new Set(props.selectedTags.map((t) => t.id));
- searchQuery.value = '';
- newTagName.value = '';
- }
- },
-);
-
-const tagMap = computed(() => new Map(props.tagList.map((tag) => [tag.id, tag])));
-
-const selectedTagsList = computed(() => {
- return Array.from(selectedSet.value)
- .map((id) => tagMap.value.get(id))
- .filter((tag): tag is Tag => Boolean(tag));
-});
-
-const availableTagsList = computed(() => {
- const query = searchQuery.value.trim().toLowerCase();
- return props.tagList.filter((tag) => {
- if (selectedSet.value.has(tag.id)) return false;
- if (query && !(tag.name || '').toLowerCase().includes(query)) return false;
- return true;
- });
-});
-
-function toggleTag(tagId: string) {
- const next = new Set(selectedSet.value);
- if (next.has(tagId)) {
- next.delete(tagId);
- } else {
- next.add(tagId);
- }
- selectedSet.value = next;
-}
-
-function clearAll() {
- selectedSet.value = new Set();
-}
-
-async function handleCreateTag() {
- const name = searchQuery.value.trim();
- if (!name) return;
- creatingTag.value = true;
- try {
- const res: any = await createKnowledgeBaseTag(props.kbId, { name });
- const newTag = res?.data || res;
- const next = new Set(selectedSet.value);
- next.add(newTag.id);
- selectedSet.value = next;
- searchQuery.value = '';
+const {
+ searchQuery, newTagName, selectedSet, creatingTag, selectedTagsList, availableTagsList,
+ toggleTag, clearAll, handleCreateTag, handleAddNewTag,
+} = useKnowledgeTagSelection({
+ visible: () => props.visible,
+ kbId: () => props.kbId,
+ tags: () => props.tagList,
+ selectedIds: () => props.selectedTags.map(tag => tag.id),
+ createTag: createKnowledgeBaseTag,
+ onCreated: () => {
emit('tag-created');
MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('common.operationFailed'));
- } finally {
- creatingTag.value = false;
- }
-}
+ },
+ onError: (error: any) => MessagePlugin.error(error?.message || t('common.operationFailed')),
+});
-async function handleAddNewTag() {
- const name = newTagName.value.trim();
- if (!name) return;
- const exists = props.tagList.find((t) => t.name === name);
- if (exists) {
- const next = new Set(selectedSet.value);
- next.add(exists.id);
- selectedSet.value = next;
- newTagName.value = '';
- return;
- }
- creatingTag.value = true;
- try {
- const res: any = await createKnowledgeBaseTag(props.kbId, { name });
- const newTag = res?.data || res;
- const next = new Set(selectedSet.value);
- next.add(newTag.id);
- selectedSet.value = next;
- newTagName.value = '';
- emit('tag-created');
- MessagePlugin.success(t('knowledgeBase.tagCreateSuccess'));
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('common.operationFailed'));
- } finally {
- creatingTag.value = false;
- }
-}
+const saving = ref(false);
async function handleConfirm() {
saving.value = true;
diff --git a/frontend/src/views/knowledge/settings/DataSourceEditorDialog.vue b/frontend/src/views/knowledge/settings/DataSourceEditorDialog.vue
index 746a76080..d6cec9091 100644
--- a/frontend/src/views/knowledge/settings/DataSourceEditorDialog.vue
+++ b/frontend/src/views/knowledge/settings/DataSourceEditorDialog.vue
@@ -2773,7 +2773,7 @@ const drawerConfirmText = computed(() => {
</style>
<!--
- Drawer header logo — same white badge as list cards / StorageEngineSettings.
+ Drawer header logo — same white badge as the data-source list cards.
-->
<style lang="less">
.datasource-editor-drawer .setting-drawer__header-icon:has(.datasource-header-icon__img) {
diff --git a/frontend/src/views/knowledge/settings/KBIndexingStrategy.vue b/frontend/src/views/knowledge/settings/KBIndexingStrategy.vue
deleted file mode 100644
index 75ef68b55..000000000
--- a/frontend/src/views/knowledge/settings/KBIndexingStrategy.vue
+++ /dev/null
@@ -1,109 +0,0 @@
-<template>
- <div class="kb-multimodal-settings">
- <div class="section-header">
- <h2>{{ $t('knowledgeEditor.indexing.title') }}</h2>
- <p class="section-description">{{ $t('knowledgeEditor.indexing.description') }}</p>
- </div>
-
- <div class="settings-group">
- <!-- Hybrid Search (vector + keyword combined) -->
- <div class="setting-row">
- <div class="setting-info">
- <label>{{ $t('knowledgeEditor.indexing.searchTitle') }}</label>
- <p class="desc">{{ $t('knowledgeEditor.indexing.searchDesc') }}</p>
- </div>
- <div class="setting-control">
- <t-switch
- :model-value="searchEnabled"
- @change="handleSearchToggle"
- size="medium"
- />
- </div>
- </div>
-
- <!-- Wiki -->
- <div class="setting-row">
- <div class="setting-info">
- <label>{{ $t('knowledgeEditor.indexing.wikiTitle') }}</label>
- <p class="desc">{{ $t('knowledgeEditor.indexing.wikiDesc') }}</p>
- </div>
- <div class="setting-control">
- <t-switch
- :model-value="modelValue.wikiEnabled"
- @change="(val: boolean) => update('wikiEnabled', val)"
- size="medium"
- />
- </div>
- </div>
-
- <!-- Wiki sub-settings (inline when enabled) -->
- <template v-if="modelValue.wikiEnabled">
- <slot name="wiki-settings" />
- </template>
-
- <!-- Knowledge Graph -->
- <div class="setting-row">
- <div class="setting-info">
- <label>{{ $t('knowledgeEditor.indexing.graphTitle') }}</label>
- <p class="desc">{{ $t('knowledgeEditor.indexing.graphDesc') }}</p>
- </div>
- <div class="setting-control">
- <t-switch
- :model-value="modelValue.graphEnabled"
- @change="(val: boolean) => update('graphEnabled', val)"
- size="medium"
- />
- </div>
- </div>
-
- <!-- Graph sub-settings (inline when enabled) -->
- <template v-if="modelValue.graphEnabled">
- <slot name="graph-settings" />
- </template>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { computed } from 'vue'
-
-export interface IndexingStrategy {
- vectorEnabled: boolean
- keywordEnabled: boolean
- wikiEnabled: boolean
- graphEnabled: boolean
-}
-
-const props = defineProps<{
- modelValue: IndexingStrategy
-}>()
-
-const emit = defineEmits<{
- (e: 'update:modelValue', value: IndexingStrategy): void
-}>()
-
-// Search = vector + keyword combined (the system always uses hybrid search internally)
-const searchEnabled = computed(() => props.modelValue.vectorEnabled || props.modelValue.keywordEnabled)
-
-const handleSearchToggle = (val: boolean) => {
- emit('update:modelValue', {
- ...props.modelValue,
- vectorEnabled: val,
- keywordEnabled: val,
- })
-}
-
-const update = (field: keyof IndexingStrategy, value: boolean) => {
- emit('update:modelValue', {
- ...props.modelValue,
- [field]: value,
- })
-}
-</script>
-
-<style lang="less">
-/* NOT scoped — these classes must match the parent modal's scoped styles.
- Since slot content is rendered in the parent scope, only the wrapper
- elements defined HERE need their own styles. We replicate the same
- design tokens used by .kb-multimodal-settings in the parent. */
-</style>
diff --git a/frontend/src/views/organization/JoinOrganization.vue b/frontend/src/views/organization/JoinOrganization.vue
deleted file mode 100644
index 7384b5313..000000000
--- a/frontend/src/views/organization/JoinOrganization.vue
+++ /dev/null
@@ -1,127 +0,0 @@
-<template>
- <div class="join-page">
- <div class="join-card">
- <div class="join-icon">
- <t-icon name="user-add" size="48px" />
- </div>
- <h2 class="join-title">{{ $t('organization.join.title') }}</h2>
- <p v-if="loading" class="join-message">{{ $t('organization.join.joining') }}</p>
- <p v-else-if="error" class="join-message error">{{ error }}</p>
- <p v-else class="join-message success">{{ $t('organization.join.success') }}</p>
-
- <t-button
- v-if="!loading"
- theme="primary"
- @click="goToOrganizations"
- >
- {{ $t('organization.join.goToOrganizations') }}
- </t-button>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { ref, onMounted } from 'vue'
-import { useRoute, useRouter } from 'vue-router'
-import { useI18n } from 'vue-i18n'
-import { MessagePlugin } from 'tdesign-vue-next'
-import { useOrganizationStore } from '@/stores/organization'
-import { useAuthStore } from '@/stores/auth'
-
-const route = useRoute()
-const router = useRouter()
-const { t } = useI18n()
-const orgStore = useOrganizationStore()
-const authStore = useAuthStore()
-
-const loading = ref(true)
-const error = ref('')
-
-onMounted(async () => {
- const code = route.query.code as string
-
- if (!code) {
- error.value = t('organization.join.noCode')
- loading.value = false
- return
- }
-
- // 后端 POST /organizations/join 要求当前空间角色 ≥ admin,先在前端拦截以给出友好提示
- if (!authStore.hasRole('admin') && !authStore.canAccessAllTenants) {
- error.value = t('organization.rbac.cannotJoin')
- loading.value = false
- return
- }
-
- try {
- const result = await orgStore.join(code)
- if (result) {
- MessagePlugin.success(t('organization.join.success'))
- } else {
- error.value = orgStore.error || t('organization.join.failed')
- }
- } catch (e: any) {
- error.value = e?.message || t('organization.join.failed')
- } finally {
- loading.value = false
- }
-})
-
-const goToOrganizations = () => {
- router.push('/platform/organizations')
-}
-</script>
-
-<style scoped lang="less">
-.join-page {
- min-height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- background: var(--td-bg-color-container);
- padding: 20px;
-}
-
-.join-card {
- background: var(--td-bg-color-container);
- border-radius: 16px;
- padding: 48px;
- text-align: center;
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
- max-width: 400px;
- width: 100%;
-}
-
-.join-icon {
- width: 80px;
- height: 80px;
- margin: 0 auto 24px;
- border-radius: 50%;
- background: var(--td-success-color-light);
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--td-success-color);
-}
-
-.join-title {
- font-size: 20px;
- font-weight: 600;
- color: var(--td-text-color-primary);
- margin: 0 0 16px;
-}
-
-.join-message {
- font-size: 14px;
- color: var(--td-text-color-secondary);
- margin: 0 0 24px;
-
- &.error {
- color: var(--td-error-color);
- }
-
- &.success {
- color: var(--td-success-color);
- }
-}
-</style>
diff --git a/frontend/src/views/organization/OrganizationEditorModal.vue b/frontend/src/views/organization/OrganizationEditorModal.vue
deleted file mode 100644
index 8f9850569..000000000
--- a/frontend/src/views/organization/OrganizationEditorModal.vue
+++ /dev/null
@@ -1,914 +0,0 @@
-<template>
- <Teleport to="body">
- <Transition name="modal">
- <div v-if="visible" class="settings-overlay" @click.self="handleClose">
- <div class="settings-modal" :class="{ 'join-mode': mode === 'join' }">
- <!-- 关闭按钮 -->
- <button class="close-btn" @click="handleClose" :aria-label="$t('common.close')">
- <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
- <path d="M15 5L5 15M5 5L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
- </svg>
- </button>
-
- <div class="settings-container">
- <!-- 左侧导航 -->
- <div class="settings-sidebar">
- <div class="sidebar-header">
- <h2 class="sidebar-title">{{ modalTitle }}</h2>
- </div>
- <div class="settings-nav">
- <div
- v-for="(item, index) in navItems"
- :key="index"
- :class="['nav-item', { 'active': currentSection === item.key }]"
- @click="currentSection = item.key"
- >
- <t-icon :name="item.icon" class="nav-icon" />
- <span class="nav-label">{{ item.label }}</span>
- </div>
- </div>
- </div>
-
- <!-- 右侧内容区域 -->
- <div class="settings-content">
- <div class="content-wrapper">
- <!-- 创建组织 - 基本信息 -->
- <div v-if="mode === 'create'" v-show="currentSection === 'basic'" class="section">
- <div class="section-content">
- <div class="section-header">
- <h3 class="section-title">{{ $t('organization.editor.basicTitle') }}</h3>
- <p class="section-desc">{{ $t('organization.editor.basicDesc') }}</p>
- </div>
- <div class="section-body">
- <div class="form-item">
- <label class="form-label required">{{ $t('organization.name') }}</label>
- <div class="name-input-wrapper">
- <SpaceAvatar :name="createForm.name || '?'" size="medium" />
- <t-input
- v-model="createForm.name"
- :placeholder="$t('organization.namePlaceholder')"
- :maxlength="100"
- class="name-input"
- />
- </div>
- <p class="form-tip">{{ $t('organization.editor.nameTip') }}</p>
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('organization.description') }}</label>
- <t-textarea
- v-model="createForm.description"
- :placeholder="$t('organization.descriptionPlaceholder')"
- :maxlength="500"
- :autosize="{ minRows: 3, maxRows: 6 }"
- />
- <p class="form-tip">{{ $t('organization.editor.descriptionTip') }}</p>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 创建组织 - 权限说明 -->
- <div v-if="mode === 'create'" v-show="currentSection === 'permissions'" class="section">
- <div class="section-content">
- <div class="section-header">
- <h3 class="section-title">{{ $t('organization.editor.permissionsTitle') }}</h3>
- <p class="section-desc">{{ $t('organization.editor.permissionsDesc') }}</p>
- </div>
- <div class="section-body">
- <div class="permissions-info">
- <div class="permission-card">
- <div class="permission-header">
- <div class="permission-icon admin">
- <t-icon name="user-safety" />
- </div>
- <div class="permission-title">
- <span class="role-name">{{ $t('organization.role.admin') }}</span>
- <t-tag size="small" theme="primary">{{ $t('organization.editor.fullAccess') }}</t-tag>
- </div>
- </div>
- <ul class="permission-list">
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm1') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm2') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm3') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm4') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.useSharedAgentsPerm') }}</li>
- </ul>
- </div>
- <div class="permission-card">
- <div class="permission-header">
- <div class="permission-icon editor">
- <t-icon name="edit" />
- </div>
- <div class="permission-title">
- <span class="role-name">{{ $t('organization.role.editor') }}</span>
- <t-tag size="small" theme="warning">{{ $t('organization.editor.editAccess') }}</t-tag>
- </div>
- </div>
- <ul class="permission-list">
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.editorPerm1') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.editorPerm2') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.useSharedAgentsPerm') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.shareKBPerm') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.editorPerm3') }}</li>
- </ul>
- </div>
- <div class="permission-card">
- <div class="permission-header">
- <div class="permission-icon viewer">
- <t-icon name="browse" />
- </div>
- <div class="permission-title">
- <span class="role-name">{{ $t('organization.role.viewer') }}</span>
- <t-tag size="small">{{ $t('organization.editor.viewAccess') }}</t-tag>
- </div>
- </div>
- <ul class="permission-list">
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.viewerPerm1') }}</li>
- <li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.useSharedAgentsPerm') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.shareKBPerm') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.viewerPerm2') }}</li>
- <li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.viewerPerm3') }}</li>
- </ul>
- </div>
- </div>
- <div class="info-notice">
- <t-icon name="info-circle" />
- <span>{{ $t('organization.editor.ownerNote') }}</span>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 加入组织 -->
- <div v-if="mode === 'join'" v-show="currentSection === 'join'" class="section">
- <div class="section-content">
- <div class="section-header">
- <h3 class="section-title">{{ $t('organization.editor.joinTitle') }}</h3>
- <p class="section-desc">{{ $t('organization.editor.joinDesc') }}</p>
- </div>
- <div class="section-body">
- <div class="join-illustration">
- <div class="illustration-icon">
- <t-icon name="user-add" size="48px" />
- </div>
- <p class="illustration-text">{{ $t('organization.editor.joinIllustration') }}</p>
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('organization.inviteCode') }}</label>
- <t-input
- v-model="joinForm.invite_code"
- :placeholder="$t('organization.inviteCodePlaceholder')"
- :maxlength="32"
- size="medium"
- class="invite-code-input"
- />
- <p class="form-tip">{{ $t('organization.editor.inviteCodeTip') }}</p>
- </div>
- <div class="join-steps">
- <div class="step-title">{{ $t('organization.editor.howToGetCode') }}</div>
- <div class="step-list">
- <div class="step-item">
- <span class="step-number">1</span>
- <span class="step-text">{{ $t('organization.editor.step1') }}</span>
- </div>
- <div class="step-item">
- <span class="step-number">2</span>
- <span class="step-text">{{ $t('organization.editor.step2') }}</span>
- </div>
- <div class="step-item">
- <span class="step-number">3</span>
- <span class="step-text">{{ $t('organization.editor.step3') }}</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 底部按钮 -->
- <div class="settings-footer">
- <t-button theme="default" variant="outline" @click="handleClose">
- {{ $t('common.cancel') }}
- </t-button>
- <t-button theme="primary" @click="handleSubmit" :loading="submitting">
- {{ mode === 'create' ? $t('common.create') : $t('organization.join.preview') }}
- </t-button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </Transition>
-
- <!-- 加入确认弹窗 -->
- <t-dialog
- v-model:visible="showJoinConfirm"
- :header="$t('organization.join.confirmTitle')"
- :confirm-btn="previewInfo?.is_already_member ? $t('common.close') : $t('organization.join.confirm')"
- :cancel-btn="previewInfo?.is_already_member ? null : $t('common.cancel')"
- :confirm-on-enter="!previewInfo?.is_already_member"
- @confirm="previewInfo?.is_already_member ? (showJoinConfirm = false) : confirmJoin()"
- @cancel="showJoinConfirm = false"
- :confirm-loading="joining"
- >
- <div v-if="previewInfo" class="join-confirm-content">
- <div class="org-preview-card">
- <div class="org-preview-header">
- <div class="org-avatar">
- <t-icon name="usergroup" size="24px" />
- </div>
- <div class="org-info">
- <h4 class="org-name">{{ previewInfo.name }}</h4>
- <p class="org-desc">{{ previewInfo.description || $t('organization.noDescription') }}</p>
- </div>
- </div>
- <div class="org-stats">
- <div class="stat-item">
- <t-icon name="user" />
- <span>{{ $t('organization.join.memberCount', { count: previewInfo.member_count }) }}</span>
- </div>
- <div class="stat-item">
- <t-icon name="folder" />
- <span>{{ $t('organization.join.shareCount', { count: previewInfo.share_count }) }}</span>
- </div>
- <div class="stat-item stat-item-agent">
- <img src="@/assets/img/agent.svg" class="stat-agent-icon" alt="" aria-hidden="true" />
- <span>{{ $t('organization.join.agentShareCount', { count: previewInfo.agent_share_count ?? 0 }) }}</span>
- </div>
- </div>
- </div>
- <div v-if="previewInfo.is_already_member" class="already-member-notice">
- <t-icon name="check-circle-filled" />
- <span>{{ $t('organization.join.alreadyMember') }}</span>
- </div>
- </div>
- </t-dialog>
- </Teleport>
-</template>
-
-<script setup lang="ts">
-import { ref, computed, watch } from 'vue'
-import { MessagePlugin } from 'tdesign-vue-next'
-import { useOrganizationStore } from '@/stores/organization'
-import { useI18n } from 'vue-i18n'
-import type { OrganizationPreview } from '@/api/organization'
-import SpaceAvatar from '@/components/SpaceAvatar.vue'
-
-const { t } = useI18n()
-const orgStore = useOrganizationStore()
-
-// Props
-const props = defineProps<{
- visible: boolean
- mode: 'create' | 'join'
-}>()
-
-// Emits
-const emit = defineEmits<{
- (e: 'update:visible', value: boolean): void
- (e: 'success'): void
-}>()
-
-const currentSection = ref<string>('basic')
-const submitting = ref(false)
-const showJoinConfirm = ref(false)
-const previewInfo = ref<OrganizationPreview | null>(null)
-const joining = ref(false)
-
-const createForm = ref({
- name: '',
- description: ''
-})
-
-const joinForm = ref({
- invite_code: ''
-})
-
-// 计算属性
-const modalTitle = computed(() => {
- return props.mode === 'create'
- ? t('organization.createOrg')
- : t('organization.joinOrg')
-})
-
-const navItems = computed(() => {
- if (props.mode === 'create') {
- return [
- { key: 'basic', icon: 'info-circle', label: t('organization.editor.navBasic') },
- { key: 'permissions', icon: 'user-safety', label: t('organization.editor.navPermissions') }
- ]
- } else {
- return [
- { key: 'join', icon: 'user-add', label: t('organization.editor.navJoin') }
- ]
- }
-})
-
-// 方法
-const resetForm = () => {
- createForm.value = { name: '', description: '' }
- joinForm.value = { invite_code: '' }
- currentSection.value = props.mode === 'create' ? 'basic' : 'join'
- showJoinConfirm.value = false
- previewInfo.value = null
-}
-
-const handleClose = () => {
- emit('update:visible', false)
- setTimeout(resetForm, 300)
-}
-
-const handleSubmit = async () => {
- if (props.mode === 'create') {
- await handleCreate()
- } else {
- await handleJoin()
- }
-}
-
-const handleCreate = async () => {
- if (!createForm.value.name.trim()) {
- MessagePlugin.warning(t('organization.nameRequired'))
- currentSection.value = 'basic'
- return
- }
-
- submitting.value = true
- try {
- const result = await orgStore.create(
- createForm.value.name.trim(),
- createForm.value.description.trim()
- )
- if (result) {
- MessagePlugin.success(t('organization.createSuccess'))
- emit('success')
- handleClose()
- } else {
- MessagePlugin.error(orgStore.error || t('organization.createFailed'))
- }
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('organization.createFailed'))
- } finally {
- submitting.value = false
- }
-}
-
-const handleJoin = async () => {
- if (!joinForm.value.invite_code.trim()) {
- MessagePlugin.warning(t('organization.inviteCodeRequired'))
- return
- }
-
- submitting.value = true
- try {
- // First preview the organization
- const preview = await orgStore.preview(joinForm.value.invite_code.trim())
- if (preview) {
- previewInfo.value = preview
- showJoinConfirm.value = true
- } else {
- MessagePlugin.error(orgStore.error || t('organization.join.invalidCode'))
- }
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('organization.join.invalidCode'))
- } finally {
- submitting.value = false
- }
-}
-
-const confirmJoin = async () => {
- if (!joinForm.value.invite_code.trim()) {
- return
- }
-
- joining.value = true
- try {
- const result = await orgStore.join(joinForm.value.invite_code.trim())
- if (result) {
- MessagePlugin.success(t('organization.joinSuccess'))
- showJoinConfirm.value = false
- emit('success')
- handleClose()
- } else {
- MessagePlugin.error(orgStore.error || t('organization.joinFailed'))
- }
- } catch (error: any) {
- MessagePlugin.error(error?.message || t('organization.joinFailed'))
- } finally {
- joining.value = false
- }
-}
-
-// 监听
-watch(() => props.visible, (newVal) => {
- if (newVal) {
- resetForm()
- }
-})
-
-watch(() => props.mode, () => {
- currentSection.value = props.mode === 'create' ? 'basic' : 'join'
-})
-</script>
-
-<style scoped lang="less">
-.settings-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 1000;
- backdrop-filter: blur(4px);
-}
-
-.settings-modal {
- position: relative;
- width: 90vw;
- max-width: 900px;
- height: 80vh;
- max-height: 650px;
- background: var(--td-bg-color-container);
- border-radius: 12px;
- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
- display: flex;
- flex-direction: column;
- overflow: hidden;
-
- &.join-mode {
- max-width: 700px;
- max-height: 580px;
- }
-}
-
-.close-btn {
- position: absolute;
- top: 20px;
- right: 20px;
- width: 32px;
- height: 32px;
- border: none;
- background: var(--td-bg-color-secondarycontainer);
- border-radius: 6px;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--td-text-color-secondary);
- transition: all 0.2s ease;
- z-index: 10;
-
- &:hover {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-text-color-primary);
- }
-}
-
-.settings-container {
- display: flex;
- height: 100%;
- overflow: hidden;
-}
-
-.settings-sidebar {
- width: 200px;
- background: var(--td-bg-color-secondarycontainer);
- border-right: 1px solid var(--td-component-stroke);
- display: flex;
- flex-direction: column;
- flex-shrink: 0;
-}
-
-.sidebar-header {
- padding: 24px 20px;
- border-bottom: 1px solid var(--td-component-stroke);
-}
-
-.sidebar-title {
- margin: 0;
- font-family: var(--app-font-family);
- font-size: 18px;
- font-weight: 600;
- color: var(--td-text-color-primary);
-}
-
-.settings-nav {
- flex: 1;
- padding: 12px 8px;
- overflow-y: auto;
-}
-
-.nav-item {
- display: flex;
- align-items: center;
- padding: 10px 12px;
- margin-bottom: 4px;
- border-radius: 6px;
- cursor: pointer;
- transition: all 0.2s ease;
- font-family: var(--app-font-family);
- font-size: 14px;
- color: var(--td-text-color-secondary);
-
- &:hover {
- background: var(--td-bg-color-container-hover);
- color: var(--td-text-color-primary);
- }
-
- &.active {
- background: var(--td-bg-color-secondarycontainer);
- color: var(--td-brand-color);
- font-weight: 500;
- }
-}
-
-.nav-icon {
- margin-right: 8px;
- font-size: 18px;
- flex-shrink: 0;
-}
-
-.nav-label {
- flex: 1;
-}
-
-.settings-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
-}
-
-.content-wrapper {
- flex: 1;
- overflow-y: auto;
- padding: 24px 32px;
-}
-
-.section {
- margin-bottom: 32px;
-}
-
-.section-content {
- .section-header {
- margin-bottom: 24px;
- }
-
- .section-title {
- margin: 0 0 8px 0;
- font-family: var(--app-font-family);
- font-size: 16px;
- font-weight: 600;
- color: var(--td-text-color-primary);
- }
-
- .section-desc {
- margin: 0;
- font-family: var(--app-font-family);
- font-size: 14px;
- color: var(--td-text-color-placeholder);
- line-height: 22px;
- }
-}
-
-.form-item {
- margin-bottom: 24px;
-
- &:last-child {
- margin-bottom: 0;
- }
-}
-
-.form-label {
- display: block;
- margin-bottom: 8px;
- font-family: var(--app-font-family);
- font-size: 14px;
- font-weight: 500;
- color: var(--td-text-color-primary);
-
- &.required::after {
- content: '*';
- color: var(--td-error-color);
- margin-left: 4px;
- }
-}
-
-.form-tip {
- margin-top: 8px;
- font-size: 12px;
- color: var(--td-text-color-placeholder);
- line-height: 18px;
-}
-
-.name-input-wrapper {
- display: flex;
- align-items: center;
- gap: 12px;
-}
-.name-input-wrapper .name-input {
- flex: 1;
- min-width: 0;
-}
-
-// 权限说明样式
-.permissions-info {
- display: flex;
- flex-direction: column;
- gap: 16px;
-}
-
-.permission-card {
- background: var(--td-bg-color-secondarycontainer);
- border-radius: 8px;
- padding: 16px;
- border: 1px solid var(--td-component-stroke);
-}
-
-.permission-header {
- display: flex;
- align-items: center;
- gap: 12px;
- margin-bottom: 12px;
-}
-
-.permission-icon {
- width: 40px;
- height: 40px;
- border-radius: 8px;
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--td-text-color-anti);
-
- &.admin {
- background: linear-gradient(135deg, var(--td-brand-color), var(--td-brand-color-active));
- }
-
- &.editor {
- background: linear-gradient(135deg, var(--td-warning-color), var(--td-warning-color-active));
- }
-
- &.viewer {
- background: var(--td-bg-color-component-disabled);
- }
-}
-
-.permission-title {
- display: flex;
- align-items: center;
- gap: 8px;
-
- .role-name {
- font-size: 15px;
- font-weight: 600;
- color: var(--td-text-color-primary);
- }
-}
-
-.permission-list {
- margin: 0;
- padding: 0;
- list-style: none;
-
- li {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 6px 0;
- font-size: 13px;
- color: var(--td-text-color-secondary);
- }
-
- .check-icon {
- color: var(--td-brand-color);
- font-size: 14px;
- }
-
- .close-icon {
- color: var(--td-error-color);
- font-size: 14px;
- }
-}
-
-.info-notice {
- display: flex;
- align-items: flex-start;
- gap: 8px;
- margin-top: 20px;
- padding: 12px 16px;
- background: var(--td-brand-color-light);
- border-radius: 8px;
- color: var(--td-brand-color);
- font-size: 13px;
- line-height: 20px;
-
- .t-icon {
- flex-shrink: 0;
- margin-top: 2px;
- }
-}
-
-// 加入组织样式
-.join-illustration {
- text-align: center;
- padding: 24px 0 32px;
-
- .illustration-icon {
- width: 80px;
- height: 80px;
- margin: 0 auto 16px;
- background: linear-gradient(135deg, var(--td-brand-color-light), #07c05f0d);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--td-brand-color);
- }
-
- .illustration-text {
- margin: 0;
- font-size: 14px;
- color: var(--td-text-color-placeholder);
- }
-}
-
-.invite-code-input {
- :deep(.t-input__inner) {
- font-size: 16px;
- letter-spacing: 1px;
- text-align: center;
- }
-}
-
-.join-steps {
- margin-top: 32px;
- padding: 20px;
- background: var(--td-bg-color-secondarycontainer);
- border-radius: 8px;
-
- .step-title {
- font-size: 14px;
- font-weight: 500;
- color: var(--td-text-color-primary);
- margin-bottom: 16px;
- }
-
- .step-list {
- display: flex;
- flex-direction: column;
- gap: 12px;
- }
-
- .step-item {
- display: flex;
- align-items: center;
- gap: 12px;
- }
-
- .step-number {
- width: 24px;
- height: 24px;
- background: var(--td-brand-color);
- color: var(--td-text-color-anti);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 12px;
- font-weight: 600;
- flex-shrink: 0;
- }
-
- .step-text {
- font-size: 13px;
- color: var(--td-text-color-secondary);
- }
-}
-
-.settings-footer {
- padding: 16px 32px;
- border-top: 1px solid var(--td-component-stroke);
- display: flex;
- justify-content: flex-end;
- gap: 12px;
- flex-shrink: 0;
-}
-
-// 过渡动画
-.modal-enter-active,
-.modal-leave-active {
- transition: all 0.3s ease;
-}
-
-.modal-enter-from,
-.modal-leave-to {
- opacity: 0;
-
- .settings-modal {
- transform: scale(0.95);
- }
-}
-
-// 加入确认弹窗样式
-.join-confirm-content {
- padding: 8px 0;
-}
-
-.org-preview-card {
- background: var(--td-bg-color-secondarycontainer);
- border-radius: 8px;
- padding: 16px;
- border: 1px solid var(--td-component-stroke);
-}
-
-.org-preview-header {
- display: flex;
- gap: 12px;
- margin-bottom: 16px;
-}
-
-.org-avatar {
- width: 48px;
- height: 48px;
- background: linear-gradient(135deg, var(--td-brand-color), var(--td-brand-color-active));
- border-radius: 8px;
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--td-text-color-anti);
- flex-shrink: 0;
-}
-
-.org-info {
- flex: 1;
- min-width: 0;
-}
-
-.org-name {
- margin: 0 0 4px 0;
- font-size: 16px;
- font-weight: 600;
- color: var(--td-text-color-primary);
-}
-
-.org-desc {
- margin: 0;
- font-size: 13px;
- color: var(--td-text-color-placeholder);
- line-height: 20px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
-}
-
-.org-stats {
- display: flex;
- gap: 24px;
- padding-top: 12px;
- border-top: 1px solid var(--td-component-stroke);
-}
-
-.stat-item {
- display: flex;
- align-items: center;
- gap: 6px;
- font-size: 13px;
- color: var(--td-text-color-secondary);
-
- .t-icon {
- font-size: 16px;
- color: var(--td-text-color-placeholder);
- }
-
- &.stat-item-agent .stat-agent-icon {
- width: 16px;
- height: 16px;
- flex-shrink: 0;
- }
-}
-
-.already-member-notice {
- display: flex;
- align-items: center;
- gap: 8px;
- margin-top: 16px;
- padding: 12px 16px;
- background: var(--td-brand-color-light);
- border-radius: 8px;
- color: var(--td-brand-color);
- font-size: 14px;
-
- .t-icon {
- font-size: 18px;
- color: var(--td-brand-color);
- }
-}
-</style>
diff --git a/frontend/src/views/platform/RoutePlaceholder.vue b/frontend/src/views/platform/RoutePlaceholder.vue
deleted file mode 100644
index fb1355c85..000000000
--- a/frontend/src/views/platform/RoutePlaceholder.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-<template><div class="route-placeholder" aria-hidden="true" /></template>
-
-<style scoped>
-.route-placeholder {
- display: none;
-}
-</style>
diff --git a/frontend/src/views/settings/ParserEngineSettings.vue b/frontend/src/views/settings/ParserEngineSettings.vue
index d0c6739ca..9251f3eef 100644
--- a/frontend/src/views/settings/ParserEngineSettings.vue
+++ b/frontend/src/views/settings/ParserEngineSettings.vue
@@ -1161,8 +1161,8 @@ onMounted(loadAll)
</style>
<!--
- Non-scoped block: per-engine header-icon coloring. Same approach as
- StorageEngineSettings — keep these rules global so they always apply
+ Non-scoped block: per-engine header-icon coloring. Keep these rules global
+ so they always apply
regardless of whether the drawer panel inherits the parent's scoped
data attributes. Each rule mirrors the matching .engine-card--{name}
.engine-card__badge from the scoped block above.
diff --git a/frontend/src/views/settings/Settings.vue b/frontend/src/views/settings/Settings.vue
index dbceb495b..57168e3e5 100644
--- a/frontend/src/views/settings/Settings.vue
+++ b/frontend/src/views/settings/Settings.vue
@@ -151,7 +151,7 @@
<!-- 存储引擎 -->
<div v-if="currentSection === 'storage'" class="section">
- <StorageEngineSettings />
+ <StorageBackendSettings />
</div>
<!-- 沙箱 -->
@@ -249,7 +249,7 @@ import EnvVarSettings from './EnvVarSettings.vue'
import MemoryWorkspaceSettings from './MemoryWorkspaceSettings.vue'
import VectorStoreSettings from './VectorStoreSettings.vue'
import ParserEngineSettings from './ParserEngineSettings.vue'
-import StorageEngineSettings from './StorageBackendSettings.vue'
+import StorageBackendSettings from './StorageBackendSettings.vue'
import SandboxSettings from './SandboxSettings.vue'
import SkillSettings from './SkillSettings.vue'
import WeKnoraCloudSettings from './WeKnoraCloudSettings.vue'
diff --git a/frontend/src/views/settings/StorageEngineSettings.vue b/frontend/src/views/settings/StorageEngineSettings.vue
deleted file mode 100644
index 26161621a..000000000
--- a/frontend/src/views/settings/StorageEngineSettings.vue
+++ /dev/null
@@ -1,1687 +0,0 @@
-<template>
- <div class="storage-engine-settings">
- <div class="section-header">
- <h2>{{ $t('settings.storage.title') }}</h2>
- <p class="section-description">
- {{ $t('settings.storage.description') }}
- </p>
- </div>
-
- <div v-if="loading" class="loading-state">
- <t-loading size="small" />
- <span>{{ $t('settings.storage.loading') }}</span>
- </div>
-
- <div v-else-if="error" class="error-inline">
- <t-alert theme="error" :message="error">
- <template #operation>
- <t-button size="small" @click="loadAll">{{ $t('settings.storage.retry') }}</t-button>
- </template>
- </t-alert>
- </div>
-
- <template v-else>
- <div class="settings-group">
- <div class="setting-row">
- <div class="setting-info">
- <label>{{ $t('settings.storage.defaultEngine') }}</label>
- <p class="desc">{{ $t('settings.storage.defaultEngineDesc') }}</p>
- </div>
- <div class="setting-control">
- <t-select
- v-model="config.default_provider"
- style="width: 280px;"
- :placeholder="$t('settings.storage.defaultEngine')"
- :disabled="!hasAllowedProviders"
- @change="onSaveDefaultEngine"
- >
- <t-option
- v-for="opt in providerOptions"
- :key="opt.value"
- :value="opt.value"
- :label="opt.label"
- :disabled="!opt.allowed"
- />
- </t-select>
- <span v-if="saveMessage && !drawerVisible" :class="['save-msg', saveSuccess ? 'success' : 'error']" style="margin-left: 12px;">
- {{ saveMessage }}
- </span>
- </div>
- </div>
- </div>
-
- <!-- 与其它 settings 列表同形:左侧 monogram 徽章 + 标题 + 状态徽 + 描述。
- 整张卡是一个 button,单击打开配置抽屉;当前抽屉对应的卡获得品牌色描边。
- 原本 8 张手写卡片由统一的 STORAGE_PROVIDERS 数组驱动,把状态判定收敛到
- providerStatus(),新增 provider 时只需在数组里加一项 + 翻译键即可。 -->
- <div class="engine-cards">
- <button
- v-for="provider in STORAGE_PROVIDERS"
- v-show="isProviderAllowed(provider.id)"
- :key="provider.id"
- type="button"
- class="engine-card"
- :class="[
- `engine-card--${provider.id}`,
- { 'engine-card--active': drawerVisible && currentEngine === provider.id }
- ]"
- @click="openDrawer(provider.id)"
- >
- <div
- class="engine-card__badge"
- :class="badgeClass(provider.id)"
- :style="badgeStyle(provider.id)"
- :aria-label="provider.id"
- >
- <img
- v-if="resolveLogo(provider.id)?.mode === 'color'"
- :src="resolveLogo(provider.id)!.url"
- :alt="provider.id"
- class="engine-card__badge-img"
- />
- <template v-else-if="!resolveLogo(provider.id)">{{ providerInitial(provider.id) }}</template>
- </div>
- <div class="engine-card__body">
- <div class="engine-card__header">
- <h3 class="engine-card__title">{{ providerTitle(provider.id) }}</h3>
- <span
- class="engine-card__status"
- :class="`engine-card__status--${providerStatus(provider.id).kind}`"
- >
- <span class="engine-card__status-dot" />
- {{ providerStatus(provider.id).label }}
- </span>
- </div>
- <p class="engine-card__desc">{{ $t(`settings.storage.${provider.id}Desc`) }}</p>
- </div>
- </button>
- </div>
- </template>
-
- <!-- 配置抽屉 — SettingDrawer 包装,与 ModelEditorDialog / ParserEngineSettings 同款 -->
- <SettingDrawer
- v-model:visible="drawerVisible"
- :title="drawerTitle"
- :class="currentEngine ? `storage-engine-drawer storage-engine-drawer--${currentEngine}` : 'storage-engine-drawer'"
- :hide-footer="!authStore.hasRole('admin') && !needsTestButton"
- :confirm-loading="saving"
- @confirm="onSave"
- @cancel="drawerVisible = false"
- >
- <!--
- Header icon — 复用列表卡片同款 logo / 配色徽章。
- - color logo(如 MinIO/AWS): 直接 <img>,保留品牌彩色
- - mono logo(mask-image): 通过 ::before + currentColor 染色,颜色由
- .storage-engine-drawer--{id} :deep(.setting-drawer__header-icon) 决定
- - 无 logo: 渲染首字母作为 monogram
- -->
- <template v-if="currentEngine" #headerIcon>
- <img
- v-if="currentLogo?.mode === 'color'"
- :src="currentLogo.url"
- :alt="currentEngine"
- class="header-icon__img"
- />
- <span
- v-else-if="currentLogo?.mode === 'mono'"
- class="header-icon__mono"
- :style="monoLogoStyle"
- />
- <span v-else class="header-icon__text">{{ providerInitial(currentEngine as StorageProviderId) }}</span>
- </template>
-
- <!-- 副标题:引擎描述 + inline 控制台/文档外链(若有) -->
- <template v-if="currentEngine" #subtitle>
- <span>{{ engineDescText }}</span>
- <template v-for="link in engineLinks" :key="link.url">
- <a :href="link.url" target="_blank" rel="noopener" class="doc-link doc-link--inline">
- {{ link.label }}
- <t-icon name="link" class="link-icon" />
- </a>
- </template>
- </template>
-
- <!-- 测试连接挪到 footer-left(local 不需要) -->
- <template v-if="needsTestButton" #footer-left>
- <t-button
- variant="outline"
- :loading="currentCheckState.loading"
- @click="currentCheckState.onCheck"
- >
- <template #icon>
- <t-icon
- v-if="!currentCheckState.loading && currentCheckState.result?.ok"
- name="check-circle-filled"
- class="status-icon available"
- />
- <t-icon
- v-else-if="!currentCheckState.loading && currentCheckState.result && !currentCheckState.result.ok"
- name="close-circle-filled"
- class="status-icon unavailable"
- />
- </template>
- {{ $t('settings.storage.testConnection') }}
- </t-button>
- <span
- v-if="currentCheckState.result"
- :class="[
- 'footer-test-message',
- currentCheckState.result.ok
- ? ((currentCheckState.result as { bucket_created?: boolean }).bucket_created ? 'created' : 'success')
- : 'error'
- ]"
- :title="currentCheckState.result.message"
- >
- {{ currentCheckState.result.message }}
- </span>
- </template>
-
- <div v-if="currentEngine">
- <!-- ===== local ===== -->
- <template v-if="currentEngine === 'local'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.basicSection', '基本配置') }}</h4>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input
- v-model="config.local.path_prefix"
- :placeholder="$t('settings.storage.pathPrefixPlaceholder')"
- clearable
- />
- </div>
- </section>
- </template>
-
- <!-- ===== minio ===== -->
- <template v-else-if="currentEngine === 'minio'">
- <!-- Section 1 — 部署模式(Docker / 远程) -->
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.modeSection', '部署模式') }}</h4>
- <div class="form-item">
- <div class="source-options" role="radiogroup">
- <button
- type="button"
- class="source-option"
- :class="{ 'is-active': config.minio.mode !== 'remote' }"
- @click="config.minio.mode = 'docker'"
- >
- <t-icon name="server" class="source-option__icon" />
- <span class="source-option__label">{{ $t('settings.storage.minioDocker') }}</span>
- </button>
- <button
- type="button"
- class="source-option"
- :class="{ 'is-active': config.minio.mode === 'remote' }"
- @click="config.minio.mode = 'remote'"
- >
- <t-icon name="cloud" class="source-option__icon" />
- <span class="source-option__label">{{ $t('settings.storage.minioRemote') }}</span>
- </button>
- </div>
-
- <!-- Docker 模式状态提示 inline-alert -->
- <div v-if="config.minio.mode !== 'remote'" class="inline-alert"
- :class="minioEnvAvailable ? 'inline-alert--ok' : 'inline-alert--warn'">
- <t-icon
- :name="minioEnvAvailable ? 'check-circle-filled' : 'error-circle-filled'"
- class="inline-alert__icon"
- />
- <span class="inline-alert__text">
- {{ minioEnvAvailable ? $t('settings.storage.minioDockerDetected') : $t('settings.storage.minioDockerNotDetected') }}
- </span>
- </div>
-
- <div v-else class="inline-alert">
- <t-icon name="info-circle-filled" class="inline-alert__icon" />
- <span class="inline-alert__text">{{ $t('settings.storage.minioRemoteHint') }}</span>
- </div>
- </div>
- </section>
-
- <!-- Section 2 — 远程模式凭证(仅 remote) -->
- <section v-if="config.minio.mode === 'remote'" class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <div class="form-item">
- <label class="form-label required">Endpoint</label>
- <t-input v-model="config.minio.endpoint" placeholder="e.g. minio.example.com:9000" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">Access Key ID</label>
- <t-input v-model="config.minio.access_key_id" placeholder="MinIO Access Key" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">Secret Access Key</label>
- <t-input v-model="config.minio.secret_access_key" type="password" placeholder="MinIO Secret Key" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- </section>
-
- <!-- Section 3 — Bucket 与选项 -->
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input
- v-model="config.minio.bucket_name"
- :placeholder="$t('settings.storage.bucketPlaceholder')"
- :disabled="config.minio.mode !== 'remote' && !minioEnvAvailable"
- clearable
- />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input
- v-model="config.minio.path_prefix"
- :placeholder="$t('settings.storage.prefixPlaceholder')"
- clearable
- />
- </div>
- <div class="form-item">
- <label class="form-label">SSL</label>
- <div class="vision-toggle">
- <t-switch v-model="config.minio.use_ssl" />
- <span class="form-desc form-desc--inline">{{ $t('settings.storage.useSslDesc', '通过 HTTPS 访问 MinIO') }}</span>
- </div>
- </div>
- </section>
- </template>
-
- <!-- ===== cos ===== -->
- <template v-else-if="currentEngine === 'cos'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <div class="form-item">
- <label class="form-label required">Secret ID</label>
- <t-input v-model="config.cos.secret_id" :placeholder="$t('settings.storage.cosSecretIdPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">Secret Key</label>
- <t-input v-model="config.cos.secret_key" type="password" :placeholder="$t('settings.storage.cosSecretKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">App ID</label>
- <t-input v-model="config.cos.app_id" :placeholder="$t('settings.storage.cosAppIdPlaceholder')" clearable />
- </div>
- </section>
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label required">Region</label>
- <t-input v-model="config.cos.region" placeholder="e.g. ap-guangzhou" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input v-model="config.cos.bucket_name" :placeholder="$t('settings.storage.bucketPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input v-model="config.cos.path_prefix" :placeholder="$t('settings.storage.prefixPlaceholder')" clearable />
- </div>
- </section>
- </template>
-
- <!-- ===== tos ===== -->
- <template v-else-if="currentEngine === 'tos'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <div class="form-item">
- <label class="form-label required">Access Key</label>
- <t-input v-model="config.tos.access_key" :placeholder="$t('settings.storage.tosAccessKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">Secret Key</label>
- <t-input v-model="config.tos.secret_key" type="password" :placeholder="$t('settings.storage.tosSecretKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- </section>
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label required">Endpoint</label>
- <t-input v-model="config.tos.endpoint" placeholder="e.g. https://tos-cn-beijing.volces.com" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">Region</label>
- <t-input v-model="config.tos.region" placeholder="e.g. cn-beijing" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input v-model="config.tos.bucket_name" :placeholder="$t('settings.storage.bucketPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input v-model="config.tos.path_prefix" :placeholder="$t('settings.storage.prefixPlaceholder')" clearable />
- </div>
- </section>
- </template>
-
- <!-- ===== s3 ===== -->
- <template v-else-if="currentEngine === 's3'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <p class="form-desc">{{ $t('settings.storage.s3DefaultCredentialsHint') }}</p>
- <div class="form-item">
- <label class="form-label">Access Key</label>
- <t-input v-model="config.s3.access_key" :placeholder="$t('settings.storage.s3AccessKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label">Secret Key</label>
- <t-input v-model="config.s3.secret_key" type="password" :placeholder="$t('settings.storage.s3SecretKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- </section>
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label">Endpoint</label>
- <t-input v-model="config.s3.endpoint" :placeholder="$t('settings.storage.s3EndpointPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">Region</label>
- <t-input v-model="config.s3.region" placeholder="e.g. us-east-1" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input v-model="config.s3.bucket_name" :placeholder="$t('settings.storage.bucketPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input v-model="config.s3.path_prefix" :placeholder="$t('settings.storage.prefixPlaceholder')" clearable />
- </div>
- </section>
- </template>
-
- <!-- ===== oss ===== -->
- <template v-else-if="currentEngine === 'oss'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <div class="form-item">
- <label class="form-label required">Access Key</label>
- <t-input v-model="config.oss.access_key" :placeholder="$t('settings.storage.ossAccessKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">Secret Key</label>
- <t-input v-model="config.oss.secret_key" type="password" :placeholder="$t('settings.storage.ossSecretKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- </section>
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label required">Endpoint</label>
- <t-input v-model="config.oss.endpoint" placeholder="e.g. https://oss-cn-hangzhou.aliyuncs.com" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">Region</label>
- <t-input v-model="config.oss.region" placeholder="e.g. cn-hangzhou" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input v-model="config.oss.bucket_name" :placeholder="$t('settings.storage.bucketPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input v-model="config.oss.path_prefix" :placeholder="$t('settings.storage.prefixPlaceholder')" clearable />
- </div>
- </section>
- </template>
-
- <!-- ===== ks3 ===== -->
- <template v-else-if="currentEngine === 'ks3'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <div class="form-item">
- <label class="form-label required">Access Key</label>
- <t-input v-model="config.ks3.access_key" :placeholder="$t('settings.storage.ks3AccessKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">Secret Key</label>
- <t-input v-model="config.ks3.secret_key" type="password" :placeholder="$t('settings.storage.ks3SecretKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- </section>
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label required">Endpoint</label>
- <t-input v-model="config.ks3.endpoint" :placeholder="$t('settings.storage.ks3EndpointPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">Region</label>
- <t-input v-model="config.ks3.region" :placeholder="$t('settings.storage.ks3RegionPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input v-model="config.ks3.bucket_name" :placeholder="$t('settings.storage.bucketPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input v-model="config.ks3.path_prefix" :placeholder="$t('settings.storage.prefixPlaceholder')" clearable />
- </div>
- </section>
- </template>
-
- <!-- ===== obs ===== -->
- <template v-else-if="currentEngine === 'obs'">
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.credentialsSection', '凭证') }}</h4>
- <div class="form-item">
- <label class="form-label required">Access Key</label>
- <t-input v-model="config.obs.access_key" :placeholder="$t('settings.storage.obsAccessKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- <div class="form-item">
- <label class="form-label required">Secret Key</label>
- <t-input v-model="config.obs.secret_key" type="password" :placeholder="$t('settings.storage.obsSecretKeyPlaceholder')" clearable>
- <template #prefix-icon><t-icon name="lock-on" /></template>
- </t-input>
- </div>
- </section>
- <section class="setting-drawer__section">
- <h4 class="setting-drawer__section-title">{{ $t('settings.storage.bucketSection', 'Bucket') }}</h4>
- <div class="form-item">
- <label class="form-label required">Endpoint</label>
- <t-input v-model="config.obs.endpoint" :placeholder="$t('settings.storage.obsEndpointPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">Region</label>
- <t-input v-model="config.obs.region" :placeholder="$t('settings.storage.obsRegionPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label required">{{ $t('settings.storage.bucketName') }}</label>
- <t-input v-model="config.obs.bucket_name" :placeholder="$t('settings.storage.bucketPlaceholder')" clearable />
- </div>
- <div class="form-item">
- <label class="form-label">{{ $t('settings.storage.pathPrefix') }}</label>
- <t-input v-model="config.obs.path_prefix" :placeholder="$t('settings.storage.prefixPlaceholder')" clearable />
- </div>
- </section>
- </template>
- </div>
- </SettingDrawer>
- </div>
-</template>
-
-<script setup lang="ts">
-import { computed, onMounted, ref } from 'vue'
-import { useI18n } from 'vue-i18n'
-import {
- checkStorageEngine,
- getStorageEngineConfig,
- getStorageEngineStatus,
- updateStorageEngineConfig,
- type StorageEngineConfig,
-} from '@/api/system'
-import { useAuthStore } from '@/stores/auth'
-import { providerLogo } from './providerLogos'
-import SettingDrawer from '@/components/settings/SettingDrawer.vue'
-
-const { t } = useI18n()
-const authStore = useAuthStore()
-
-const defaultConfig = (): StorageEngineConfig => ({
- default_provider: 'local',
- local: { path_prefix: '' },
- minio: { mode: 'docker', endpoint: '', access_key_id: '', secret_access_key: '', bucket_name: '', use_ssl: false, path_prefix: '' },
- cos: { secret_id: '', secret_key: '', region: '', bucket_name: '', app_id: '', path_prefix: '' },
- tos: { endpoint: '', region: '', access_key: '', secret_key: '', bucket_name: '', path_prefix: '' },
- s3: { endpoint: '', region: '', access_key: '', secret_key: '', bucket_name: '', path_prefix: '' },
- oss: {
- endpoint: '',
- region: '',
- access_key: '',
- secret_key: '',
- bucket_name: '',
- path_prefix: '',
- use_temp_bucket: false,
- temp_bucket_name: '',
- temp_region: '',
- },
- ks3: {
- endpoint: '',
- region: '',
- access_key: '',
- secret_key: '',
- bucket_name: '',
- path_prefix: '',
- },
- obs: {
- endpoint: '',
- region: '',
- access_key: '',
- secret_key: '',
- bucket_name: '',
- path_prefix: '',
- },
-})
-
-const loading = ref(true)
-const error = ref('')
-const config = ref<StorageEngineConfig>(defaultConfig())
-const allowedProviders = ref<string[] | null>(null)
-const engineStatus = ref<{ local: boolean; minio: boolean; cos: boolean }>({ local: true, minio: false, cos: true })
-const minioEnvAvailable = ref(false)
-const saving = ref(false)
-const saveMessage = ref('')
-const saveSuccess = ref(false)
-
-const checkingMinio = ref(false)
-const minioCheckResult = ref<{ ok: boolean; message: string; bucket_created?: boolean } | null>(null)
-const checkingCos = ref(false)
-const cosCheckResult = ref<{ ok: boolean; message: string } | null>(null)
-const checkingTos = ref(false)
-const tosCheckResult = ref<{ ok: boolean; message: string } | null>(null)
-const checkingS3 = ref(false)
-const s3CheckResult = ref<{ ok: boolean; message: string } | null>(null)
-const checkingOss = ref(false)
-const ossCheckResult = ref<{ ok: boolean; message: string } | null>(null)
-const checkingKs3 = ref(false)
-const ks3CheckResult = ref<{ ok: boolean; message: string } | null>(null)
-const checkingObs = ref(false)
-const obsCheckResult = ref<{ ok: boolean; message: string } | null>(null)
-
-const drawerVisible = ref(false)
-const currentEngine = ref<string | null>(null)
-
-const providerOptions = computed(() => [
- { value: 'local', label: t('settings.storage.engineLocal'), allowed: isProviderAllowed('local') },
- { value: 'minio', label: 'MinIO', allowed: isProviderAllowed('minio') },
- { value: 'cos', label: t('settings.storage.engineCos'), allowed: isProviderAllowed('cos') },
- { value: 'tos', label: t('settings.storage.engineTos'), allowed: isProviderAllowed('tos') },
- { value: 's3', label: 'AWS S3', allowed: isProviderAllowed('s3') },
- { value: 'oss', label: t('settings.storage.engineOss'), allowed: isProviderAllowed('oss') },
- { value: 'ks3', label: t('settings.storage.engineKs3'), allowed: isProviderAllowed('ks3') },
- { value: 'obs', label: t('settings.storage.engineObs'), allowed: isProviderAllowed('obs') },
-])
-
-const hasAllowedProviders = computed(() => (allowedProviders.value?.length ?? 0) > 0)
-
-const currentCheckState = computed(() => {
- switch (currentEngine.value) {
- case 'minio':
- return { loading: checkingMinio.value, result: minioCheckResult.value, onCheck: onCheckMinio }
- case 'cos':
- return { loading: checkingCos.value, result: cosCheckResult.value, onCheck: onCheckCos }
- case 'tos':
- return { loading: checkingTos.value, result: tosCheckResult.value, onCheck: onCheckTos }
- case 's3':
- return { loading: checkingS3.value, result: s3CheckResult.value, onCheck: onCheckS3 }
- case 'oss':
- return { loading: checkingOss.value, result: ossCheckResult.value, onCheck: onCheckOss }
- case 'ks3':
- return { loading: checkingKs3.value, result: ks3CheckResult.value, onCheck: onCheckKs3 }
- case 'obs':
- return { loading: checkingObs.value, result: obsCheckResult.value, onCheck: onCheckObs }
- default:
- return { loading: false, result: null, onCheck: () => undefined }
- }
-})
-
-const drawerTitle = computed(() => {
- if (!currentEngine.value) return ''
- const titles: Record<string, string> = {
- local: t('settings.storage.localTitle'),
- minio: 'MinIO',
- cos: t('settings.storage.cosTitle'),
- tos: t('settings.storage.tosTitle'),
- s3: t('settings.storage.s3Title'),
- oss: t('settings.storage.ossTitle'),
- ks3: t('settings.storage.ks3Title'),
- obs: t('settings.storage.obsTitle'),
- }
- return titles[currentEngine.value] || currentEngine.value
-})
-
-// SettingDrawer 头部图标 — 走列表卡片同款 logo(color / mono / fallback)。
-// providerLogo 已经处理了 storage 域内每个 id 的 logo URL + 模式。
-const currentLogo = computed(() => {
- if (!currentEngine.value) return null
- return providerLogo('storage', currentEngine.value as StorageProviderId)
-})
-
-// Inline style for the mono mask span. We expose it as a computed instead
-// of inlining the literal in the template because Vue's template parser
-// chokes on the nested-quote pattern (template-literal inside an object
-// literal inside a v-bind expression).
-const monoLogoStyle = computed((): Record<string, string> => {
- const logo = currentLogo.value
- if (!logo || logo.mode !== 'mono') return {}
- return { '--logo-url': `url("${logo.url}")` }
-})
-
-// 引擎描述(副标题主体文本)。
-const engineDescText = computed((): string => {
- if (!currentEngine.value) return ''
- const key = `settings.storage.${currentEngine.value}Desc`
- const translated = t(key)
- return translated !== key ? translated : ''
-})
-
-// 控制台 / 文档外链 — 副标题尾部 inline 显示,与 ParserEngineSettings
-// 同款。各 provider 的 console / docs 链接来自原模板里的硬编码地址。
-const ENGINE_LINK_TABLE: Record<string, { console?: string; docs?: string }> = {
- cos: {
- console: 'https://console.cloud.tencent.com/cos',
- docs: 'https://cloud.tencent.com/document/product/436',
- },
- tos: {
- console: 'https://console.volcengine.com/tos',
- docs: 'https://www.volcengine.com/docs/6349',
- },
- s3: {
- console: 'https://aws.amazon.com/s3/',
- docs: 'https://docs.aws.amazon.com/s3/',
- },
- oss: {
- console: 'https://oss.console.aliyun.com/',
- docs: 'https://help.aliyun.com/zh/oss/',
- },
- obs: {
- console: 'https://obs.huaweicloud.com/',
- docs: 'https://support.huaweicloud.com/obs/',
- },
-}
-
-const engineLinks = computed((): Array<{ label: string; url: string }> => {
- if (!currentEngine.value) return []
- const links = ENGINE_LINK_TABLE[currentEngine.value]
- if (!links) return []
- const result: Array<{ label: string; url: string }> = []
- if (links.console) result.push({ label: t('settings.storage.console'), url: links.console })
- if (links.docs) result.push({ label: t('settings.storage.docs'), url: links.docs })
- return result
-})
-
-// 是否在 footer 显示"测试连接"按钮 — 本地直接读写文件系统,无连接概念,
-// 跳过;其余 provider 都需要远程 endpoint,必须能测。
-const needsTestButton = computed(() => {
- return !!currentEngine.value && currentEngine.value !== 'local'
-})
-
-const minioAvailable = computed(() => {
- if (config.value.minio?.mode === 'remote') {
- return !!(config.value.minio.endpoint && config.value.minio.access_key_id && config.value.minio.secret_access_key)
- }
- return minioEnvAvailable.value
-})
-
-// Single source-of-truth for the cards列 + 状态/标题查询。新增 provider 时
-// 在数组里加一项 + 翻译键即可,模板 v-for 自动跟进。
-type StorageProviderId = 'local' | 'minio' | 'cos' | 'tos' | 's3' | 'oss' | 'ks3' | 'obs'
-const STORAGE_PROVIDERS: { id: StorageProviderId }[] = [
- { id: 'local' },
- { id: 'minio' },
- { id: 'cos' },
- { id: 'tos' },
- { id: 's3' },
- { id: 'oss' },
- { id: 'ks3' },
- { id: 'obs' },
-]
-
-const providerTitle = (id: StorageProviderId): string => {
- if (id === 'minio') return 'MinIO'
- if (id === 's3') return 'AWS S3'
- return t(`settings.storage.${id}Title`)
-}
-
-const providerInitial = (id: StorageProviderId): string => {
- return providerTitle(id).trim().charAt(0).toUpperCase() || '?'
-}
-
-// 见 VectorStoreSettings 的同名注释:返回 --logo-url 给 ::before 用 mask 渲染。
-const resolveLogo = (id: StorageProviderId) => providerLogo('storage', id)
-
-const badgeClass = (id: StorageProviderId) => {
- const m = resolveLogo(id)?.mode
- return {
- 'engine-card__badge--logo': !!m,
- 'engine-card__badge--color': m === 'color',
- 'engine-card__badge--mono': m === 'mono',
- }
-}
-
-const badgeStyle = (id: StorageProviderId): Record<string, string> => {
- const logo = resolveLogo(id)
- return logo?.mode === 'mono' ? { '--logo-url': `url("${logo.url}")` } : {}
-}
-
-const providerStatus = (id: StorageProviderId): { kind: 'on' | 'off'; label: string } => {
- if (id === 'minio' && !minioAvailable.value) {
- return { kind: 'off', label: t('settings.storage.needsConfig') }
- }
- if (id === 'local' || id === 'minio') {
- return { kind: 'on', label: t('settings.storage.available') }
- }
- return { kind: 'on', label: t('settings.storage.configurable') }
-}
-
-function isProviderAllowed(provider: string) {
- if (allowedProviders.value === null) return true
- return allowedProviders.value.includes(provider)
-}
-
-function ensureAllowedDefaultProvider() {
- if (isProviderAllowed(config.value.default_provider)) return
- config.value.default_provider = allowedProviders.value?.[0] || 'local'
-}
-
-function openDrawer(engine: string) {
- if (!isProviderAllowed(engine)) return
- currentEngine.value = engine
- drawerVisible.value = true
- saveMessage.value = ''
- minioCheckResult.value = null
- cosCheckResult.value = null
- tosCheckResult.value = null
- s3CheckResult.value = null
- ossCheckResult.value = null
- ks3CheckResult.value = null
- obsCheckResult.value = null
-}
-
-async function loadConfig() {
- try {
- const res = await getStorageEngineConfig()
- const d = res?.data
- if (d) {
- config.value = {
- default_provider: d.default_provider || 'local',
- local: d.local ? { path_prefix: d.local.path_prefix || '' } : { path_prefix: '' },
- minio: d.minio
- ? {
- mode: d.minio.mode || 'docker',
- endpoint: d.minio.endpoint || '',
- access_key_id: d.minio.access_key_id || '',
- secret_access_key: d.minio.secret_access_key || '',
- bucket_name: d.minio.bucket_name || '',
- use_ssl: d.minio.use_ssl ?? false,
- path_prefix: d.minio.path_prefix || '',
- }
- : defaultConfig().minio,
- cos: d.cos
- ? {
- secret_id: d.cos.secret_id || '',
- secret_key: d.cos.secret_key || '',
- region: d.cos.region || '',
- bucket_name: d.cos.bucket_name || '',
- app_id: d.cos.app_id || '',
- path_prefix: d.cos.path_prefix || '',
- }
- : defaultConfig().cos,
- tos: d.tos
- ? {
- endpoint: d.tos.endpoint || '',
- region: d.tos.region || '',
- access_key: d.tos.access_key || '',
- secret_key: d.tos.secret_key || '',
- bucket_name: d.tos.bucket_name || '',
- path_prefix: d.tos.path_prefix || '',
- }
- : defaultConfig().tos,
- s3: d.s3
- ? {
- endpoint: d.s3.endpoint || '',
- region: d.s3.region || '',
- access_key: d.s3.access_key || '',
- secret_key: d.s3.secret_key || '',
- bucket_name: d.s3.bucket_name || '',
- path_prefix: d.s3.path_prefix || '',
- }
- : defaultConfig().s3,
- oss: d.oss
- ? {
- endpoint: d.oss.endpoint || '',
- region: d.oss.region || '',
- access_key: d.oss.access_key || '',
- secret_key: d.oss.secret_key || '',
- bucket_name: d.oss.bucket_name || '',
- path_prefix: d.oss.path_prefix || '',
- use_temp_bucket: d.oss.use_temp_bucket ?? false,
- temp_bucket_name: d.oss.temp_bucket_name || '',
- temp_region: d.oss.temp_region || '',
- }
- : defaultConfig().oss,
- ks3: d.ks3
- ? {
- endpoint: d.ks3.endpoint || '',
- region: d.ks3.region || '',
- access_key: d.ks3.access_key || '',
- secret_key: d.ks3.secret_key || '',
- bucket_name: d.ks3.bucket_name || '',
- path_prefix: d.ks3.path_prefix || '',
- }
- : defaultConfig().ks3,
- obs: d.obs
- ? {
- endpoint: d.obs.endpoint || '',
- region: d.obs.region || '',
- access_key: d.obs.access_key || '',
- secret_key: d.obs.secret_key || '',
- bucket_name: d.obs.bucket_name || '',
- path_prefix: d.obs.path_prefix || '',
- }
- : defaultConfig().obs,
- }
- }
- } catch {
- config.value = defaultConfig()
- }
-}
-
-async function loadStatus() {
- try {
- const res = await getStorageEngineStatus()
- const engines = res?.data?.engines ?? []
- allowedProviders.value = res?.data?.allowed_providers?.length
- ? res.data.allowed_providers
- : engines.filter(e => e.allowed !== false).map(e => e.name)
- const status = { local: true, minio: false, cos: true }
- for (const e of engines) {
- if (e.name === 'local') status.local = e.available
- if (e.name === 'minio') status.minio = e.available
- if (e.name === 'cos') status.cos = e.available
- }
- engineStatus.value = status
- minioEnvAvailable.value = res?.data?.minio_env_available ?? false
- } catch {
- engineStatus.value = { local: true, minio: false, cos: true }
- allowedProviders.value = ['local', 'minio', 'cos', 'tos', 's3', 'oss']
- minioEnvAvailable.value = false
- }
-}
-
-async function loadAll() {
- loading.value = true
- error.value = ''
- try {
- await Promise.all([loadConfig(), loadStatus()])
- ensureAllowedDefaultProvider()
- } catch (e: unknown) {
- error.value = e instanceof Error ? e.message : t('settings.storage.loadFailed')
- } finally {
- loading.value = false
- }
-}
-
-function buildPayload(): StorageEngineConfig {
- const mode = config.value.minio?.mode || 'docker'
- return {
- default_provider: config.value.default_provider || 'local',
- local: { path_prefix: (config.value.local?.path_prefix || '').trim() },
- minio: {
- mode,
- endpoint: mode === 'remote' ? (config.value.minio?.endpoint || '').trim() : '',
- access_key_id: mode === 'remote' ? (config.value.minio?.access_key_id || '').trim() : '',
- secret_access_key: mode === 'remote' ? (config.value.minio?.secret_access_key || '').trim() : '',
- bucket_name: (config.value.minio?.bucket_name || '').trim(),
- use_ssl: config.value.minio?.use_ssl ?? false,
- path_prefix: (config.value.minio?.path_prefix || '').trim(),
- },
- cos: {
- secret_id: (config.value.cos?.secret_id || '').trim(),
- secret_key: (config.value.cos?.secret_key || '').trim(),
- region: (config.value.cos?.region || '').trim(),
- bucket_name: (config.value.cos?.bucket_name || '').trim(),
- app_id: (config.value.cos?.app_id || '').trim(),
- path_prefix: (config.value.cos?.path_prefix || '').trim(),
- },
- tos: {
- endpoint: (config.value.tos?.endpoint || '').trim(),
- region: (config.value.tos?.region || '').trim(),
- access_key: (config.value.tos?.access_key || '').trim(),
- secret_key: (config.value.tos?.secret_key || '').trim(),
- bucket_name: (config.value.tos?.bucket_name || '').trim(),
- path_prefix: (config.value.tos?.path_prefix || '').trim(),
- },
- s3: {
- endpoint: (config.value.s3?.endpoint || '').trim(),
- region: (config.value.s3?.region || '').trim(),
- access_key: (config.value.s3?.access_key || '').trim(),
- secret_key: (config.value.s3?.secret_key || '').trim(),
- bucket_name: (config.value.s3?.bucket_name || '').trim(),
- path_prefix: (config.value.s3?.path_prefix || '').trim(),
- },
- oss: {
- endpoint: (config.value.oss?.endpoint || '').trim(),
- region: (config.value.oss?.region || '').trim(),
- access_key: (config.value.oss?.access_key || '').trim(),
- secret_key: (config.value.oss?.secret_key || '').trim(),
- bucket_name: (config.value.oss?.bucket_name || '').trim(),
- path_prefix: (config.value.oss?.path_prefix || '').trim(),
- use_temp_bucket: config.value.oss?.use_temp_bucket ?? false,
- temp_bucket_name: (config.value.oss?.temp_bucket_name || '').trim(),
- temp_region: (config.value.oss?.temp_region || '').trim(),
- },
- ks3: {
- endpoint: (config.value.ks3?.endpoint || '').trim(),
- region: (config.value.ks3?.region || '').trim(),
- access_key: (config.value.ks3?.access_key || '').trim(),
- secret_key: (config.value.ks3?.secret_key || '').trim(),
- bucket_name: (config.value.ks3?.bucket_name || '').trim(),
- path_prefix: (config.value.ks3?.path_prefix || '').trim(),
- },
- obs: {
- endpoint: (config.value.obs?.endpoint || '').trim(),
- region: (config.value.obs?.region || '').trim(),
- access_key: (config.value.obs?.access_key || '').trim(),
- secret_key: (config.value.obs?.secret_key || '').trim(),
- bucket_name: (config.value.obs?.bucket_name || '').trim(),
- path_prefix: (config.value.obs?.path_prefix || '').trim(),
- },
- }
-}
-
-async function onSave() {
- saving.value = true
- saveMessage.value = ''
- try {
- ensureAllowedDefaultProvider()
- await updateStorageEngineConfig(buildPayload())
- await loadStatus()
- ensureAllowedDefaultProvider()
- saveSuccess.value = true
- saveMessage.value = t('settings.storage.saveSuccess')
- drawerVisible.value = false
- } catch (e: unknown) {
- saveSuccess.value = false
- saveMessage.value = e instanceof Error ? e.message : t('settings.storage.saveFailed')
- } finally {
- saving.value = false
- }
-}
-
-async function onSaveDefaultEngine() {
- await onSave()
-}
-
-async function onCheckMinio() {
- checkingMinio.value = true
- minioCheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 'minio', minio: payload.minio })
- minioCheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- minioCheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingMinio.value = false
- }
-}
-
-async function onCheckCos() {
- checkingCos.value = true
- cosCheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 'cos', cos: payload.cos })
- cosCheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- cosCheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingCos.value = false
- }
-}
-
-async function onCheckTos() {
- checkingTos.value = true
- tosCheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 'tos', tos: payload.tos })
- tosCheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- tosCheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingTos.value = false
- }
-}
-
-async function onCheckS3() {
- checkingS3.value = true
- s3CheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 's3', s3: payload.s3 })
- s3CheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- s3CheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingS3.value = false
- }
-}
-
-async function onCheckOss() {
- checkingOss.value = true
- ossCheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 'oss', oss: payload.oss })
- ossCheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- ossCheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingOss.value = false
- }
-}
-
-async function onCheckKs3() {
- checkingKs3.value = true
- ks3CheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 'ks3', ks3: payload.ks3 })
- ks3CheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- ks3CheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingKs3.value = false
- }
-}
-
-async function onCheckObs() {
- checkingObs.value = true
- obsCheckResult.value = null
- try {
- const payload = buildPayload()
- const res = await checkStorageEngine({ provider: 'obs', obs: payload.obs })
- obsCheckResult.value = res?.data ?? { ok: false, message: t('settings.storage.unknownError') }
- } catch (e: unknown) {
- obsCheckResult.value = { ok: false, message: e instanceof Error ? e.message : t('settings.storage.requestFailed') }
- } finally {
- checkingObs.value = false
- }
-}
-
-onMounted(loadAll)
-</script>
-
-<style lang="less" scoped>
-.storage-engine-settings {
- width: 100%;
-}
-
-.section-header {
- margin-bottom: 32px;
-
- h2 {
- font-size: 20px;
- font-weight: 600;
- color: var(--td-text-color-primary);
- margin: 0 0 8px 0;
- }
-
- .section-description {
- font-size: 14px;
- color: var(--td-text-color-secondary);
- margin: 0;
- line-height: 1.5;
- }
-}
-
-.loading-state {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 8px;
- padding: 48px 0;
- color: var(--td-text-color-placeholder);
- font-size: 14px;
-}
-
-.error-inline {
- padding: 16px 0;
-}
-
-.settings-group {
- display: flex;
- flex-direction: column;
- gap: 0;
-}
-
-.setting-row {
- display: flex;
- align-items: flex-start;
- justify-content: space-between;
- padding: 20px 0;
- border-bottom: 1px solid var(--td-component-stroke);
-
- &:last-child {
- border-bottom: none;
- }
-}
-
-.setting-info {
- flex: 1;
- max-width: 65%;
- padding-right: 24px;
-
- label {
- font-size: 15px;
- font-weight: 500;
- color: var(--td-text-color-primary);
- display: block;
- margin-bottom: 4px;
- }
-
- .desc {
- font-size: 13px;
- color: var(--td-text-color-secondary);
- margin: 0;
- line-height: 1.5;
- }
-}
-
-.setting-control {
- flex-shrink: 0;
- min-width: 280px;
- display: flex;
- justify-content: flex-end;
- align-items: center;
-}
-
-.engine-cards {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
- gap: 12px;
- margin-top: 24px;
-}
-
-// 与 Parser / Model / WebSearch / Mcp 一致的卡片样式 —— 整张是 button,
-// 单击打开抽屉;active 是「当前正在编辑」的语义而不是「默认引擎」。
-.engine-card {
- display: flex;
- align-items: flex-start;
- gap: 12px;
- padding: 14px 14px 14px 12px;
- border: 1px solid var(--td-component-stroke);
- border-radius: 10px;
- background: var(--td-bg-color-container);
- text-align: left;
- font: inherit;
- color: inherit;
- cursor: pointer;
- transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
- min-width: 0;
-
- &:hover {
- border-color: var(--td-brand-color-3, var(--td-brand-color));
- box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
- }
-
- &--active {
- border-color: var(--td-brand-color);
- background: var(--td-brand-color-1, rgba(7, 192, 95, 0.06));
- }
-}
-
-.engine-card__badge {
- flex-shrink: 0;
- width: 36px;
- height: 36px;
- border-radius: 9px;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 1px;
- font-size: 15px;
- font-weight: 600;
- letter-spacing: 0.02em;
- background: rgba(0, 82, 217, 0.1);
- color: #0052D9;
-}
-
-// 真实品牌 logo:白底 + 细边,logo 用 mask-image 染成 currentColor(沿用品牌色)。
-// 多套一层 .engine-card 以胜过 `.engine-card--<id> .engine-card__badge` 的具体规则。
-.engine-card .engine-card__badge--logo {
- background: var(--td-bg-color-container, #fff);
- box-shadow: inset 0 0 0 1px var(--td-component-stroke);
-}
-
-.engine-card .engine-card__badge--mono::before {
- content: '';
- width: 22px;
- height: 22px;
- background-color: currentColor;
- -webkit-mask-image: var(--logo-url);
- -webkit-mask-position: center;
- -webkit-mask-repeat: no-repeat;
- -webkit-mask-size: contain;
- mask-image: var(--logo-url);
- mask-position: center;
- mask-repeat: no-repeat;
- mask-size: contain;
-}
-
-.engine-card__badge-img {
- width: 24px;
- height: 24px;
- object-fit: contain;
- display: block;
-}
-
-// 各对象存储徽章配色 —— 和 LOGO 主色对齐,但走低饱和版以维持 settings 整体调性。
-.engine-card--local .engine-card__badge {
- background: rgba(70, 70, 70, 0.1);
- color: #464646;
-}
-.engine-card--minio .engine-card__badge {
- background: rgba(225, 38, 38, 0.12);
- color: #C0382B;
-}
-.engine-card--cos .engine-card__badge {
- background: rgba(0, 82, 217, 0.1);
- color: #0052D9;
-}
-.engine-card--tos .engine-card__badge {
- background: rgba(0, 137, 255, 0.12);
- color: #0089FF;
-}
-.engine-card--s3 .engine-card__badge {
- background: rgba(255, 153, 0, 0.12);
- color: #D97706;
-}
-.engine-card--oss .engine-card__badge {
- background: rgba(255, 90, 0, 0.12);
- color: #E55A00;
-}
-.engine-card--ks3 .engine-card__badge {
- background: rgba(7, 192, 95, 0.12);
- color: #07A050;
-}
-.engine-card--obs .engine-card__badge {
- background: rgba(206, 17, 38, 0.1);
- color: #CE1126;
-}
-
-.engine-card__body {
- flex: 1;
- min-width: 0;
- display: flex;
- flex-direction: column;
- gap: 4px;
-}
-
-.engine-card__header {
- display: flex;
- align-items: center;
- gap: 6px;
- min-width: 0;
-}
-
-.engine-card__title {
- flex: 1;
- min-width: 0;
- margin: 0;
- font-size: 14px;
- font-weight: 600;
- line-height: 1.4;
- color: var(--td-text-color-primary);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.engine-card__status {
- flex-shrink: 0;
- display: inline-flex;
- align-items: center;
- gap: 5px;
- padding: 1px 8px 1px 6px;
- font-size: 11px;
- font-weight: 500;
- line-height: 16px;
- border-radius: 10px;
- background: var(--td-bg-color-secondarycontainer);
-
- &--on {
- color: var(--td-success-color-7, #118053);
-
- .engine-card__status-dot { background: var(--td-success-color, #118053); }
- }
-
- &--off {
- color: var(--td-text-color-placeholder);
-
- .engine-card__status-dot { background: var(--td-gray-color-5); }
- }
-}
-
-.engine-card__status-dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
-}
-
-.engine-card__desc {
- font-size: 12px;
- color: var(--td-text-color-secondary);
- margin: 0;
- line-height: 1.5;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
-}
-
-// ---- 抽屉内容 — 与 ModelEditorDialog 同款约定 ----
-
-// color logo 容器内部的图片
-.header-icon__img {
- width: 24px;
- height: 24px;
- object-fit: contain;
- display: block;
-}
-
-// mono logo(用 mask-image 渲染,颜色由 currentColor 决定)
-.header-icon__mono {
- display: inline-block;
- width: 22px;
- height: 22px;
- background-color: currentColor;
- -webkit-mask-image: var(--logo-url);
- -webkit-mask-position: center;
- -webkit-mask-repeat: no-repeat;
- -webkit-mask-size: contain;
- mask-image: var(--logo-url);
- mask-position: center;
- mask-repeat: no-repeat;
- mask-size: contain;
-}
-
-// fallback:首字母 monogram
-.header-icon__text {
- font-size: 15px;
- font-weight: 600;
- letter-spacing: 0.02em;
-}
-
-.form-item {
- margin-bottom: 0;
-}
-
-.form-label {
- display: block;
- margin-bottom: 6px;
- font-size: 13px;
- font-weight: 500;
- color: var(--td-text-color-primary);
- line-height: 1.4;
-
- // 必填星号前置(与 ModelEditorDialog 一致)
- &.required::before {
- content: '*';
- color: var(--td-error-color);
- margin-right: 4px;
- font-weight: 500;
- line-height: 1;
- }
-}
-
-.form-desc {
- margin: 4px 0 0 0;
- font-size: 12px;
- line-height: 1.5;
- color: var(--td-text-color-placeholder);
-
- &--inline {
- margin: 0;
- }
-}
-
-:deep(.t-input),
-:deep(.t-select),
-:deep(.t-textarea),
-:deep(.t-input-number) {
- width: 100%;
- font-size: 13px;
-}
-
-// ---- MinIO 部署模式:紧凑 pill segmented(与 ModelEditorDialog 来源切换同款)----
-.source-options {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- padding: 3px;
- background: var(--td-bg-color-component);
- border: 1px solid var(--td-component-stroke);
- border-radius: 8px;
-}
-
-.source-option {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 5px 12px;
- height: 28px;
- background: transparent;
- border: 1px solid transparent;
- border-radius: 6px;
- cursor: pointer;
- font-family: inherit;
- font-size: 13px;
- color: var(--td-text-color-secondary);
- line-height: 1;
- transition: all 0.15s ease;
-
- &:hover:not(.is-active) {
- color: var(--td-text-color-primary);
- background: var(--td-bg-color-container-hover);
- }
-
- &.is-active {
- background: var(--td-bg-color-container);
- border-color: var(--td-brand-color);
- color: var(--td-brand-color);
- font-weight: 500;
- box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
- }
-}
-
-.source-option__icon {
- font-size: 14px;
- flex-shrink: 0;
-}
-
-.source-option__label {
- white-space: nowrap;
-}
-
-// ---- inline-alert(与 ParserEngineSettings 同款,瘦身的状态行) ----
-.inline-alert {
- display: flex;
- align-items: center;
- gap: 8px;
- margin-top: 10px;
- font-size: 13px;
- line-height: 1.5;
- color: var(--td-text-color-secondary);
- flex-wrap: wrap;
-}
-
-.inline-alert__icon {
- font-size: 15px;
- flex-shrink: 0;
- color: var(--td-text-color-placeholder);
-}
-
-.inline-alert--ok .inline-alert__icon {
- color: var(--td-success-color);
-}
-
-.inline-alert--warn {
- color: var(--td-text-color-primary);
-
- .inline-alert__icon {
- color: var(--td-warning-color, #f97316);
- }
-}
-
-.inline-alert__text {
- flex: 1 1 auto;
- min-width: 0;
-}
-
-// ---- vision-toggle(switch + 行内描述)----
-.vision-toggle {
- display: flex;
- align-items: center;
- gap: 8px;
-}
-
-// ---- footer-left 测试连接消息(与 ModelEditorDialog 同款) ----
-.footer-test-message {
- font-size: 12px;
- line-height: 1.4;
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-
- &.success {
- color: var(--td-brand-color-active);
- }
-
- &.error {
- color: var(--td-error-color);
- }
-
- &.created {
- color: var(--td-warning-color, #f97316);
- }
-}
-
-.status-icon {
- font-size: 16px;
- flex-shrink: 0;
-
- &.available {
- color: var(--td-brand-color);
- }
-
- &.unavailable {
- color: var(--td-error-color);
- }
-}
-
-// ---- 文档外链 ----
-.doc-link {
- display: inline-flex;
- align-items: center;
- gap: 4px;
- font-size: 13px;
- font-weight: 500;
- color: var(--td-brand-color);
- text-decoration: none;
- transition: color 0.15s ease;
-
- &:hover {
- color: var(--td-brand-color-active);
- }
-
- .link-icon {
- font-size: 14px;
- }
-
- &--inline {
- margin-left: 6px;
- font-size: 12px;
- font-weight: 500;
- vertical-align: baseline;
-
- .link-icon {
- font-size: 12px;
- }
- }
-}
-
-.save-msg {
- font-size: 13px;
-
- &.success {
- color: var(--td-success-color);
- }
-
- &.error {
- color: var(--td-error-color);
- }
-}
-</style>
-
-<!--
- Non-scoped block: per-engine header icon coloring. The drawer panel is
- rendered into the component tree (no teleport since attach is unset),
- but TDesign's t-drawer can in some builds reuse a shared root that
- drops scoped data attributes — keep these rules global so the mapping
- always lands. Namespaced under .storage-engine-drawer--{id} so it
- cannot bleed into other consumers of SettingDrawer.
-
- Each rule mirrors the matching .engine-card--{id} .engine-card__badge
- background + color pair from the scoped block above, so the list-card
- → drawer hand-off is visually continuous.
--->
-<style lang="less">
-// 当抽屉里渲染了彩色 logo(如 MinIO/AWS)时,给 header-icon 容器一个白底
-// + 细边,避免品牌色浅底盖在彩色图标上影响对比度。
-.storage-engine-drawer .setting-drawer__header-icon:has(.header-icon__img) {
- background: var(--td-bg-color-container, #fff);
- box-shadow: inset 0 0 0 1px var(--td-component-stroke);
-}
-
-// 单色 logo / 首字母 fallback 的徽章配色 — 与列表卡片 .engine-card--{id}
-// .engine-card__badge 完全一致。
-.storage-engine-drawer--local .setting-drawer__header-icon {
- background: rgba(70, 70, 70, 0.1);
- color: #464646;
-}
-.storage-engine-drawer--minio .setting-drawer__header-icon {
- background: rgba(225, 38, 38, 0.12);
- color: #C0382B;
-}
-.storage-engine-drawer--cos .setting-drawer__header-icon {
- background: rgba(0, 82, 217, 0.1);
- color: #0052D9;
-}
-.storage-engine-drawer--tos .setting-drawer__header-icon {
- background: rgba(0, 137, 255, 0.12);
- color: #0089FF;
-}
-.storage-engine-drawer--s3 .setting-drawer__header-icon {
- background: rgba(255, 153, 0, 0.12);
- color: #D97706;
-}
-.storage-engine-drawer--oss .setting-drawer__header-icon {
- background: rgba(255, 90, 0, 0.12);
- color: #E55A00;
-}
-.storage-engine-drawer--ks3 .setting-drawer__header-icon {
- background: rgba(7, 192, 95, 0.12);
- color: #07A050;
-}
-.storage-engine-drawer--obs .setting-drawer__header-icon {
- background: rgba(206, 17, 38, 0.1);
- color: #CE1126;
-}
-</style>
diff --git a/frontend/src/views/settings/WebSearchSettings.vue b/frontend/src/views/settings/WebSearchSettings.vue
index a866ce5f7..111954ed2 100644
--- a/frontend/src/views/settings/WebSearchSettings.vue
+++ b/frontend/src/views/settings/WebSearchSettings.vue
@@ -7,9 +7,7 @@
<h3 class="list-section-title">{{ t('webSearchSettings.providersTitle') }}</h3>
- <!-- Provider List —— 与 ModelSettings 的卡片同形:左侧标识徽章 + 标题 / 副标题 / proxy URL 三段式。
- 不复用 SettingCard 的原因和 Models 一样:每页有微妙不同的右上侧栏需求(这里没有控件,
- Mcp 有开关),SettingCard 仍服务于其它消费者。 -->
+ <!-- Provider cards keep their page-specific actions beside the provider details. -->
<div v-if="providerEntities.length === 0 && !authStore.hasRole('admin')" class="empty-state">
<t-empty :description="t('webSearchSettings.noProvidersDesc')" />
</div>
diff --git a/frontend/src/views/settings/components/McpTestResultBody.vue b/frontend/src/views/settings/components/McpTestResultBody.vue
deleted file mode 100644
index 174430f83..000000000
--- a/frontend/src/views/settings/components/McpTestResultBody.vue
+++ /dev/null
@@ -1,434 +0,0 @@
-<template>
- <div v-if="result" class="mtr">
- <!-- 状态条 -->
- <div class="mtr-status" :class="result.success ? 'is-success' : 'is-error'">
- <t-icon :name="result.success ? 'check-circle-filled' : 'close-circle-filled'" />
- <span>{{ result.success ? $t('mcp.testResult.connectionSuccess') : $t('mcp.testResult.connectionFailed') }}</span>
- </div>
- <p v-if="result.message" class="mtr-message">{{ result.message }}</p>
- <div v-if="result.success && result.description" class="mtr-service-desc">
- <span>{{ $t('mcp.testResult.descriptionLabel') }}</span>
- <p>{{ result.description }}</p>
- </div>
-
- <template v-if="result.success">
- <!-- 工具列表 -->
- <div v-if="result.tools && result.tools.length > 0" class="mtr-group">
- <div class="mtr-group-title">
- <span>{{ $t('mcp.testResult.toolsTitle') }}</span>
- <t-tag theme="primary" variant="light" size="small">{{ result.tools.length }}</t-tag>
- </div>
- <div class="mtr-list">
- <div
- v-for="(tool, index) in displayTools"
- :key="index"
- class="mtr-item"
- :class="{ 'is-open': expandedToolIndex === index }"
- >
- <div class="mtr-item-head" @click="toggleTool(index)">
- <t-icon name="tools" class="mtr-item-icon" />
- <span class="mtr-item-name">{{ tool.name }}</span>
- <div class="mtr-item-actions" @click.stop>
- <t-tooltip v-if="serviceId" :content="$t('mcp.testResult.toolEnabledTip')" placement="top">
- <span class="mtr-approval">
- <span class="mtr-approval-label">{{ $t('mcp.testResult.toolEnabled') }}</span>
- <t-switch
- :value="tool.enabled !== false"
- :loading="toolLoading[tool.name]"
- :disabled="isToolPolicyBusy(tool.name)"
- size="small"
- @change="(v: boolean) => onToolEnabledChange(tool.name, v)"
- />
- </span>
- </t-tooltip>
- <t-tooltip v-if="serviceId" :content="$t('mcp.testResult.requireApprovalTip')" placement="top">
- <span class="mtr-approval">
- <t-icon name="error-circle-filled" class="mtr-approval-icon" />
- <span class="mtr-approval-label">{{ $t('mcp.testResult.requireApproval') }}</span>
- <t-switch
- :value="tool.require_approval"
- :loading="approvalLoading[tool.name]"
- :disabled="isToolPolicyBusy(tool.name)"
- size="small"
- @change="(v: boolean) => onRequireApprovalChange(tool.name, v)"
- />
- </span>
- </t-tooltip>
- </div>
- <t-icon
- :name="expandedToolIndex === index ? 'chevron-up' : 'chevron-down'"
- class="mtr-chevron"
- />
- </div>
- <div
- v-if="tool.description"
- class="mtr-item-desc"
- :class="{ 'is-clamped': expandedToolIndex !== index }"
- >
- {{ tool.description }}
- </div>
- <div v-if="expandedToolIndex === index && tool.inputSchema" class="mtr-item-schema">
- <div class="mtr-schema-label">{{ $t('mcp.testResult.schemaLabel') }}</div>
- <pre>{{ formatSchema(tool.inputSchema) }}</pre>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 资源列表 -->
- <div v-if="result.resources && result.resources.length > 0" class="mtr-group">
- <div class="mtr-group-title">
- <span>{{ $t('mcp.testResult.resourcesTitle') }}</span>
- <t-tag theme="primary" variant="light" size="small">{{ result.resources.length }}</t-tag>
- </div>
- <div class="mtr-list">
- <div v-for="(resource, index) in result.resources" :key="index" class="mtr-item">
- <div class="mtr-item-head is-static">
- <t-icon name="file" class="mtr-item-icon" />
- <span class="mtr-item-name">{{ resource.name || resource.uri }}</span>
- <t-tag v-if="resource.mimeType" theme="default" variant="light-outline" size="small">
- {{ resource.mimeType }}
- </t-tag>
- </div>
- <div v-if="resource.description" class="mtr-item-desc">{{ resource.description }}</div>
- <div v-if="resource.uri" class="mtr-item-uri">
- <t-icon name="link" />
- <span>{{ resource.uri }}</span>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 空状态 -->
- <t-empty
- v-if="(!result.tools || result.tools.length === 0) && (!result.resources || result.resources.length === 0)"
- :description="$t('mcp.testResult.emptyDescription')"
- class="mtr-empty"
- />
- </template>
- </div>
-</template>
-
-<script setup lang="ts">
-import { ref, watch } from 'vue'
-import type { MCPTestResult, MCPTool } from '@/api/mcp-service'
-import { getMCPToolApprovals, setMCPToolApproval, setMCPToolEnabled } from '@/api/mcp-service'
-import { MessagePlugin } from 'tdesign-vue-next'
-import { useI18n } from 'vue-i18n'
-
-interface Props {
- result: MCPTestResult | null
- /** When set, loads/saves per-tool approval flags */
- serviceId?: string
- /** When true, (re)loads approval flags. Lets the dialog gate the fetch on
- * visibility; defaults to true for always-rendered inline usage. */
- active?: boolean
-}
-
-const props = withDefaults(defineProps<Props>(), { active: true })
-
-const expandedToolIndex = ref<number | null>(null)
-const { t } = useI18n()
-const displayTools = ref<MCPTool[]>([])
-const approvalLoading = ref<Record<string, boolean>>({})
-const toolLoading = ref<Record<string, boolean>>({})
-
-const isToolPolicyBusy = (toolName: string) =>
- Boolean(toolLoading.value[toolName] || approvalLoading.value[toolName])
-
-const mergeApprovals = async () => {
- const tools = props.result?.tools
- if (!tools?.length) {
- displayTools.value = []
- return
- }
- if (!props.serviceId) {
- displayTools.value = tools.map((x) => ({ ...x }))
- return
- }
- try {
- const rows = await getMCPToolApprovals(props.serviceId)
- const map = new Map(rows.map((r) => [r.tool_name, r]))
- displayTools.value = tools.map((tool) => ({
- ...tool,
- require_approval: map.get(tool.name)?.require_approval || false,
- enabled: map.get(tool.name)?.enabled !== false,
- }))
- } catch {
- displayTools.value = tools.map((x) => ({ ...x }))
- }
-}
-
-const onToolEnabledChange = async (toolName: string, value: boolean) => {
- if (!props.serviceId) return
- toolLoading.value = { ...toolLoading.value, [toolName]: true }
- try {
- await setMCPToolEnabled(props.serviceId, toolName, value)
- displayTools.value = displayTools.value.map((x) =>
- x.name === toolName ? { ...x, enabled: value } : x
- )
- } catch (e) {
- console.error(e)
- MessagePlugin.error(t('mcp.testResult.toolEnabledSaveFailed'))
- } finally {
- toolLoading.value = { ...toolLoading.value, [toolName]: false }
- }
-}
-
-watch(
- () => [props.active, props.serviceId, props.result?.tools],
- () => {
- if (props.active) {
- void mergeApprovals()
- }
- },
- { deep: true, immediate: true }
-)
-
-const onRequireApprovalChange = async (toolName: string, value: boolean) => {
- if (!props.serviceId) return
- approvalLoading.value = { ...approvalLoading.value, [toolName]: true }
- try {
- await setMCPToolApproval(props.serviceId, toolName, value)
- displayTools.value = displayTools.value.map((x) =>
- x.name === toolName ? { ...x, require_approval: value } : x
- )
- } catch (e) {
- console.error(e)
- MessagePlugin.error(t('mcp.testResult.approvalSaveFailed'))
- } finally {
- approvalLoading.value = { ...approvalLoading.value, [toolName]: false }
- }
-}
-
-const toggleTool = (index: number) => {
- expandedToolIndex.value = expandedToolIndex.value === index ? null : index
-}
-
-const formatSchema = (schema: any): string => {
- if (!schema) return ''
- return JSON.stringify(schema, null, 2)
-}
-</script>
-
-<style scoped lang="less">
-.mtr {
- display: flex;
- flex-direction: column;
- gap: 16px;
-}
-
-/* 状态条 */
-.mtr-status {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 10px 12px;
- border-radius: 6px;
- font-size: 14px;
- font-weight: 500;
-
- &.is-success {
- color: var(--td-success-color);
- background: var(--td-success-color-1, var(--td-bg-color-secondarycontainer));
- }
-
- &.is-error {
- color: var(--td-error-color);
- background: var(--td-error-color-1, var(--td-bg-color-secondarycontainer));
- }
-
- :deep(.t-icon) {
- font-size: 18px;
- }
-}
-
-.mtr-message {
- margin: 0;
- font-size: 13px;
- color: var(--td-text-color-secondary);
- line-height: 1.6;
- word-break: break-word;
-}
-
-.mtr-service-desc {
- padding: 10px 12px;
- border: 1px solid var(--td-component-stroke);
- border-radius: 6px;
- background: var(--td-bg-color-secondarycontainer);
-
- span {
- display: block;
- margin-bottom: 4px;
- color: var(--td-text-color-placeholder);
- font-size: 12px;
- font-weight: 600;
- }
-
- p {
- margin: 0;
- color: var(--td-text-color-primary);
- font-size: 13px;
- line-height: 1.6;
- word-break: break-word;
- }
-}
-
-/* 分组 */
-.mtr-group {
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
-
-.mtr-group-title {
- display: flex;
- align-items: center;
- gap: 8px;
- font-size: 13px;
- font-weight: 600;
- color: var(--td-text-color-secondary);
-}
-
-/* 列表:扁平卡片,靠分隔与圆角,无重阴影,贴合抽屉 */
-.mtr-list {
- display: flex;
- flex-direction: column;
- border: 1px solid var(--td-component-stroke);
- border-radius: 8px;
- overflow: hidden;
-}
-
-.mtr-item {
- padding: 12px 14px;
- background: var(--td-bg-color-container);
-
- & + .mtr-item {
- border-top: 1px solid var(--td-component-stroke);
- }
-
- &.is-open {
- background: var(--td-bg-color-secondarycontainer);
- }
-}
-
-.mtr-item-head {
- display: flex;
- align-items: center;
- gap: 8px;
- cursor: pointer;
- user-select: none;
-
- &.is-static {
- cursor: default;
- }
-}
-
-.mtr-item-icon {
- flex-shrink: 0;
- font-size: 16px;
- color: var(--td-brand-color);
-}
-
-.mtr-item-name {
- flex: 1;
- min-width: 0;
- font-size: 14px;
- font-weight: 600;
- color: var(--td-text-color-primary);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-
-.mtr-item-actions {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-shrink: 0;
-}
-
-.mtr-approval {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- font-size: 12px;
- color: var(--td-text-color-secondary);
-
- .mtr-approval-icon {
- font-size: 15px;
- color: var(--td-warning-color);
- }
-
- .mtr-approval-label {
- white-space: nowrap;
- }
-}
-
-.mtr-chevron {
- font-size: 16px;
- color: var(--td-text-color-placeholder);
- flex-shrink: 0;
-}
-
-/* 描述:独占整行,绝不与右侧开关挤在一起 */
-.mtr-item-desc {
- margin-top: 6px;
- font-size: 13px;
- color: var(--td-text-color-placeholder);
- line-height: 1.6;
- word-break: break-word;
-
- &.is-clamped {
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- overflow: hidden;
- }
-}
-
-.mtr-item-schema {
- margin-top: 10px;
-
- .mtr-schema-label {
- font-size: 12px;
- font-weight: 600;
- color: var(--td-text-color-placeholder);
- text-transform: uppercase;
- letter-spacing: 0.5px;
- margin-bottom: 6px;
- }
-
- pre {
- margin: 0;
- padding: 10px 12px;
- border-radius: 6px;
- background: var(--td-bg-color-page);
- border: 1px solid var(--td-component-stroke);
- overflow-x: auto;
- font-size: 12px;
- font-family: var(--app-font-family-mono);
- color: var(--td-text-color-primary);
- line-height: 1.6;
- }
-}
-
-.mtr-item-uri {
- display: flex;
- align-items: center;
- gap: 6px;
- margin-top: 8px;
- font-size: 12px;
- color: var(--td-text-color-placeholder);
-
- span {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-}
-
-.mtr-empty {
- padding: 24px 0;
-}
-</style>