Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7951fb983a | ||
|
|
bbe365429d |
No files matched your search
@@ -88,11 +88,21 @@ offline-backend-20260512/backend/skill_evolution.json
|
|||||||
# Automatic config.yaml backups written by the admin models page on every save
|
# Automatic config.yaml backups written by the admin models page on every save
|
||||||
offline-backend-20260512/backend/.model-config-backups/
|
offline-backend-20260512/backend/.model-config-backups/
|
||||||
skills/
|
skills/
|
||||||
|
# Harness skill-versioning logic is product source, not a runtime skill package.
|
||||||
|
!offline-backend-20260512/backend/packages/harness/deerflow/skills/
|
||||||
|
offline-backend-20260512/backend/packages/harness/deerflow/skills/*
|
||||||
|
!offline-backend-20260512/backend/packages/harness/deerflow/skills/versioning.py
|
||||||
hermes-agent-main/
|
hermes-agent-main/
|
||||||
.gitignore
|
.gitignore
|
||||||
offline-backend-20260512/backend/tests/*
|
offline-backend-20260512/backend/tests/*
|
||||||
|
!offline-backend-20260512/backend/tests/test_goview_projects.py
|
||||||
|
!offline-backend-20260512/backend/tests/test_goview_templates.py
|
||||||
|
!offline-backend-20260512/backend/tests/test_goview_assets.py
|
||||||
|
!offline-backend-20260512/backend/tests/test_skill_versioning.py
|
||||||
!offline-backend-20260512/backend/tests/test_large_file_safety.py
|
!offline-backend-20260512/backend/tests/test_large_file_safety.py
|
||||||
!offline-backend-20260512/backend/tests/test_account_authentication.py
|
!offline-backend-20260512/backend/tests/test_account_authentication.py
|
||||||
|
# HTML 结构化模板(no.1)引擎/存储/路由回归
|
||||||
|
!offline-backend-20260512/backend/tests/test_structured_templates.py
|
||||||
!offline-backend-20260512/backend/tests/test_html_runtime_addresses.py
|
!offline-backend-20260512/backend/tests/test_html_runtime_addresses.py
|
||||||
!offline-backend-20260512/backend/tests/test_app_identity.py
|
!offline-backend-20260512/backend/tests/test_app_identity.py
|
||||||
!offline-backend-20260512/backend/tests/test_roundtable_room_limit.py
|
!offline-backend-20260512/backend/tests/test_roundtable_room_limit.py
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
## 背景
|
||||||
|
|
||||||
|
配置管理页(`/page/strategy/custom-deeplink-entry` 的上游配置工具)允许用户自定义任意多个业务类型,每个类型绑定一个执行智能体,深链落地到 `AgentChatPage` 的 landing 态。目前所有智能体的落地页完全一样(红色调 BotIcon 头像 + 「Hi,我是XX」+ 描述 + 输入框),用户从不同类型进来看到同一张脸,会觉得奇怪。
|
||||||
|
|
||||||
|
类型数量不定、由用户自由创建,人工逐个挑样式不可扩展。方案:**预设 6 套落地页风格 + 按智能体 id 确定性自动分配**——同一智能体永远同一套风格(深链入口、智能体管理「对话」按钮进入都一致),不同智能体尽量落在不同套;零配置、零后端改动。
|
||||||
|
|
||||||
|
纯前端改动,只用显式 hex/rgba 色值(遵循 globals.css:1840 注释的旧 Chrome 兼容铁律,不用 color-mix)。
|
||||||
|
|
||||||
|
## 实施步骤
|
||||||
|
|
||||||
|
### 1. 新增 `frontend-web/src/core/agents/appearance.ts`
|
||||||
|
- FNV-1a 字符串 hash(项目里无现成工具);
|
||||||
|
- `AGENT_LANDING_STYLE_COUNT = 6`;
|
||||||
|
- `agentLandingStyleIndex(id: string): number` = hash % 6(稳定,id 不变风格不变);
|
||||||
|
- 每套风格对应的头像图标表(lucide:Bot / Sparkles / Brain / Compass / MessagesSquare / Workflow),导出 `agentLandingStyleIcon(index)`。
|
||||||
|
|
||||||
|
### 2. `frontend-web/src/pages/AgentChatPage.tsx`
|
||||||
|
- 在 `<main>`(~1471 行)上加 `data-agent-style={agentLandingStyleIndex(agent_id)}`,同时内联覆盖 `--primary: var(--agent-accent)`(CSS 里按风格定义)——让页头智能体胶囊图标、发送按钮等**纯色** primary 元素自动跟随风格(纯色工具类不依赖 color-mix,旧 Chrome 安全);
|
||||||
|
- landing 分支(~1635 行)里加一个绝对定位、`pointer-events-none` 的氛围光斑 div(`.agent-style-glow`),按风格给页面顶部一层淡淡的对应色径向渐变,增强「换了个地方」的观感。
|
||||||
|
|
||||||
|
### 3. `frontend-web/src/components/workspace/agent-welcome.tsx`
|
||||||
|
- 头像图标从写死 `BotIcon` 改为按风格轮换(`agentLandingStyleIcon(index)`);
|
||||||
|
- 给问候语标题加 `agent-welcome-name` class 钩子(供 CSS 做渐变字等风格差异);
|
||||||
|
- `.agent-avatar` 结构不动。
|
||||||
|
|
||||||
|
### 4. `frontend-web/src/styles/globals.css`
|
||||||
|
- `.gemini-gradient-border::before` 的 conic-gradient 改为 `var(--agent-gemini-gradient, <现有四色默认>)`(默认值 = 现状,不影响其他页面);
|
||||||
|
- 文件末尾新增一个非 layer 块「智能体专属落地页风格」,6 套风格 × 明/暗两版(沿用 `.dark` 前缀模式),每套定义:
|
||||||
|
- `--agent-accent`(主色)、`--agent-accent-soft`(浅底)、`--agent-accent-border`(描边 rgba)、`--agent-gemini-gradient`(输入框专属旋转描边渐变);
|
||||||
|
- `[data-agent-style="N"] .agent-avatar` 的底色/图标色/内描边(显式 hex,放在现有 `.agent-avatar` 主题块之后,非 layer 规则优先级高于工具类);
|
||||||
|
- `[data-agent-style="N"] .agent-style-glow` 的径向渐变;
|
||||||
|
- 2-3 套风格给 `.agent-welcome-name` 加渐变字/下划线装饰等排版差异,头像圆角形状在圆角方/圆形间轮换,让 6 套不只是换色。
|
||||||
|
- 顺带处理 `input-box.tsx:754` 唯一的透明度主色用法(`border-primary/20 bg-primary/5 hover:bg-primary/10` 的 promptPrefix 横幅)→ 改用 `var(--agent-accent-border/-soft)` 显式变量 + 默认兜底,旧 Chrome 下不会退化成实色块。
|
||||||
|
|
||||||
|
### 5. 单测(轻量)
|
||||||
|
- `frontend-web/src/core/agents/appearance.test.ts`:hash 稳定性(同一 id 结果恒定)、索引落在 0–5、不同 id 有分散性;沿用 vitest(参考 `core/settings/composer-scope.test.ts` 的位置与写法)。
|
||||||
|
|
||||||
|
## 明确不做 / 后续可选
|
||||||
|
- 不改后端、不加配置字段。若以后想让管理员在配置管理页手动指定某类型的风格,可在此基础上把「风格号」存进业务映射配置、路由透传覆盖 hash 值即可(本次不做)。
|
||||||
|
- 多个类型绑定同一智能体时共享同一套风格(这是智能体的身份,属预期行为);确实需要区分可创建不同智能体。
|
||||||
|
- 会话开始后的消息流保持全局主题不变,只有页头智能体胶囊保留专属色 + landing 态整页风格化。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
1. `cd frontend-web && pnpm typecheck` + `pnpm test:composer-session` 同款方式跑新增单测(或 `pnpm test` 过滤 appearance)。
|
||||||
|
2. `pnpm dev` 起前端,打开 `http://localhost:5173/#/page/strategy/custom-deeplink-entry?goPath=测试`,确认落到绑定智能体且 landing 风格与全局红色主题不同;
|
||||||
|
3. 在智能体管理临时建 2-3 个测试智能体分别进入问答页,确认不同 id 落到不同风格、同一智能体刷新/换入口风格恒定;
|
||||||
|
4. 切深色主题复查 6 套风格的暗色变体;发送一条消息进入会话态,确认消息流恢复全局主题、页头胶囊保留专属色、输入框描边过渡正常。
|
||||||
@@ -94,6 +94,26 @@ The frontend (`frontend-web/`) is a React 19 + Vite SPA:
|
|||||||
- **AI 写作·对话版(对话驱动写作台)**: a **parallel new entry** beside the classic AI-writing page (classic page/routes untouched) — route `/page/canvas/ai-writing-chat`, sidebar 「问答管理 → 课题研究(对话版)」. Page `open-canvas/pages/AIWritingChatPage.tsx` reuses the engine (`AIWritingContext` + `useStream` + `AIWritingDraftPanel`); **idle keeps the classic setup layout** (`WritingSetupChat` + collapsible form) and switches to the chat workbench once writing starts; left panel `components/ai-writing-chat/WritingChatPanel.tsx` = **unified chronological feed** (`ChatFlowTimeline.tsx`, chat bubbles anchor-interleaved into the progress timeline so triggered events render below the user's message) + button-only intervention cards (`ChatInterventionCards.tsx`, inline textareas removed) + bottom unified smart composer. Intent resolution: frontend fast path + `POST /api/ai-writing/sessions/{id}/intent` → `deerflow/agents/ai_writing/intent_router.py` (per-pause action whitelist, high-cost confidence gates, payload cleaning); supports QA bypass, clarify follow-ups, control intents, and material-stage auto re-search + pending-intent resume. Tests `tests/test_ai_writing_intent.py`; plan doc `frontend-web/docs/ai-writing-对话驱动写作台-实现方案.md`. **素材检索技能池限定白名单**:`researcher_node` 通用检索的候选池 = **ai-writing-researcher 智能体 config.yaml `skills` 白名单里的启用技能**(管理员在智能体管理页增删,内置 `knowledge-base-search` 保底且始终排最前),不再列全部启用技能——300+ 技能部署把选择提示词撑爆导致素材检索不可用;容错兜底 `_fallback_candidate_skills` 同样限定白名单;白名单未配置/加载失败回退仅内置知识库检索。实现 `deerflow/agents/ai_writing/nodes/researcher.py::_load_candidate_skills/_researcher_skill_whitelist`,测试 `tests/test_ai_writing_knowledge_base.py`。
|
- **AI 写作·对话版(对话驱动写作台)**: a **parallel new entry** beside the classic AI-writing page (classic page/routes untouched) — route `/page/canvas/ai-writing-chat`, sidebar 「问答管理 → 课题研究(对话版)」. Page `open-canvas/pages/AIWritingChatPage.tsx` reuses the engine (`AIWritingContext` + `useStream` + `AIWritingDraftPanel`); **idle keeps the classic setup layout** (`WritingSetupChat` + collapsible form) and switches to the chat workbench once writing starts; left panel `components/ai-writing-chat/WritingChatPanel.tsx` = **unified chronological feed** (`ChatFlowTimeline.tsx`, chat bubbles anchor-interleaved into the progress timeline so triggered events render below the user's message) + button-only intervention cards (`ChatInterventionCards.tsx`, inline textareas removed) + bottom unified smart composer. Intent resolution: frontend fast path + `POST /api/ai-writing/sessions/{id}/intent` → `deerflow/agents/ai_writing/intent_router.py` (per-pause action whitelist, high-cost confidence gates, payload cleaning); supports QA bypass, clarify follow-ups, control intents, and material-stage auto re-search + pending-intent resume. Tests `tests/test_ai_writing_intent.py`; plan doc `frontend-web/docs/ai-writing-对话驱动写作台-实现方案.md`. **素材检索技能池限定白名单**:`researcher_node` 通用检索的候选池 = **ai-writing-researcher 智能体 config.yaml `skills` 白名单里的启用技能**(管理员在智能体管理页增删,内置 `knowledge-base-search` 保底且始终排最前),不再列全部启用技能——300+ 技能部署把选择提示词撑爆导致素材检索不可用;容错兜底 `_fallback_candidate_skills` 同样限定白名单;白名单未配置/加载失败回退仅内置知识库检索。实现 `deerflow/agents/ai_writing/nodes/researcher.py::_load_candidate_skills/_researcher_skill_whitelist`,测试 `tests/test_ai_writing_knowledge_base.py`。
|
||||||
- **轻应用中心 (Light App Center)**: a sibling of 任务管理 in the sidebar with two pages — 应用管理 (admin registers `window_open` or `iframe` mini-apps with a route-param builder: login params resolved from `localStorage.userInfo`, theme params literal) and 应用列表 (card grid of `window_open` apps, `window.open` launch). `iframe` apps are mounted under a chosen parent menu (XK/PG/TY/综合管理) and **dynamically injected into the sidebar** by `core/page-layout/use-sidebar-menu.ts` (`useSidebarMenuItems`), opening in the `LightAppIframeView` host. Client + React Query hooks in `strategy-components/api/light-apps.ts`; URL builder/constants in `strategy-components/lib/light-app.ts`. Backend: `/api/light-apps` (global/shared, admin-gated writes).
|
- **轻应用中心 (Light App Center)**: a sibling of 任务管理 in the sidebar with two pages — 应用管理 (admin registers `window_open` or `iframe` mini-apps with a route-param builder: login params resolved from `localStorage.userInfo`, theme params literal) and 应用列表 (card grid of `window_open` apps, `window.open` launch). `iframe` apps are mounted under a chosen parent menu (XK/PG/TY/综合管理) and **dynamically injected into the sidebar** by `core/page-layout/use-sidebar-menu.ts` (`useSidebarMenuItems`), opening in the `LightAppIframeView` host. Client + React Query hooks in `strategy-components/api/light-apps.ts`; URL builder/constants in `strategy-components/lib/light-app.ts`. Backend: `/api/light-apps` (global/shared, admin-gated writes).
|
||||||
- **菜单管理 (Menu Management, admin defaults + personal layouts)**: `MenuManagementPage` (`pages/MenuManagementPage.tsx`) is available from「设置和更多」and the global Header account dropdown. Administrators edit the shared default menu; ordinary users edit only their own full/compact menu snapshot. For users with a saved snapshot, known node ids keep the personal `label`/`disabled`/`parentId`/`sortOrder` (or compact placement/order), while administrator defaults for node ids absent from that snapshot flow through—so newly-added code menus and iframe light apps follow the current default without overwriting older personal choices. Temporarily absent dynamic nodes are preserved when an unrelated personal edit is saved;「恢复默认」deletes only that user's snapshot. The static tree (`core/page-layout/sidebar-menu.ts`) remains the source of icons/routes and administrator defaults remain sparse per-node deltas. Merge/snapshot helpers live in `core/page-layout/menu-overrides.ts` and `compact-menu-overrides.ts`; full-menu writes carry the complete effective parent hierarchy for cycle/strict three-level validation while persisting only the sparse admin delta or full personal snapshot. Backend `/api/menu-overrides` uses `menu_overrides` (default) + `user_menu_override_configs` (per-user snapshot); `/api/compact-menu-overrides` uses `compact_menu_overrides` (type `A` / `B` defaults) + `user_compact_menu_override_configs` (per-user/type snapshots). Each website selects its compact type via `runtime-config.js` `VITE_COMPACT_MENU_TYPE`; `CompactToolbox` renders `toolbox` items.
|
- **菜单管理 (Menu Management, admin defaults + personal layouts)**: `MenuManagementPage` (`pages/MenuManagementPage.tsx`) is available from「设置和更多」and the global Header account dropdown. Administrators edit the shared default menu; ordinary users edit only their own full/compact menu snapshot. For users with a saved snapshot, known node ids keep the personal `label`/`disabled`/`parentId`/`sortOrder` (or compact placement/order), while administrator defaults for node ids absent from that snapshot flow through—so newly-added code menus and iframe light apps follow the current default without overwriting older personal choices. Temporarily absent dynamic nodes are preserved when an unrelated personal edit is saved;「恢复默认」deletes only that user's snapshot. The static tree (`core/page-layout/sidebar-menu.ts`) remains the source of icons/routes and administrator defaults remain sparse per-node deltas. Merge/snapshot helpers live in `core/page-layout/menu-overrides.ts` and `compact-menu-overrides.ts`; full-menu writes carry the complete effective parent hierarchy for cycle/strict three-level validation while persisting only the sparse admin delta or full personal snapshot. Backend `/api/menu-overrides` uses `menu_overrides` (default) + `user_menu_override_configs` (per-user snapshot); `/api/compact-menu-overrides` uses `compact_menu_overrides` (type `A` / `B` defaults) + `user_compact_menu_override_configs` (per-user/type snapshots). Each website selects its compact type via `runtime-config.js` `VITE_COMPACT_MENU_TYPE`; `CompactToolbox` renders `toolbox` items.
|
||||||
|
- **生成网页标识 (Generated Page Branding, admin-only write)**: 管理员在设置弹窗「生成网页标识」中填写网页展示名称、上传 PNG/JPG/WebP Logo(≤10MB)、单独移除 Logo 或整体清除配置。配置保存在 runtime `system_settings.json -> generated_page_branding`,图片保存在 runtime `generated-page-branding/`,`GET /api/system-settings/generated-page-branding` 全员可读,`PUT/DELETE` 仅管理员;生成 HTML 通过公开只读 `/api/public/html-runtime/generated-page-logo` 获取图片。**只有网页展示名称非空且 Logo 文件真实存在时功能才启用**;缺少任意一项(含单独移除 Logo)都不注入任何内容,完全保持原有网页生成逻辑。该配置只约束后续生成的 HTML 网页内容,不修改 DeerFlow 自身的系统名称、主导航、欢迎区、工作区标题或 Logo。启用时,HTML 写入与 `page_report_template validate` 会由 `html_runtime/generated_page_chrome.py` 确定性注入平台套壳:页头**通栏全宽、贴顶、无圆角**,**背景直接用全量模式导航栏设计图**(`html_runtime/assets/topbar-light.svg` 浅色红调 / `topbar-dark.svg` 深色深蓝,已注册进网关 `html_runtime.py` 的 `_STATIC_ASSETS` 白名单以 `/api/public/html-runtime/topbar-*.svg` 提供;页头运行时按 body 明暗 tone 自动切图),**只注入页头、不注入页脚**;设置弹窗不再提供「品牌位置」选择,新配置默认使用 `center`:「Logo+系统名称」居中锁孔(26px 白色金属渐变字 + 深浅辉光,落在设计图中央发光基座上)+ 页面导航**分列两侧**白字页签(当前项白色加粗 + 白色墨条)。`generated_page_branding.header_layout` 字段继续兼容存量配置,既有 `left` 仍按品牌居左 + 导航居中单行渲染。页签均为通栏等高下划线式(当前项主色 + 底部渐变墨条),多页强制首个逻辑页初始可见。开关 `chrome_enabled` **默认开启**;明确关闭时完全回归无注入:不注入页头、也不对页面提任何品牌要求(校验不检查品牌,模型不会被迫自写)。页脚与「网页页脚文字」设置项均已按需求移除(`FOOTER_MARKER` 常量仅为旧页面兼容保留)。模板套件的兜底导航条同款(品牌左 + 导航中、通栏贴顶),平台注入时经 `body:has([data-df-generated-header])` + 兜底脚本双保险自动隐藏。后处理会隐藏旧的多页导航、移除模型写入的 `data-df-brand` 重复标识且保持幂等;lead prompt 只让模型生成正文和逻辑页。注入点共四处且全部**账号无关**(admin 配置对全部账号生效,非 admin 仅无配置入口):**`page_report_template prepare`(工作副本创建时即预注入页头,模型从第一秒起编辑的就是带品牌导航的页面,brief 的 `platform_branding.pre_injected` 标记此状态)**、`write_file`/`str_replace`(`sandbox/tools.py` 的 `maybe_fix_generated_html`)、`page_report_template validate`、以及 `present_files` 交付兜底(`present_file_tool._ensure_generated_html_chrome`,覆盖模型经 bash 等旁路写出的 HTML;幂等,>4MB 跳过);注入时还会**归一化 body/html 顶部 padding/margin(清零)**(防弱模型为自想页头留白)并**隐藏模型自写的顶部 nav/header**(仅正文首个内容容器之前的,正文内导航不受影响);品牌配置每次实时读取 `system_settings.json`,无缓存无账号隔离。
|
||||||
|
- **生成网页默认明暗模式 (Generated Page Theme)**: `ChatPage` 与 `AgentChatPage` 每次发送只把当前界面的明暗模式作为 `presentation_theme=light|dark` 上下文传入。用户未明确指定网页主题时,自由生成 HTML、显式模板的 `auto` 选择以及平台注入的品牌页眉/页脚按该明暗模式生成;用户明确指定浅色、深色或其他配色时以用户要求为准。不得跟随系统的红、蓝、绿等主题主色或自定义主色,网页强调色由页面内容与可读性决定;科技、数据、看板、驾驶舱或地图题材本身不得再触发深色默认。
|
||||||
|
- **生成网页离线下载包 (Generated HTML Offline Bundle)**: 产物面板下载 `.htm/.html/.xhtml` 时不再只保存单个 HTML,而是请求 `GET /api/threads/{thread_id}/artifacts/{path}?download=true&offline_bundle=true`(公开只读分享的文件端点同样支持),下载 `{原名}-离线包.zip`。纯引擎 `deerflow/html_runtime/offline_bundle.py` 把入口统一为 `index.html`,只将平台信任的 `/api/public/html-runtime/*` JS/CSS/GeoJSON/品牌资源、认知态势图运行目录和签名 `/api/public/html-images/*` 图片复制到 `assets/` 并改写为相对地址;不得联网抓取任意第三方 URL。包内还带 `manifest.json`、中文 `README.txt` 和实际使用库的许可证。Leaflet 在线瓦片及用户主动引用的公网图片/API 不复制,保留原地址并列入 `external_urls`。非 HTML 下载、HTML 预览/新窗口打开及流式未落盘的临时下载行为不变。
|
||||||
|
- **系统名称与 Logo(与生成网页标识分开)**: 管理员在设置弹窗「系统名称」里填写本系统导航、侧栏和欢迎区使用的名称,并可上传一张 PNG/JPG/WebP Logo。顶部导航名称字号可选 `adaptive`(默认,30px 上限、24px 下限)或 `fixed`(16–40px);配置字段为 `app_identity.header_title_font_mode/header_title_font_size`,固定模式不再按分辨率缩放,超长名称仍单行完整显示。红色主题还可分别上传导航栏背景图与菜单选中样式图(PNG/JPG/WebP/SVG,不设应用层文件大小限制),字段为 `light_red_header_background_*` / `light_red_nav_active_*`;选择文件或恢复默认时顶部导航即时预览,未配置时继续使用 `top-bg-light-red.svg` / `nav-active-light-red.svg`。其余配置在 `system_settings.json -> app_identity`,图片统一放在运行目录 `app-identity/`,接口 `GET/PUT/DELETE /api/system-settings/app-identity`(写仅管理员),图片通过 `/api/public/app-identity/*` 读取。名称留空继续用「CM业务中心」/「CM 助手」;未上传 Logo 继续用各主题静态图片和既有 `runtime-config.js` 覆盖。不读写 `generated_page_branding`,也不改已生成的 HTML。
|
||||||
|
- **平台模板套件 (Bootstrap page-template-suite 技能)**: 内置技能 `skills/public/page-template-suite`(public 类,缺省启用)让「画页面」走平台预制 Bootstrap 模板而不是从零手写。**套件只提供多页面门户(最低 2 个逻辑页),不做单页面 HTML**(单页请求自动回落共享响应式文档模板):5 套设计 × 明暗两版共 10 个 `deerflow/page_reports/assets/report-bootstrap-*-template.html`(图表门户 3 页 / 甘特双页「进度总览+里程碑风险」/ 瓦片地图门户 3 页 / 文字杂志双页「正文论述+脉络结论」/ 研判简报双页「核心结论+风险行动」),profile 注册于 `page_reports/templates.py`(id `bootstrap-charts-portal-{light,dark}`、`bootstrap-gantt-{light,dark}`、`bootstrap-map-portal-{light,dark}`、`bootstrap-text-magazine-{light,dark}`、`bootstrap-text-briefing-{light,dark}`)。显式 `template_id` 时**页数以模板为准**(prepare 会把 brief 的页数对齐到模板页数,技能无需依赖用户说出「多页」)。模板源文件用 `__DF_HTML_RUNTIME_BASE__` 占位符引用 Gateway 运行库(Bootstrap/Alpine/ECharts/Leaflet/deerflow-runtime.js),`page_report_template prepare` 在会话副本中替换为设置里保存的 HTML 运行库地址,部署无关;图表走 `data-df-chart` 严格 JSON(甘特 = 时间轴 + 阶段重叠柱 `barGap:-100%`),地图门户走 `data-df-map` Leaflet 瓦片契约(瓦片地址来自设置里保存的地图瓦片地址,需管理员在「外观设置 → HTML 地图」选择「地图网页」引擎,引擎不符时 prepare 的 brief 会带 `map_engine_warning`)。prepare 的 brief 还带 `platform_branding`(管理员「生成网页标识」的名称/Logo/页脚文字与注入规则,正文禁止自写品牌)和 `runtime_base_url`;`_choose_page_profile` 现在**显式 `template_id` 优先**(单页文档模式也能选中套件模板,此前单页一律回落共享文档模板),未显式指定时旧选择行为不变。多页门户模板自带锚点切页兜底脚本(检测 `data-df-generated-header` 让位平台套壳,勿用 `data-df-generated-chrome` 字面量——会被注入幂等检查误判)。测试 `tests/test_page_template_suite.py`(10 模板 prepare→validate 全绿 + 品牌注入 + 居左/居中布局 + 引擎门控)。
|
||||||
|
- **Docker 内置技能同步**: Linux Docker 启动时不能让旧的持久化 `/app/skills` 遮住当前版本的 `backend/skills/public`。共享实现 `app/builtin_skill_sync.py` 会把 bundled public 覆盖同步到 live public 根、保留 `custom/`,并强制校验 Facebook/X/TikTok/YouTube/Threads/CNN/BBC/新华社/白宫官网/马尼拉时报/GMA News/雅虎日本/读卖新闻共 13 个硬路由页面技能;它使用跨进程文件锁和必需包内容摘要,多 worker 首次只复制一次,后续相同版本只校验跳过。两个受支持启动脚本仍在 Gateway 前调用 `backend/scripts/sync_builtin_skills.py`,把当前源码 `backend/skills` 只读挂载为 `/app/bundled-skills`、live skills 读写挂载到 `/app/skills`;同时 Gateway lifespan 在加载配置后、技能 ownership 迁移/MySQL 目录投影/提示词缓存之前再次调用同一共享实现,所以镜像默认入口、Compose 或外部发版脚本绕过 Shell 时也会自动补齐。任一硬路由技能缺失会 fail-fast 并打印名单,不能静默启动成“技能不可用”。
|
||||||
|
- **自定义技能迭代与版本切换**: 管理员设置弹窗的「自定义技能迭代」总开关默认关闭(`GET/PUT /api/system-settings/skill-versioning`);关闭时保持原同名覆盖逻辑。开启后仅 `skills/custom` 参与:本人上传同名技能可选「迭代为新版本」(保留完整历史包并激活新版)或「直接覆盖」(清除旧版本链,以本次内容重新作为 v1);本人技能详情顶部也提供「迭代新版本」安装包入口,详情弹窗「版本」页可切换任一快照。历史包保存在 runtime `skill-versions/<name>/vNNNNNN`,位于技能扫描/沙箱挂载目录之外;`skills/custom/<name>` 永远只保留一个活动包,所以大模型只能发现当前激活版本。版本元数据与调用统计解耦并继续以稳定技能名计数,上传迭代和版本切换都不清零外部调用次数。实现 `deerflow/skills/versioning.py`、`app/gateway/routers/skills.py` 的 `/versions` 接口,测试 `tests/test_skill_versioning.py` 与 `tests/test_strategy_project_settings.py`。
|
||||||
|
- **Facebook 页面生成技能**: 内置公共技能 `skills/public/facebook-page-generator` 只在用户明确要求 Facebook/Facebook 风格网页时触发;`lead_agent/prompt.py` 的普通问答 HTML 分流会强制读取该技能,并排除通用 `page-report-generation`、模板套件和从零手写 HTML。单账号单动态场景强制只写小型中文规格 JSON,再调用一次 `scripts/fast_single_post.py --spec`;脚本可将总评论数与实际展示数分离,按 `commentTopics` 自动补齐最多 100 条中文热评,也接受用户指定的逐条评论,并在一次进程内完成七模块 JSON、内部校验和 HTML 渲染。用户已提供素材或明确不搜索时禁止联网、图像生成、读模板/脚本源码和临时构建脚本;动态与评论正文必须为简体中文。多帖子场景仍使用 `scripts/render_facebook_page.py` 的 `init → validate → render` 流程确定性注入 `assets/facebook-template.html`,模型不得重写模板 DOM/CSS;渲染器拒绝覆盖已有文件并对 `</script>` 注入做转义。最终单文件 HTML 保留右上角设置按钮、分模块 JSON 编辑弹窗、实时校验与「应用并渲染」,以及响应式、深浅主题、发布/点赞/评论/搜索交互;浏览器缓存键包含初始 JSON 的 FNV-1a 指纹,同一制品刷新保留手动编辑,不同新制品不会再被沙箱同源旧 JSON 覆盖。测试 `tests/test_facebook_page_generator_skill.py`。
|
||||||
|
- **X 页面生成技能**: 内置公共技能 `skills/public/x-page-generator` 只在用户明确要求 X 平台、Twitter/推特或 X 风格社交时间线网页时触发;专用路由会强制读取技能并绕开通用 HTML 生成器。单账号单推文场景强制只写小型中文规格 JSON,再调用一次 `scripts/fast_single_post.py --spec`;脚本可将总回复数与实际展示数分离,按 `replyTopics` 自动补齐最多 100 条中文热评,也接受用户指定的逐条回复,并在一次进程内完成六模块 JSON、内部校验和 HTML 渲染。用户已提供素材或明确不搜索时禁止联网、图像生成、读模板/脚本源码和临时构建脚本;推文与回复正文必须为简体中文。多帖子场景仍通过 `scripts/render_x_page.py` 的 `init → validate → render` 流程注入固定三栏模板与内联运行时。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、实时校验和「应用并渲染」,保留深浅主题、发布、回复、点赞、转发、收藏、搜索、关注与响应式移动布局;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_x_page_generator_skill.py`。
|
||||||
|
- **TikTok 页面生成技能**: 内置公共技能 `skills/public/tiktok-page-generator` 只在用户明确要求 TikTok、抖音国际版或 TikTok 风格短视频信息流网页时触发。默认只写小型六模块补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_tiktok_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、实时校验和「应用并渲染」,保留滚动吸附、播放/暂停、双击点赞、静音、收藏、关注、评论、分享、搜索、方向键切换和移动端全屏布局;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_tiktok_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **YouTube 页面生成技能**: 内置公共技能 `skills/public/youtube-page-generator` 只在用户明确要求 YouTube 或 YouTube 风格视频门户、视频首页、频道页时触发。默认只写小型七模块补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_youtube_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、分类筛选、搜索、响应式视频网格、Shorts 横向列表、观看弹窗、点赞、收藏、订阅和评论;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_youtube_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **Threads 页面生成技能**: 内置公共技能 `skills/public/threads-page-generator` 只在用户明确要求 Threads 或 Threads 风格串文首页、文本社交信息流时触发。默认只写 `accountName`、`postText`、`topic`、`displayReplyCount` 等高层规格 JSON,并调用一次专用 `scripts/fast_page.py --spec`;脚本自动映射六模块、补齐作者/统计/中文热评、保留示例视觉并一次完成校验与渲染,禁止模型猜测 `$set` 深层路径或读取默认数据。只有结构改造才回退 `scripts/render_threads_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、深浅主题、发帖、搜索、点赞、回复、转发、分享、关注、动态面板和移动端导航;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_threads_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **CNN 页面生成技能**: 内置公共技能 `skills/public/cnn-page-generator` 只在用户明确要求 CNN 或 CNN 风格全球新闻门户、新闻首页时触发。默认只写以 `topic` 为核心、可选 `headline`/`breaking`/栏目标题数组的高层规格 JSON,并调用一次专用 `scripts/fast_page.py --spec`;脚本自动生成完整中文十模块与明确标注的非实时示意数据,禁止模型猜测 `$set` 深层路径、读取生成后的合并数据或探路后二次渲染。只有结构改造才回退 `scripts/render_cnn_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、突发条、搜索、直播弹窗、字幕切换、收藏、分享、移动菜单、市场快照和订阅表单;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_cnn_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **BBC 页面生成技能**: 内置公共技能 `skills/public/bbc-page-generator` 只在用户明确要求 BBC 或 BBC 风格国际公共新闻门户、新闻首页时触发。默认只写小型十模块补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_bbc_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、搜索、快讯、直播弹窗、字幕切换、音频进度、移动抽屉、新闻排行、地区天气和订阅反馈;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_bbc_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **新华社页面生成技能**: 内置公共技能 `skills/public/xinhua-page-generator` 只在用户明确要求新华社、新华网或新华社风格中文通讯社门户、新闻首页时触发。默认只写小型十模块中文补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_xinhua_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、多语种顶栏、报道专集、焦点图、要闻分类、名专栏、专题、记者工作室、地方切换、行业频道、媒体矩阵、直播字幕和订阅反馈;缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_xinhua_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **白宫官网页面生成技能**: 内置公共技能 `skills/public/white-house-page-generator` 只在用户明确要求白宫官网、White House 风格政府首页或美国行政机构门户时触发。技能把材料整理为 `site/navigation/hero/notice/updates/priorities/administration/calendar/participation/footer` 十模块 JSON;键名、`id`、锚点和视觉枚举保留英文技术值,所有读者可见内容强制使用简体中文,英文来源先翻译,`site.language` 固定为 `zh-CN`。默认只写小型中文补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_white_house_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、透明转吸顶导航、建筑主视觉、公告、官方动态、优先事项、行政团队、公共日历、全屏菜单搜索、直播字幕和订阅反馈;默认内容明确为概念模板,不冒充政府官网,缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_white_house_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **马尼拉时报页面生成技能**: 内置公共技能 `skills/public/manila-times-page-generator` 只在用户明确要求马尼拉时报、The Manila Times 或其风格的菲律宾大报门户时触发。技能把材料整理为 `site/navigation/ticker/lead/pulse/regions/opinion/sections/media/footer` 十模块 JSON;键名、`id`、锚点、视觉和涨跌枚举保留英文技术值,所有读者可见内容强制使用简体中文,英文或菲律宾语来源先翻译,`site.language` 固定为 `zh-CN`。默认只写小型中文补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_manila_times_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、菲律宾旗色带、衬线报头、三栏头条、地区切换、评论、商业体育、视频弹窗、数字报翻页和订阅反馈;默认内容明确为概念模板,不冒充官方网站,缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_manila_times_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **GMA News 页面生成技能**: 内置公共技能 `skills/public/gma-news-page-generator` 只在用户明确要求 GMA News、GMA 新闻或菲律宾广播新闻门户风格页面时触发。技能把材料整理为 `site/navigation/justIn/lead/news/services/broadcast/channels/media/footer` 十模块 JSON;键名、`id`、锚点和视觉枚举保留英文技术值,品牌缩写 `GMA` 可保留,其余读者可见内容强制使用简体中文,英文或菲律宾语来源先翻译,`site.language` 固定为 `zh-CN`。默认只写小型中文补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_gma_news_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、即时新闻条、天气切换、吸顶导航、头条视频、最新/热门/地方切换、公共服务、电视直播字幕、频道卡片、播客、彩票开奖和订阅反馈;默认内容明确为概念模板,不冒充官方网站,缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_gma_news_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **雅虎日本页面生成技能**: 内置公共技能 `skills/public/yahoo-japan-page-generator` 只在用户明确要求雅虎日本、Yahoo! JAPAN、Yahoo Japan 或日本综合门户风格页面时触发。技能把材料整理为 `site/search/services/news/account/weather/utilities/shopping/pulse/footer` 十模块 JSON;键名、`id`、锚点和视觉枚举保留英文技术值,品牌 `Yahoo! JAPAN` 可保留,其余读者可见内容强制使用简体中文,日文或英文来源先翻译,`site.language` 固定为 `zh-CN`。默认只写小型中文补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_yahoo_japan_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、多类型搜索、服务展开、分类新闻、推荐轮换、演示登录、城市天气、路线查询、市场切换、商品收藏、体育比分、实时热榜、移动抽屉和返回顶部;默认内容明确为概念模板,不冒充官方网站,缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_yahoo_japan_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
|
- **读卖新闻页面生成技能**: 内置公共技能 `skills/public/yomiuri-news-page-generator` 只在用户明确要求读卖新闻、读买新闻、Yomiuri、Yomiuri Shimbun 或日本全国大报风格页面时触发。技能把材料整理为 `site/navigation/breaking/lead/edition/features/news/opinion/media/footer` 十模块 JSON;键名、`id`、锚点和视觉枚举保留英文技术值,品牌罗马字 `YOMIURI ONLINE` 可保留,其余读者可见内容强制使用简体中文,日文或英文来源先翻译,`site.language` 固定为 `zh-CN`。默认只写小型中文补丁规格 JSON,并调用一次 `scripts/fast_page.py --spec` 在内部合并、校验和渲染;只有结构改造才回退 `scripts/render_yomiuri_news_page.py` 的 `init → validate → render`。最终单文件 HTML 自带右上角设置按钮、按模块 JSON 编辑弹窗、字号切换、速报展开、三栏头条、文章收藏、吸顶导航、全屏菜单、搜索、演示登录、数字报翻页、专题与分类切换、社论、视频字幕和邮件订阅;默认内容明确为概念模板,不冒充官方网站,缓存键包含初始 JSON 指纹并兼容禁止 localStorage 的沙箱。测试 `tests/test_yomiuri_news_page_generator_skill.py` 与 `tests/test_fast_page_generator_specs.py`。
|
||||||
- **舆情分析智能体(前端虚拟智能体)**: 智能体管理页新增「舆情分析」类型 tab,固定一张虚拟智能体卡片(名称/简介可编辑,存 localStorage)。对话页 `pages/SentimentAgentChatPage.tsx`(路由 `agents/sentiment-analysis/chats/:thread_id`)复用普通问答布局 + `MessageList`,**输入框只有发送按钮**;问答经 Gateway `POST /api/sentiment-agent/stream` 转发外部 AG-UI 网关(不经过 LangGraph),会话仅存 sessionStorage。接口地址 + Basic Auth 在 `runtime-config.js` 配置(`VITE_SENTIMENT_AGENT_API_URL` / `_AUTH_USERNAME` / `_AUTH_PASSWORD`)并随请求传给后台;后台按传入地址转发、关闭 TLS 校验,失败时把完整错误回传。核心模块 `src/core/sentiment-agent/`。
|
- **舆情分析智能体(前端虚拟智能体)**: 智能体管理页新增「舆情分析」类型 tab,固定一张虚拟智能体卡片(名称/简介可编辑,存 localStorage)。对话页 `pages/SentimentAgentChatPage.tsx`(路由 `agents/sentiment-analysis/chats/:thread_id`)复用普通问答布局 + `MessageList`,**输入框只有发送按钮**;问答经 Gateway `POST /api/sentiment-agent/stream` 转发外部 AG-UI 网关(不经过 LangGraph),会话仅存 sessionStorage。接口地址 + Basic Auth 在 `runtime-config.js` 配置(`VITE_SENTIMENT_AGENT_API_URL` / `_AUTH_USERNAME` / `_AUTH_PASSWORD`)并随请求传给后台;后台按传入地址转发、关闭 TLS 校验,失败时把完整错误回传。核心模块 `src/core/sentiment-agent/`。
|
||||||
- **简洁模式用户引导 (Compact-mode onboarding tour)**: 简洁模式(外观设置的「全量/简洁」= compact,无全局导航栏 + 页面侧边栏)新增 TDesign React `Guide` 组件驱动的分步引导。组件 `components/workspace/compact-mode-guide.tsx`(挂在 `ChatPage`):9 步 —— 欢迎弹窗(dialog 模式)→ 左侧功能导航 → 聊天记录 → 设置和更多 → 换肤 → 界面模式(切回全量)→ 常用提示词栏 → 提示词管理弹窗 → 输入框;高亮目标由各组件上的 `data-compact-guide` 标记定位(`workspace-nav-chat-list` / `recent-chat-list` / `workspace-nav-menu` / `appearance-controls` / `custom-prompt-menu.tsx` 的 `CustomPromptBar`(提示词栏,仅新对话落地态渲染)与其 `ManagePromptsDialog`(`prompt-dialog` 锚点)/ ChatPage 输入框容器),**启动时按目标是否存在过滤步骤**(如新用户无聊天记录、侧栏收起时自动剔除该步 —— Guide 对缺失元素会抛错,不能盲传)。**提示词管理弹窗步骤是动态目标**:弹窗平时不渲染,引导切到该步前先广播 `PROMPT_DIALOG_GUIDE_EVENT`(`custom-prompt-menu.tsx` 导出)让 `CustomPromptBar` 打开 `ManagePromptsDialog` 并**接管**(`owner: true` 期间 ESC/点遮罩不关闭,防止高亮目标消失导致 Guide 报错),轮询锚点真正挂载后才切步;离开该步 / 跳过 / 完成 / 中途卸载时以 `owner: false` 收回弹窗,4 秒打不开则跳过该步防卡死。**TDesign Guide × Radix 模态互操作**:Radix 模态弹窗打开时会把 `body` 置 `pointer-events:none`(滚动锁定),Guide 直接挂在 body 下的遮罩/高亮/弹层会一并继承失活(引导按钮点不动),`styles/tdesign-theme.css` 末尾对 `.t-guide__overlay/__highlight/__popup/__wrapper` 显式 `pointer-events:auto` 兜底。触发:① 自动 —— 简洁模式新对话落地页自动演示,直到用户显式点「完成」或「跳过」才写 localStorage `deerflow.compact-guide-finished` 记忆(浏览器级);**中途刷新/离开不记忆,下次进入还会再演示**。② 手动 —— 「设置和更多」下拉新增「界面使用引导」(该下拉仅存在于简洁模式工作区侧栏 footer):已在问答页时广播 `compact-guide:start` 窗口事件直接启动,否则写 sessionStorage 请求并导航 `/chats/new` 由挂载的引导消费(消费在定时器真正启动时才执行,规避 StrictMode effect 双跑吞请求)。`eligible` 排除 embed=1 / hideChrome=1 / chats_iframe / FORCE_COLLAPSED_SIDEBAR(无界)等同样无全局 chrome 的特殊环境;启动延迟 800ms 等侧栏宽度过渡稳定后再测量高亮框。
|
- **简洁模式用户引导 (Compact-mode onboarding tour)**: 简洁模式(外观设置的「全量/简洁」= compact,无全局导航栏 + 页面侧边栏)新增 TDesign React `Guide` 组件驱动的分步引导。组件 `components/workspace/compact-mode-guide.tsx`(挂在 `ChatPage`):9 步 —— 欢迎弹窗(dialog 模式)→ 左侧功能导航 → 聊天记录 → 设置和更多 → 换肤 → 界面模式(切回全量)→ 常用提示词栏 → 提示词管理弹窗 → 输入框;高亮目标由各组件上的 `data-compact-guide` 标记定位(`workspace-nav-chat-list` / `recent-chat-list` / `workspace-nav-menu` / `appearance-controls` / `custom-prompt-menu.tsx` 的 `CustomPromptBar`(提示词栏,仅新对话落地态渲染)与其 `ManagePromptsDialog`(`prompt-dialog` 锚点)/ ChatPage 输入框容器),**启动时按目标是否存在过滤步骤**(如新用户无聊天记录、侧栏收起时自动剔除该步 —— Guide 对缺失元素会抛错,不能盲传)。**提示词管理弹窗步骤是动态目标**:弹窗平时不渲染,引导切到该步前先广播 `PROMPT_DIALOG_GUIDE_EVENT`(`custom-prompt-menu.tsx` 导出)让 `CustomPromptBar` 打开 `ManagePromptsDialog` 并**接管**(`owner: true` 期间 ESC/点遮罩不关闭,防止高亮目标消失导致 Guide 报错),轮询锚点真正挂载后才切步;离开该步 / 跳过 / 完成 / 中途卸载时以 `owner: false` 收回弹窗,4 秒打不开则跳过该步防卡死。**TDesign Guide × Radix 模态互操作**:Radix 模态弹窗打开时会把 `body` 置 `pointer-events:none`(滚动锁定),Guide 直接挂在 body 下的遮罩/高亮/弹层会一并继承失活(引导按钮点不动),`styles/tdesign-theme.css` 末尾对 `.t-guide__overlay/__highlight/__popup/__wrapper` 显式 `pointer-events:auto` 兜底。触发:① 自动 —— 简洁模式新对话落地页自动演示,直到用户显式点「完成」或「跳过」才写 localStorage `deerflow.compact-guide-finished` 记忆(浏览器级);**中途刷新/离开不记忆,下次进入还会再演示**。② 手动 —— 「设置和更多」下拉新增「界面使用引导」(该下拉仅存在于简洁模式工作区侧栏 footer):已在问答页时广播 `compact-guide:start` 窗口事件直接启动,否则写 sessionStorage 请求并导航 `/chats/new` 由挂载的引导消费(消费在定时器真正启动时才执行,规避 StrictMode effect 双跑吞请求)。`eligible` 排除 embed=1 / hideChrome=1 / chats_iframe / FORCE_COLLAPSED_SIDEBAR(无界)等同样无全局 chrome 的特殊环境;启动延迟 800ms 等侧栏宽度过渡稳定后再测量高亮框。
|
||||||
- **智能体使用引导 (Agent onboarding tour, 三段式)**: 智能体「浏览管理 → 创建与配置 → 发起问答」全流程分步引导,组件 `components/workspace/agents/agent-guide.tsx`(同一 TDesign `Guide` 封装模式,与简洁模式引导共享记忆语义:**仅显式点「完成/跳过」才写 localStorage** `deerflow.agent-guide.<stage>.finished`,中途刷新/离开不记忆)。**自动演示仅 create / chat 两段**(进智能体列表页不弹引导,点「创建智能体」进入新建页时才自动演示;list 段的 `AgentGuide` 传 `autoStart={false}`,只能由头部「使用引导」按钮手动触发)。三段各自挂载、各自记忆:① `list`(`agent-gallery.tsx`,/page/workspace/agents)——分区 Tabs、搜索排序、智能体卡片操作、右上「创建智能体」按钮;**完成/跳过就地结束(不跳转创建页,与 create 段无联动)**,最后一步仅提示进入创建页后会有配置引导;② `create`(`NewAgentPage.tsx`,/page/workspace/agents/new)——左侧对话式创建输入区、基本信息、运行模型+入库模板名、知识空间、SOUL.md、技能穿梭框、保存按钮(9 步);③ `chat`(`AgentChatPage.tsx`,agents/:id/chats)——左栏切换与历史、常用问题 chips、输入框(落地态/会话态两个挂点同一 `chat-input` 标记)、右侧详情面板;`eligible` 限定普通智能体对话页(`showAgentList && !isEmbedded && !taskCtxOn`,即排除通用问答原地嵌入与任务深链工作区),三段共用 `isAgentGuideEnvironment()` 排除 embed/hideChrome/无界环境。高亮锚点 `data-agent-guide`:列表页 `tabs`/`search`/`agent-card`(卡片+列表两种布局的根元素)/`new-agent-btn`,创建页 `create-chat-input`/`create-basic`/`create-model`/`create-knowledge`/`create-soul`/`create-skills`/`create-save-btn`,对话页 `chat-sidebar`/`chat-questions`/`chat-input`/`chat-detail`;同样**启动时按目标存在性过滤步骤**(新用户无卡片/无预设问题时自动剔除)。手动重放:三个页面头部各有「使用引导」按钮(列表页创建按钮左侧、创建页 header 右侧、对话页 header),广播 `agent-guide:start:<stage>` 窗口事件强制重放(忽略已看过记忆)。
|
- **智能体使用引导 (Agent onboarding tour, 三段式)**: 智能体「浏览管理 → 创建与配置 → 发起问答」全流程分步引导,组件 `components/workspace/agents/agent-guide.tsx`(同一 TDesign `Guide` 封装模式,与简洁模式引导共享记忆语义:**仅显式点「完成/跳过」才写 localStorage** `deerflow.agent-guide.<stage>.finished`,中途刷新/离开不记忆)。**自动演示仅 create / chat 两段**(进智能体列表页不弹引导,点「创建智能体」进入新建页时才自动演示;list 段的 `AgentGuide` 传 `autoStart={false}`,只能由头部「使用引导」按钮手动触发)。三段各自挂载、各自记忆:① `list`(`agent-gallery.tsx`,/page/workspace/agents)——分区 Tabs、搜索排序、智能体卡片操作、右上「创建智能体」按钮;**完成/跳过就地结束(不跳转创建页,与 create 段无联动)**,最后一步仅提示进入创建页后会有配置引导;② `create`(`NewAgentPage.tsx`,/page/workspace/agents/new)——左侧对话式创建输入区、基本信息、运行模型+入库模板名、知识空间、SOUL.md、技能穿梭框、保存按钮(9 步);③ `chat`(`AgentChatPage.tsx`,agents/:id/chats)——左栏切换与历史、常用问题 chips、输入框(落地态/会话态两个挂点同一 `chat-input` 标记)、右侧详情面板;`eligible` 限定普通智能体对话页(`showAgentList && !isEmbedded && !taskCtxOn`,即排除通用问答原地嵌入与任务深链工作区),三段共用 `isAgentGuideEnvironment()` 排除 embed/hideChrome/无界环境。高亮锚点 `data-agent-guide`:列表页 `tabs`/`search`/`agent-card`(卡片+列表两种布局的根元素)/`new-agent-btn`,创建页 `create-chat-input`/`create-basic`/`create-model`/`create-knowledge`/`create-soul`/`create-skills`/`create-save-btn`,对话页 `chat-sidebar`/`chat-questions`/`chat-input`/`chat-detail`;同样**启动时按目标存在性过滤步骤**(新用户无卡片/无预设问题时自动剔除)。手动重放:三个页面头部各有「使用引导」按钮(列表页创建按钮左侧、创建页 header 右侧、对话页 header),广播 `agent-guide:start:<stage>` 窗口事件强制重放(忽略已看过记忆)。
|
||||||
|
|||||||
@@ -0,0 +1,366 @@
|
|||||||
|
# GoView 第一阶段离线项目模板与发布实施方案
|
||||||
|
|
||||||
|
## 1. 阶段目标
|
||||||
|
|
||||||
|
第一阶段只解决 GoView 的离线可用和内容管理闭环。
|
||||||
|
|
||||||
|
用户在保留原有画布编辑器的前提下,能够完成:
|
||||||
|
|
||||||
|
1. 我的项目:新建、编辑、重命名、删除、保存、预览和发布;
|
||||||
|
2. 我的模板:把自己的项目保存为模板、查看、编辑模板信息和用模板创建项目;
|
||||||
|
3. 模板市场:查看内置模板、用模板创建个人项目;
|
||||||
|
4. 离线部署:项目 JSON、缩略图、模板封面和地图瓦片均由本地部署提供;
|
||||||
|
5. 发布链接:项目发布后获得可直接访问的只读预览链接;
|
||||||
|
6. 地图瓦片背景:在原有画布的组件库中增加一张可离线使用的 Leaflet 瓦片地图背景组件。
|
||||||
|
|
||||||
|
现有画布的拖拽、缩放、分组、样式、数据面板和事件面板不在本阶段改造范围内。
|
||||||
|
|
||||||
|
### 原生数据面板完整保留
|
||||||
|
|
||||||
|
截图中的“数据”标签页属于每个 GoView 组件自身的画布配置,不属于项目、模板或发布后台。第一阶段必须完整保留:
|
||||||
|
|
||||||
|
- 静态数据和 JSON 在线编辑;
|
||||||
|
- JSON 或 TXT 导入、下载;
|
||||||
|
- 动态请求;
|
||||||
|
- 公共接口和数据池;
|
||||||
|
- 数据字段映射及匹配状态;
|
||||||
|
- 组件原有的刷新与轮询配置。
|
||||||
|
|
||||||
|
项目保存接口把整份 ChartEditStorage 作为 content_json 原样保存,其中已包含组件的 request、filter、option.dataset、字段映射和其它数据配置。模板创建和“使用模板”也只深拷贝同一份 JSON,不能删除、重置或改写这些数据配置。
|
||||||
|
|
||||||
|
后续如要增加新的数据来源,只能在这个数据面板中新增选项或适配器,不能替换、收窄或移除现有的静态数据、动态请求和公共接口能力。
|
||||||
|
|
||||||
|
## 2. 已核实的 GoView 基线
|
||||||
|
|
||||||
|
前端基线使用 H:\code\go-view 的官方 origin/master-fetch 分支。
|
||||||
|
|
||||||
|
| 功能 | 开源现状 | 第一阶段处理 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 我的项目 | 已有项目卡片、创建、保存、删除、发布和预览请求 | 本地 Gateway 实现兼容接口 |
|
||||||
|
| 我的模板 | 页面仅显示“暂时还没有东西呢” | 新增模板列表和模板操作 |
|
||||||
|
| 模板市场 | 页面只展示 GoView Pro 宣传图和外链 | 替换为本地模板卡片列表 |
|
||||||
|
| 新建弹窗模板入口 | “我的模板”和“模板市场”按钮处于禁用状态 | 启用并跳转到可用模板页 |
|
||||||
|
| 项目发布 | 已有 state 字段和发布按钮 | 保存状态,并生成公开预览链接 |
|
||||||
|
| 地图组件 | 有 ECharts 和高德地图组件,无离线 XYZ 瓦片背景组件 | 新增 Leaflet 瓦片背景组件 |
|
||||||
|
|
||||||
|
因此,项目画布本身不需要重写;模板中心不是“补一个后端开关”即可完成,必须同时补前端页面和接口。
|
||||||
|
|
||||||
|
## 3. 总体结构
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
GoView master-fetch 前端
|
||||||
|
|
|
||||||
|
| /api/goview/*
|
||||||
|
v
|
||||||
|
DeerFlow Gateway
|
||||||
|
|
|
||||||
|
+-- 项目和项目内容
|
||||||
|
+-- 个人模板和市场模板
|
||||||
|
+-- 本地图片与缩略图
|
||||||
|
+-- 已发布项目的只读数据
|
||||||
|
+-- 离线地图瓦片
|
||||||
|
~~~
|
||||||
|
|
||||||
|
GoView 保持为独立的 Vue 前端。其他现有前端工程不参与第一阶段改造。
|
||||||
|
|
||||||
|
## 4. 接口兼容策略
|
||||||
|
|
||||||
|
### 4.1 保留现有项目接口前缀
|
||||||
|
|
||||||
|
GoView master-fetch 的请求前缀是 /api/goview,项目页和画布保存逻辑已经依赖下面的路径。Gateway 应优先兼容这些接口,避免改动画布同步逻辑。
|
||||||
|
|
||||||
|
| 方法和路径 | 请求 | 响应用途 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| GET /api/goview/project/list | page、limit | 我的项目卡片和分页 |
|
||||||
|
| POST /api/goview/project/create | JSON:projectName、remarks、indexImage | 新建项目,返回 id |
|
||||||
|
| GET /api/goview/project/getData | projectId | 编辑器读取项目元信息和 content |
|
||||||
|
| POST /api/goview/project/save/data | 表单:projectId、content | 自动保存画布 JSON |
|
||||||
|
| POST /api/goview/project/edit | JSON:id 和可编辑元信息 | 修改名称、说明或封面 |
|
||||||
|
| POST /api/goview/project/rename | JSON:id、projectName | 快速重命名 |
|
||||||
|
| DELETE /api/goview/project/delete | ids | 删除自己的项目 |
|
||||||
|
| PUT /api/goview/project/publish | JSON:id、state | 发布或取消发布 |
|
||||||
|
| POST /api/goview/project/upload | multipart:object | 上传本地缩略图或图片 |
|
||||||
|
|
||||||
|
响应保持 GoView 的 ResultEnum 约定:
|
||||||
|
|
||||||
|
~~~json
|
||||||
|
{
|
||||||
|
"code": 200,
|
||||||
|
"msg": "获取成功",
|
||||||
|
"data": {},
|
||||||
|
"count": 0
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
项目列表的 count 与 data 同级,保持现有项目页的读取方式。项目详情使用现有字段 id、projectName、state、createTime、indexImage、createUserId、remarks 和 content。
|
||||||
|
|
||||||
|
### 4.2 新增模板接口
|
||||||
|
|
||||||
|
模板页面当前没有可复用接口,因此新增清晰的模板 API,不伪装成项目接口。
|
||||||
|
|
||||||
|
| 方法和路径 | 权限 | 用途 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| GET /api/goview/templates/mine | 登录用户 | 我的模板列表和分页 |
|
||||||
|
| POST /api/goview/templates/from-project | 项目所有者 | 从一个项目创建个人模板 |
|
||||||
|
| GET /api/goview/templates/{id} | 模板所有者或市场可见 | 读取模板详情与 canvas JSON |
|
||||||
|
| PUT /api/goview/templates/{id} | 模板所有者 | 修改名称、说明、封面 |
|
||||||
|
| DELETE /api/goview/templates/{id} | 模板所有者 | 删除个人模板 |
|
||||||
|
| GET /api/goview/templates/market | 登录用户或公开读取 | 模板市场列表 |
|
||||||
|
| POST /api/goview/templates/{id}/create-project | 登录用户 | 深拷贝模板为新项目并返回项目 id |
|
||||||
|
| POST /api/goview/templates/admin/seed | 管理员或启动期内部调用 | 导入内置模板,不在普通 UI 展示 |
|
||||||
|
|
||||||
|
市场模板只能“使用并创建项目”,不能直接编辑模板内容。个人模板只能由模板创建者编辑或删除。管理员维护市场模板不需要引入租户、空间和成员模型。
|
||||||
|
|
||||||
|
### 4.3 已发布项目访问链接
|
||||||
|
|
||||||
|
编辑器继续使用:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
/#/chart/home/{projectId}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
发布后的用户访问链接使用原有预览路由:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
/#/chart/preview/{projectId}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
为了让链接在没有登录态时可直接访问,新增只读接口:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
GET /api/goview/project/published/{projectId}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
该接口仅当项目 state 为 1 时返回项目元信息和 content;未发布、已取消发布或不存在的项目统一返回 404。编辑器接口 getData 保持登录和所有者校验,不能为了预览方便而开放草稿。
|
||||||
|
|
||||||
|
预览页面启动时根据路由判断:
|
||||||
|
|
||||||
|
1. 编辑预览或已登录所有者预览,读取 getData;
|
||||||
|
2. 直接打开已发布链接,读取 published/{projectId};
|
||||||
|
3. published 接口返回 404 时显示“项目未发布或不存在”页面。
|
||||||
|
|
||||||
|
发布接口成功后返回 relative_view_url,例如 /#/chart/preview/id_38xq54e9uoo000。前端用当前站点 origin 拼成完整链接并提供“复制链接”按钮,不在后端写死域名、端口或部署前缀。
|
||||||
|
|
||||||
|
## 5. 持久化设计
|
||||||
|
|
||||||
|
第一阶段只需要项目、项目内容、模板和本地资源存储。
|
||||||
|
|
||||||
|
### 5.1 goview_projects
|
||||||
|
|
||||||
|
| 字段 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| id | 字符串主键,兼容 GoView 的 id 路由参数 |
|
||||||
|
| project_name | 项目名 |
|
||||||
|
| remarks | 说明 |
|
||||||
|
| state | -1 未发布,1 已发布 |
|
||||||
|
| index_image | 缩略图资源地址 |
|
||||||
|
| owner_id | 当前登录用户 ID |
|
||||||
|
| created_at / updated_at | 创建和更新时间 |
|
||||||
|
|
||||||
|
### 5.2 goview_project_contents
|
||||||
|
|
||||||
|
| 字段 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| project_id | 一对一关联项目,唯一 |
|
||||||
|
| content_json | GoView ChartEditStorage 的完整 JSON,使用 PortableLongText |
|
||||||
|
| updated_at | 最后保存时间 |
|
||||||
|
|
||||||
|
列表查询不读取 content_json,只有编辑器和预览页读取,避免大画布 JSON 进入列表响应。
|
||||||
|
|
||||||
|
### 5.3 goview_templates
|
||||||
|
|
||||||
|
| 字段 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| id | 模板主键 |
|
||||||
|
| name / description | 模板名称和描述 |
|
||||||
|
| cover_image | 模板封面资源地址 |
|
||||||
|
| content_json | 可直接复制为项目内容的 GoView JSON |
|
||||||
|
| owner_id | 个人模板的创建者;内置市场模板可为空 |
|
||||||
|
| scope | personal 或 market |
|
||||||
|
| is_builtin | 内置模板标记;内置模板不可由普通用户删除 |
|
||||||
|
| sort_order | 市场排序 |
|
||||||
|
| created_at / updated_at | 创建和更新时间 |
|
||||||
|
|
||||||
|
### 5.4 本地资源目录
|
||||||
|
|
||||||
|
上传的图片、缩略图和模板封面保存到运行时可持久化目录,例如:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
{runtime_dir}/goview-assets/
|
||||||
|
~~~
|
||||||
|
|
||||||
|
上传服务校验文件类型、大小、文件名和真实图片格式,使用服务端生成的随机文件名,禁止保留用户路径。资源通过 Gateway 的受控 GET 接口提供,不依赖 OSS、CDN 或公网地址。
|
||||||
|
|
||||||
|
离线发版的镜像、离线依赖和部署脚本与业务源码分开维护;业务源码仓库只保留接口、数据库迁移、内置模板定义和前端源码。
|
||||||
|
|
||||||
|
## 6. 身份与权限
|
||||||
|
|
||||||
|
不新建 GoView 用户系统。项目和模板直接复用平台现有登录态。
|
||||||
|
|
||||||
|
| 场景 | 规则 |
|
||||||
|
| --- | --- |
|
||||||
|
| 我的项目 | 只列出 owner_id 为当前用户的项目 |
|
||||||
|
| 我的模板 | 只列出 owner_id 为当前用户且 scope 为 personal 的模板 |
|
||||||
|
| 模板市场 | 所有登录用户可读 market 模板 |
|
||||||
|
| 创建项目 | 当前用户成为 owner |
|
||||||
|
| 发布、保存、删除、重命名 | 仅项目 owner;无鉴权单用户部署按单管理空间规则处理 |
|
||||||
|
| 维护市场模板 | 管理员 |
|
||||||
|
| 发布项目预览 | 无需登录,但只读且仅返回已发布 content |
|
||||||
|
|
||||||
|
GoView 现有 axios 登录逻辑依赖自己的 GO_SYSTEM_STORE 和 /login。第一阶段替换为平台现有 Bearer Token 与 Cookie 逻辑;这个改动只影响网络层和路由守卫,不改编辑器画布。
|
||||||
|
|
||||||
|
## 7. 前端最小改造清单
|
||||||
|
|
||||||
|
### 7.1 保持不动的部分
|
||||||
|
|
||||||
|
- /chart/home/:id 的画布、左侧组件库、右侧样式/动画/数据/事件面板;
|
||||||
|
- ChartEditStorage 的序列化结构;
|
||||||
|
- useSync 中动态注册组件、恢复画布和自动保存机制;
|
||||||
|
- 现有项目卡片布局和发布状态展示。
|
||||||
|
|
||||||
|
### 7.2 项目页
|
||||||
|
|
||||||
|
项目页继续调用现有 project.api.ts。适配 axios 的平台鉴权后,项目列表、新建、保存、删除、发布和缩略图上传可直接对接 Gateway。
|
||||||
|
|
||||||
|
项目卡片新增两个轻量操作:
|
||||||
|
|
||||||
|
1. 复制发布链接:仅已发布时显示;
|
||||||
|
2. 保存为模板:把当前项目的最新 content 创建为个人模板。
|
||||||
|
|
||||||
|
### 7.3 我的模板
|
||||||
|
|
||||||
|
替换 src/views/project/mtTemplate/index.vue 的空状态页。
|
||||||
|
|
||||||
|
页面提供模板卡片列表、分页、预览、编辑名称/描述/封面、删除和“使用模板”按钮。点击使用模板调用 create-project,成功后直接跳转 /chart/home/{newProjectId}。
|
||||||
|
|
||||||
|
新建弹窗中“我的模板”按钮解除禁用,跳转到该页面或直接打开模板选择抽屉。
|
||||||
|
|
||||||
|
### 7.4 模板市场
|
||||||
|
|
||||||
|
替换 src/views/project/templateMarket/index.vue 的 Pro 宣传图和外链。
|
||||||
|
|
||||||
|
页面读取 market 接口,以与项目卡片相同的视觉语言展示内置模板。市场模板至少准备:
|
||||||
|
|
||||||
|
1. 深色通用数据驾驶舱;
|
||||||
|
2. 地图基础概览大屏;
|
||||||
|
3. 指标总览与趋势分析大屏;
|
||||||
|
4. 时间轴与进度概览大屏。
|
||||||
|
|
||||||
|
模板内容作为版本化的内置 seed 文件随 Gateway 发布。首次启动只插入不存在的内置模板,后续升级不覆盖管理员已修改或新增的模板。
|
||||||
|
|
||||||
|
新建弹窗中“模板市场”按钮解除禁用,跳转到该页面或打开市场模板选择抽屉。
|
||||||
|
|
||||||
|
### 7.5 公开预览
|
||||||
|
|
||||||
|
预览页保留现有 /chart/preview/:id 和原始画布渲染。只修改加载项目数据的入口:未登录时走 published 接口,已登录编辑场景继续走 getData。预览页不显示编辑、保存、删除、模板和管理员操作。
|
||||||
|
|
||||||
|
## 8. 离线地图瓦片背景组件
|
||||||
|
|
||||||
|
### 8.1 目标
|
||||||
|
|
||||||
|
新增一个“地图瓦片背景”组件。第一阶段只提供离线底图和通用显示配置。
|
||||||
|
|
||||||
|
### 8.2 实现方式
|
||||||
|
|
||||||
|
在 GoView 组件库新增 Leaflet 组件:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
src/packages/components/Business/Maps/LeafletTileBackground/
|
||||||
|
config.ts
|
||||||
|
index.vue
|
||||||
|
config.vue
|
||||||
|
~~~
|
||||||
|
|
||||||
|
依赖使用 Leaflet 1.9,并在 GoView 入口加载 Leaflet CSS。组件作为普通 GoView 图层,可调整位置、尺寸、层级、边框、透明度和隐藏状态。
|
||||||
|
|
||||||
|
配置面板只暴露:
|
||||||
|
|
||||||
|
- 底图样式:默认离线底图、管理员配置的其他离线底图;
|
||||||
|
- 初始中心点和缩放级别;
|
||||||
|
- 最小和最大缩放;
|
||||||
|
- 是否允许鼠标缩放和拖拽;
|
||||||
|
- 明暗遮罩、透明度和灰度效果。
|
||||||
|
|
||||||
|
不允许用户输入任意瓦片 URL,避免离线部署失效、内网地址泄漏和任意外部请求。
|
||||||
|
|
||||||
|
### 8.3 瓦片服务
|
||||||
|
|
||||||
|
Gateway 新增受控瓦片路由:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
GET /api/goview/map-tiles/{style}/{z}/{x}/{y}.png
|
||||||
|
~~~
|
||||||
|
|
||||||
|
瓦片数据位于部署的可持久化目录或只读地图资源卷。路由严格校验 style、z、x、y 范围并阻止路径穿越。
|
||||||
|
|
||||||
|
第一期配置一个默认样式,对接部署时挂载的 XYZ 瓦片目录。GoView 组件始终只使用 Gateway 的受控地址。
|
||||||
|
|
||||||
|
编辑器内默认关闭地图拖拽,避免和画布选择、移动组件冲突;预览页可按组件配置开启交互。组件卸载时必须调用 map.remove(),避免切换项目时保留 DOM、瓦片和事件监听。
|
||||||
|
|
||||||
|
## 9. 后端代码落点
|
||||||
|
|
||||||
|
建议新增:
|
||||||
|
|
||||||
|
~~~text
|
||||||
|
offline-backend-20260512/backend/
|
||||||
|
app/gateway/routers/goview_projects.py
|
||||||
|
app/gateway/routers/goview_templates.py
|
||||||
|
app/gateway/routers/goview_assets.py
|
||||||
|
app/gateway/routers/goview_map_tiles.py
|
||||||
|
packages/harness/deerflow/persistence/goview/
|
||||||
|
__init__.py
|
||||||
|
models.py
|
||||||
|
project_store.py
|
||||||
|
template_store.py
|
||||||
|
packages/harness/deerflow/persistence/migrations/versions/
|
||||||
|
YYYYMMDD_NN_goview_projects_and_templates.py
|
||||||
|
app/gateway/goview_builtin_templates.py
|
||||||
|
tests/test_goview_projects.py
|
||||||
|
tests/test_goview_templates.py
|
||||||
|
tests/test_goview_assets.py
|
||||||
|
~~~
|
||||||
|
|
||||||
|
并在 app/gateway/deps.py 创建 Store,在 app/gateway/app.py 注册路由,在 persistence/models/__init__.py 导入 ORM 模型。Harness 只保存数据和仓储,HTTP 表单解析、上传、鉴权、公开预览和瓦片文件响应只放在 app/gateway。
|
||||||
|
|
||||||
|
## 10. 实施顺序
|
||||||
|
|
||||||
|
### A. 项目闭环
|
||||||
|
|
||||||
|
1. 实现 goview_projects 和 goview_project_contents;
|
||||||
|
2. 兼容 project/list、create、getData、save/data、edit、rename、delete、publish、upload;
|
||||||
|
3. 替换 GoView axios 登录逻辑为 DeerFlow 登录态;
|
||||||
|
4. 实现 published 接口和复制发布链接。
|
||||||
|
|
||||||
|
验收:用户在当前画布编辑页保存,回到“全部项目”可以看到项目;发布后,无登录浏览器可通过 /#/chart/preview/{id} 查看同一画布。
|
||||||
|
|
||||||
|
### B. 模板闭环
|
||||||
|
|
||||||
|
1. 实现模板表和模板接口;
|
||||||
|
2. 完成“保存为模板”和“我的模板”页面;
|
||||||
|
3. 替换模板市场宣传页;
|
||||||
|
4. 内置至少四套离线模板;
|
||||||
|
5. 从任意模板创建独立项目。
|
||||||
|
|
||||||
|
验收:模板市场的模板不会被用户编辑;点击“使用模板”后生成新项目,修改新项目不会改变模板或其他用户的项目。
|
||||||
|
|
||||||
|
### C. 地图瓦片背景
|
||||||
|
|
||||||
|
1. 接入 Leaflet;
|
||||||
|
2. 实现受控瓦片路由和默认离线瓦片配置;
|
||||||
|
3. 新增 LeafletTileBackground 组件;
|
||||||
|
4. 把地图背景加入至少一套内置模板。
|
||||||
|
|
||||||
|
验收:断开公网后,地图背景仍能显示;编辑器与预览页都不会因地图组件引发拖拽冲突或内存泄漏。
|
||||||
|
|
||||||
|
## 11. 测试清单
|
||||||
|
|
||||||
|
1. 项目列表只返回当前用户的项目;
|
||||||
|
2. 项目所有者外的登录用户不能读取、保存、删除或发布草稿;
|
||||||
|
3. 已发布预览只返回 state 为 1 的项目;
|
||||||
|
4. 取消发布后原公开链接返回 404;
|
||||||
|
5. 项目 content 为大 JSON 时能完整保存和恢复;
|
||||||
|
6. 模板创建项目为深拷贝,模板 content 不被后续项目保存覆盖;
|
||||||
|
7. 内置模板重复启动不重复插入,不覆盖已存在记录;
|
||||||
|
8. 上传拒绝非图片、超大文件和路径穿越文件名;
|
||||||
|
9. 瓦片路由拒绝非法 style、缩放层级和路径穿越;
|
||||||
|
10. 无公网网络下,项目缩略图、模板封面和默认瓦片可正常加载。
|
||||||
@@ -62,6 +62,9 @@
|
|||||||
# 问答页「极速」模式:true=在模式菜单显示并直连大模型;false 或未设=隐藏。
|
# 问答页「极速」模式:true=在模式菜单显示并直连大模型;false 或未设=隐藏。
|
||||||
# 部署后优先改 dist/runtime-config.js 的 VITE_TURBO_MODE_VISIBLE,刷新即可。
|
# 部署后优先改 dist/runtime-config.js 的 VITE_TURBO_MODE_VISIBLE,刷新即可。
|
||||||
# VITE_TURBO_MODE_VISIBLE=false
|
# VITE_TURBO_MODE_VISIBLE=false
|
||||||
|
# 知识库视图切换:true=显示“列表 / 卡片”切换;false 或未设=固定为列表(默认)。
|
||||||
|
# 部署后优先改 dist/runtime-config.js 的 VITE_KNOWLEDGE_VIEW_SWITCH_ENABLED,刷新即可。
|
||||||
|
# VITE_KNOWLEDGE_VIEW_SWITCH_ENABLED=false
|
||||||
# VITE_GITHUB_OAUTH_TOKEN=
|
# VITE_GITHUB_OAUTH_TOKEN=
|
||||||
|
|
||||||
# --- 官方 DeerFlow 风格页面入口(仅 Vite,不引入 Next.js)---
|
# --- 官方 DeerFlow 风格页面入口(仅 Vite,不引入 Next.js)---
|
||||||
|
|||||||
@@ -889,7 +889,7 @@ Step 2(chat 步骤)
|
|||||||
| `@tanstack/react-query` | - | 服务端状态缓存 |
|
| `@tanstack/react-query` | - | 服务端状态缓存 |
|
||||||
| `@langchain/langgraph-sdk` | - | LangGraph WebSocket 连接 |
|
| `@langchain/langgraph-sdk` | - | LangGraph WebSocket 连接 |
|
||||||
| `next-themes` | - | 主题管理 |
|
| `next-themes` | - | 主题管理 |
|
||||||
| `sonner` | - | Toast 通知 |
|
| `tdesign-react` | - | 全局消息、确认对话框与输入提示 |
|
||||||
| `lucide-react` | - | 图标库 |
|
| `lucide-react` | - | 图标库 |
|
||||||
| `tailwindcss` | - | CSS 框架 |
|
| `tailwindcss` | - | CSS 框架 |
|
||||||
| `rehype` 系列 | - | Markdown 渲染 |
|
| `rehype` 系列 | - | Markdown 渲染 |
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ chain 模式的 Step 2 init **完全复用** `initMultiAgent`:`agentNames = ch
|
|||||||
**目标**:能创建/编辑/保存/删除链条。
|
**目标**:能创建/编辑/保存/删除链条。
|
||||||
- [x] 路由:`WorkspaceRoutes.tsx` 注册 `roundtable/chains`(套 `WorkspaceLayout`;本页**不需要** `ChatRuntime`,无沙箱依赖)。
|
- [x] 路由:`WorkspaceRoutes.tsx` 注册 `roundtable/chains`(套 `WorkspaceLayout`;本页**不需要** `ChatRuntime`,无沙箱依赖)。
|
||||||
- [x] 页面 `roundtable-planning/pages/BusinessChainEditorPage.tsx`:
|
- [x] 页面 `roundtable-planning/pages/BusinessChainEditorPage.tsx`:
|
||||||
- [x] 顶部:链条列表下拉(`<select>` 列出已存链条 + 新建项)/ 新建按钮 / 标题+描述输入 / 保存 / 删除(`window.confirm`)。
|
- [x] 顶部:链条列表下拉(`<select>` 列出已存链条 + 新建项)/ 新建按钮 / 标题+描述输入 / 保存 / 删除(TDesign 确认对话框)。
|
||||||
- [x] **左栏**:候选智能体(`listAgents()` + `filterRecommendCandidates`),竖排卡片,可拖、可点「+」快捷加入;已加入的置灰「已加入」。
|
- [x] **左栏**:候选智能体(`listAgents()` + `filterRecommendCandidates`),竖排卡片,可拖、可点「+」快捷加入;已加入的置灰「已加入」。
|
||||||
- [x] **右栏**:有序长条卡片(序号 tag + 名称 + 描述 + 移除),`SortableContext` 内拖拽排序;空态有占位提示。
|
- [x] **右栏**:有序长条卡片(序号 tag + 名称 + 描述 + 移除),`SortableContext` 内拖拽排序;空态有占位提示。
|
||||||
- [x] 拖拽用 `@dnd-kit`:左栏 `useDraggable`,右栏 `useDroppable` + `SortableContext`/`useSortable`,`onDragEnd` 计算插入 index(pool→右栏按落点插入;seat→seat `arrayMove`);`DragOverlay` 跟手卡片。
|
- [x] 拖拽用 `@dnd-kit`:左栏 `useDraggable`,右栏 `useDroppable` + `SortableContext`/`useSortable`,`onDragEnd` 计算插入 index(pool→右栏按落点插入;seat→seat `arrayMove`);`DragOverlay` 跟手卡片。
|
||||||
|
|||||||
@@ -591,7 +591,7 @@ isOrchestrating = false
|
|||||||
| Step 2 干预 | 底部输入框 → `runOrchestration` 新 seed,wrap 进「用户人工干预新指令:...」 prompt |
|
| Step 2 干预 | 底部输入框 → `runOrchestration` 新 seed,wrap 进「用户人工干预新指令:...」 prompt |
|
||||||
| Step 2 Persona | 点圆桌头像打开抽屉;保存后下一轮该席位使用所选模型 |
|
| Step 2 Persona | 点圆桌头像打开抽屉;保存后下一轮该席位使用所选模型 |
|
||||||
| 新建任务 | `handleStartNewTask`:abort 全部、清 state、`runStep1Init`,与 Step 3「重新起草」共用 |
|
| 新建任务 | `handleStartNewTask`:abort 全部、清 state、`runStep1Init`,与 Step 3「重新起草」共用 |
|
||||||
| 历史草稿 | 顶栏下拉:加载 / 重命名 / 删除(删除带 `window.confirm`) |
|
| 历史草稿 | 顶栏下拉:加载 / 重命名 / 删除(删除使用 TDesign 确认对话框) |
|
||||||
| Step 3 预览 | 文本类 → 模态预览;其它 → 新窗口下载 |
|
| Step 3 预览 | 文本类 → 模态预览;其它 → 新窗口下载 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ const [thread, sendMessage, isUploading] = useThreadStream({
|
|||||||
|
|
||||||
5. **附件上传**:先 `uploadFiles(threadId, files)` 上传到 Gateway `/api/threads/:threadId/uploads`,然后将 `path/filename/size` 写入 `messages[0].additional_kwargs.files`,与 lead_agent 后端约定一致。
|
5. **附件上传**:先 `uploadFiles(threadId, files)` 上传到 Gateway `/api/threads/:threadId/uploads`,然后将 `path/filename/size` 写入 `messages[0].additional_kwargs.files`,与 lead_agent 后端约定一致。
|
||||||
6. **TanStack Query 失效**:流式完成或新建会话时调用 `queryClient.invalidateQueries({ queryKey: ["threads", "search"] })`,让侧边栏「最近会话」自动刷新。
|
6. **TanStack Query 失效**:流式完成或新建会话时调用 `queryClient.invalidateQueries({ queryKey: ["threads", "search"] })`,让侧边栏「最近会话」自动刷新。
|
||||||
7. **错误降级**:`onError` 弹 sonner toast;`getStreamErrorMessage(error)` 兜底解析对象/嵌套字段。
|
7. **错误降级**:`onError` 通过项目反馈层弹出 TDesign Message;`getStreamErrorMessage(error)` 兜底解析对象/嵌套字段。
|
||||||
|
|
||||||
### 7.4 重要回调事件
|
### 7.4 重要回调事件
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ LocalSettings = {
|
|||||||
|
|
||||||
### 9.1 `src/components/ui/`
|
### 9.1 `src/components/ui/`
|
||||||
|
|
||||||
shadcn 风格的「无业务」基础组件:`button`、`badge`、`avatar`、`card`、`carousel`、`command`、`dialog`、`dropdown-menu`、`hover-card`、`input`、`input-group`、`item`、`progress`、`resizable`、`scroll-area`、`select`、`separator`、`sidebar`、`skeleton`、`sonner`、`switch`、`tabs`、`textarea`、`toggle`、`toggle-group`、`tooltip` 等。
|
shadcn 风格的「无业务」基础组件:`button`、`badge`、`avatar`、`card`、`carousel`、`command`、`dialog`、`dropdown-menu`、`hover-card`、`input`、`input-group`、`item`、`progress`、`resizable`、`scroll-area`、`select`、`separator`、`sidebar`、`skeleton`、`switch`、`tabs`、`textarea`、`toggle`、`toggle-group`、`tooltip` 等。全局消息、确认框和输入提示统一使用 `src/core/ui/feedback.tsx` 封装的 TDesign 反馈层。
|
||||||
|
|
||||||
特色组件:
|
特色组件:
|
||||||
- `aurora-text` / `flickering-grid` / `magic-bento` / `spotlight-card` / `shine-border` / `confetti-button` —— Landing 视觉效果
|
- `aurora-text` / `flickering-grid` / `magic-bento` / `spotlight-card` / `shine-border` / `confetti-button` —— Landing 视觉效果
|
||||||
@@ -695,7 +695,7 @@ URL 加 `?mock=true` 时,`useThreadChat()` 设 `isMock=true`,`getAPIClient(t
|
|||||||
|
|
||||||
### 18.4 在浏览器调试 SSE
|
### 18.4 在浏览器调试 SSE
|
||||||
|
|
||||||
LangGraph SDK 走标准 SSE。开发期通过 Chrome DevTools `Network -> EventSource` 可以直接查看 frames。失败原因(如 422)可在 sonner toast 看到 `getStreamErrorMessage()` 的解析结果。
|
LangGraph SDK 走标准 SSE。开发期通过 Chrome DevTools `Network -> EventSource` 可以直接查看 frames。失败原因(如 422)可在 TDesign Message 中看到 `getStreamErrorMessage()` 的解析结果。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -795,7 +795,7 @@ setSettings("context", { model_name: "gpt-5" }); // 仅当前线程
|
|||||||
| 发起 GET/POST | `apiFetch(`${getBackendBaseURL()}/api/...`, { method, body })` |
|
| 发起 GET/POST | `apiFetch(`${getBackendBaseURL()}/api/...`, { method, body })` |
|
||||||
| 发起 SSE 聊天 | `useThreadStream({ threadId, context, ... })` |
|
| 发起 SSE 聊天 | `useThreadStream({ threadId, context, ... })` |
|
||||||
| 跨标签同步偏好 | `useLocalSettings()` / `useThreadSettings(threadId)` |
|
| 跨标签同步偏好 | `useLocalSettings()` / `useThreadSettings(threadId)` |
|
||||||
| 弹 toast | `import { toast } from "sonner"; toast.success("done")` |
|
| 弹全局消息 | `import { toast } from "@/core/ui/feedback"; toast.success("done")` |
|
||||||
| 弹浏览器通知 | `useNotification().showNotification(title, { body })` |
|
| 弹浏览器通知 | `useNotification().showNotification(title, { body })` |
|
||||||
| 国际化 | `const { t } = useI18n(); t.common.loading` |
|
| 国际化 | `const { t } = useI18n(); t.common.loading` |
|
||||||
| 合并 className | `cn("base", cond && "x-y")` |
|
| 合并 className | `cn("base", cond && "x-y")` |
|
||||||
|
|||||||
@@ -88,7 +88,6 @@
|
|||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
"shiki": "3.15.0",
|
"shiki": "3.15.0",
|
||||||
"sonner": "^2.0.7",
|
|
||||||
"streamdown": "1.4.0",
|
"streamdown": "1.4.0",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
"tdesign-react": "^1.12.3",
|
"tdesign-react": "^1.12.3",
|
||||||
@@ -9743,14 +9742,6 @@
|
|||||||
"@types/hast": "^3.0.4"
|
"@types/hast": "^3.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/sonner": {
|
|
||||||
"version": "2.0.7",
|
|
||||||
"license": "MIT",
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
||||||
"react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/sortablejs": {
|
"node_modules/sortablejs": {
|
||||||
"version": "1.15.7",
|
"version": "1.15.7",
|
||||||
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.7.tgz",
|
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.7.tgz",
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"test:html-preview": "pnpm exec esbuild src/core/utils/legacy-html-preview.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/legacy-html-preview.test.mjs && node --test .runtime/unit-tests/legacy-html-preview.test.mjs",
|
"test:html-preview": "pnpm exec esbuild src/core/utils/legacy-html-preview.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/legacy-html-preview.test.mjs && node --test .runtime/unit-tests/legacy-html-preview.test.mjs",
|
||||||
"test:visualizations": "node --experimental-strip-types --test src/components/workspace/visualizations/visualization-spec.test.ts src/components/workspace/visualizations/map-style.test.ts",
|
"test:visualizations": "node --experimental-strip-types --test src/components/workspace/visualizations/visualization-spec.test.ts src/components/workspace/visualizations/map-style.test.ts",
|
||||||
"test:composer-session": "node --experimental-strip-types --test src/core/settings/composer-scope.test.ts",
|
"test:composer-session": "node --experimental-strip-types --test src/core/settings/composer-scope.test.ts",
|
||||||
|
"test:agent-appearance": "node --experimental-strip-types --test src/core/agents/appearance.test.ts",
|
||||||
"test:report-collaboration": "npx esbuild src/report-collaboration/tests/event-reducer.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/event-reducer.test.mjs && npx esbuild src/report-collaboration/tests/message-adapter.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/message-adapter.test.mjs && node --test .runtime/unit-tests/event-reducer.test.mjs .runtime/unit-tests/message-adapter.test.mjs",
|
"test:report-collaboration": "npx esbuild src/report-collaboration/tests/event-reducer.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/event-reducer.test.mjs && npx esbuild src/report-collaboration/tests/message-adapter.test.ts --bundle --platform=node --format=esm --outfile=.runtime/unit-tests/message-adapter.test.mjs && node --test .runtime/unit-tests/event-reducer.test.mjs .runtime/unit-tests/message-adapter.test.mjs",
|
||||||
"check:chrome109-css": "node scripts/check-chrome109-css.mjs",
|
"check:chrome109-css": "node scripts/check-chrome109-css.mjs",
|
||||||
"check:legacy-chrome-css": "node scripts/check-chrome109-css.mjs",
|
"check:legacy-chrome-css": "node scripts/check-chrome109-css.mjs",
|
||||||
@@ -111,7 +112,6 @@
|
|||||||
"remark-gfm": "^4.0.1",
|
"remark-gfm": "^4.0.1",
|
||||||
"remark-math": "^6.0.0",
|
"remark-math": "^6.0.0",
|
||||||
"shiki": "3.15.0",
|
"shiki": "3.15.0",
|
||||||
"sonner": "^2.0.7",
|
|
||||||
"streamdown": "1.4.0",
|
"streamdown": "1.4.0",
|
||||||
"tailwind-merge": "^3.4.0",
|
"tailwind-merge": "^3.4.0",
|
||||||
"tdesign-react": "^1.12.3",
|
"tdesign-react": "^1.12.3",
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
// 4. 这里的默认值来自 .env.network;如某个环境不用某项,可以留空字符串。
|
// 4. 这里的默认值来自 .env.network;如某个环境不用某项,可以留空字符串。
|
||||||
// 5. 布尔开关也用字符串形式填写:"true" / "false"。
|
// 5. 布尔开关也用字符串形式填写:"true" / "false"。
|
||||||
window.__CM_RUNTIME_CONFIG__ = {
|
window.__CM_RUNTIME_CONFIG__ = {
|
||||||
|
// CMZS 扩展 ID;部署后可直接修改,无需重新构建前端。
|
||||||
|
VITE_BROWSER_EXTENSION_ID: "fkphoilppiodafnombhnjfocpphcjlam",
|
||||||
// 品牌图片相对路径会以 runtime-config.js 所在目录为基准解析。
|
// 品牌图片相对路径会以 runtime-config.js 所在目录为基准解析。
|
||||||
// Nginx 以子路径部署时不需要修改前端图片路径。
|
// Nginx 以子路径部署时不需要修改前端图片路径。
|
||||||
// 打包后可直接替换 dist/brand-assets/ 内的同名 PNG。
|
// 打包后可直接替换 dist/brand-assets/ 内的同名 PNG。
|
||||||
@@ -147,6 +149,10 @@ window.__CM_RUNTIME_CONFIG__ = {
|
|||||||
// 静态站点模式开关;一般部署业务系统时保持 false。
|
// 静态站点模式开关;一般部署业务系统时保持 false。
|
||||||
VITE_STATIC_WEBSITE_ONLY: "false",
|
VITE_STATIC_WEBSITE_ONLY: "false",
|
||||||
|
|
||||||
|
// 知识库页面是否显示“列表 / 卡片”视图切换。默认 false:固定使用紧凑列表;
|
||||||
|
// 改为 true 并刷新页面后,才允许用户切换到卡片视图。
|
||||||
|
VITE_KNOWLEDGE_VIEW_SWITCH_ENABLED: "false",
|
||||||
|
|
||||||
// 紧凑导航开关:true 时固定使用简洁布局,工作台左侧栏收起为菜单图标,
|
// 紧凑导航开关:true 时固定使用简洁布局,工作台左侧栏收起为菜单图标,
|
||||||
// 隐藏系统 Logo、换肤按钮以及“全量/简洁模式”切换。修改后刷新页面即可生效。
|
// 隐藏系统 Logo、换肤按钮以及“全量/简洁模式”切换。修改后刷新页面即可生效。
|
||||||
VITE_FORCE_COLLAPSED_SIDEBAR: "false",
|
VITE_FORCE_COLLAPSED_SIDEBAR: "false",
|
||||||
|
|||||||
@@ -93,6 +93,21 @@ const requiredLegacyFallbacks = [
|
|||||||
pattern: /AbortSignal\.timeout = function/,
|
pattern: /AbortSignal\.timeout = function/,
|
||||||
description: "Chrome 102 needs AbortSignal.timeout before any module loads",
|
description: "Chrome 102 needs AbortSignal.timeout before any module loads",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
file: "vite.config.ts",
|
||||||
|
pattern: /export function jsx\(\)\{return null\}/,
|
||||||
|
description: "Stale Vite deps chunks must locally export jsx for Chrome 102",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: "vite.config.ts",
|
||||||
|
pattern: /export const \$\{name\} = __jsxRuntime\.\$\{name\}/,
|
||||||
|
description: "Vite jsx-runtime CJS interop must expose a named jsx export",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: "src/components/workspace/question-navigator.tsx",
|
||||||
|
pattern: /animateScrollTop\(parent, Math\.max\(0, Math\.min\(nextTop, maxScrollTop\(parent\)\)\)\)/,
|
||||||
|
description: "Question list anchors must set nested scrollTop for Chrome 102",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
file: "src/styles/globals.css",
|
file: "src/styles/globals.css",
|
||||||
pattern: /\.workspace-chat-bg,\s*\n\s*\.canvas-writing-bg\s*\{\s*background-color:\s*var\(--background\);/,
|
pattern: /\.workspace-chat-bg,\s*\n\s*\.canvas-writing-bg\s*\{\s*background-color:\s*var\(--background\);/,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { DesensitizeWordsLoader } from "@/components/desensitize-words-loader";
|
|||||||
import { FontScaleApplier } from "@/components/font-scale";
|
import { FontScaleApplier } from "@/components/font-scale";
|
||||||
import { QueryClientProvider } from "@/components/query-client-provider";
|
import { QueryClientProvider } from "@/components/query-client-provider";
|
||||||
import { RouteLoadingFallback } from "@/components/route-loading";
|
import { RouteLoadingFallback } from "@/components/route-loading";
|
||||||
import { Toaster } from "@/components/ui/sonner";
|
|
||||||
import { AuthSyncWatcher } from "@/core/auth/sync";
|
import { AuthSyncWatcher } from "@/core/auth/sync";
|
||||||
import { RequireAccount } from "@/core/auth/require-account";
|
import { RequireAccount } from "@/core/auth/require-account";
|
||||||
import { I18nProvider } from "@/core/i18n/context";
|
import { I18nProvider } from "@/core/i18n/context";
|
||||||
@@ -209,7 +208,6 @@ export function App() {
|
|||||||
element={
|
element={
|
||||||
<div className="h-dvh overflow-hidden">
|
<div className="h-dvh overflow-hidden">
|
||||||
<MarkdownDocxEditorPage />
|
<MarkdownDocxEditorPage />
|
||||||
<Toaster />
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 53 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg width="28" height="20" viewBox="0 0 28 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M1 2L17 10L1 18V2Z" fill="#F5222D"/>
|
||||||
|
<path d="M8 2L24 10L8 18V2Z" fill="#FDDADC"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 199 B |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="152" height="42.359" viewBox="0 0 152 42.359"><defs><style>.a{fill:url(#a);}</style><pattern id="a" preserveAspectRatio="none" width="100%" height="100%" viewBox="0 0 536 150"><image width="536" height="150" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhgAAACWCAYAAACcofGRAABDtklEQVR42u2dW5bkOJJkVUC6R2RlzRLmu9fSK56t9Hz3EqarMjLcCJ0PgCQA4kkCfJjD8sTJCHcz2hu4FBUVBfVLvzS6/J//+N94g6eBb3Kf73Dhb3KfVS//+X//m/tHp1/6QtYvHSie+z3o37XvByPcgaNfOmD0S7+8P1DgDb5D/ft6/sbN3x0+OnD0S1+w+qVDRZvPNfp3r0PJScflDhv90gGjXzpQvNfnF/071S83BgbuwNEvHTD6pYPFcz636N+ffjlxg7/LMTpo9EsHjH7pUFHpM4pv/v1A91Pc+jnwu71+HTb6pQNGv9wNKNCViP7dfDNQuVK14A4c/dIXsX75rmCBb6ZGoH+3b7Uh8jdTPbiDRr90wOiXDhTXKxpX32f/Xt4DGp4U3MUdOPqlA0a/dLC4l7LxLt0r/fJ+3RxnKBUdNPqlA0a/PAYsWgLF3UOt+vfp+wLJXcO/HgMcHTQ6YPRLB4p3gAm86/eFH/6dxjO6Su5ovHw76OjA0QGjX74fWLSAhDvBBDogdEA5ET7uAB18Z9jooNEBo1/eFyqeAhR3LbVUhwZ80+8tV97ccG9PBXfg6LDRAaNf3hUungAWt4OKWjCB/t28BD5OhI4rN/FHg0aHjA4Y/dKh4qoZH7gjPHRgeB8gwfPKGjWO1WGjXzpgdKi4dNM+s30TdwGIp8LDWX4PPDQOfC+E4LryxtntuFfAUIeNDhj9cmOwqLl544kwUbKxops+u6mzEoTgmlLHmXHlZ0JQB40OGP3ypnDxOLC4O1TcASRqPe/aZsyngMeFsHEn0OiQ0S8dML4JVNRSIs4ACpy5UeNhps/u42gDMGeBSO5jxnllDr7RfXCHjQ4Y/fJeYNF6w28OFDmbN25o+mwNCk8tq7Te7G/mqch+TLgXDLQ8fgeNDhj98lCoaF2SQKvP2RUgsWeTxgnPs1/aA8EeEKkNISeBB1847fUMhaXDRgeMDhYXQsXtgOJMmCjd0Pfcb4eG94ORUgCpBR8nQMdVwHEZbHTQ6IDR4eJecHEJWFwBFaX3+Y4wkXoN7mDovBo6rjB3pu7zhqDRIaMDRr90qLgeKM6EiZL7eqdOD+oGz1MA5ESPRfS+bgYcHTY6YPRLh4o6x2upTtSEiLMB4omdLE9sJT0bSnKfV2v4aKRydNjolw4YDweLI9BweemjlTpRCyZabrg4qTumX9oAS0sYyXl8V0IH6k6CbVFKuQQ2Omh0wPjuYFEbKqqpFHs33BqqR4uNutXz6ZdnwEgLAKkBHrWfT2V1ozZsdNDogNHh4iQFoWYJ5HKl4ugx7zAavcNE7yi5CjZagFNFZePMkkyHjA4Y3x4szlQsmkJF7Y04o3vhsoTMGwIE3tfT+T26S47ed23oqKhsnAEbpysaHTQ6YDwVLGqqFYeh4g5AUWNDf0i3SP8+PhhManeXHLm/mwJHLdi4jarRQaMvaHcBi7PUiiZQgRN9GUc2+Bt2jDS5H/zjz2/13eV//4ufDCM1O0tqqxy1gONmsHGqqtFBowPGHcGillqBFqUPnFA+aQ0TDUECbwMILNs8Fgh+I0DhO3eW1FQ5apSCKpVS+GmqRgeNDhgdLi4Gi6ObfutySu3vymkw0QoUTl+VzgGTg9BxOnAcLauEjn0j0OiQ0QGjg0UjsHgMVJylVJxp9DzyfTgMEO8CBm8GKgcA5NTOktrD2WoAx41ho4NGB4zHwkUpWOAsb0ULqKgJFCfDBE6Bhw4Obw8ihRDCd4WOUuA4ETZqeDVKYYU7ZHTAeIJicalacQQqSlSK2upEJZhoM9TsH392gPjOAPLvf7VqU+W7lVd8xzuqbjSAjZaqRlc0OmBcBhctyyC3gYpaPorGQIHqIPHHH+jfXeqZGLmXv/5q0aLKdwGOEv/GA2DjsvLJd4MMdLh4X7hoUQK5EVjUhYp7AkVXSJ4KH5nAcQZstAaN2iWUDhkdML4rXJwJFk0Vi1ZqRaPOEbyJOnGr7xszn/J4AHAHkiYqB5/VUXKGqlFZ0bg1aHwXyEAHiyY+i6ZqRWuouBgo8FBVAu8CBLdftM4BFn6o2sF3Ao4LYKO2qsFdzeiAcRfF4lSwuAIqzgaK5HNsDxHooNDB5DIQScBHBgBcAhwtYeNmoNEVje8EGDdWLN4KKrjuwLU8VaItTKBDQ79UhBG+UvHgyhtiSUfJG8FGVzQ6YHS4KL3NBWrFXcECHSj65QTg4HcAjTNUjQ4Z7wUZ6HBxus+iCBJqKRZ3USsuKnmgQ0Tww4PGKwx3+DgRPPaXVC5VNWooGjtB45b+jHeBDHS4uIdicVStuLgEght4KN4fIri3rT4NWi6Hj2MeDr5DCaWRqnF7ReMdIANdtciGgepg0aIEwge6MGpAxUlAgbcAiA4M3x5ICgGEn6BwHCmlpJSNBrDRGjS+tZqBrlpUybJAa7XCvF0tqGiuUtQvd+ARUHEDcAA9q7zDdIOsjAtB5HTQyICOq9WNEGzsTQrdoWrs7dDhrmY8GDBOhIs9qkVVuGilWPCxltr44z4OFs9RKC6AiafBw6Mh5GL141TwiKgbR5WN2pCxd+hbA8g4Tc14ImTgm8FFrkJxa7B4Q6i4pzLREB6+KyS8JZycDCEF0MHvChsPAQ2u/b48DTLQVYv7lEOOqhWnQcUJCsWpMFERJK4CB36zlnNcFOddFUROBI9M6KiucFwBG0dUjYvKJt9WzcA3VS2agsXVagXvN6S28FPcR52oABKtAYL7gLNbg0kVADkBPJqrHOW+Da7RunqhqnE70HgCZKDDxXVwcaFigW8DFgehohVQdJB4D/A4DByNYeNmoMEPVzQ6ZLwTYNwALpqUQ46AxZOhohlM3EyZ6PDQIeTOSkcGdDwSNvaCRuOyybeGDHSwqKta7FUsStWKm0DFuUBxACQ6QPTL2wBIZfBoAhyNYaNE1diraHQ14w0B4wBctAAL1Ij0jl2vgVrREipuDxQ1QKIDRL9cBSC7wOPuwFERNmqqGpVAw33Ml4LG3SAD3wguqigWez0WR8CiGlRUVCmalDsKgOIoSLwRRODtO0w7fJSBR4PSSgQ6uGE3CtdSNWqARuK6RxWNt4QMdOWifjmklseiahmkolpRFS5OUikeDBRdTXlDANkDHFerGwllg58MGbkejYplk2+hZOAb+C2qlESOlkNKPBYXKhZtoeIEmHgASHRg6EBSDTyugo67w8Zej0YDf8ZlSsYdQANdtbgOLI6WQipAxa2A4g1gAtTh5R0ggL8VdNwJOPJgo4mqcSFovK2agW+oWlT1WpwAFmm14i5Q0dBDwd9j8+7qxnMAgd8WOg4CRyvYKFU1WoJGI2/G26kZ+MZGTpROLa0JFierFW2gIhMoHuSZQAeHDiJPhI+mno4DwFEFNiqrGq0UjSeUTc6GDDxYubisJHI5XFRQLDpYNPsOdJjo0HEZbDwQNGoqGpdAxkUlk0coGfgGykVxSeQNwOIRUPFQmOgA0QHkbaHjEbDxbNAoeayPVzLwjeDiNLA44rF4ElS8OUx0kOiXM6HhudDxUNjI9WicABpvCxl4EFzs9Vvs9lqUBmVdABZ1oeKZQNFVCSIC81sBEQPcoeM88LgDcByCjcagURrUtaNsctSXcUvIwBvCRTPVolIpBC3Uim8CFW+vSrwbKHQweZ7acWPYqKFqcK3SyQ3VjD2ZKPSf/9UOMvBmZZGqcFFZtWhWCtkFFxmeily4uDlYoMNEh443hY1bgEaWb2MHaDSEjOBxjqgZJ0BGznPgPatjK8jAd1QuWngtdoHFmVDxHKDA00HibHB41+FsONmXcDMQYboZdFwJHLVgYw9o1PZm3ErJMFaOFpAx3jgFcQ9c7FItGoFFjXJIU7C4AVA8EiZaAkSf5HrstTgCJan39WQAwc4NFa2gwxM+yDnrihc45nUpEzTmdc8BDWQ9vz/+wAwZRrmbjWNw5GSUPbeJXsf8ubtvxH7vPB9Enpf7u9S/3yedcId6cQvV4hTFIg8smqsVKbC4GVDgHUDiMnC4exnmItWgpjpysfLBdBOVI/Wa1vZr7FI1KpROShSN26sZzupQW8XAxWWRZnBRU7U4rFjsUCveQKl4jDpxFCSawkP3aVwGKIdHrF8DHpeXVqqUUo7DBh8onew2gpaUTTLKKu0hI7C61AKN8aHqCXKPcxJcHPFZNFMscsCC75FkiacpE02gosNEndes0sburBN89HN2EnBgJzSgFmjkvm7z+hQsoRRABjOjuHzilE6csgmFSidY1Qf4yia+35s/d0smifeE71b2OH1hb6BenOq3eBxY3K8EgrsCxRGYqPY6dXB4a/XjiNJxssrBdGEp5awSytHSSa2ySW47a2GXyd4oci5diWuoGHiQ5+I0v0VO7gWF7qsQLIrUimcqFbeHiSqvzftBBOjBI87vAB97weOm0MFnl5+CwFGgbBSXTsIejaJcjFJfxomtrFzyLT8KGXgHuLhKtTiiWNRQK05WKnAnheISmLgfRKDHcD8LPm4OHXxHz0YNr8YR0MjxZ5yoZtSFjIwV5Ahk4EFwUaxavCNYxKDiXYHidJi4DiTuAAx4AxjgJ4HHjaHjdsBxVNV4GmgcKJnkQUbmt30vZIxPPhO7Yt7FXrg4Wgo5Ua3At4OLine truncated
|
||||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1920" height="64" viewBox="0 0 1920 64"><image width="1920" height="64" preserveAspectRatio="none" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAABACAYAAAD77Wr8AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhe7P1VdJxJuif89lqz9+5iM4Mkg2zLIGZmxmRmVIJYJpktMrOLqauaqpmqqbq4u6D3/jbOnHVuz8C5mIuZOff/s54n4s18M5WS5erqge+ci9+KiCfifVMm2c5/Rrzf+O//5T//1/8T/DdpubraSnOr819WkHyNR1+XXk//+v9LRpmvXV7qdZnn0qWvW4l6/eNem36f9NfPVHtcj3OPldZlmlvu3plqK0v/vZL2+/Q/C/9dsdLaDB41r16zmrXLyXR9ptpX81/+63/7f6ss+TkUP4+pr5WcW+7XKtOa9PpfKvN90398qV9v6vVLf33+j5P2+3eJ5ebU160k/TrpfzzOPb4W/ylDTakr/vN//R8sWaO+InVtZunr0q9V3+//7y/wn6T0+tdpuddQ6n+x/ygtN17q/yOl1v6jirhPau2rS35NS+f+9/D/UrVKXz33fyP/MUMtHa1ZSfq69OsfNfe4vs57/c+W/nP3KOrrlrtPhtf4H1LGNbKmrElZtwrq6zJJX/9VpN/z/xf891VIv2Yl6deudB917VHrVjP3l0i/X/rrfBXpr/G/2v/OX1d6TT230vz/DF/Hr2nK9f/pP6rQOL0m/cfUsfLvlyXr/o/znxL91B8T1ZdS/n2YXn8syv9d0uvLzWf4P9H/Ksq/19Pr//eX6f+36f/v/frQ/5nTa1+LR71HsNL7Eem15d5zeNQ90usZ3st4pPRrl7vPcvW/pvSv7a+Aft755/5/pcSvoerPQsoa1Xt/6fPyz5D6vV7lvd/U94CTfwb/25I/k+l/DtPry1F/7cnrkt/bls59HVK/b6Z/DX8d4r23pfWvw196b+X6v+Qej/L13TvTr9vSX+OVLHnPa9XUP470ucwyvWZy/PjvyS53f+XnIn0+fd1q65mkfy0rXbfadcpapf+N30yPI5PfTo+x9HrClJRez2hCWqauvg/fl2rKNcJvpyeF4xMJv6OW5+T6KTlWrXkk1bUpr7Oc4yrpc8utSyfX/Ob4FH57QvgNm5amEmvT66njdMr8FN+bayePJ6WvP6mguQzzmZycxq9Xcuq4ROMp0So1mj8hKeszjN89cRzvniTTwqnjePfUCdU9pvDrk3TPE/j16TS8Tkqfe5w1X4Xqvu+eJifx61Mn8bvpSbw/EcNHo2H2wdgwPhwNS0F8OBLEh3ESkq2sjYQEWjMWwofjIXwwEcb7ZDKEDydkbTyMDyekcVFjPFYk6x9NhFmiPhHEhxMBfDgeXGos1UcK1XyilhDAR2N+ifrquqo/TvcRaz8e9eODyWH87uQE3p05hV+dPY1fnTmFX505yX49cxK/Pk2/Ryfxu+kxvDcZx3tTI/jd8XH5e/KE+D3BfWqFR/++Ta4Rvw/TruM6/X4jqnsr66XEev5zp/wZpD/j0gmFaj7lz6tqLf/Zl9+fTkyylHnV90WBakLyexB9D1/BVKrfTY2x306NCpOj+N3EKH5LJkfwu8kR/F6ivlL73cQIfjcex2/HYimoxnWJx1RXzYlaHL8fjeH3I1EhHhFGo0lUp3Ysg/Eo3hun+Qh+PyKufW8kgvd4PIzfxyWaY6pamvfiYSE2rELjdCG8F1WhcSyEP6hFQ3ifRIL4Q1R4PxrA+9zKWiSwovcyjN8b9ifG76twbVh4P+JnfyC0ftiP99XCxMc+CPsZj0NefCBRn8dhFXVd5UNqg168H/SImmo91cmHkrKeUS1xvQfvBwTqfxgSqJ+cc+ODgBsfEr8bH5BEzYUP/RL1FUotzUd+p+Bz4iOvRH11Xc3rYB96nQlKTe1D1RoxtgseOz4iXoW8xm3LwKpiw0ceicYeyW3BR64M+BoLPnSZ8RHLtEb42GXBx04LPnKaEz52mASnCR/T9U4TPnIY8JHdgI8dEvV5rMcndjWDpMfHdh0+tumSrU2Hj2xafGTT4GObBp9YNfjEomWfWrX41EY0+NRKhvAJsZBBfErMwiemAfapeQCfmvrZJ8Y+fMp62SeGXnxq6MEfib47SdeNT7ntZH8i2g72GWtnf9K0JXymacMXQ6QVnw+14POhZnwx1IzPB4Uvhprw+WAjPh9oxBeDjfhyQPhC+nKgAX/ur8eXffX4gvQr6vBFX9KXsv28t5Z90VuLL0mPogZfkO501fhSov7n3K+RqvFlVxX7QrZCNb7orJIqVarweWclo/HnHcIXHRX4klE/6fPOCnzeUYHP26WOCnzRUY4vpS/ak76U1H3yZ/Vcm9RelpCcK8OXajwn17UJ6nmlpvZ5axk+z1RXXZ8+l7xvKb5oK8VnraX4vG2pL6jeKub/1FoiKeNSfNpSwv4ofSL9saWUUf+j5hJ80lyCP7WI6/5IWkr4vvTa9BqftZbgj63iXsr9ldekOt3nY9W96VoF3ZeuU16b8H1aSvCZRH2FUlPQ+g+aS/Bhs/haFcqYvtbEta2rIb9++vHKa5SfjxTKz4X8MdDP0YdN4nW5bUr9elLQnFyb6Mv2k6YSfNpcij82l3KbiuYk+WuW+vUK9PUsh+5L/iQpY3X9k6ZSfNBYkqD8eD5gxfiouTjxeyJd+v2UH8fH8lrysfw9RT8Omv+8pYwpX4/yY+U18veh+D2R/lrK7xf6cZfhy9YyfNlSxn26j/o65X5M/hryPej3kHwdNWVejX5uP2+h3/Nlq8ZfUyaqP9v0PYDXUi0xX54g/rwrY/HnXkiv0/ce9fey5PcqJr+X0feWz9sF8f1EfA/kOs+V4zNel/xeSTXFZyl9+f1Wou/LRN1X1/j7M3+PrsRnEn1v/yzxPV75O0CSf0983lW9FP/dUoPPJOoLtfi8py7hM0VvHf7E6vGZok/RgM/7GxM+U/cHmvB5vzTQjM8HWvDZQAs+H1TQ38MC/d38+VA7+0xDOvC5pgNfaDvwubYTn2m78Lmum30mW6bvwWeGXvzJ0IvPjH34zEit0u8XTP34k7kffzINCGbJMphkHUr4I9PgT3Ztwh9tevYnux5/sukEux5/tOvxKXEY8KnTyD5xiJa5zCom9onLLLipZuGW+x5rwiduFRozGz712tkn1HoE7ifqDnyc4MQnxOfExz4H+8RPYwfjmrKW+n5nqoBLxY2Pgx4hpBL04CMppS/neaysDXuTQl58RMLEt2ofhtJQTZFeS58P+4VhSV1LkGsTa5I+GFaJkMCqpPx/jaj+r/dBVFDXkv8PFP+/TEjMUV+F5tL/z6r6vyujfjwsxMJLaxkNCzEir+P/W6v+Ty3HYo3wHv2/PR5JXE/z4v/loq5c896IkJij/+vLWgrlOvlewHtjsqUxvb+gvB9A7xOQsQi/l8CU9xzU7ztkeh9CvY6MRfG7cfEex5J7jMfwe/l+x+9GYwL1FWnviSytJ99b+c1YHL/hVukLifdZlPdjqD8xgt/TezQTynsxI0kTAr+Po3pfh2vj8r0d1VzK+z7Ke0ET6tcUeEx19XX8NSxzT+X1lNdUKD8edS2d6msRP85HX/f7iVGBX1OspWsVia9FjesxvDc6jA/ofdpYEH+IBfn9JH6/i34uJ+m9szFu6df7/XgQH0U8+CTixsdRKeLCJxEXPh52c53nhiX1Ol4r6h8pcxHRV8afRD0S9YXEdYqoi9HrfDrsYZ8Q+XV9EnZJ9LWIuljjxifDLon6bnwapnsISo0p9wi58GnIhT9Kn4bFmHwSFD4O0X08+GPYw+3Hw158SO+F8Xt+8r1Apnr/j6n+rEr05/kPaiP0/UN+H6E+SVujfO9Y8v1iJfSe4IjE7xGqvofJ73vK9yuujSjCSfw9VH6/GxnG+0w1z2voe2sIfxiRrfL9WHkN1XuQie+tsTDejytCCR+MyH5MigeFmGyVPv99IN+rpHXK3xvKuhi9ZxkQYwW/j6nUZct/Z2Wg+vvqkWIS9fnvwSATX+PSvyNTpP2dmF4T46CQ+Ps1/e9c5WtOvk8q/t5WviYf3h8mNB9k4lr5d3tUtnytWJuoyznl7/PENYnrfPiA1itzUfEebvJrUd0v5Z7iutT3d+W91K+hQvdU+t8Y8fox4g1ixBeSgmLsDciW5hTKfAAjHj9GPMoaauk+/tR1Kdel11aop7+uN4hRX2iJMX8IY74gxvwBjPkCGPUHpRBG/WFJ1MZSBBLXJAUxRvdk1FdRrvMFMe4PCYFwsu+nPqH5IMYDRKkra5a5jtYx6g/LeWVNGGMBxbCqvwry2vHgMMaDEYn6S02o8deQoa6Scn1ISMxTX5E+XiIspV3zqOt4PiKEhzHJIpgMR5c1NRzFJFHXJHVfbenaCKbCw7JNXZN6bUzWY5gajuFkMITLLgfumDR4Rd+NVwzduG/sx3WTBlfMWly36HHHqsddq5Hdthpwm2s63LXqcMdqwB2LmLtrN+G23YRbNlqnT7hlEfg6iy5Nav2uWcvumJV5Le4SqpskuSaVBvfMGtxnWtyTdWqpLua0khgzkwb3jKK9b9LggXTfNIS71Jo1eNE4gJcMvbhtGsJ5px0TwRBGonGMxEYwGo1jNBLDaCQqhMKY8vlxyuPBWY8LM14vjvuDmMz0+0b9+1b5vaqqJ38vRzAWikryzwr/mQxjLBjGWGiY6wL1wxgNDjP6s8nrAmGMBmRNdb24h6jxvRLEn+nRQBgj9L2KrvUPY8QX5u+L/H1MuWdgmNfwnDeU/B7JaJwq7g0g7vVLQcLine truncated
|
||||||
|
After Width: | Height: | Size: 193 KiB |
@@ -78,7 +78,7 @@ import {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Provider Context & Types
|
// Provider Context & Types
|
||||||
@@ -1225,7 +1225,7 @@ export const PromptInputButton = ({
|
|||||||
}: PromptInputButtonProps) => {
|
}: PromptInputButtonProps) => {
|
||||||
return (
|
return (
|
||||||
<InputGroupButton
|
<InputGroupButton
|
||||||
className={cn(className)}
|
className={cn("agent-composer-tool", className)}
|
||||||
size="sm"
|
size="sm"
|
||||||
type="button"
|
type="button"
|
||||||
variant={variant}
|
variant={variant}
|
||||||
@@ -1306,7 +1306,7 @@ export const PromptInputSubmit = ({
|
|||||||
<InputGroupButton
|
<InputGroupButton
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
className={cn(
|
className={cn(
|
||||||
"transition-all duration-300",
|
"agent-composer-send transition-all duration-300",
|
||||||
status === "streaming" &&
|
status === "streaming" &&
|
||||||
"animate-breathe-stop bg-primary/10 text-primary border-primary/25 shadow-[0_0_0_0_rgba(217,33,33,0.25)] hover:bg-primary/14",
|
"animate-breathe-stop bg-primary/10 text-primary border-primary/25 shadow-[0_0_0_0_rgba(217,33,33,0.25)] hover:bg-primary/14",
|
||||||
className,
|
className,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { FileOutput } from "lucide-react";
|
import { FileOutput } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import responsibilityIcon from "@/assets/position-roundtable/责任岗位.svg";
|
import responsibilityIcon from "@/assets/position-roundtable/责任岗位.svg";
|
||||||
import resultTimeIcon from "@/assets/position-roundtable/时间.svg";
|
import resultTimeIcon from "@/assets/position-roundtable/时间.svg";
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
Trash2,
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
import { getStoredAuth } from "@/core/auth";
|
import { getStoredAuth } from "@/core/auth";
|
||||||
import { readRuntimeEnv } from "@/env";
|
import { readRuntimeEnv } from "@/env";
|
||||||
import "./document-upload-popup.css";
|
import "./document-upload-popup.css";
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
UsersRound,
|
UsersRound,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
import { getStoredAuth } from "@/core/auth";
|
import { getStoredAuth } from "@/core/auth";
|
||||||
import { authenticatedFetch } from "@/components/assistant-ui/document-upload-popup";
|
import { authenticatedFetch } from "@/components/assistant-ui/document-upload-popup";
|
||||||
import { readRuntimeEnv } from "@/env";
|
import { readRuntimeEnv } from "@/env";
|
||||||
|
|||||||
@@ -443,6 +443,25 @@
|
|||||||
background-size: 152px 42px;
|
background-size: 152px 42px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 浅红科技感顶栏保持深色版的尺寸与排布,只替换文字光效和选中底图。 */
|
||||||
|
.strategy-app-header--light-red-top-nav .top-submenu-item {
|
||||||
|
color: rgba(255, 255, 255, 0.86);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strategy-app-header--light-red-top-nav .top-submenu-item:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
text-shadow: 0 0 10px rgba(196, 51, 40, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strategy-app-header--light-red-top-nav .top-submenu-item--active {
|
||||||
|
color: #ffffff;
|
||||||
|
text-shadow: 0 0 12px rgba(177, 38, 28, 0.48);
|
||||||
|
background-image: var(
|
||||||
|
--light-red-nav-active-background-image,
|
||||||
|
url("../assets/img/nav-active-light-red.svg")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
.third-submenu-bar {
|
.third-submenu-bar {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 34;
|
z-index: 34;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ function ResizablePanel({
|
|||||||
function ResizableHandle({
|
function ResizableHandle({
|
||||||
withHandle,
|
withHandle,
|
||||||
className,
|
className,
|
||||||
|
children,
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<typeof ResizablePrimitive.Separator> & {
|
}: React.ComponentProps<typeof ResizablePrimitive.Separator> & {
|
||||||
withHandle?: boolean;
|
withHandle?: boolean;
|
||||||
@@ -70,6 +71,7 @@ function ResizableHandle({
|
|||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
{children}
|
||||||
{withHandle && (
|
{withHandle && (
|
||||||
<div className="bg-border z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm">
|
<div className="bg-border z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm">
|
||||||
<GripVerticalIcon className="size-3.5" />
|
<GripVerticalIcon className="size-3.5" />
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import {
|
|
||||||
CircleCheckIcon,
|
|
||||||
InfoIcon,
|
|
||||||
Loader2Icon,
|
|
||||||
OctagonXIcon,
|
|
||||||
TriangleAlertIcon,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { useTheme } from "next-themes";
|
|
||||||
import { Toaster as Sonner, type ToasterProps } from "sonner";
|
|
||||||
|
|
||||||
const Toaster = ({ ...props }: ToasterProps) => {
|
|
||||||
const { theme = "system" } = useTheme();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Sonner
|
|
||||||
theme={theme as ToasterProps["theme"]}
|
|
||||||
className="toaster group"
|
|
||||||
icons={{
|
|
||||||
success: <CircleCheckIcon className="size-4" />,
|
|
||||||
info: <InfoIcon className="size-4" />,
|
|
||||||
warning: <TriangleAlertIcon className="size-4" />,
|
|
||||||
error: <OctagonXIcon className="size-4" />,
|
|
||||||
loading: <Loader2Icon className="size-4 animate-spin" />,
|
|
||||||
}}
|
|
||||||
style={
|
|
||||||
{
|
|
||||||
"--normal-bg": "var(--popover)",
|
|
||||||
"--normal-text": "var(--popover-foreground)",
|
|
||||||
"--normal-border": "var(--border)",
|
|
||||||
"--border-radius": "var(--radius)",
|
|
||||||
} as React.CSSProperties
|
|
||||||
}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export { Toaster };
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Plus, Trash2 } from "lucide-react";
|
import { Plus, Trash2 } from "lucide-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { confirmAction, promptAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -136,7 +136,12 @@ export function FolderManageDialog({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleRename = async (folderId: string, current: string) => {
|
const handleRename = async (folderId: string, current: string) => {
|
||||||
const next = window.prompt("重命名 / 移动目录(输入新的完整路径,斜杠分隔)", current);
|
const next = await promptAction("输入新的完整路径,使用斜杠分隔层级。", {
|
||||||
|
title: "重命名 / 移动目录",
|
||||||
|
defaultValue: current,
|
||||||
|
placeholder: "例如:业务资料/项目文档",
|
||||||
|
confirmText: "保存",
|
||||||
|
});
|
||||||
if (next === null) return;
|
if (next === null) return;
|
||||||
try {
|
try {
|
||||||
await rename.mutateAsync({ folderId, path: next });
|
await rename.mutateAsync({ folderId, path: next });
|
||||||
@@ -147,7 +152,11 @@ export function FolderManageDialog({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (folderId: string, path: string) => {
|
const handleDelete = async (folderId: string, path: string) => {
|
||||||
if (!window.confirm(`删除目录「${path}」?其中的知识将变为未归类(不会被删除)。`)) return;
|
if (!(await confirmAction(`删除目录「${path}」?其中的知识将变为未归类(不会被删除)。`, {
|
||||||
|
title: "删除目录?",
|
||||||
|
confirmText: "删除",
|
||||||
|
danger: true,
|
||||||
|
}))) return;
|
||||||
try {
|
try {
|
||||||
await remove.mutateAsync({ folderId });
|
await remove.mutateAsync({ folderId });
|
||||||
toast.success("目录已删除");
|
toast.success("目录已删除");
|
||||||
@@ -292,7 +301,11 @@ export function ExtractTemplateManageDialog({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async (t: KnowledgeExtractTemplate) => {
|
const handleDelete = async (t: KnowledgeExtractTemplate) => {
|
||||||
if (!window.confirm(`删除模板「${t.name}」?`)) return;
|
if (!(await confirmAction(`删除模板「${t.name}」?`, {
|
||||||
|
title: "删除模板?",
|
||||||
|
confirmText: "删除",
|
||||||
|
danger: true,
|
||||||
|
}))) return;
|
||||||
try {
|
try {
|
||||||
await remove.mutateAsync(t.id);
|
await remove.mutateAsync(t.id);
|
||||||
if (selectedId === t.id) setSelectedId(null);
|
if (selectedId === t.id) setSelectedId(null);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ExternalLink, Sparkles } from "lucide-react";
|
import { ExternalLink, Sparkles } from "lucide-react";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ function HeaderButton({
|
|||||||
|
|
||||||
/** Light 56px wiki header: plain page title on the left, action entries on the right. */
|
/** Light 56px wiki header: plain page title on the left, action entries on the right. */
|
||||||
export function WikiHeader({
|
export function WikiHeader({
|
||||||
|
title = "知识库管理",
|
||||||
|
description,
|
||||||
onToggleSidebar,
|
onToggleSidebar,
|
||||||
onImportFile,
|
onImportFile,
|
||||||
onBatchImport,
|
onBatchImport,
|
||||||
@@ -55,6 +57,8 @@ export function WikiHeader({
|
|||||||
onManageTemplates,
|
onManageTemplates,
|
||||||
extraActions,
|
extraActions,
|
||||||
}: {
|
}: {
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
onToggleSidebar: () => void;
|
onToggleSidebar: () => void;
|
||||||
onImportFile: () => void;
|
onImportFile: () => void;
|
||||||
onBatchImport: () => void;
|
onBatchImport: () => void;
|
||||||
@@ -66,8 +70,13 @@ export function WikiHeader({
|
|||||||
extraActions?: ReactNode;
|
extraActions?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<header className="flex h-14 shrink-0 items-center justify-between border-b border-slate-100 bg-white px-4 sm:px-6 dark:border-slate-800 dark:bg-slate-900">
|
<header
|
||||||
<div className="flex items-center gap-3">
|
className={cn(
|
||||||
|
"flex shrink-0 items-center justify-between border-b border-slate-100 bg-white px-4 sm:px-6 dark:border-slate-800 dark:bg-slate-900",
|
||||||
|
description ? "min-h-14 py-2" : "h-14",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="flex min-w-0 items-center gap-3">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onToggleSidebar}
|
onClick={onToggleSidebar}
|
||||||
@@ -76,8 +85,15 @@ export function WikiHeader({
|
|||||||
>
|
>
|
||||||
<Menu className="size-5" />
|
<Menu className="size-5" />
|
||||||
</button>
|
</button>
|
||||||
|
<div className="min-w-0">
|
||||||
<div className="text-base font-semibold tracking-tight text-slate-900 dark:text-slate-100">
|
<div className="text-base font-semibold tracking-tight text-slate-900 dark:text-slate-100">
|
||||||
知识库管理
|
{title}
|
||||||
|
</div>
|
||||||
|
{description ? (
|
||||||
|
<p className="mt-0.5 max-w-xl truncate text-xs text-slate-500 dark:text-slate-400">
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Check, Loader2, Pencil, Plus, Trash2, X } from "lucide-react";
|
import { Check, Loader2, Pencil, Plus, Trash2, X } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -3,18 +3,15 @@
|
|||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
Gauge,
|
Gauge,
|
||||||
Loader2,
|
|
||||||
OctagonX,
|
OctagonX,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
Square,
|
Square,
|
||||||
Zap,
|
Zap,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useId, useMemo, useState } from "react";
|
import { useId, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { Button, Switch, Tag } from "tdesign-react";
|
||||||
|
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
import type {
|
import type {
|
||||||
ActiveRunItem,
|
ActiveRunItem,
|
||||||
ConcurrencyPoint,
|
ConcurrencyPoint,
|
||||||
@@ -35,6 +32,9 @@ import { cn } from "@/lib/utils";
|
|||||||
/** lookback window (hours) per granularity. */
|
/** lookback window (hours) per granularity. */
|
||||||
const LOOKBACK: Record<Granularity, number> = { minute: 3, hour: 48 };
|
const LOOKBACK: Record<Granularity, number> = { minute: 3, hour: 48 };
|
||||||
|
|
||||||
|
/** 主题色(浅红主题下为深红),SVG 引用以跟随换肤。 */
|
||||||
|
const BRAND_COLOR = "var(--td-brand-color, #C1121F)";
|
||||||
|
|
||||||
function fmtBucket(iso: string, granularity: Granularity): string {
|
function fmtBucket(iso: string, granularity: Granularity): string {
|
||||||
const date = new Date(iso);
|
const date = new Date(iso);
|
||||||
if (Number.isNaN(date.getTime())) return iso;
|
if (Number.isNaN(date.getTime())) return iso;
|
||||||
@@ -103,7 +103,11 @@ function latestOf(values: (number | null)[]): number | null {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Minimal dependency-free SVG line chart: legend + 1–2 series + area + caption. */
|
/**
|
||||||
|
* Dependency-free SVG line chart in the 浅红 UI spec style: soft area fill
|
||||||
|
* under the first series, dashed gridlines, hollow hover markers and a dark
|
||||||
|
* hover tooltip (ref: 8.2 图表-折线图 mock).
|
||||||
|
*/
|
||||||
function LineChart({
|
function LineChart({
|
||||||
labels,
|
labels,
|
||||||
series,
|
series,
|
||||||
@@ -119,6 +123,7 @@ function LineChart({
|
|||||||
note?: string;
|
note?: string;
|
||||||
emptyHint: string;
|
emptyHint: string;
|
||||||
}) {
|
}) {
|
||||||
|
const [hoverIdx, setHoverIdx] = useState<number | null>(null);
|
||||||
const gradId = `cm-area-${useId().replace(/:/g, "")}`;
|
const gradId = `cm-area-${useId().replace(/:/g, "")}`;
|
||||||
const width = 760;
|
const width = 760;
|
||||||
const height = 220;
|
const height = 220;
|
||||||
@@ -132,17 +137,25 @@ function LineChart({
|
|||||||
const ticks = buildTicks(dataMax, integer);
|
const ticks = buildTicks(dataMax, integer);
|
||||||
const axisMax = ticks[ticks.length - 1] || 1;
|
const axisMax = ticks[ticks.length - 1] || 1;
|
||||||
|
|
||||||
|
const handleMove = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
const rect = event.currentTarget.getBoundingClientRect();
|
||||||
|
const vx = ((event.clientX - rect.left) / rect.width) * width;
|
||||||
|
const rel = (vx - pad.left) / cw;
|
||||||
|
const idx = Math.round(rel * (n - 1));
|
||||||
|
setHoverIdx(Math.max(0, Math.min(n - 1, idx)));
|
||||||
|
};
|
||||||
|
|
||||||
// Legend always renders (even with no data) so the lines are self-explanatory.
|
// Legend always renders (even with no data) so the lines are self-explanatory.
|
||||||
const legend = (
|
const legend = (
|
||||||
<div className="mb-2 flex flex-wrap items-center gap-x-4 gap-y-1">
|
<div className="mb-2 flex flex-wrap items-center gap-x-4 gap-y-1">
|
||||||
{series.map((s) => {
|
{series.map((s) => {
|
||||||
const latest = latestOf(s.values);
|
const latest = latestOf(s.values);
|
||||||
return (
|
return (
|
||||||
<span key={s.name} className="flex items-center gap-1.5 text-xs text-[#5F6368] dark:text-slate-300">
|
<span key={s.name} className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||||
<span className="inline-block h-[3px] w-4 rounded-full" style={{ backgroundColor: s.color }} />
|
<span className="inline-block h-[3px] w-4 rounded-full" style={{ backgroundColor: s.color }} />
|
||||||
{s.name}
|
{s.name}
|
||||||
{latest != null && (
|
{latest != null && (
|
||||||
<span className="font-semibold tabular-nums text-[#231815] dark:text-white">
|
<span className="font-semibold tabular-nums text-card-foreground">
|
||||||
{Number.isInteger(latest) ? latest : latest.toFixed(1)}
|
{Number.isInteger(latest) ? latest : latest.toFixed(1)}
|
||||||
{unit}
|
{unit}
|
||||||
</span>
|
</span>
|
||||||
@@ -154,14 +167,14 @@ function LineChart({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const caption = note ? (
|
const caption = note ? (
|
||||||
<p className="mt-2 text-[11px] leading-4 text-[#8B6B6B] dark:text-[#7FACF2]">{note}</p>
|
<p className="mt-2 text-[11px] leading-4 text-muted-foreground">{note}</p>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
if (n === 0) {
|
if (n === 0) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{legend}
|
{legend}
|
||||||
<div className="flex h-[160px] items-center justify-center rounded-lg border border-dashed border-[#F1D6D6] text-sm text-[#5F6368] dark:border-[#213D5E] dark:text-slate-400">
|
<div className="flex h-[160px] items-center justify-center rounded-[5px] border border-dashed border-border/70 text-sm text-muted-foreground">
|
||||||
{emptyHint}
|
{emptyHint}
|
||||||
</div>
|
</div>
|
||||||
{caption}
|
{caption}
|
||||||
@@ -194,16 +207,22 @@ function LineChart({
|
|||||||
return `${line} L ${xFor(n - 1).toFixed(1)} ${(pad.top + ch).toFixed(1)} L ${xFor(0).toFixed(1)} ${(pad.top + ch).toFixed(1)} Z`;
|
return `${line} L ${xFor(n - 1).toFixed(1)} ${(pad.top + ch).toFixed(1)} L ${xFor(0).toFixed(1)} ${(pad.top + ch).toFixed(1)} Z`;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const hoverX = hoverIdx != null ? xFor(hoverIdx) : null;
|
||||||
const labelStep = Math.max(1, Math.ceil(n / 7));
|
const labelStep = Math.max(1, Math.ceil(n / 7));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{legend}
|
{legend}
|
||||||
|
<div
|
||||||
|
className="relative"
|
||||||
|
onMouseMove={handleMove}
|
||||||
|
onMouseLeave={() => setHoverIdx(null)}
|
||||||
|
>
|
||||||
<svg viewBox={`0 0 ${width} ${height}`} className="w-full" role="img" aria-label="时序折线图">
|
<svg viewBox={`0 0 ${width} ${height}`} className="w-full" role="img" aria-label="时序折线图">
|
||||||
<defs>
|
<defs>
|
||||||
<linearGradient id={gradId} x1="0" x2="0" y1="0" y2="1">
|
<linearGradient id={gradId} x1="0" x2="0" y1="0" y2="1">
|
||||||
<stop offset="0%" stopColor={first?.color ?? "#C1121F"} stopOpacity="0.18" />
|
<stop offset="0%" stopColor={first?.color ?? BRAND_COLOR} stopOpacity="0.14" />
|
||||||
<stop offset="100%" stopColor={first?.color ?? "#C1121F"} stopOpacity="0.02" />
|
<stop offset="100%" stopColor={first?.color ?? BRAND_COLOR} stopOpacity="0.01" />
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
</defs>
|
</defs>
|
||||||
{ticks.map((t) => {
|
{ticks.map((t) => {
|
||||||
@@ -216,19 +235,33 @@ function LineChart({
|
|||||||
y1={y}
|
y1={y}
|
||||||
y2={y}
|
y2={y}
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
className="text-[#E5E7EB] dark:text-[#3F3F46]"
|
className="text-border/70"
|
||||||
strokeWidth="1"
|
strokeWidth="1"
|
||||||
|
strokeDasharray="4 4"
|
||||||
/>
|
/>
|
||||||
<text x={pad.left - 6} y={y + 3} textAnchor="end" className="fill-[#9CA3AF] text-[10px]">
|
<text x={pad.left - 6} y={y + 3} textAnchor="end" className="fill-muted-foreground text-[10px]">
|
||||||
{fmtAxis(t, integer)}
|
{fmtAxis(t, integer)}
|
||||||
</text>
|
</text>
|
||||||
</g>
|
</g>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{areaPath && <path d={areaPath} fill={`url(#${gradId})`} />}
|
{areaPath && <path d={areaPath} fill={`url(#${gradId})`} />}
|
||||||
{series.map((s) => (
|
{hoverX != null && (
|
||||||
|
<line
|
||||||
|
x1={hoverX}
|
||||||
|
x2={hoverX}
|
||||||
|
y1={pad.top}
|
||||||
|
y2={pad.top + ch}
|
||||||
|
stroke={BRAND_COLOR}
|
||||||
|
strokeWidth="1"
|
||||||
|
strokeDasharray="3 3"
|
||||||
|
opacity="0.45"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{series.map((s, sIndex) => (
|
||||||
|
<g key={s.name}>
|
||||||
|
{/* 基线:实色线 */}
|
||||||
<path
|
<path
|
||||||
key={s.name}
|
|
||||||
d={linePath(s.values)}
|
d={linePath(s.values)}
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke={s.color}
|
stroke={s.color}
|
||||||
@@ -236,50 +269,90 @@ function LineChart({
|
|||||||
strokeLinecap="round"
|
strokeLinecap="round"
|
||||||
strokeLinejoin="round"
|
strokeLinejoin="round"
|
||||||
/>
|
/>
|
||||||
|
{/* 流动高光:同路径短划沿 dashoffset 无限循环,白亮光带从左向右流过 */}
|
||||||
|
<path
|
||||||
|
d={linePath(s.values)}
|
||||||
|
fill="none"
|
||||||
|
stroke="rgba(255, 255, 255, 0.75)"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
pathLength={1}
|
||||||
|
className="lb-line-flow"
|
||||||
|
style={{ animationDelay: `${sIndex * -2.75}s` }}
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
))}
|
))}
|
||||||
|
{hoverIdx != null &&
|
||||||
|
series.map((s) => {
|
||||||
|
const v = s.values[hoverIdx];
|
||||||
|
if (v == null) return null;
|
||||||
|
return (
|
||||||
|
<circle
|
||||||
|
key={`${s.name}-hover`}
|
||||||
|
cx={xFor(hoverIdx)}
|
||||||
|
cy={yFor(v)}
|
||||||
|
r="4"
|
||||||
|
fill="var(--td-bg-color-container, #fff)"
|
||||||
|
stroke={s.color}
|
||||||
|
strokeWidth="2"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
{labels.map((label, i) => {
|
{labels.map((label, i) => {
|
||||||
if (i !== 0 && i !== n - 1 && i % labelStep !== 0) return null;
|
if (i !== 0 && i !== n - 1 && i % labelStep !== 0) return null;
|
||||||
return (
|
return (
|
||||||
<text key={`${label}-${i}`} x={xFor(i)} y={height - 8} textAnchor="middle" className="fill-[#6B7280] text-[10px]">
|
<text key={`${label}-${i}`} x={xFor(i)} y={height - 8} textAnchor="middle" className="fill-muted-foreground text-[10px]">
|
||||||
{label}
|
{label}
|
||||||
</text>
|
</text>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{series.map((s) =>
|
|
||||||
s.values.map((v, i) =>
|
|
||||||
v == null ? null : (
|
|
||||||
<circle key={`${s.name}-${i}`} cx={xFor(i)} cy={yFor(v)} r={2.5} fill={s.color}>
|
|
||||||
<title>{`${labels[i]} · ${s.name}: ${v}${unit}`}</title>
|
|
||||||
</circle>
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)}
|
|
||||||
</svg>
|
</svg>
|
||||||
|
{hoverIdx != null && (
|
||||||
|
<div
|
||||||
|
className="pointer-events-none absolute top-2 z-10 min-w-[110px] -translate-x-1/2 rounded-[5px] bg-[#1D2939]/95 px-2.5 py-1.5 text-xs text-white shadow-lg"
|
||||||
|
style={{ left: `${Math.min(92, Math.max(8, (xFor(hoverIdx) / width) * 100))}%` }}
|
||||||
|
>
|
||||||
|
<div className="mb-1 font-medium text-white/90">{labels[hoverIdx]}</div>
|
||||||
|
{series.map((s) => {
|
||||||
|
const v = s.values[hoverIdx];
|
||||||
|
return (
|
||||||
|
<div key={s.name} className="flex items-center gap-1.5 whitespace-nowrap">
|
||||||
|
<span className="size-1.5 rounded-full" style={{ backgroundColor: s.color }} aria-hidden />
|
||||||
|
<span className="text-white/75">{s.name}</span>
|
||||||
|
<span className="ml-auto font-semibold tabular-nums">{v == null ? "-" : `${Number.isInteger(v) ? v : v.toFixed(1)}${unit}`}</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
{caption}
|
{caption}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ChartCard({
|
/** 浅红 UI 规范的「▎标题」小节头(面板内使用)。 */
|
||||||
icon: Icon,
|
function ChartSection({
|
||||||
title,
|
title,
|
||||||
subtitle,
|
icon: Icon,
|
||||||
|
extra,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
icon: typeof Activity;
|
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string;
|
icon?: typeof Activity;
|
||||||
|
extra?: React.ReactNode;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className="rounded-lg border border-[#F1D6D6] bg-white p-4 shadow-sm dark:border-[#213D5E] dark:bg-[#02244C]">
|
<div className="rounded-[5px] bg-muted/30 p-4">
|
||||||
<div className="mb-3 flex items-center gap-2">
|
<div className="mb-3 flex items-center gap-2.5">
|
||||||
<Icon className="size-4 text-[#C1121F] dark:text-[#7FACF2]" />
|
<span className="h-3.5 w-[3px] shrink-0 rounded-full bg-primary" aria-hidden />
|
||||||
<h3 className="font-semibold text-[#231815] dark:text-white">{title}</h3>
|
{Icon ? <Icon className="size-4 shrink-0 text-muted-foreground" /> : null}
|
||||||
<span className="ml-auto text-xs text-[#8B6B6B] dark:text-[#7FACF2]">{subtitle}</span>
|
<h3 className="text-sm font-semibold text-card-foreground">{title}</h3>
|
||||||
|
<span className="ml-auto text-xs text-muted-foreground">{extra}</span>
|
||||||
</div>
|
</div>
|
||||||
{children}
|
{children}
|
||||||
</section>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,36 +366,35 @@ function ActiveRunRow({
|
|||||||
stopping: boolean;
|
stopping: boolean;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] items-center gap-3 border-b border-[#F1D6D6] px-3 py-2 text-sm last:border-b-0 dark:border-[#213D5E]">
|
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] items-center gap-3 border-b border-border/60 px-3 py-2 text-sm transition-colors last:border-b-0 hover:bg-muted/40">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<div className="truncate font-medium text-[#202124] dark:text-white">{run.user_name || "未知用户"}</div>
|
<div className="truncate font-medium text-card-foreground">{run.user_name || "未知用户"}</div>
|
||||||
<div className="truncate text-xs text-[#5F6368] dark:text-slate-400" title={run.thread_title}>
|
<div className="truncate text-xs text-muted-foreground" title={run.thread_title}>
|
||||||
{run.thread_title || run.thread_id}
|
{run.thread_title || run.thread_id}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 truncate text-[#202124] dark:text-slate-100">{run.agent_name}</div>
|
<div className="min-w-0 truncate text-card-foreground">{run.agent_name}</div>
|
||||||
<Badge variant="outline" className="justify-center">
|
<Tag variant="outline" size="small" className="justify-center">
|
||||||
{run.kind}
|
{run.kind}
|
||||||
</Badge>
|
</Tag>
|
||||||
<span
|
<span className="text-center">
|
||||||
className={cn(
|
{run.status === "running" ? (
|
||||||
"text-center text-xs font-medium",
|
<Tag theme="success" variant="light" size="small">运行中</Tag>
|
||||||
run.status === "running" ? "text-[#0F766E] dark:text-teal-300" : "text-[#B45309] dark:text-amber-300",
|
) : (
|
||||||
|
<Tag theme="warning" variant="light" size="small">排队中</Tag>
|
||||||
)}
|
)}
|
||||||
>
|
|
||||||
{run.status === "running" ? "运行中" : "排队中"}
|
|
||||||
</span>
|
</span>
|
||||||
<span className="text-center text-xs tabular-nums text-[#5F6368] dark:text-slate-400">
|
<span className="text-center text-xs tabular-nums text-muted-foreground">
|
||||||
{fmtElapsed(run.elapsed_seconds)}
|
{fmtElapsed(run.elapsed_seconds)}
|
||||||
</span>
|
</span>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="small"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="h-7 border-[#C1121F]/40 text-[#C1121F] hover:bg-[#FFF1F1] dark:border-rose-400/40 dark:text-rose-200"
|
theme="danger"
|
||||||
disabled={stopping}
|
disabled={stopping}
|
||||||
|
icon={<Square className="size-3.5" />}
|
||||||
onClick={() => onStop(run.run_id)}
|
onClick={() => onStop(run.run_id)}
|
||||||
>
|
>
|
||||||
{stopping ? <Loader2 className="size-3.5 animate-spin" /> : <Square className="size-3.5" />}
|
|
||||||
停止
|
停止
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -363,8 +435,8 @@ export function ConcurrencyMonitorPanel() {
|
|||||||
return {
|
return {
|
||||||
labels: points.map((p) => fmtBucket(p.bucket, granularity)),
|
labels: points.map((p) => fmtBucket(p.bucket, granularity)),
|
||||||
series: [
|
series: [
|
||||||
{ name: "平均速度", color: "#2563EB", values: points.map((p) => p.avg_tokens_per_sec) },
|
{ name: "平均速度", color: "#2F6BFF", values: points.map((p) => p.avg_tokens_per_sec) },
|
||||||
{ name: "最慢", color: "#9333EA", values: points.map((p) => p.min_tokens_per_sec) },
|
{ name: "最慢", color: "#7C3AED", values: points.map((p) => p.min_tokens_per_sec) },
|
||||||
] as LineSeries[],
|
] as LineSeries[],
|
||||||
};
|
};
|
||||||
}, [tokenSpeed.data, granularity]);
|
}, [tokenSpeed.data, granularity]);
|
||||||
@@ -383,7 +455,11 @@ export function ConcurrencyMonitorPanel() {
|
|||||||
|
|
||||||
const handleStopAll = async () => {
|
const handleStopAll = async () => {
|
||||||
if (runs.length === 0) return;
|
if (runs.length === 0) return;
|
||||||
if (!window.confirm(`确定要停止当前全部 ${count} 个并发调用吗?这会中断这些用户正在生成的回答。`)) return;
|
if (!(await confirmAction(`确定要停止当前全部 ${count} 个并发调用吗?这会中断这些用户正在生成的回答。`, {
|
||||||
|
title: "停止全部调用?",
|
||||||
|
confirmText: "全部停止",
|
||||||
|
danger: true,
|
||||||
|
}))) return;
|
||||||
try {
|
try {
|
||||||
const res = await cancelAll.mutateAsync();
|
const res = await cancelAll.mutateAsync();
|
||||||
toast.success(`已停止 ${res.cancelled_count} 个调用`);
|
toast.success(`已停止 ${res.cancelled_count} 个调用`);
|
||||||
@@ -402,52 +478,56 @@ export function ConcurrencyMonitorPanel() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="space-y-4 rounded-xl border border-[#F1D6D6] bg-[#FFF7F7] p-4 shadow-sm dark:border-[#213D5E] dark:bg-[#011226]">
|
<section className="lb-icon-gap space-y-4 rounded-[5px] bg-card p-4 shadow-[0_2px_8px_rgba(15,23,42,0.06)]">
|
||||||
{/* header */}
|
{/* header */}
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="flex size-9 items-center justify-center rounded-lg bg-[#C1121F] text-white dark:bg-[#2563EB]">
|
<span className="flex size-9 items-center justify-center rounded-lg bg-primary text-primary-foreground">
|
||||||
<Activity className="size-5" />
|
<Activity className="size-5" />
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<div className="font-semibold text-[#231815] dark:text-white">实时并发监控</div>
|
<div className="font-semibold text-card-foreground">实时并发监控</div>
|
||||||
<div className="text-xs text-[#8B6B6B] dark:text-[#7FACF2]">
|
<div className="text-xs text-muted-foreground">
|
||||||
监控大模型并发压力,可直接停止任意对话调用
|
监控大模型并发压力,可直接停止任意对话调用
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="ml-auto flex flex-wrap items-center gap-3">
|
<div className="ml-auto flex h-8 flex-wrap items-center gap-2">
|
||||||
<div className="flex items-center gap-2 rounded-lg border border-[#F1D6D6] bg-white px-3 py-1.5 dark:border-[#213D5E] dark:bg-[#02244C]">
|
<div className="flex h-8 items-center gap-2 rounded-[5px] bg-muted/40 px-3">
|
||||||
<span className="text-xs text-[#5F6368] dark:text-slate-300">当前并发</span>
|
<span className="text-xs text-muted-foreground">当前并发</span>
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-2xl font-semibold tabular-nums",
|
"text-lg font-semibold leading-none tabular-nums",
|
||||||
count > 0 ? "text-[#C1121F] dark:text-[#7FACF2]" : "text-[#202124] dark:text-white",
|
count > 0 ? "text-primary" : "text-card-foreground",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{count}
|
{count}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2 rounded-lg border border-[#F1D6D6] bg-white px-3 py-1.5 dark:border-[#213D5E] dark:bg-[#02244C]">
|
<div className="flex h-8 items-center gap-2 rounded-[5px] bg-muted/40 px-3">
|
||||||
<span className="text-xs text-[#5F6368] dark:text-slate-300">后台采样</span>
|
<span className="text-xs text-muted-foreground">后台采样</span>
|
||||||
<Switch checked={samplerOn} onCheckedChange={handleToggleSampler} disabled={updateSettings.isPending} />
|
<Switch value={samplerOn} onChange={handleToggleSampler} loading={updateSettings.isPending} />
|
||||||
</div>
|
</div>
|
||||||
<Button variant="outline" size="sm" onClick={() => refetch()} disabled={isRefetching}>
|
<Button
|
||||||
<RefreshCw className={cn("mr-1 size-4", isRefetching && "animate-spin")} />
|
variant="outline"
|
||||||
|
theme="default"
|
||||||
|
icon={<RefreshCw className={cn("size-4", isRefetching && "animate-spin")} />}
|
||||||
|
onClick={() => refetch()}
|
||||||
|
disabled={isRefetching}
|
||||||
|
>
|
||||||
刷新
|
刷新
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
theme="danger"
|
||||||
className="border-[#C1121F]/50 text-[#C1121F] hover:bg-[#FFF1F1] dark:border-rose-400/40 dark:text-rose-200"
|
icon={<OctagonX className="size-4" />}
|
||||||
onClick={handleStopAll}
|
onClick={handleStopAll}
|
||||||
disabled={cancelAll.isPending || runs.length === 0}
|
disabled={cancelAll.isPending || runs.length === 0}
|
||||||
>
|
>
|
||||||
<OctagonX className="mr-1 size-4" />
|
|
||||||
全部停止
|
全部停止
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="ghost" size="sm" onClick={() => setOpen((v) => !v)}>
|
<Button variant="text" theme="default" onClick={() => setOpen((v) => !v)}>
|
||||||
{open ? "收起" : "展开"}
|
{open ? "收起" : "展开"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -456,36 +536,38 @@ export function ConcurrencyMonitorPanel() {
|
|||||||
{open && (
|
{open && (
|
||||||
<>
|
<>
|
||||||
{!samplerOn && (
|
{!samplerOn && (
|
||||||
<div className="rounded-lg border border-amber-300/60 bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:border-amber-300/30 dark:bg-amber-300/10 dark:text-amber-100">
|
<div className="rounded-[5px] bg-amber-50 px-3 py-2 text-xs text-amber-800 dark:bg-amber-400/10 dark:text-amber-100">
|
||||||
后台采样默认关闭:实时并发数与「停止」功能始终可用。需要并发量历史折线图时,打开右上角「后台采样」开关即可开始记录(对线上服务影响极小,可随时关闭)。
|
后台采样默认关闭:实时并发数与「停止」功能始终可用。需要并发量历史折线图时,打开右上角「后台采样」开关即可开始记录(对线上服务影响极小,可随时关闭)。
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* granularity toggle */}
|
{/* granularity toggle */}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-xs text-[#5F6368] dark:text-slate-300">统计粒度</span>
|
<span className="text-xs text-muted-foreground">统计粒度</span>
|
||||||
|
<div className="lb-pill-group flex items-center gap-1.5">
|
||||||
{(["minute", "hour"] as Granularity[]).map((g) => (
|
{(["minute", "hour"] as Granularity[]).map((g) => (
|
||||||
<Button
|
<Button
|
||||||
key={g}
|
key={g}
|
||||||
size="sm"
|
size="small"
|
||||||
variant={granularity === g ? "default" : "outline"}
|
variant={granularity === g ? "base" : "outline"}
|
||||||
className={cn("h-7", granularity === g && "bg-[#C1121F] hover:bg-[#A50F1A] dark:bg-[#2563EB]")}
|
theme={granularity === g ? "primary" : "default"}
|
||||||
onClick={() => setGranularity(g)}
|
onClick={() => setGranularity(g)}
|
||||||
>
|
>
|
||||||
{g === "minute" ? "按分钟" : "按小时"}
|
{g === "minute" ? "按分钟" : "按小时"}
|
||||||
</Button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
<span className="text-xs text-[#8B6B6B] dark:text-[#7FACF2]">
|
</div>
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
{granularity === "minute" ? "近 3 小时" : "近 48 小时"}
|
{granularity === "minute" ? "近 3 小时" : "近 48 小时"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* charts */}
|
{/* charts */}
|
||||||
<div className="grid gap-3 xl:grid-cols-2">
|
<div className="grid gap-3 xl:grid-cols-2">
|
||||||
<ChartCard icon={Gauge} title="并发量(系统压力)" subtitle={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
|
<ChartSection icon={Gauge} title="并发量(系统压力)" extra={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
|
||||||
{concurrency.isLoading ? (
|
{concurrency.isLoading ? (
|
||||||
<div className="flex h-[220px] items-center justify-center text-sm text-[#5F6368] dark:text-slate-400">
|
<div className="flex h-[220px] items-center justify-center text-sm text-muted-foreground">
|
||||||
<Loader2 className="mr-2 size-4 animate-spin" /> 加载中
|
加载中…
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<LineChart
|
<LineChart
|
||||||
@@ -497,11 +579,11 @@ export function ConcurrencyMonitorPanel() {
|
|||||||
emptyHint="暂无并发采样数据(需打开「后台采样」开关后才开始记录)"
|
emptyHint="暂无并发采样数据(需打开「后台采样」开关后才开始记录)"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ChartCard>
|
</ChartSection>
|
||||||
<ChartCard icon={Zap} title="大模型出字速度" subtitle={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
|
<ChartSection icon={Zap} title="大模型出字速度" extra={`每${granularity === "hour" ? "小时" : "分钟"}一个点`}>
|
||||||
{tokenSpeed.isLoading ? (
|
{tokenSpeed.isLoading ? (
|
||||||
<div className="flex h-[220px] items-center justify-center text-sm text-[#5F6368] dark:text-slate-400">
|
<div className="flex h-[220px] items-center justify-center text-sm text-muted-foreground">
|
||||||
<Loader2 className="mr-2 size-4 animate-spin" /> 加载中
|
加载中…
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<LineChart
|
<LineChart
|
||||||
@@ -512,23 +594,24 @@ export function ConcurrencyMonitorPanel() {
|
|||||||
emptyHint="暂无大模型调用记录"
|
emptyHint="暂无大模型调用记录"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ChartCard>
|
</ChartSection>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* active run list */}
|
{/* active run list */}
|
||||||
<section className="rounded-lg border border-[#F1D6D6] bg-white dark:border-[#213D5E] dark:bg-[#02244C]">
|
<section className="overflow-hidden rounded-[5px] bg-muted/20">
|
||||||
<div className="flex items-center gap-2 border-b border-[#F1D6D6] px-3 py-2 dark:border-[#213D5E]">
|
<div className="flex items-center gap-2 border-b border-border/70 px-3 py-2">
|
||||||
<span className="font-semibold text-[#231815] dark:text-white">正在进行的调用</span>
|
<span className="h-3.5 w-[3px] rounded-full bg-primary" aria-hidden />
|
||||||
<Badge variant="outline">{count}</Badge>
|
<span className="text-sm font-semibold text-card-foreground">正在进行的调用</span>
|
||||||
{liveLoading && <Loader2 className="size-3.5 animate-spin text-[#8B6B6B]" />}
|
<Tag variant="outline" size="small">{count}</Tag>
|
||||||
|
{liveLoading && <span className="text-xs text-muted-foreground">加载中…</span>}
|
||||||
</div>
|
</div>
|
||||||
{runs.length === 0 ? (
|
{runs.length === 0 ? (
|
||||||
<div className="py-10 text-center text-sm text-[#5F6368] dark:text-slate-400">
|
<div className="py-10 text-center text-sm text-muted-foreground">
|
||||||
当前没有正在进行的大模型调用
|
当前没有正在进行的大模型调用
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] gap-3 border-b border-[#F1D6D6] px-3 py-2 text-xs text-[#8B6B6B] dark:border-[#213D5E] dark:text-[#7FACF2]">
|
<div className="grid grid-cols-[minmax(0,1.4fr)_minmax(0,1.2fr)_72px_64px_64px_72px] gap-3 border-b border-border/60 bg-muted/30 px-3 py-2 text-xs text-muted-foreground">
|
||||||
<span>用户 / 会话</span>
|
<span>用户 / 会话</span>
|
||||||
<span>智能体</span>
|
<span>智能体</span>
|
||||||
<span className="text-center">类型</span>
|
<span className="text-center">类型</span>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
UsersIcon,
|
UsersIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -391,7 +391,11 @@ export function PositionManagementPage() {
|
|||||||
}, [positions, selectedId]);
|
}, [positions, selectedId]);
|
||||||
|
|
||||||
const handleDelete = async (p: Position) => {
|
const handleDelete = async (p: Position) => {
|
||||||
if (!window.confirm(`确认删除岗位「${p.name}」?其成员将回退到默认岗位。`)) return;
|
if (!(await confirmAction(`确认删除岗位「${p.name}」?其成员将回退到默认岗位。`, {
|
||||||
|
title: "删除岗位?",
|
||||||
|
confirmText: "删除",
|
||||||
|
danger: true,
|
||||||
|
}))) return;
|
||||||
try {
|
try {
|
||||||
await deletePosition.mutateAsync(p.id);
|
await deletePosition.mutateAsync(p.id);
|
||||||
if (selectedId === p.id) setSelectedId(null);
|
if (selectedId === p.id) setSelectedId(null);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Loader2, PencilIcon, PlusIcon, Trash2Icon } from "lucide-react";
|
import { Loader2, PencilIcon, PlusIcon, Trash2Icon } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -172,7 +172,11 @@ export function TagManagementPage() {
|
|||||||
setDialogOpen(true);
|
setDialogOpen(true);
|
||||||
};
|
};
|
||||||
const handleDelete = async (tag: Tag) => {
|
const handleDelete = async (tag: Tag) => {
|
||||||
if (!window.confirm(t.adminTags.deleteConfirm)) return;
|
if (!(await confirmAction(t.adminTags.deleteConfirm, {
|
||||||
|
title: "删除标签?",
|
||||||
|
confirmText: "删除",
|
||||||
|
danger: true,
|
||||||
|
}))) return;
|
||||||
try {
|
try {
|
||||||
await deleteTag.mutateAsync(tag.id);
|
await deleteTag.mutateAsync(tag.id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { AlertCircle,CheckCircle2, Download, Loader2 } from "lucide-react";
|
import { AlertCircle,CheckCircle2, Download, Loader2 } from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -1,11 +1,33 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { BotIcon } from "lucide-react";
|
import {
|
||||||
|
BotIcon,
|
||||||
|
BrainIcon,
|
||||||
|
CompassIcon,
|
||||||
|
MessagesSquareIcon,
|
||||||
|
SparklesIcon,
|
||||||
|
WorkflowIcon,
|
||||||
|
} from "lucide-react";
|
||||||
|
|
||||||
import { type Agent } from "@/core/agents";
|
import { type Agent } from "@/core/agents";
|
||||||
import { desensitize } from "@/lib/desensitize";
|
import { desensitize } from "@/lib/desensitize";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Per-style avatar glyphs — the landing style index (derived from the agent
|
||||||
|
* id in globals.css' [data-agent-style] block) also swaps the hero mark so
|
||||||
|
* two agents on different styles don't just differ by color. Keep in sync
|
||||||
|
* with AGENT_LANDING_STYLE_COUNT.
|
||||||
|
*/
|
||||||
|
const STYLE_ICONS = [
|
||||||
|
BotIcon,
|
||||||
|
SparklesIcon,
|
||||||
|
BrainIcon,
|
||||||
|
CompassIcon,
|
||||||
|
MessagesSquareIcon,
|
||||||
|
WorkflowIcon,
|
||||||
|
] as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Landing (home) hero shown above the input box before the first message of an
|
* Landing (home) hero shown above the input box before the first message of an
|
||||||
* agent conversation: centered avatar, a "Hi,我是{name}" greeting and the
|
* agent conversation: centered avatar, a "Hi,我是{name}" greeting and the
|
||||||
@@ -13,20 +35,33 @@ import { cn } from "@/lib/utils";
|
|||||||
* (full text on hover) so a long blurb can never push the input box below the
|
* (full text on hover) so a long blurb can never push the input box below the
|
||||||
* fold. The agent's 常用问题 are rendered by the page as a list beside the
|
* fold. The agent's 常用问题 are rendered by the page as a list beside the
|
||||||
* input box, not here.
|
* input box, not here.
|
||||||
|
*
|
||||||
|
* The avatar color/shape, greeting treatment and page glow are themed per
|
||||||
|
* agent via the ancestor `[data-agent-style]` attribute (AgentChatPage) —
|
||||||
|
* see the 智能体专属落地页风格 block in globals.css.
|
||||||
*/
|
*/
|
||||||
export function AgentWelcome({
|
export function AgentWelcome({
|
||||||
className,
|
className,
|
||||||
agent,
|
agent,
|
||||||
agentName,
|
agentName,
|
||||||
|
styleIndex,
|
||||||
}: {
|
}: {
|
||||||
className?: string;
|
className?: string;
|
||||||
agent: Agent | null | undefined;
|
agent: Agent | null | undefined;
|
||||||
agentName: string;
|
agentName: string;
|
||||||
|
/** 仅自定义业务深链入口传入(风格分配完成后的档位;未分配完成时为
|
||||||
|
* undefined):启用按风格轮换的头像图标;缺省保持全局原样的 BotIcon。 */
|
||||||
|
styleIndex?: number;
|
||||||
}) {
|
}) {
|
||||||
const displayName = desensitize(agent?.name ?? agentName);
|
const displayName = desensitize(agent?.name ?? agentName);
|
||||||
const description = agent?.description
|
const description = agent?.description
|
||||||
? desensitize(agent.description)
|
? desensitize(agent.description)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const styleIcon =
|
||||||
|
styleIndex === undefined
|
||||||
|
? BotIcon
|
||||||
|
: (STYLE_ICONS[styleIndex % STYLE_ICONS.length] ?? BotIcon);
|
||||||
|
const StyleIcon = styleIcon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -35,15 +70,15 @@ export function AgentWelcome({
|
|||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="agent-avatar bg-primary/10 ring-primary/15 mb-2 flex h-[72px] w-[72px] items-center justify-center rounded-3xl ring-1">
|
<div className="agent-avatar rounded-3xl mb-2 flex h-[72px] w-[72px] items-center justify-center">
|
||||||
<BotIcon className="text-primary h-9 w-9" />
|
<StyleIcon className="h-9 w-9" />
|
||||||
</div>
|
</div>
|
||||||
<div className="text-3xl font-bold tracking-tight">
|
<div className="agent-welcome-name text-3xl font-bold tracking-tight">
|
||||||
Hi,我是{displayName}
|
Hi,我是{displayName}
|
||||||
</div>
|
</div>
|
||||||
{description && (
|
{description && (
|
||||||
<p
|
<p
|
||||||
className="text-muted-foreground line-clamp-2 max-w-xl text-base leading-relaxed"
|
className="agent-welcome-description text-muted-foreground line-clamp-2 max-w-xl text-base leading-relaxed"
|
||||||
title={description}
|
title={description}
|
||||||
>
|
>
|
||||||
{description}
|
{description}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import agentAvatarDark from "@/assets/agents-plaza/blue/robot.png";
|
||||||
|
import agentAvatarLight from "@/assets/agents-plaza/robot-orange.png";
|
||||||
|
import { useTheme } from "@/contexts/ThemeContext";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
type AgentBrandIconProps = {
|
||||||
|
className?: string;
|
||||||
|
size?: "md" | "lg";
|
||||||
|
};
|
||||||
|
|
||||||
|
const SIZE_STYLES = {
|
||||||
|
md: "size-12",
|
||||||
|
lg: "size-16",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
/** The master-zl agent gallery mark, switching artwork with the app theme. */
|
||||||
|
export function AgentBrandIcon({
|
||||||
|
className,
|
||||||
|
size = "md",
|
||||||
|
}: AgentBrandIconProps) {
|
||||||
|
const { theme } = useTheme();
|
||||||
|
const avatarSrc = theme === "light" ? agentAvatarLight : agentAvatarDark;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn(
|
||||||
|
"relative inline-flex shrink-0 overflow-hidden rounded-full",
|
||||||
|
SIZE_STYLES[size],
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={avatarSrc}
|
||||||
|
alt=""
|
||||||
|
className="size-full object-contain"
|
||||||
|
draggable={false}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BotIcon,
|
|
||||||
ClockIcon,
|
ClockIcon,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
EyeIcon,
|
EyeIcon,
|
||||||
@@ -9,6 +8,7 @@ import {
|
|||||||
GlobeIcon,
|
GlobeIcon,
|
||||||
LockIcon,
|
LockIcon,
|
||||||
MessageSquareIcon,
|
MessageSquareIcon,
|
||||||
|
MoreHorizontalIcon,
|
||||||
PinIcon,
|
PinIcon,
|
||||||
ShieldIcon,
|
ShieldIcon,
|
||||||
SparklesIcon,
|
SparklesIcon,
|
||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
type ReactNode,
|
type ReactNode,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { toast } from "sonner";
|
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -47,6 +47,13 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
@@ -94,6 +101,8 @@ import { formatDateTime } from "@/core/utils/datetime";
|
|||||||
import { desensitize } from "@/lib/desensitize";
|
import { desensitize } from "@/lib/desensitize";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
import { AgentBrandIcon } from "./agent-brand-icon";
|
||||||
|
|
||||||
interface AgentCardProps {
|
interface AgentCardProps {
|
||||||
agent: Agent;
|
agent: Agent;
|
||||||
/** "card" (default) renders the full gallery card; "list" renders a compact
|
/** "card" (default) renders the full gallery card; "list" renders a compact
|
||||||
@@ -497,7 +506,7 @@ export function AgentCard({
|
|||||||
setPublishPickerOpen(true);
|
setPublishPickerOpen(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!warnIfAccountSwitched()) {
|
if (!(await warnIfAccountSwitched())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -515,18 +524,22 @@ export function AgentCard({
|
|||||||
|
|
||||||
// 发布操作以实时 token 执行。若会话中途账号被切换(常见于另一标签页登录了别的
|
// 发布操作以实时 token 执行。若会话中途账号被切换(常见于另一标签页登录了别的
|
||||||
// 账号),先弹一次确认 —— 避免误以本人之外的账号执行发布。返回 false = 用户取消。
|
// 账号),先弹一次确认 —— 避免误以本人之外的账号执行发布。返回 false = 用户取消。
|
||||||
function warnIfAccountSwitched(): boolean {
|
function warnIfAccountSwitched(): boolean | Promise<boolean> {
|
||||||
if (!live.switched) {
|
if (!live.switched) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return window.confirm(
|
return confirmAction(
|
||||||
`当前登录账号已从「${live.mountDisplayName}」切换为「${live.displayName}」。\n` +
|
`当前登录账号已从「${live.mountDisplayName}」切换为「${live.displayName}」。\n` +
|
||||||
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。\n\n仍要继续吗?`,
|
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。`,
|
||||||
|
{
|
||||||
|
title: "登录账号已切换",
|
||||||
|
confirmText: "继续发布",
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handlePublishToSquare(squareId: string) {
|
async function handlePublishToSquare(squareId: string) {
|
||||||
if (!warnIfAccountSwitched()) {
|
if (!(await warnIfAccountSwitched())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -608,6 +621,12 @@ export function AgentCard({
|
|||||||
// both the card header and the compact list row.
|
// both the card header and the compact list row.
|
||||||
const statusBadges = (
|
const statusBadges = (
|
||||||
<>
|
<>
|
||||||
|
{isPinned && (
|
||||||
|
<Badge className="border border-primary/20 bg-primary/5 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/5 dark:border-primary/40 dark:bg-primary/15">
|
||||||
|
<PinIcon className="mr-1 size-3.5 fill-current" />
|
||||||
|
置顶
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
{isBuiltin && (
|
{isBuiltin && (
|
||||||
<Badge variant="secondary" className="text-xs">
|
<Badge variant="secondary" className="text-xs">
|
||||||
内置
|
内置
|
||||||
@@ -730,7 +749,12 @@ export function AgentCard({
|
|||||||
...(agent.tool_groups ?? []).map((group) => ({
|
...(agent.tool_groups ?? []).map((group) => ({
|
||||||
key: `tg:${group}`,
|
key: `tg:${group}`,
|
||||||
node: (
|
node: (
|
||||||
<Badge key={`tg:${group}`} variant="outline" className="text-xs">
|
<Badge
|
||||||
|
key={`tg:${group}`}
|
||||||
|
variant="outline"
|
||||||
|
className="rounded-full border-border/50 bg-muted/40 text-muted-foreground text-xs"
|
||||||
|
title="工具组"
|
||||||
|
>
|
||||||
{desensitize(group)}
|
{desensitize(group)}
|
||||||
</Badge>
|
</Badge>
|
||||||
),
|
),
|
||||||
@@ -740,8 +764,8 @@ export function AgentCard({
|
|||||||
node: (
|
node: (
|
||||||
<Badge
|
<Badge
|
||||||
key={`sk:${skill}`}
|
key={`sk:${skill}`}
|
||||||
variant="secondary"
|
variant="outline"
|
||||||
className="hover:bg-secondary/70 cursor-pointer text-xs"
|
className="cursor-pointer rounded-full border-primary/20 bg-primary/5 text-primary hover:border-primary/40 hover:bg-primary/15 text-xs"
|
||||||
title={t.settings.skills.viewDetailAction}
|
title={t.settings.skills.viewDetailAction}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -916,74 +940,193 @@ export function AgentCard({
|
|||||||
|
|
||||||
const chatButton = (
|
const chatButton = (
|
||||||
<Button
|
<Button
|
||||||
|
variant={isList ? "default" : "outline"}
|
||||||
size="sm"
|
size="sm"
|
||||||
className={cn(isList ? "shrink-0" : "w-full")}
|
className={cn(
|
||||||
|
isList
|
||||||
|
? "shrink-0 rounded-xl bg-primary px-4 font-medium text-primary-foreground hover:bg-primary/90"
|
||||||
|
: "h-11 w-full rounded-lg border-primary/35 bg-background font-medium text-primary shadow-none hover:border-primary/55 hover:bg-primary/5 dark:bg-slate-900",
|
||||||
|
)}
|
||||||
onClick={() => void handleChat()}
|
onClick={() => void handleChat()}
|
||||||
>
|
>
|
||||||
<MessageSquareIcon className="mr-1.5 h-3.5 w-3.5" />
|
<MessageSquareIcon className="mr-1.5 h-3.5 w-3.5" />
|
||||||
{t.agents.chat}
|
{isList ? t.agents.chat : "开始对话"}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const cardStatusBadge = (
|
||||||
|
<>
|
||||||
|
{agent.is_private ? (
|
||||||
|
<Badge className="border-0 bg-purple-50 px-2.5 py-1 text-xs font-normal text-purple-600 hover:bg-purple-50 dark:bg-purple-500/15 dark:text-purple-300">
|
||||||
|
<span className="mr-1.5 size-1.5 rounded-full bg-purple-500" />
|
||||||
|
私密
|
||||||
|
</Badge>
|
||||||
|
) : agent.published || isBuiltin ? (
|
||||||
|
<Badge className="border-0 bg-primary/5 px-2.5 py-1 text-xs font-normal text-primary hover:bg-primary/5 dark:bg-primary/15">
|
||||||
|
<span className="mr-1.5 size-1.5 rounded-full bg-primary" />
|
||||||
|
已发布
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge className="border-0 bg-emerald-50 px-2.5 py-1 text-xs font-normal text-emerald-600 hover:bg-emerald-50 dark:bg-emerald-500/15 dark:text-emerald-300">
|
||||||
|
<span className="mr-1.5 size-1.5 rounded-full bg-emerald-500" />
|
||||||
|
运行中
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
const updatedAtText = formatDateTime(agent.updated_at ?? agent.created_at);
|
||||||
|
const cardActionsMenu = (
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<Button
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
className="size-8 rounded-lg text-slate-500 hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-slate-800 dark:hover:text-white"
|
||||||
|
title="更多操作"
|
||||||
|
>
|
||||||
|
<MoreHorizontalIcon className="size-5" />
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="end" className="w-44">
|
||||||
|
{canFavorite && (
|
||||||
|
<DropdownMenuItem onSelect={() => void handleToggleFavorite()}>
|
||||||
|
<StarIcon className={cn("size-4", isFavorite && "fill-current text-amber-500")} />
|
||||||
|
{isFavorite ? "取消收藏" : "收藏到我的"}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<DropdownMenuItem onSelect={() => void handleTogglePin()}>
|
||||||
|
<PinIcon className={cn("size-4", isPinned && "fill-current text-emerald-600")} />
|
||||||
|
{isPinned ? "取消置顶" : "置顶"}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{isAdmin && (
|
||||||
|
<DropdownMenuItem onSelect={() => void handleToggleFeatured()}>
|
||||||
|
<SparklesIcon className="size-4" />
|
||||||
|
{agent.featured_order != null ? "取消推荐" : "设为推荐"}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<DropdownMenuItem onSelect={() => setTagPickerOpen(true)}>
|
||||||
|
<TagsIcon className="size-4" />
|
||||||
|
{t.adminTags.manageTags}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{isOwned && (
|
||||||
|
<DropdownMenuItem onSelect={() => void handleTogglePublished()}>
|
||||||
|
{agent.published ? <LockIcon className="size-4" /> : <GlobeIcon className="size-4" />}
|
||||||
|
{agent.published ? "取消发布" : "发布"}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
{(isOwned || isAdmin) && (
|
||||||
|
<DropdownMenuItem onSelect={() => void handleTogglePrivate()}>
|
||||||
|
<ShieldIcon className="size-4" />
|
||||||
|
{agent.is_private ? "移出私密广场" : "放入私密广场"}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
{onToggleHidden && (
|
||||||
|
<DropdownMenuItem
|
||||||
|
disabled={toggleHiddenPending}
|
||||||
|
onSelect={() => void onToggleHidden(!agent.hidden)}
|
||||||
|
>
|
||||||
|
{agent.hidden ? <EyeIcon className="size-4" /> : <EyeOffIcon className="size-4" />}
|
||||||
|
{agent.hidden ? "恢复展示" : "隐藏智能体"}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem onSelect={() => void handleDuplicate()}>
|
||||||
|
<CopyIcon className="size-4" />
|
||||||
|
复制智能体
|
||||||
|
</DropdownMenuItem>
|
||||||
|
{canEdit && (
|
||||||
|
<DropdownMenuItem onSelect={() => setEditOpen(true)}>
|
||||||
|
<SquarePenIcon className="size-4" />
|
||||||
|
编辑智能体
|
||||||
|
</DropdownMenuItem>
|
||||||
|
)}
|
||||||
|
{canDelete && (
|
||||||
|
<>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem
|
||||||
|
className="text-destructive focus:text-destructive"
|
||||||
|
onSelect={() => setDeleteOpen(true)}
|
||||||
|
>
|
||||||
|
<Trash2Icon className="size-4" />
|
||||||
|
{t.agents.delete}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
|
||||||
const cardLayout = (
|
const cardLayout = (
|
||||||
<Card
|
<Card
|
||||||
className={cn(
|
className={cn(
|
||||||
"group flex min-w-0 flex-col transition-shadow hover:shadow-md",
|
"group flex min-h-[300px] min-w-0 flex-col gap-0 overflow-hidden rounded-[5px] border-0 bg-gradient-to-br from-primary/[0.04] via-card to-card py-0 shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-[background-color,border-color,box-shadow] duration-200 hover:!shadow-[0_4px_14px_rgba(15,23,42,0.10)] dark:from-primary/[0.07] dark:via-card dark:to-card",
|
||||||
|
(agent.featured_order != null || agent.is_pinned) && "ring-1 ring-primary/25",
|
||||||
agent.hidden && "opacity-60",
|
agent.hidden && "opacity-60",
|
||||||
)}
|
)}
|
||||||
data-agent-guide="agent-card"
|
data-agent-guide="agent-card"
|
||||||
>
|
>
|
||||||
<CardHeader className="min-w-0 pb-2">
|
<CardHeader className="min-w-0 gap-0 px-5 pb-2 pt-5">
|
||||||
<div className="flex min-w-0 items-start justify-between gap-2">
|
{(isPinned || agent.featured_order != null) && (
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
|
<div className="mb-2 flex h-7 items-center justify-between">
|
||||||
<div className="agent-avatar bg-primary/10 text-primary flex h-9 w-9 shrink-0 items-center justify-center rounded-lg">
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
<BotIcon className="h-5 w-5" />
|
{isPinned && (
|
||||||
|
<Badge className="border border-primary/20 bg-primary/5 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/5 dark:border-primary/40 dark:bg-primary/15">
|
||||||
|
<PinIcon className="mr-1 size-3.5 fill-current" />
|
||||||
|
置顶
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
{agent.featured_order != null && (
|
||||||
|
<Badge className="border border-primary/20 bg-primary/5 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/5 dark:border-primary/40 dark:bg-primary/15">
|
||||||
|
<SparklesIcon className="mr-1 size-3.5 fill-current" />
|
||||||
|
推荐
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1 overflow-hidden">
|
{cardActionsMenu}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{/* 标题与 logo 同行,避免头部留白过高 */}
|
||||||
|
<div className="flex w-full items-start justify-between gap-3">
|
||||||
|
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||||
|
<AgentBrandIcon size="lg" className="shrink-0" />
|
||||||
<CardTitle
|
<CardTitle
|
||||||
className="block w-full min-w-0 overflow-hidden text-base text-ellipsis whitespace-nowrap"
|
className="min-w-0 flex-1 overflow-hidden text-[17px] leading-6 font-semibold tracking-[-0.015em] text-ellipsis whitespace-nowrap text-slate-950 dark:text-white"
|
||||||
title={desensitize(agent.name)}
|
title={desensitize(agent.name)}
|
||||||
>
|
>
|
||||||
{desensitize(agent.name)}
|
{desensitize(agent.name)}
|
||||||
</CardTitle>
|
</CardTitle>
|
||||||
{agent.model && (
|
|
||||||
<Badge variant="secondary" className="mt-0.5 text-xs">
|
|
||||||
{desensitize(agent.model)}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex shrink-0 flex-wrap items-center justify-end gap-1">
|
|
||||||
{statusBadges}
|
|
||||||
</div>
|
</div>
|
||||||
|
{!isPinned && agent.featured_order == null && cardActionsMenu}
|
||||||
</div>
|
</div>
|
||||||
{agent.description && (
|
{agent.description && (
|
||||||
<CardDescription className="mt-2 line-clamp-2 text-sm">
|
<CardDescription className="mt-2 line-clamp-2 text-[14px] leading-[22px] text-slate-600 dark:text-slate-400">
|
||||||
{desensitize(agent.description)}
|
{desensitize(agent.description)}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
)}
|
)}
|
||||||
{publisherNode && <div className="mt-2">{publisherNode}</div>}
|
{(agent.tags?.length ?? 0) > 0 && (
|
||||||
{createdAtNode && <div className="mt-1">{createdAtNode}</div>}
|
<div className="mt-2.5">
|
||||||
|
<TagChipList tags={agent.tags!} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
{(agent.tags?.length ?? 0) > 0 && (
|
|
||||||
<CardContent className="pt-0 pb-2">
|
|
||||||
<TagChipList tags={agent.tags!} />
|
|
||||||
</CardContent>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{hasSkillsOrTools && (
|
{hasSkillsOrTools && (
|
||||||
<CardContent className="pt-0 pb-2">
|
<CardContent className="px-5 pb-2 pt-0">
|
||||||
<ClampedBadgeRow items={skillBadgeItems} />
|
<ClampedBadgeRow items={skillBadgeItems} />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<CardFooter className="mt-auto flex flex-col items-stretch gap-2 pt-2">
|
<CardFooter className="mt-auto flex flex-col items-stretch gap-4 px-5 pb-4 pt-2">
|
||||||
{showActionRow && (
|
<div className="flex min-w-0 items-center gap-3">
|
||||||
<div className="flex flex-wrap items-center justify-end gap-1">
|
{cardStatusBadge}
|
||||||
{actionButtons}
|
<span
|
||||||
|
className="min-w-0 truncate text-xs text-slate-400"
|
||||||
|
title={updatedAtText ? `更新于 ${updatedAtText}` : undefined}
|
||||||
|
>
|
||||||
|
{updatedAtText ? `更新于 ${updatedAtText}` : ""}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
{chatButton}
|
{chatButton}
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -992,14 +1135,14 @@ export function AgentCard({
|
|||||||
const listLayout = (
|
const listLayout = (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"group flex min-w-0 items-center gap-3 rounded-lg border p-2.5 transition-shadow hover:shadow-sm dark:border-[#213D5E] dark:bg-[#02244C]",
|
"group flex min-w-0 items-center gap-3 rounded-[5px] border-0 p-2.5 shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-shadow hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)]",
|
||||||
|
"bg-gradient-to-br from-primary/[0.04] via-card to-card dark:from-primary/[0.07] dark:via-card dark:to-card",
|
||||||
|
agent.is_pinned && "ring-1 ring-primary/25",
|
||||||
agent.hidden && "opacity-60",
|
agent.hidden && "opacity-60",
|
||||||
)}
|
)}
|
||||||
data-agent-guide="agent-card"
|
data-agent-guide="agent-card"
|
||||||
>
|
>
|
||||||
<div className="agent-avatar bg-primary/10 text-primary flex h-9 w-9 shrink-0 items-center justify-center rounded-lg">
|
<AgentBrandIcon size="md" className="agent-avatar" />
|
||||||
<BotIcon className="h-5 w-5" />
|
|
||||||
</div>
|
|
||||||
<div className="min-w-0 flex-1 overflow-hidden">
|
<div className="min-w-0 flex-1 overflow-hidden">
|
||||||
<div className="flex min-w-0 items-center gap-2">
|
<div className="flex min-w-0 items-center gap-2">
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useParams, usePathname, useRouter } from "next/navigation";
|
import { useParams, usePathname, useRouter } from "next/navigation";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { agentColor } from "@/components/workspace/agent-icon-color";
|
import { agentColor } from "@/components/workspace/agent-icon-color";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
CheckIcon,
|
CheckIcon,
|
||||||
DatabaseIcon,
|
DatabaseIcon,
|
||||||
GlobeIcon,
|
GlobeIcon,
|
||||||
|
GripVertical,
|
||||||
InfoIcon,
|
InfoIcon,
|
||||||
// Link2Icon,
|
// Link2Icon,
|
||||||
Loader2Icon,
|
Loader2Icon,
|
||||||
@@ -23,8 +24,17 @@ import {
|
|||||||
XIcon,
|
XIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
import {
|
||||||
import { toast } from "sonner";
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
type KeyboardEvent as ReactKeyboardEvent,
|
||||||
|
type PointerEvent as ReactPointerEvent,
|
||||||
|
type ReactNode,
|
||||||
|
} from "react";
|
||||||
|
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
// import { AgentChatLinkFields } from "@/components/workspace/agents/agent-chat-link-fields";
|
// import { AgentChatLinkFields } from "@/components/workspace/agents/agent-chat-link-fields";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
@@ -79,6 +89,30 @@ import { usePublishSquares } from "@/core/system-settings/hooks";
|
|||||||
import { desensitize } from "@/lib/desensitize";
|
import { desensitize } from "@/lib/desensitize";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
const AGENT_DETAIL_WIDTH_STORAGE_KEY = "workspace:agent-detail-panel-width";
|
||||||
|
const AGENT_DETAIL_MIN_WIDTH = 280;
|
||||||
|
const AGENT_DETAIL_DEFAULT_WIDTH = 360;
|
||||||
|
const AGENT_DETAIL_MAX_WIDTH = 640;
|
||||||
|
const AGENT_DETAIL_KEYBOARD_STEP = 16;
|
||||||
|
|
||||||
|
function readStoredAgentDetailWidth(): number {
|
||||||
|
if (typeof window === "undefined") return AGENT_DETAIL_DEFAULT_WIDTH;
|
||||||
|
const raw = window.localStorage.getItem(AGENT_DETAIL_WIDTH_STORAGE_KEY);
|
||||||
|
if (!raw) return AGENT_DETAIL_DEFAULT_WIDTH;
|
||||||
|
const parsed = Number(raw);
|
||||||
|
return Number.isFinite(parsed)
|
||||||
|
? Math.min(AGENT_DETAIL_MAX_WIDTH, Math.max(AGENT_DETAIL_MIN_WIDTH, Math.round(parsed)))
|
||||||
|
: AGENT_DETAIL_DEFAULT_WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
function maximumAgentDetailWidth(): number {
|
||||||
|
const viewportBound = Math.max(
|
||||||
|
AGENT_DETAIL_MIN_WIDTH,
|
||||||
|
window.innerWidth - 520,
|
||||||
|
);
|
||||||
|
return Math.min(AGENT_DETAIL_MAX_WIDTH, viewportBound);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Local edit-mode draft — committed in one `updateAgent` call on 保存. */
|
/** Local edit-mode draft — committed in one `updateAgent` call on 保存. */
|
||||||
interface AgentDraft {
|
interface AgentDraft {
|
||||||
@@ -128,7 +162,7 @@ function Section({
|
|||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<section className={cn("bg-card/60 rounded-xl border p-4", className)}>
|
<section className={cn("agent-detail-section bg-card/60 rounded-xl border p-4", className)}>
|
||||||
<div className="mb-3 flex items-center justify-between gap-2">
|
<div className="mb-3 flex items-center justify-between gap-2">
|
||||||
<h4 className="text-foreground flex items-center gap-1.5 text-sm font-semibold">
|
<h4 className="text-foreground flex items-center gap-1.5 text-sm font-semibold">
|
||||||
{icon}
|
{icon}
|
||||||
@@ -225,6 +259,109 @@ export function AgentDetailPanel({
|
|||||||
if (collapsedProp === undefined) setInternalCollapsed(next);
|
if (collapsedProp === undefined) setInternalCollapsed(next);
|
||||||
onCollapsedChange?.(next);
|
onCollapsedChange?.(next);
|
||||||
};
|
};
|
||||||
|
// 智能体问答页的右侧信息栏可拖宽。宽度记在本面板,不走对话/预览那条分隔条。
|
||||||
|
const [panelWidth, setPanelWidth] = useState(readStoredAgentDetailWidth);
|
||||||
|
const [isResizingPanel, setIsResizingPanel] = useState(false);
|
||||||
|
const panelResizeStart = useRef<{ x: number; width: number } | null>(null);
|
||||||
|
const latestPanelWidth = useRef(panelWidth);
|
||||||
|
const bodyStyleBeforeResize = useRef<{ cursor: string; userSelect: string } | null>(null);
|
||||||
|
|
||||||
|
const constrainPanelWidth = useCallback(
|
||||||
|
(width: number) =>
|
||||||
|
Math.min(
|
||||||
|
maximumAgentDetailWidth(),
|
||||||
|
Math.max(AGENT_DETAIL_MIN_WIDTH, Math.round(width)),
|
||||||
|
),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const setAndPersistPanelWidth = useCallback(
|
||||||
|
(width: number, persist = false) => {
|
||||||
|
const next = constrainPanelWidth(width);
|
||||||
|
latestPanelWidth.current = next;
|
||||||
|
setPanelWidth(next);
|
||||||
|
if (persist) {
|
||||||
|
window.localStorage.setItem(AGENT_DETAIL_WIDTH_STORAGE_KEY, String(next));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[constrainPanelWidth],
|
||||||
|
);
|
||||||
|
|
||||||
|
const finishPanelResize = useCallback(() => {
|
||||||
|
const previousBodyStyle = bodyStyleBeforeResize.current;
|
||||||
|
if (previousBodyStyle) {
|
||||||
|
document.body.style.cursor = previousBodyStyle.cursor;
|
||||||
|
document.body.style.userSelect = previousBodyStyle.userSelect;
|
||||||
|
bodyStyleBeforeResize.current = null;
|
||||||
|
}
|
||||||
|
panelResizeStart.current = null;
|
||||||
|
setIsResizingPanel(false);
|
||||||
|
window.localStorage.setItem(
|
||||||
|
AGENT_DETAIL_WIDTH_STORAGE_KEY,
|
||||||
|
String(latestPanelWidth.current),
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handlePanelResizeStart = useCallback(
|
||||||
|
(event: ReactPointerEvent<HTMLElement>) => {
|
||||||
|
if (event.button !== 0) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
event.currentTarget.setPointerCapture(event.pointerId);
|
||||||
|
const width = constrainPanelWidth(latestPanelWidth.current);
|
||||||
|
latestPanelWidth.current = width;
|
||||||
|
panelResizeStart.current = { x: event.clientX, width };
|
||||||
|
bodyStyleBeforeResize.current = {
|
||||||
|
cursor: document.body.style.cursor,
|
||||||
|
userSelect: document.body.style.userSelect,
|
||||||
|
};
|
||||||
|
document.body.style.cursor = "col-resize";
|
||||||
|
document.body.style.userSelect = "none";
|
||||||
|
setIsResizingPanel(true);
|
||||||
|
},
|
||||||
|
[constrainPanelWidth],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePanelResizeMove = useCallback(
|
||||||
|
(event: ReactPointerEvent<HTMLElement>) => {
|
||||||
|
if (!panelResizeStart.current || event.buttons !== 1) return;
|
||||||
|
// 面板在右侧:向左拖变宽,向右拖变窄。
|
||||||
|
setAndPersistPanelWidth(
|
||||||
|
panelResizeStart.current.width - (event.clientX - panelResizeStart.current.x),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[setAndPersistPanelWidth],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePanelResizeEnd = useCallback(
|
||||||
|
(event: ReactPointerEvent<HTMLElement>) => {
|
||||||
|
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
||||||
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
||||||
|
}
|
||||||
|
if (!panelResizeStart.current) return;
|
||||||
|
finishPanelResize();
|
||||||
|
},
|
||||||
|
[finishPanelResize],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlePanelResizeKeyDown = useCallback(
|
||||||
|
(event: ReactKeyboardEvent<HTMLElement>) => {
|
||||||
|
if (event.key === "ArrowLeft") {
|
||||||
|
event.preventDefault();
|
||||||
|
setAndPersistPanelWidth(latestPanelWidth.current + AGENT_DETAIL_KEYBOARD_STEP, true);
|
||||||
|
} else if (event.key === "ArrowRight") {
|
||||||
|
event.preventDefault();
|
||||||
|
setAndPersistPanelWidth(latestPanelWidth.current - AGENT_DETAIL_KEYBOARD_STEP, true);
|
||||||
|
} else if (event.key === "Home") {
|
||||||
|
event.preventDefault();
|
||||||
|
setAndPersistPanelWidth(AGENT_DETAIL_MIN_WIDTH, true);
|
||||||
|
} else if (event.key === "End") {
|
||||||
|
event.preventDefault();
|
||||||
|
setAndPersistPanelWidth(maximumAgentDetailWidth(), true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[setAndPersistPanelWidth],
|
||||||
|
);
|
||||||
const [mobileOpen, setMobileOpen] = useState(false);
|
const [mobileOpen, setMobileOpen] = useState(false);
|
||||||
const [editing, setEditing] = useState(false);
|
const [editing, setEditing] = useState(false);
|
||||||
const [draft, setDraft] = useState<AgentDraft | null>(null);
|
const [draft, setDraft] = useState<AgentDraft | null>(null);
|
||||||
@@ -444,7 +581,7 @@ export function AgentDetailPanel({
|
|||||||
setPublishPickerOpen(true);
|
setPublishPickerOpen(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!warnIfAccountSwitched()) {
|
if (!(await warnIfAccountSwitched())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -462,19 +599,23 @@ export function AgentDetailPanel({
|
|||||||
|
|
||||||
// 发布以实时 token 执行。会话中途账号被切换(常见于另一标签页登录了别的账号)时
|
// 发布以实时 token 执行。会话中途账号被切换(常见于另一标签页登录了别的账号)时
|
||||||
// 先弹确认,避免误以本人之外的账号执行发布。返回 false = 用户取消。
|
// 先弹确认,避免误以本人之外的账号执行发布。返回 false = 用户取消。
|
||||||
function warnIfAccountSwitched(): boolean {
|
function warnIfAccountSwitched(): boolean | Promise<boolean> {
|
||||||
if (!live.switched) {
|
if (!live.switched) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return window.confirm(
|
return confirmAction(
|
||||||
`当前登录账号已从「${live.mountDisplayName}」切换为「${live.displayName}」。\n` +
|
`当前登录账号已从「${live.mountDisplayName}」切换为「${live.displayName}」。\n` +
|
||||||
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。\n\n仍要继续吗?`,
|
`本次发布将以「${live.displayName}」执行。如需以「${live.mountDisplayName}」操作,请取消并刷新页面。`,
|
||||||
|
{
|
||||||
|
title: "登录账号已切换",
|
||||||
|
confirmText: "继续发布",
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handlePublishToSquare(squareId: string) {
|
async function handlePublishToSquare(squareId: string) {
|
||||||
if (!agent) return;
|
if (!agent) return;
|
||||||
if (!warnIfAccountSwitched()) {
|
if (!(await warnIfAccountSwitched())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -625,7 +766,7 @@ export function AgentDetailPanel({
|
|||||||
) : (
|
) : (
|
||||||
<div className="space-y-4 px-4 py-4">
|
<div className="space-y-4 px-4 py-4">
|
||||||
{/* ── Identity / 基础信息 ─────────────────────────────────────────── */}
|
{/* ── Identity / 基础信息 ─────────────────────────────────────────── */}
|
||||||
<section className="bg-card/60 rounded-xl border p-4">
|
<section className="agent-detail-section agent-detail-identity bg-card/60 rounded-xl border p-4">
|
||||||
<div className="flex items-start gap-3">
|
<div className="flex items-start gap-3">
|
||||||
<div className="agent-avatar bg-primary/10 ring-primary/15 flex size-12 shrink-0 items-center justify-center rounded-2xl ring-1">
|
<div className="agent-avatar bg-primary/10 ring-primary/15 flex size-12 shrink-0 items-center justify-center rounded-2xl ring-1">
|
||||||
{avatarSrc ? (
|
{avatarSrc ? (
|
||||||
@@ -646,7 +787,7 @@ export function AgentDetailPanel({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
className="truncate text-base font-bold"
|
className="agent-detail-name truncate text-base font-bold"
|
||||||
title={displayName}
|
title={displayName}
|
||||||
>
|
>
|
||||||
{displayName}
|
{displayName}
|
||||||
@@ -681,7 +822,7 @@ export function AgentDetailPanel({
|
|||||||
className="min-h-16 text-sm"
|
className="min-h-16 text-sm"
|
||||||
/>
|
/>
|
||||||
) : agent.description ? (
|
) : agent.description ? (
|
||||||
<p className="text-muted-foreground text-sm leading-relaxed">
|
<p className="agent-detail-description text-muted-foreground text-sm leading-relaxed">
|
||||||
{desensitize(agent.description)}
|
{desensitize(agent.description)}
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
@@ -855,7 +996,7 @@ export function AgentDetailPanel({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={beginEdit}
|
onClick={beginEdit}
|
||||||
className="text-muted-foreground hover:text-foreground hover:border-border w-full rounded-lg border border-dashed px-3 py-4 text-center text-xs transition-colors"
|
className="agent-detail-empty-add text-muted-foreground hover:text-foreground hover:border-border w-full rounded-lg border border-dashed px-3 py-4 text-center text-xs transition-colors"
|
||||||
>
|
>
|
||||||
<PlusIcon className="mr-1 inline size-3.5 align-[-2px]" />
|
<PlusIcon className="mr-1 inline size-3.5 align-[-2px]" />
|
||||||
添加常用问题
|
添加常用问题
|
||||||
@@ -867,7 +1008,7 @@ export function AgentDetailPanel({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className="border-border/60 bg-background/60 rounded-xl border p-2"
|
className="agent-detail-question-item border-border/60 bg-background/60 rounded-xl border p-2"
|
||||||
>
|
>
|
||||||
{isEditingThis ? (
|
{isEditingThis ? (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -1045,11 +1186,17 @@ export function AgentDetailPanel({
|
|||||||
header「新对话」按钮右侧。 */
|
header「新对话」按钮右侧。 */
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"hidden h-full shrink-0 overflow-hidden transition-[width] duration-300 ease-in-out lg:block",
|
"relative hidden h-full shrink-0 lg:block",
|
||||||
collapsed ? "w-0" : "w-[360px]",
|
isResizingPanel ? "transition-none" : "transition-[width] duration-300 ease-in-out",
|
||||||
|
collapsed && "pointer-events-none",
|
||||||
)}
|
)}
|
||||||
|
style={{ width: collapsed ? 0 : panelWidth }}
|
||||||
|
>
|
||||||
|
<div className="h-full overflow-hidden">
|
||||||
|
<aside
|
||||||
|
className="bg-card/40 flex h-full flex-col border-l"
|
||||||
|
style={{ width: panelWidth }}
|
||||||
>
|
>
|
||||||
<aside className="bg-card/40 flex h-full w-[360px] flex-col border-l">
|
|
||||||
{panelChrome(
|
{panelChrome(
|
||||||
<Tooltip content="收起">
|
<Tooltip content="收起">
|
||||||
<Button
|
<Button
|
||||||
@@ -1065,6 +1212,39 @@ export function AgentDetailPanel({
|
|||||||
)}
|
)}
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
{!collapsed && (
|
||||||
|
<div className="group/detail-edge absolute inset-y-0 -left-1 z-30 w-8 cursor-default">
|
||||||
|
<div
|
||||||
|
role="separator"
|
||||||
|
aria-orientation="vertical"
|
||||||
|
aria-label="调整智能体信息宽度"
|
||||||
|
aria-valuenow={panelWidth}
|
||||||
|
aria-valuemin={AGENT_DETAIL_MIN_WIDTH}
|
||||||
|
aria-valuemax={AGENT_DETAIL_MAX_WIDTH}
|
||||||
|
tabIndex={0}
|
||||||
|
title="拖拽调整智能体信息宽度"
|
||||||
|
className="absolute top-1/2 left-1 z-30 flex h-16 w-10 -translate-x-1/2 -translate-y-1/2 cursor-col-resize touch-none items-center justify-center outline-none"
|
||||||
|
onPointerDown={handlePanelResizeStart}
|
||||||
|
onPointerMove={handlePanelResizeMove}
|
||||||
|
onPointerUp={handlePanelResizeEnd}
|
||||||
|
onPointerCancel={handlePanelResizeEnd}
|
||||||
|
onKeyDown={handlePanelResizeKeyDown}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn(
|
||||||
|
"bg-border pointer-events-none z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm transition-opacity",
|
||||||
|
isResizingPanel
|
||||||
|
? "opacity-100"
|
||||||
|
: "opacity-0 group-hover/detail-edge:opacity-100 group-focus-within/detail-edge:opacity-100",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<GripVertical className="size-3.5" />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
) : collapsed ? (
|
) : collapsed ? (
|
||||||
<div className="hidden shrink-0 items-start border-l px-2 pt-3 lg:flex">
|
<div className="hidden shrink-0 items-start border-l px-2 pt-3 lg:flex">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
|
|||||||
@@ -3,22 +3,30 @@
|
|||||||
import { ArrowDownUpIcon, BotIcon, Compass, Loader2, LockIcon, PlusIcon, RefreshCwIcon, ShieldIcon, XIcon } from "lucide-react";
|
import { ArrowDownUpIcon, BotIcon, Compass, Loader2, LockIcon, PlusIcon, RefreshCwIcon, ShieldIcon, XIcon } from "lucide-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Pagination } from "@/components/ui/pagination";
|
import { Pagination as TPagination } from "tdesign-react";
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { TagSearchBar } from "@/components/workspace/tags/tag-search-bar";
|
import { TagSearchBar } from "@/components/workspace/tags/tag-search-bar";
|
||||||
import { ViewModeToggle } from "@/components/workspace/view-mode-toggle";
|
import { ViewModeToggle } from "@/components/workspace/view-mode-toggle";
|
||||||
import { getStoredAuth } from "@/core/auth";
|
import { getStoredAuth } from "@/core/auth";
|
||||||
import { useAgentsPaginated, usePrivateAgentsPaginated, useSyncAgentDirectory } from "@/core/agents";
|
import { useAgentsPaginated, usePrivateAgentsPaginated, useSyncAgentDirectory } from "@/core/agents";
|
||||||
|
import { useLocalSettings } from "@/core/settings";
|
||||||
|
import { resolveAgentGridLayout } from "@/core/settings/agent-grid";
|
||||||
|
import { useAppearanceSettings } from "@/core/system-settings/hooks";
|
||||||
import type { Agent, AgentSort } from "@/core/agents";
|
import type { Agent, AgentSort } from "@/core/agents";
|
||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
import { useRouteBase } from "@/core/route-base";
|
import { useRouteBase } from "@/core/route-base";
|
||||||
import { isSentimentAgentVisible } from "@/core/sentiment-agent/config";
|
import { isSentimentAgentVisible } from "@/core/sentiment-agent/config";
|
||||||
import { usePrivateSquareStatus, usePublishSquares, useViewMode } from "@/core/system-settings/hooks";
|
import {
|
||||||
|
usePageDescriptionsSettings,
|
||||||
|
usePrivateSquareStatus,
|
||||||
|
usePublishSquares,
|
||||||
|
useViewMode,
|
||||||
|
} from "@/core/system-settings/hooks";
|
||||||
import {
|
import {
|
||||||
WX_RESTRICTED_TAB_DEFAULT_SQUARE,
|
WX_RESTRICTED_TAB_DEFAULT_SQUARE,
|
||||||
WX_RESTRICTED_TAB_NANJING_DB,
|
WX_RESTRICTED_TAB_NANJING_DB,
|
||||||
@@ -51,6 +59,8 @@ export function AgentGallery({
|
|||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const routeBase = useRouteBase();
|
const routeBase = useRouteBase();
|
||||||
|
const pageDescriptions = usePageDescriptionsSettings();
|
||||||
|
const pageDescription = pageDescriptions.data?.agents;
|
||||||
const sentimentAgentVisible = isSentimentAgentVisible();
|
const sentimentAgentVisible = isSentimentAgentVisible();
|
||||||
// 「内置智能体」筛选仅管理员可见(后端 scope=builtin 也做了 admin 闸门兜底)。
|
// 「内置智能体」筛选仅管理员可见(后端 scope=builtin 也做了 admin 闸门兜底)。
|
||||||
const isAdmin = getStoredAuth()?.system_role === "admin";
|
const isAdmin = getStoredAuth()?.system_role === "admin";
|
||||||
@@ -257,10 +267,20 @@ export function AgentGallery({
|
|||||||
const handlePublisherClick = (p: { id: string; label: string }) =>
|
const handlePublisherClick = (p: { id: string; label: string }) =>
|
||||||
setPublisher(p);
|
setPublisher(p);
|
||||||
|
|
||||||
|
// 置顶的智能体始终排在最前(后端按创建/更新时间分页,这里做展示层重排)。
|
||||||
|
const pinFirst = (items: Agent[]) =>
|
||||||
|
[...items].sort(
|
||||||
|
(a, b) => Number(b.is_pinned ?? false) - Number(a.is_pinned ?? false),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [gridSettings] = useLocalSettings();
|
||||||
|
const { data: gridAppearance } = useAppearanceSettings();
|
||||||
|
const agentGrid = resolveAgentGridLayout(gridSettings.display, gridAppearance);
|
||||||
|
|
||||||
const renderGrid = (list: Agent[]) =>
|
const renderGrid = (list: Agent[]) =>
|
||||||
viewMode === "list" ? (
|
viewMode === "list" ? (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{list.map((agent) => (
|
{pinFirst(list).map((agent) => (
|
||||||
<AgentCard
|
<AgentCard
|
||||||
key={agent.id}
|
key={agent.id}
|
||||||
agent={agent}
|
agent={agent}
|
||||||
@@ -269,9 +289,29 @@ export function AgentGallery({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
) : agentGrid.adaptive ? (
|
||||||
|
<div
|
||||||
|
className="grid w-full grid-cols-4 gap-4 min-[3072px]:grid-cols-5"
|
||||||
|
data-agent-grid="adaptive"
|
||||||
|
>
|
||||||
|
{pinFirst(list).map((agent) => (
|
||||||
|
<AgentCard
|
||||||
|
key={agent.id}
|
||||||
|
agent={agent}
|
||||||
|
onPublisherClick={handlePublisherClick}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
<div
|
||||||
{list.map((agent) => (
|
className="grid w-full gap-4"
|
||||||
|
data-agent-grid="fixed"
|
||||||
|
data-agent-grid-columns={agentGrid.columns}
|
||||||
|
style={{
|
||||||
|
gridTemplateColumns: `repeat(${agentGrid.columns}, minmax(0, 1fr))`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{pinFirst(list).map((agent) => (
|
||||||
<AgentCard
|
<AgentCard
|
||||||
key={agent.id}
|
key={agent.id}
|
||||||
agent={agent}
|
agent={agent}
|
||||||
@@ -332,11 +372,12 @@ export function AgentGallery({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Pagination
|
<TPagination
|
||||||
page={pages[tab] ?? 1}
|
current={pages[tab] ?? 1}
|
||||||
pageSize={PAGE_SIZE}
|
pageSize={PAGE_SIZE}
|
||||||
total={total}
|
total={total}
|
||||||
onPageChange={(p) => setTabPage(tab, p)}
|
showJumper
|
||||||
|
onChange={(pageInfo) => setTabPage(tab, pageInfo.current)}
|
||||||
className="pt-2"
|
className="pt-2"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -360,7 +401,7 @@ export function AgentGallery({
|
|||||||
className="mt-2 dark:border-[#2580FF] dark:bg-[#2580FF] dark:text-white dark:hover:border-[#2580FF] dark:hover:bg-[#2580FF]/90 dark:hover:text-white"
|
className="mt-2 dark:border-[#2580FF] dark:bg-[#2580FF] dark:text-white dark:hover:border-[#2580FF] dark:hover:bg-[#2580FF]/90 dark:hover:text-white"
|
||||||
onClick={handleNewAgent}
|
onClick={handleNewAgent}
|
||||||
>
|
>
|
||||||
<PlusIcon className="mr-1.5 h-4 w-4" />
|
<PlusIcon className="mr-2.5 h-4 w-4" />
|
||||||
{t.agents.newAgent}
|
{t.agents.newAgent}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
@@ -451,20 +492,32 @@ export function AgentGallery({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex size-full min-h-0 flex-col">
|
<div className="flex size-full min-h-0 flex-col bg-muted/40">
|
||||||
{/* Page header */}
|
{/* Page header */}
|
||||||
<div className="flex items-center justify-between border-b px-6 py-4">
|
<div className="relative overflow-hidden border-b border-border/60 bg-card px-6 py-4">
|
||||||
|
{/* 顶部主题色渐变:自上而下淡出(跟随换肤) */}
|
||||||
|
<div
|
||||||
|
className="pointer-events-none absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-primary/[0.09] via-primary/[0.03] to-transparent"
|
||||||
|
aria-hidden
|
||||||
|
/>
|
||||||
|
<div className="relative flex items-center justify-between gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-xl font-semibold">{t.agents.title}</h1>
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="h-4 w-[3px] rounded-full bg-primary" aria-hidden />
|
||||||
|
<h1 className="text-xl font-semibold">
|
||||||
|
{pageDescription?.title || t.agents.title}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
<p className="text-muted-foreground mt-0.5 text-sm">
|
<p className="text-muted-foreground mt-0.5 text-sm">
|
||||||
{t.agents.description}
|
{pageDescription?.description || t.agents.description}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-1.5">
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
className="h-9 gap-2.5 rounded-[5px] px-3 text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
title="扫描 .deer-flow/agents 目录,把目录里的智能体同步进列表"
|
title="扫描 .deer-flow/agents 目录,把目录里的智能体同步进列表"
|
||||||
disabled={syncDirectory.isPending}
|
disabled={syncDirectory.isPending}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -483,14 +536,15 @@ export function AgentGallery({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RefreshCwIcon
|
<RefreshCwIcon
|
||||||
className={`mr-1.5 h-4 w-4 ${syncDirectory.isPending ? "animate-spin" : ""}`}
|
className={`h-4 w-4 ${syncDirectory.isPending ? "animate-spin" : ""}`}
|
||||||
/>
|
/>
|
||||||
{syncDirectory.isPending ? "扫描中…" : "重新扫描智能体目录"}
|
{syncDirectory.isPending ? "扫描中…" : "重新扫描智能体目录"}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
className="h-9 rounded-[5px] px-3 text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
title="打开智能体广场视图"
|
title="打开智能体广场视图"
|
||||||
onClick={() => router.push(`${routeBase}/agents/plaza`)}
|
onClick={() => router.push(`${routeBase}/agents/plaza`)}
|
||||||
>
|
>
|
||||||
@@ -499,19 +553,24 @@ export function AgentGallery({
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="text-muted-foreground hover:text-foreground"
|
className="h-9 gap-2.5 rounded-[5px] px-3 text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
title="重新播放智能体使用引导"
|
title="重新播放智能体使用引导"
|
||||||
onClick={() => startAgentGuide("list")}
|
onClick={() => startAgentGuide("list")}
|
||||||
>
|
>
|
||||||
<Compass className="mr-1.5 h-4 w-4" />
|
<Compass className="h-4 w-4" />
|
||||||
使用引导
|
使用引导
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleNewAgent} data-agent-guide="new-agent-btn">
|
<Button
|
||||||
<PlusIcon className="mr-1.5 h-4 w-4" />
|
className="ml-1 h-9 gap-2.5 rounded-[5px] px-4 shadow-[0_2px_6px_rgba(193,18,31,0.25)] hover:shadow-[0_4px_12px_rgba(193,18,31,0.35)]"
|
||||||
|
onClick={handleNewAgent}
|
||||||
|
data-agent-guide="new-agent-btn"
|
||||||
|
>
|
||||||
|
<PlusIcon className="h-4 w-4" />
|
||||||
{t.agents.newAgent}
|
{t.agents.newAgent}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<Tabs
|
<Tabs
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Trash2Icon,
|
Trash2Icon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Bot, Loader2 } from "lucide-react";
|
import { Bot, Loader2 } from "lucide-react";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
import { Select } from "tdesign-react";
|
import { Select } from "tdesign-react";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ export function EnabledSkillList({
|
|||||||
<div
|
<div
|
||||||
key={name}
|
key={name}
|
||||||
className={cn(
|
className={cn(
|
||||||
"group/skill bg-background/60 flex items-start gap-2.5 rounded-xl border p-2.5 transition-colors",
|
"agent-skill-row group/skill bg-background/60 flex items-start gap-2.5 rounded-xl border p-2.5 transition-colors",
|
||||||
onViewDetail && "hover:border-primary/40 hover:bg-accent/40",
|
onViewDetail && "hover:border-primary/40 hover:bg-accent/40",
|
||||||
offline && "bg-muted/60 border-dashed dark:bg-[#071D36]",
|
offline && "bg-muted/60 border-dashed dark:bg-[#071D36]",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="bg-primary/10 text-primary flex size-8 shrink-0 items-center justify-center rounded-lg text-sm font-semibold">
|
<div className="agent-skill-avatar bg-primary/10 text-primary flex size-8 shrink-0 items-center justify-center rounded-lg text-sm font-semibold">
|
||||||
{skill ? skillInitial(skill) : "?"}
|
{skill ? skillInitial(skill) : "?"}
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
XIcon,
|
XIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useMemo, useRef, useState } from "react";
|
import { useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const triggerToneClass = (tone: AppearanceControlTone) =>
|
|||||||
tone === "banner-dark"
|
tone === "banner-dark"
|
||||||
? "text-slate-400 hover:bg-slate-800/50 hover:text-slate-400"
|
? "text-slate-400 hover:bg-slate-800/50 hover:text-slate-400"
|
||||||
: tone === "banner-light"
|
: tone === "banner-light"
|
||||||
? "text-white hover:bg-[var(--brand-950)] hover:text-white active:bg-[#8a0618]"
|
? "text-white hover:bg-[var(--brand-900)] hover:text-white active:bg-[var(--brand-950)]"
|
||||||
: tone === "banner-custom"
|
: tone === "banner-custom"
|
||||||
? "text-[var(--navigation-foreground)] hover:bg-white/20 hover:text-[var(--navigation-foreground)] active:bg-white/30"
|
? "text-[var(--navigation-foreground)] hover:bg-white/20 hover:text-[var(--navigation-foreground)] active:bg-white/30"
|
||||||
: "text-muted-foreground hover:bg-muted hover:text-foreground";
|
: "text-muted-foreground hover:bg-muted hover:text-foreground";
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { useParams } from "next/navigation";
|
|||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { AnchorHTMLAttributes, HTMLAttributes, ReactNode } from "react";
|
import type { AnchorHTMLAttributes, HTMLAttributes, ReactNode } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
import { defaultUrlTransform } from "react-markdown";
|
import { defaultUrlTransform } from "react-markdown";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -1706,8 +1706,16 @@ export function ArtifactFileDetail({
|
|||||||
)}
|
)}
|
||||||
<ArtifactAction
|
<ArtifactAction
|
||||||
icon={DownloadIcon}
|
icon={DownloadIcon}
|
||||||
label={t.common.download}
|
label={
|
||||||
tooltip={t.common.download}
|
language === "html" && !useWriteFileStreaming && !onDownloadClick
|
||||||
|
? "下载离线包"
|
||||||
|
: t.common.download
|
||||||
|
}
|
||||||
|
tooltip={
|
||||||
|
language === "html" && !useWriteFileStreaming && !onDownloadClick
|
||||||
|
? "下载包含网页运行库的 ZIP 离线包"
|
||||||
|
: t.common.download
|
||||||
|
}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (onDownloadClick) {
|
if (onDownloadClick) {
|
||||||
onDownloadClick();
|
onDownloadClick();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { DownloadIcon, LoaderIcon, PackageIcon } from "lucide-react";
|
import { DownloadIcon, LoaderIcon, PackageIcon } from "lucide-react";
|
||||||
import { useCallback, useState, type ReactNode } from "react";
|
import { useCallback, useState, type ReactNode } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -130,7 +130,9 @@ export function ArtifactFileList({
|
|||||||
) : (
|
) : (
|
||||||
<DownloadIcon className="size-4" />
|
<DownloadIcon className="size-4" />
|
||||||
)}
|
)}
|
||||||
{t.common.download}
|
{!onDownloadArtifact && /\.(?:html?|xhtml)$/i.test(getFileName(file))
|
||||||
|
? "下载离线包"
|
||||||
|
: t.common.download}
|
||||||
</Button>
|
</Button>
|
||||||
</CardAction>
|
</CardAction>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
useState,
|
useState,
|
||||||
type ReactNode,
|
type ReactNode,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { useSidebarSafe } from "@/components/ui/sidebar";
|
import { useSidebarSafe } from "@/components/ui/sidebar";
|
||||||
import { env } from "@/env";
|
import { env } from "@/env";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { AlertCircleIcon, Loader2Icon, PackageIcon } from "lucide-react";
|
import { AlertCircleIcon, Loader2Icon, PackageIcon } from "lucide-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -0,0 +1,326 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { CheckIcon, CopyIcon, MonitorUpIcon, UnplugIcon } from "lucide-react";
|
||||||
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
import { PromptInputButton } from "@/components/ai-elements/prompt-input";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from "@/components/ui/dialog";
|
||||||
|
import {
|
||||||
|
createBrowserSkillPairing,
|
||||||
|
getBrowserSkillStatus,
|
||||||
|
identifyBrowserSkillExtension,
|
||||||
|
pairBrowserSkillThroughExtension,
|
||||||
|
reconnectBrowserSkillThroughExtension,
|
||||||
|
revokeBrowserSkillDevice,
|
||||||
|
subscribeBrowserSkillExtensionEvents,
|
||||||
|
type BrowserSkillStatus,
|
||||||
|
} from "@/core/browser-skill/api";
|
||||||
|
import { shouldPairCurrentBrowser } from "@/core/browser-skill/connection";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
import { Tooltip } from "./tooltip";
|
||||||
|
|
||||||
|
const ACTIVE_INSTANCE_STORAGE_KEY = "cmzs.browser-skill.active-instance-id";
|
||||||
|
|
||||||
|
function storedInstanceId(): string | null {
|
||||||
|
if (typeof window === "undefined") return null;
|
||||||
|
return window.localStorage.getItem(ACTIVE_INSTANCE_STORAGE_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberInstanceId(instanceId: string | null) {
|
||||||
|
if (instanceId) {
|
||||||
|
window.localStorage.setItem(ACTIVE_INSTANCE_STORAGE_KEY, instanceId);
|
||||||
|
} else {
|
||||||
|
window.localStorage.removeItem(ACTIVE_INSTANCE_STORAGE_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function BrowserSkillControl({
|
||||||
|
active,
|
||||||
|
onActiveChange,
|
||||||
|
disabled,
|
||||||
|
compact,
|
||||||
|
}: {
|
||||||
|
active: boolean;
|
||||||
|
onActiveChange: (active: boolean) => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
compact?: boolean;
|
||||||
|
}) {
|
||||||
|
const [status, setStatus] = useState<BrowserSkillStatus | null>();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [pairingLink, setPairingLink] = useState("");
|
||||||
|
const operationInFlight = useRef(false);
|
||||||
|
const activatedInstanceId = useRef<string | null>(storedInstanceId());
|
||||||
|
const onActiveChangeRef = useRef(onActiveChange);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onActiveChangeRef.current = onActiveChange;
|
||||||
|
}, [onActiveChange]);
|
||||||
|
|
||||||
|
const refresh = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
const next = await getBrowserSkillStatus();
|
||||||
|
setStatus(next);
|
||||||
|
if (
|
||||||
|
!next?.connected ||
|
||||||
|
(activatedInstanceId.current != null &&
|
||||||
|
next.instance_id !== activatedInstanceId.current)
|
||||||
|
) {
|
||||||
|
onActiveChangeRef.current(false);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setStatus((current) => current ?? null);
|
||||||
|
onActiveChangeRef.current(false);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
void refresh();
|
||||||
|
let replacementRefreshTimer: number | undefined;
|
||||||
|
const unsubscribe = subscribeBrowserSkillExtensionEvents(() => {
|
||||||
|
// A reconnect can close the previous socket before the same browser
|
||||||
|
// instance finishes its new handshake. Re-check the stable instance id
|
||||||
|
// after that handshake settles instead of racing it.
|
||||||
|
if (replacementRefreshTimer !== undefined) {
|
||||||
|
window.clearTimeout(replacementRefreshTimer);
|
||||||
|
}
|
||||||
|
replacementRefreshTimer = window.setTimeout(() => {
|
||||||
|
replacementRefreshTimer = undefined;
|
||||||
|
void refresh();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (replacementRefreshTimer !== undefined) {
|
||||||
|
window.clearTimeout(replacementRefreshTimer);
|
||||||
|
}
|
||||||
|
unsubscribe();
|
||||||
|
};
|
||||||
|
}, [refresh]);
|
||||||
|
|
||||||
|
if (status == null || !status.enabled) return null;
|
||||||
|
|
||||||
|
const connected = status?.connected === true;
|
||||||
|
const paired = status?.paired === true;
|
||||||
|
|
||||||
|
const handleToggle = () => {
|
||||||
|
if (active) {
|
||||||
|
onActiveChange(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void activateCurrentBrowser();
|
||||||
|
};
|
||||||
|
|
||||||
|
const confirmConnection = async (
|
||||||
|
expectedInstanceId: string,
|
||||||
|
attempts = 3,
|
||||||
|
intervalMs = 500,
|
||||||
|
) => {
|
||||||
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
||||||
|
const next = await getBrowserSkillStatus();
|
||||||
|
setStatus(next);
|
||||||
|
if (next?.connected === true && next.instance_id === expectedInstanceId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (attempt < attempts - 1) {
|
||||||
|
await new Promise((resolve) => window.setTimeout(resolve, intervalMs));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const requireInstanceId = (instanceId?: string) => {
|
||||||
|
if (!instanceId) {
|
||||||
|
throw new Error("当前浏览器中的 CMZS 插件版本过旧或插件 ID 配置不匹配,请重新加载最新插件");
|
||||||
|
}
|
||||||
|
return instanceId;
|
||||||
|
};
|
||||||
|
|
||||||
|
const waitUntilIdle = async () => {
|
||||||
|
for (let attempt = 0; attempt < 30; attempt += 1) {
|
||||||
|
const next = await getBrowserSkillStatus();
|
||||||
|
setStatus(next);
|
||||||
|
if (!next?.busy) return true;
|
||||||
|
await new Promise((resolve) => window.setTimeout(resolve, 2000));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const activateCurrentBrowser = async () => {
|
||||||
|
if (operationInFlight.current) return;
|
||||||
|
operationInFlight.current = true;
|
||||||
|
setBusy(true);
|
||||||
|
setOpen(false);
|
||||||
|
setPairingLink("");
|
||||||
|
try {
|
||||||
|
let current: BrowserSkillStatus | null | undefined = status;
|
||||||
|
if (current?.busy) {
|
||||||
|
toast.info("当前浏览器任务结束后将自动切换到此浏览器");
|
||||||
|
if (!(await waitUntilIdle())) {
|
||||||
|
throw new Error("等待当前浏览器任务结束超时,请稍后重试");
|
||||||
|
}
|
||||||
|
current = await getBrowserSkillStatus();
|
||||||
|
setStatus(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
const identity = await identifyBrowserSkillExtension();
|
||||||
|
const expectedInstanceId = requireInstanceId(identity.instance_id);
|
||||||
|
if (current?.connected && current.instance_id === expectedInstanceId) {
|
||||||
|
activatedInstanceId.current = expectedInstanceId;
|
||||||
|
rememberInstanceId(expectedInstanceId);
|
||||||
|
onActiveChange(true);
|
||||||
|
setOpen(false);
|
||||||
|
toast.success("本机浏览器已启用");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shouldPairCurrentBrowser(current?.paired === true, identity)) {
|
||||||
|
try {
|
||||||
|
await reconnectBrowserSkillThroughExtension();
|
||||||
|
if (await confirmConnection(expectedInstanceId)) {
|
||||||
|
activatedInstanceId.current = expectedInstanceId;
|
||||||
|
rememberInstanceId(expectedInstanceId);
|
||||||
|
onActiveChange(true);
|
||||||
|
setOpen(false);
|
||||||
|
toast.success("已切换到当前浏览器");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// The stored credential may have been invalidated by another browser.
|
||||||
|
// Fall through to a fresh one-time pairing for this installation.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await pairCurrentBrowser();
|
||||||
|
} catch (error) {
|
||||||
|
// Automatic pairing should remain a one-click flow. Keep the manual
|
||||||
|
// pairing dialog out of the normal path and report genuine failures as
|
||||||
|
// a toast instead.
|
||||||
|
setOpen(false);
|
||||||
|
toast.error(error instanceof Error ? error.message : "无法唤醒浏览器插件");
|
||||||
|
} finally {
|
||||||
|
operationInFlight.current = false;
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const pairCurrentBrowser = async () => {
|
||||||
|
const link = await createBrowserSkillPairing();
|
||||||
|
const identity = await pairBrowserSkillThroughExtension(link);
|
||||||
|
const instanceId = requireInstanceId(identity.instance_id);
|
||||||
|
if (!(await confirmConnection(instanceId))) {
|
||||||
|
throw new Error("插件已授权但未能连接,请检查插件状态");
|
||||||
|
}
|
||||||
|
activatedInstanceId.current = instanceId;
|
||||||
|
rememberInstanceId(instanceId);
|
||||||
|
onActiveChange(true);
|
||||||
|
setOpen(false);
|
||||||
|
setPairingLink("");
|
||||||
|
toast.success("本机浏览器已连接");
|
||||||
|
};
|
||||||
|
|
||||||
|
const copyPairingLink = async () => {
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
const link = await createBrowserSkillPairing();
|
||||||
|
await navigator.clipboard.writeText(link);
|
||||||
|
setPairingLink(link);
|
||||||
|
toast.success("配对链接已复制,5 分钟内有效且仅可使用一次");
|
||||||
|
await refresh();
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "复制配对链接失败");
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const revoke = async () => {
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
await revokeBrowserSkillDevice();
|
||||||
|
activatedInstanceId.current = null;
|
||||||
|
rememberInstanceId(null);
|
||||||
|
setPairingLink("");
|
||||||
|
onActiveChange(false);
|
||||||
|
await refresh();
|
||||||
|
toast.success("浏览器授权已撤销");
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "撤销授权失败");
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip content={connected ? (active ? "本机浏览器已启用" : "启用本机浏览器") : "连接本机浏览器"}>
|
||||||
|
<PromptInputButton
|
||||||
|
type="button"
|
||||||
|
aria-pressed={active}
|
||||||
|
disabled={disabled}
|
||||||
|
className={cn(
|
||||||
|
"gap-1.5! rounded-full px-3! shadow-none",
|
||||||
|
compact && "rounded-lg px-2.5! py-1! text-[11px] font-medium",
|
||||||
|
active
|
||||||
|
? "border border-emerald-300 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-200"
|
||||||
|
: "border-0 bg-transparent text-muted-foreground hover:bg-muted/70 hover:text-foreground dark:text-slate-400 dark:hover:bg-slate-700/70 dark:hover:text-slate-100",
|
||||||
|
)}
|
||||||
|
onClick={handleToggle}
|
||||||
|
>
|
||||||
|
{active && <CheckIcon className="size-3" />}
|
||||||
|
<MonitorUpIcon className="size-3" />
|
||||||
|
<span className="text-xs font-normal">本机浏览器</span>
|
||||||
|
</PromptInputButton>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
<DialogContent className="sm:max-w-md">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>连接本机浏览器</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
点击后会自动连接已安装的 CMZS 插件。一个账号只绑定一台浏览器。
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="rounded-xl border bg-muted/30 p-4">
|
||||||
|
<div className="flex items-center justify-between gap-3">
|
||||||
|
<span className="font-medium">连接状态</span>
|
||||||
|
<span className={cn("text-sm", connected ? "text-emerald-600 dark:text-emerald-300" : "text-muted-foreground")}>
|
||||||
|
{connected ? "已连接" : paired ? "已配对,等待扩展上线" : "未配对"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{status?.device?.label && (
|
||||||
|
<p className="mt-2 text-sm text-muted-foreground">{status.device.label}</p>
|
||||||
|
)}
|
||||||
|
{pairingLink && (
|
||||||
|
<p className="mt-3 break-all rounded-lg bg-background px-3 py-2 text-xs text-muted-foreground">
|
||||||
|
{pairingLink}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<DialogFooter className="sm:justify-between">
|
||||||
|
{paired ? (
|
||||||
|
<Button type="button" variant="ghost" className="text-destructive hover:text-destructive" disabled={busy} onClick={revoke}>
|
||||||
|
<UnplugIcon className="size-4" />
|
||||||
|
撤销授权
|
||||||
|
</Button>
|
||||||
|
) : <span />}
|
||||||
|
<Button type="button" disabled={busy} onClick={copyPairingLink}>
|
||||||
|
<CopyIcon className="size-4" />
|
||||||
|
{pairingLink ? "复制配对链接" : "手动复制配对链接"}
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,271 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import {
|
||||||
|
ExternalLinkIcon,
|
||||||
|
MousePointer2Icon,
|
||||||
|
PictureInPicture2Icon,
|
||||||
|
SquareIcon,
|
||||||
|
XIcon,
|
||||||
|
} from "lucide-react";
|
||||||
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
browserTaskAction,
|
||||||
|
getBrowserTaskStatus,
|
||||||
|
type BrowserTaskPreview as PreviewFrame,
|
||||||
|
type BrowserTaskStatus,
|
||||||
|
} from "@/core/browser-skill/api";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
interface DocumentPictureInPictureApi {
|
||||||
|
requestWindow(options: { width: number; height: number }): Promise<Window>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ACTIVE_PREVIEW_INTERVAL_MS = 2500;
|
||||||
|
const ACTIVE_STATUS_INTERVAL_MS = 15_000;
|
||||||
|
const IDLE_STATUS_INTERVAL_MS = 10_000;
|
||||||
|
const HIDDEN_STATUS_INTERVAL_MS = 30_000;
|
||||||
|
|
||||||
|
function pictureInPictureApi(): DocumentPictureInPictureApi | undefined {
|
||||||
|
return (window as Window & { documentPictureInPicture?: DocumentPictureInPictureApi })
|
||||||
|
.documentPictureInPicture;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyStyles(target: Document) {
|
||||||
|
const base = target.createElement("base");
|
||||||
|
base.href = document.baseURI;
|
||||||
|
target.head.append(base);
|
||||||
|
for (const sheet of Array.from(document.styleSheets)) {
|
||||||
|
if (sheet.href) {
|
||||||
|
const link = target.createElement("link");
|
||||||
|
link.rel = "stylesheet";
|
||||||
|
link.href = sheet.href;
|
||||||
|
target.head.append(link);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const style = target.createElement("style");
|
||||||
|
style.textContent = Array.from(sheet.cssRules, (rule) => rule.cssText).join("\n");
|
||||||
|
target.head.append(style);
|
||||||
|
} catch {
|
||||||
|
// Cross-origin stylesheets cannot expose cssRules; linked styles above remain usable.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const reset = target.createElement("style");
|
||||||
|
reset.textContent = "html,body,#browser-task-pip{width:100%;height:100%;margin:0;overflow:hidden;background:#0f172a}";
|
||||||
|
target.head.append(reset);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function BrowserTaskPreview({
|
||||||
|
threadId,
|
||||||
|
enabled,
|
||||||
|
}: {
|
||||||
|
threadId?: string;
|
||||||
|
enabled: boolean;
|
||||||
|
}) {
|
||||||
|
const [status, setStatus] = useState<BrowserTaskStatus | null>(null);
|
||||||
|
const [frame, setFrame] = useState<PreviewFrame | null>(null);
|
||||||
|
const [pipTarget, setPipTarget] = useState<HTMLElement | null>(null);
|
||||||
|
const pipWindow = useRef<Window | null>(null);
|
||||||
|
|
||||||
|
const closePip = useCallback(() => {
|
||||||
|
setPipTarget(null);
|
||||||
|
pipWindow.current?.close();
|
||||||
|
pipWindow.current = null;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => closePip, [closePip]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!enabled || !threadId) {
|
||||||
|
setStatus(null);
|
||||||
|
setFrame(null);
|
||||||
|
closePip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let alive = true;
|
||||||
|
let timer = 0;
|
||||||
|
let failures = 0;
|
||||||
|
let hasActiveTask = false;
|
||||||
|
let currentStatus: BrowserTaskStatus | null = null;
|
||||||
|
let statusCheckedAt = 0;
|
||||||
|
let polling = false;
|
||||||
|
const poll = async () => {
|
||||||
|
if (polling) return;
|
||||||
|
polling = true;
|
||||||
|
try {
|
||||||
|
const now = Date.now();
|
||||||
|
// Preview POSTs carry live frames. Status GETs only discover or
|
||||||
|
// periodically reconcile the session, so keep them on a slower cadence.
|
||||||
|
if (!currentStatus?.selected || now - statusCheckedAt >= ACTIVE_STATUS_INTERVAL_MS) {
|
||||||
|
currentStatus = await getBrowserTaskStatus(threadId);
|
||||||
|
statusCheckedAt = now;
|
||||||
|
}
|
||||||
|
if (!alive) return;
|
||||||
|
failures = 0;
|
||||||
|
hasActiveTask = Boolean(currentStatus.connected && currentStatus.selected);
|
||||||
|
setStatus(currentStatus);
|
||||||
|
if (hasActiveTask && !document.hidden) {
|
||||||
|
try {
|
||||||
|
const preview = await browserTaskAction<PreviewFrame>(threadId, "preview");
|
||||||
|
if (alive) setFrame(preview);
|
||||||
|
} catch {
|
||||||
|
// A daemon reconnect can invalidate a session between the status
|
||||||
|
// GET and preview POST. Treat it as an ended task, not a page-level
|
||||||
|
// error, and wait for the next BrowserSkill call to create one.
|
||||||
|
hasActiveTask = false;
|
||||||
|
currentStatus = null;
|
||||||
|
statusCheckedAt = 0;
|
||||||
|
if (alive) {
|
||||||
|
setStatus(null);
|
||||||
|
setFrame(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setFrame(null);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
failures += 1;
|
||||||
|
if (alive) {
|
||||||
|
setStatus(null);
|
||||||
|
setFrame(null);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
polling = false;
|
||||||
|
if (alive) {
|
||||||
|
const delay = failures
|
||||||
|
? Math.min(30_000, 2000 * 2 ** (failures - 1))
|
||||||
|
: document.hidden
|
||||||
|
? HIDDEN_STATUS_INTERVAL_MS
|
||||||
|
: hasActiveTask
|
||||||
|
? ACTIVE_PREVIEW_INTERVAL_MS
|
||||||
|
: IDLE_STATUS_INTERVAL_MS;
|
||||||
|
timer = window.setTimeout(poll, delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const onVisibilityChange = () => {
|
||||||
|
window.clearTimeout(timer);
|
||||||
|
timer = window.setTimeout(poll, 0);
|
||||||
|
};
|
||||||
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||||
|
void poll();
|
||||||
|
return () => {
|
||||||
|
alive = false;
|
||||||
|
window.clearTimeout(timer);
|
||||||
|
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||||
|
};
|
||||||
|
}, [closePip, enabled, threadId]);
|
||||||
|
|
||||||
|
const openPip = async () => {
|
||||||
|
const api = pictureInPictureApi();
|
||||||
|
if (!api || !frame) return;
|
||||||
|
const child = await api.requestWindow({ width: 420, height: 320 });
|
||||||
|
copyStyles(child.document);
|
||||||
|
child.document.title = frame.title || "本机浏览器任务";
|
||||||
|
const target = child.document.createElement("div");
|
||||||
|
target.id = "browser-task-pip";
|
||||||
|
child.document.body.append(target);
|
||||||
|
child.addEventListener("pagehide", closePip, { once: true });
|
||||||
|
pipWindow.current = child;
|
||||||
|
setPipTarget(target);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!enabled || !threadId || !status?.selected || !frame) return null;
|
||||||
|
|
||||||
|
const pointer = frame.pointer;
|
||||||
|
const viewportWidth = Math.max(1, frame.viewport?.width ?? 1);
|
||||||
|
const viewportHeight = Math.max(1, frame.viewport?.height ?? 1);
|
||||||
|
const pointerLabel = pointer
|
||||||
|
? pointer.action === "click"
|
||||||
|
? "正在点击"
|
||||||
|
: pointer.action === "wheel"
|
||||||
|
? "正在滚动"
|
||||||
|
: "正在移动"
|
||||||
|
: "浏览器正在执行";
|
||||||
|
|
||||||
|
const panel = (
|
||||||
|
<aside
|
||||||
|
className={cn(
|
||||||
|
"overflow-hidden border border-slate-700 bg-slate-950 text-white shadow-2xl",
|
||||||
|
pipTarget
|
||||||
|
? "flex size-full flex-col rounded-none"
|
||||||
|
: "fixed right-5 bottom-44 z-40 w-[360px] max-w-[calc(100vw-2.5rem)] rounded-xl",
|
||||||
|
)}
|
||||||
|
aria-label="本机浏览器任务预览"
|
||||||
|
>
|
||||||
|
<header className="flex h-10 shrink-0 items-center gap-2 px-3 text-xs">
|
||||||
|
<span className="size-2 rounded-full bg-emerald-400" />
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
|
<strong className="block truncate font-medium">
|
||||||
|
{frame.title || "本机浏览器正在执行"}
|
||||||
|
</strong>
|
||||||
|
<span className="block truncate text-[10px] text-sky-200/80">{pointerLabel}</span>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
className="size-7 text-white/80 hover:bg-slate-800 hover:text-white"
|
||||||
|
onClick={() => void browserTaskAction(threadId, "focus")}
|
||||||
|
title="定位浏览器窗口"
|
||||||
|
>
|
||||||
|
<ExternalLinkIcon className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
{pictureInPictureApi() && (
|
||||||
|
<Button
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
className="size-7 text-white/80 hover:bg-slate-800 hover:text-white"
|
||||||
|
onClick={() => (pipTarget ? closePip() : void openPip())}
|
||||||
|
title={pipTarget ? "退出画中画" : "画中画"}
|
||||||
|
>
|
||||||
|
{pipTarget ? <XIcon className="size-3.5" /> : <PictureInPicture2Icon className="size-3.5" />}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
size="icon"
|
||||||
|
variant="ghost"
|
||||||
|
className="size-7 text-white/80 hover:bg-red-950 hover:text-white"
|
||||||
|
onClick={() => void browserTaskAction(threadId, "stop").then(() => setStatus(null))}
|
||||||
|
title="停止浏览器任务"
|
||||||
|
>
|
||||||
|
<SquareIcon className="size-3.5" />
|
||||||
|
</Button>
|
||||||
|
</header>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="relative min-h-0 flex-1 overflow-hidden bg-black p-0"
|
||||||
|
onClick={() => void browserTaskAction(threadId, "focus")}
|
||||||
|
title="点击定位浏览器窗口"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={`data:image/${frame.format};base64,${frame.image_base64}`}
|
||||||
|
alt="浏览器实时预览"
|
||||||
|
className={cn("block w-full object-contain", pipTarget ? "h-full" : "aspect-video")}
|
||||||
|
/>
|
||||||
|
{pointer && (
|
||||||
|
<span
|
||||||
|
className="pointer-events-none absolute z-10 transition-[left,top] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]"
|
||||||
|
style={{
|
||||||
|
left: `${Math.min(100, Math.max(0, (pointer.x / viewportWidth) * 100))}%`,
|
||||||
|
top: `${Math.min(100, Math.max(0, (pointer.y / viewportHeight) * 100))}%`,
|
||||||
|
}}
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
{pointer.action === "click" && (
|
||||||
|
<span
|
||||||
|
key={pointer.sequence}
|
||||||
|
className="absolute -left-3 -top-3 size-7 animate-ping rounded-full border-2 border-sky-300/80"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<MousePointer2Icon className="size-6 -translate-y-0.5 fill-sky-400 text-white drop-shadow-[0_2px_3px_rgba(0,0,0,0.9)]" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
|
||||||
|
return pipTarget ? createPortal(panel, pipTarget) : panel;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import historyChatAvatar from "@/assets/img/chat-history-avatar.png";
|
||||||
|
import historyCloudAvatar from "@/assets/img/chat-history-cloud-avatar.png";
|
||||||
|
import historyDeviceAvatar from "@/assets/img/chat-history-device-avatar.png";
|
||||||
|
|
||||||
|
const CHAT_HISTORY_AVATARS = [
|
||||||
|
historyChatAvatar,
|
||||||
|
historyCloudAvatar,
|
||||||
|
historyDeviceAvatar,
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Conversations do not carry an avatar in persisted state. Derive one from
|
||||||
|
* the stable thread id, so each history row keeps its mark across refreshes
|
||||||
|
* while the list uses varied purple, green, and blue artwork.
|
||||||
|
*/
|
||||||
|
export function historyAvatarForThread(threadId: string): string {
|
||||||
|
let hash = 0;
|
||||||
|
for (let index = 0; index < threadId.length; index += 1) {
|
||||||
|
hash = (hash * 31 + threadId.charCodeAt(index)) | 0;
|
||||||
|
}
|
||||||
|
return CHAT_HISTORY_AVATARS[(hash >>> 0) % CHAT_HISTORY_AVATARS.length]!;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { Message } from "@langchain/langgraph-sdk";
|
import type { Message } from "@langchain/langgraph-sdk";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { FilesIcon, XIcon } from "lucide-react";
|
import { FilesIcon, GripVertical, XIcon } from "lucide-react";
|
||||||
import { usePathname, useSearchParams } from "next/navigation";
|
import { usePathname, useSearchParams } from "next/navigation";
|
||||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { GroupImperativeHandle } from "react-resizable-panels";
|
import type { GroupImperativeHandle } from "react-resizable-panels";
|
||||||
@@ -859,13 +859,48 @@ const ChatBox: React.FC<{
|
|||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
<ResizableHandle
|
<ResizableHandle
|
||||||
id={`${resizableIdBase}-separator`}
|
id={`${resizableIdBase}-separator`}
|
||||||
|
onPointerDownCapture={(event) => {
|
||||||
|
const target = event.target;
|
||||||
|
// The library starts a drag from any pointerdown inside the separator.
|
||||||
|
// Hovering the edge only reveals the grip; the grip is the only drag target.
|
||||||
|
if (!(target instanceof Element) || !target.closest("[data-resize-grip]")) {
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"opacity-33 hover:opacity-100",
|
"group/split z-20",
|
||||||
stackArtifactPanel &&
|
stackArtifactPanel
|
||||||
"h-px w-full after:inset-x-0 after:inset-y-auto after:top-1/2 after:h-4 after:w-full after:-translate-x-0 after:-translate-y-1/2 after:cursor-row-resize",
|
? "h-px w-full opacity-33 hover:opacity-100 after:inset-x-0 after:inset-y-auto after:top-1/2 after:h-4 after:w-full after:-translate-x-0 after:-translate-y-1/2 after:cursor-row-resize"
|
||||||
|
: // The default hit box is a full-height strip and covers both the chat
|
||||||
|
// scrollbar and the panel on the right. The separator itself stays
|
||||||
|
// inert; only the short center grip starts a drag.
|
||||||
|
"pointer-events-none after:pointer-events-none after:w-0",
|
||||||
!sidePanelOpen && "pointer-events-none opacity-0",
|
!sidePanelOpen && "pointer-events-none opacity-0",
|
||||||
)}
|
)}
|
||||||
|
>
|
||||||
|
{!stackArtifactPanel && (
|
||||||
|
<>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn(
|
||||||
|
"absolute inset-y-0 left-0 z-20 w-8 cursor-default",
|
||||||
|
sidePanelOpen ? "pointer-events-auto" : "pointer-events-none",
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
|
<span
|
||||||
|
data-resize-grip=""
|
||||||
|
className={cn(
|
||||||
|
"absolute top-1/2 left-1/2 z-30 flex h-16 w-10 -translate-x-1/2 -translate-y-1/2 items-center justify-center",
|
||||||
|
sidePanelOpen ? "pointer-events-auto cursor-col-resize" : "pointer-events-none",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="bg-border z-10 flex h-8 w-4 items-center justify-center rounded-sm border shadow-sm opacity-0 transition-opacity group-hover/split:opacity-100 group-focus-visible/split:opacity-100">
|
||||||
|
<GripVertical className="size-3.5" />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ResizableHandle>
|
||||||
<ResizablePanel
|
<ResizablePanel
|
||||||
className={cn(
|
className={cn(
|
||||||
"bg-background transition-all duration-300 ease-in-out",
|
"bg-background transition-all duration-300 ease-in-out",
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
import { useTheme } from "@/contexts/ThemeContext";
|
import { useTheme } from "@/contexts/ThemeContext";
|
||||||
import { AppBrandImage } from "@/core/branding/app-brand-image";
|
import { AppBrandImage } from "@/core/branding/app-brand-image";
|
||||||
import { useDisplayDesensitizer } from "@/core/sensitive-words/use-display-desensitizer";
|
import { useDisplayDesensitizer } from "@/core/sensitive-words/use-display-desensitizer";
|
||||||
import { useAppSystemName } from "@/core/system-settings/hooks";
|
import {
|
||||||
|
useAppSystemName,
|
||||||
|
usePageDescriptionsSettings,
|
||||||
|
} from "@/core/system-settings/hooks";
|
||||||
|
import type { GeneralQaPageDescription } from "@/core/system-settings/api";
|
||||||
import { readRuntimeFlag } from "@/env";
|
import { readRuntimeFlag } from "@/env";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
@@ -12,11 +16,25 @@ import { cn } from "@/lib/utils";
|
|||||||
* 仅展示,无交互。配色走主题 token(--workspace-brand / --primary),红/蓝/深蓝主题自适应。
|
* 仅展示,无交互。配色走主题 token(--workspace-brand / --primary),红/蓝/深蓝主题自适应。
|
||||||
* 非紧凑模式仍用 <Welcome/>,本组件不参与。
|
* 非紧凑模式仍用 <Welcome/>,本组件不参与。
|
||||||
*/
|
*/
|
||||||
export function CompactWelcome({ className }: { className?: string }) {
|
export function CompactWelcome({
|
||||||
|
className,
|
||||||
|
pageDescription,
|
||||||
|
}: {
|
||||||
|
className?: string;
|
||||||
|
/** The actual interface mode is resolved by ChatPage. */
|
||||||
|
pageDescription?: GeneralQaPageDescription;
|
||||||
|
}) {
|
||||||
const desensitizeText = useDisplayDesensitizer();
|
const desensitizeText = useDisplayDesensitizer();
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const systemName = useAppSystemName("");
|
const systemName = useAppSystemName("");
|
||||||
const welcomeTitle = systemName ? `欢迎使用${systemName}` : "欢迎使用CM助手";
|
const { data: pageDescriptions } = usePageDescriptionsSettings();
|
||||||
|
const configured = pageDescription ?? pageDescriptions?.general_qa.compact;
|
||||||
|
const welcomeTitle =
|
||||||
|
configured?.welcome_title ||
|
||||||
|
(systemName ? `欢迎使用${systemName}` : "欢迎使用CM助手");
|
||||||
|
const welcomeDescription =
|
||||||
|
configured?.welcome_description ||
|
||||||
|
"基于先进深度推理模型,为您提供高效的市场分析、专业报告撰写、调研设计与协同脑暴支持。";
|
||||||
const isWelcomeLogoVisible = readRuntimeFlag("VITE_WELCOME_LOGO_VISIBLE");
|
const isWelcomeLogoVisible = readRuntimeFlag("VITE_WELCOME_LOGO_VISIBLE");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -46,7 +64,7 @@ export function CompactWelcome({ className }: { className?: string }) {
|
|||||||
{desensitizeText(welcomeTitle)}
|
{desensitizeText(welcomeTitle)}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-muted-foreground mx-auto mt-2 max-w-sm text-xs leading-relaxed">
|
<p className="text-muted-foreground mx-auto mt-2 max-w-sm text-xs leading-relaxed">
|
||||||
基于先进深度推理模型,为您提供高效的市场分析、专业报告撰写、调研设计与协同脑暴支持。
|
{desensitizeText(welcomeDescription)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { FileSpreadsheet } from "lucide-react";
|
import { Download } from "lucide-react";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { consumerThreadMaterialsDownloadUrl } from "@/core/threads/consumer-thread-values-client";
|
import { consumerThreadMaterialsDownloadUrl } from "@/core/threads/consumer-thread-values-client";
|
||||||
@@ -9,6 +10,33 @@ import { consumerThreadMaterialsDownloadUrl } from "@/core/threads/consumer-thre
|
|||||||
import { useThread } from "./messages/context";
|
import { useThread } from "./messages/context";
|
||||||
import { Tooltip } from "./tooltip";
|
import { Tooltip } from "./tooltip";
|
||||||
|
|
||||||
|
const MATERIALS_DOWNLOAD_FRAME_ID = "consumer-materials-download-frame";
|
||||||
|
const MATERIALS_DOWNLOAD_FRAME_NAME = "consumer-materials-download-frame";
|
||||||
|
|
||||||
|
function submitDownloadWithoutNavigation(downloadUrl: string): void {
|
||||||
|
let frame = document.getElementById(
|
||||||
|
MATERIALS_DOWNLOAD_FRAME_ID,
|
||||||
|
) as HTMLIFrameElement | null;
|
||||||
|
if (!frame) {
|
||||||
|
frame = document.createElement("iframe");
|
||||||
|
frame.id = MATERIALS_DOWNLOAD_FRAME_ID;
|
||||||
|
frame.name = MATERIALS_DOWNLOAD_FRAME_NAME;
|
||||||
|
frame.title = "资料下载";
|
||||||
|
frame.setAttribute("aria-hidden", "true");
|
||||||
|
frame.style.display = "none";
|
||||||
|
document.body.appendChild(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
const anchor = document.createElement("a");
|
||||||
|
anchor.href = downloadUrl;
|
||||||
|
anchor.target = frame.name;
|
||||||
|
anchor.download = "";
|
||||||
|
anchor.rel = "noopener";
|
||||||
|
document.body.appendChild(anchor);
|
||||||
|
anchor.click();
|
||||||
|
anchor.remove();
|
||||||
|
}
|
||||||
|
|
||||||
/** Downloads the Consumer-maintained source-material workbook for this chat. */
|
/** Downloads the Consumer-maintained source-material workbook for this chat. */
|
||||||
export function ConsumerMaterialsExportTrigger({
|
export function ConsumerMaterialsExportTrigger({
|
||||||
threadId,
|
threadId,
|
||||||
@@ -19,7 +47,13 @@ export function ConsumerMaterialsExportTrigger({
|
|||||||
const downloadUrl = consumerThreadMaterialsDownloadUrl(threadId);
|
const downloadUrl = consumerThreadMaterialsDownloadUrl(threadId);
|
||||||
const handleDownload = useCallback(() => {
|
const handleDownload = useCallback(() => {
|
||||||
if (!downloadUrl) return;
|
if (!downloadUrl) return;
|
||||||
window.open(downloadUrl, "_blank", "noopener,noreferrer");
|
|
||||||
|
// The Consumer URL may be cross-origin, which makes browsers ignore an
|
||||||
|
// anchor's `download` hint and navigate the current document. Route the
|
||||||
|
// native download request through a persistent hidden frame instead, so
|
||||||
|
// the chat never leaves its current route and no extra window is opened.
|
||||||
|
submitDownloadWithoutNavigation(downloadUrl);
|
||||||
|
toast.message("正在准备资料下载…");
|
||||||
}, [downloadUrl]);
|
}, [downloadUrl]);
|
||||||
|
|
||||||
if (thread.messages.length === 0) return null;
|
if (thread.messages.length === 0) return null;
|
||||||
@@ -35,7 +69,7 @@ export function ConsumerMaterialsExportTrigger({
|
|||||||
disabled={!downloadUrl}
|
disabled={!downloadUrl}
|
||||||
onClick={handleDownload}
|
onClick={handleDownload}
|
||||||
>
|
>
|
||||||
<FileSpreadsheet />
|
<Download className="size-4" aria-hidden="true" />
|
||||||
导出资料
|
导出资料
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { CheckIcon, CopyIcon } from "lucide-react";
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
||||||
import { useCallback, useState, type ComponentProps } from "react";
|
import { useCallback, useState, type ComponentProps } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { copyTextToClipboard } from "@/core/clipboard";
|
import { copyTextToClipboard } from "@/core/clipboard";
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Trash2Icon,
|
Trash2Icon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -162,7 +162,7 @@ export function CustomPromptBar({
|
|||||||
type="button"
|
type="button"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="text-muted-foreground hover:text-foreground hover:bg-muted/70 h-7 w-7 shrink-0 rounded-full"
|
className="agent-composer-tool text-muted-foreground hover:text-foreground hover:bg-muted/70 h-7 w-7 shrink-0 rounded-full"
|
||||||
title="管理常用提示词"
|
title="管理常用提示词"
|
||||||
aria-label="管理常用提示词"
|
aria-label="管理常用提示词"
|
||||||
onClick={() => setManageOpen(true)}
|
onClick={() => setManageOpen(true)}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Download, FileJson, FileText, FileType2 } from "lucide-react";
|
import { Download, FileJson, FileText, FileType2 } from "lucide-react";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import {
|
|||||||
FileJson,
|
FileJson,
|
||||||
FileText,
|
FileText,
|
||||||
Loader2,
|
Loader2,
|
||||||
MessageSquare,
|
|
||||||
MoreHorizontal,
|
MoreHorizontal,
|
||||||
Pencil,
|
Pencil,
|
||||||
Pin,
|
Pin,
|
||||||
@@ -39,7 +38,7 @@ import Link from "next/link";
|
|||||||
import { useParams, usePathname, useRouter, useSearchParams } from "next/navigation";
|
import { useParams, usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
import { Select } from "tdesign-react";
|
import { Select } from "tdesign-react";
|
||||||
|
|
||||||
import { useTheme } from "@/contexts/ThemeContext";
|
import { useTheme } from "@/contexts/ThemeContext";
|
||||||
@@ -106,10 +105,12 @@ import { cn } from "@/lib/utils";
|
|||||||
import { strategyProjectWorkbenchPath } from "@/strategy-selection/project-routes";
|
import { strategyProjectWorkbenchPath } from "@/strategy-selection/project-routes";
|
||||||
import {
|
import {
|
||||||
mergeRecentWorkspaceItems,
|
mergeRecentWorkspaceItems,
|
||||||
|
type RecentWorkspaceItem,
|
||||||
useRecentStrategyProjects,
|
useRecentStrategyProjects,
|
||||||
} from "@/strategy-selection/recent-projects";
|
} from "@/strategy-selection/recent-projects";
|
||||||
|
|
||||||
import { agentColor } from "./agent-icon-color";
|
import { agentColor } from "./agent-icon-color";
|
||||||
|
import { historyAvatarForThread } from "./chat-history-avatar";
|
||||||
import { SidebarCollapseButton } from "./workspace-header";
|
import { SidebarCollapseButton } from "./workspace-header";
|
||||||
|
|
||||||
// 智能体图标配色(按 id 稳定散列、分主题)抽到共享模块 ./agent-icon-color,
|
// 智能体图标配色(按 id 稳定散列、分主题)抽到共享模块 ./agent-icon-color,
|
||||||
@@ -378,7 +379,6 @@ export function GeneralQaSidebar({
|
|||||||
// 未搜索时与旧版一致:最多展示 10 条
|
// 未搜索时与旧版一致:最多展示 10 条
|
||||||
return q ? list : list.slice(0, 10);
|
return q ? list : list.slice(0, 10);
|
||||||
}, [query, recentItems, t.pages.newChat]);
|
}, [query, recentItems, t.pages.newChat]);
|
||||||
|
|
||||||
const handleNewChatClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
const handleNewChatClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
|
||||||
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button === 1) return;
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.button === 1) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -451,6 +451,176 @@ export function GeneralQaSidebar({
|
|||||||
|
|
||||||
const isStatic = env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true";
|
const isStatic = env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true";
|
||||||
|
|
||||||
|
const renderRecentHistoryItem = (item: RecentWorkspaceItem) => {
|
||||||
|
if (item.kind === "strategy-project") {
|
||||||
|
const { project } = item;
|
||||||
|
const href = strategyProjectWorkbenchPath(
|
||||||
|
"/page/strategy/qa/projects",
|
||||||
|
project.id,
|
||||||
|
);
|
||||||
|
const isActive = href === pathname;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`strategy-project:${project.id}`}
|
||||||
|
className="group/item relative flex items-center"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
href={href}
|
||||||
|
title={desensitize(project.title)}
|
||||||
|
className={cn(
|
||||||
|
"gq-history-item relative flex min-h-11 min-w-0 flex-1 items-center gap-2 overflow-hidden rounded-xl px-2.5 py-1.5 text-[13px] outline-none transition-[background-color,color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-primary/55",
|
||||||
|
isActive
|
||||||
|
? "gq-history-item--active bg-primary/[0.11] font-medium text-primary shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] hover:bg-primary/[0.15]"
|
||||||
|
: "text-foreground/80 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<MyProjectThreadIcon type="strategy" />
|
||||||
|
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
|
||||||
|
<span className="block w-full truncate">{desensitize(project.title)}</span>
|
||||||
|
<MyProjectThreadBadge
|
||||||
|
className="mr-3 max-w-[calc(100%_-_0.75rem)]"
|
||||||
|
projectName={project.title}
|
||||||
|
type="strategy"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { thread } = item;
|
||||||
|
const href = buildFullChatNavigationPath(pathForThread(thread), currentSearch);
|
||||||
|
const isActive = href === pathname;
|
||||||
|
const isBoot = isBootstrapThread(thread);
|
||||||
|
const projectInfo = myProjectConversationInfoOfThread(
|
||||||
|
thread,
|
||||||
|
projectThreadNames,
|
||||||
|
);
|
||||||
|
const pinned = isThreadPinned(thread);
|
||||||
|
const favorited = isThreadFavorite(thread);
|
||||||
|
const title = desensitize(titleOfThread(thread, t.pages.newChat));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={`thread:${thread.thread_id}`} className="group/item relative flex items-center">
|
||||||
|
<Link
|
||||||
|
href={href}
|
||||||
|
title={title}
|
||||||
|
className={cn(
|
||||||
|
"gq-history-item relative flex h-9 min-w-0 flex-1 items-center gap-2 overflow-hidden rounded-xl px-2.5 pr-8 text-[13px] outline-none transition-[background-color,color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-primary/55",
|
||||||
|
projectInfo && "h-auto min-h-11 py-1.5",
|
||||||
|
isActive
|
||||||
|
? "gq-history-item--active bg-primary/[0.11] font-medium text-primary shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] hover:bg-primary/[0.15]"
|
||||||
|
: "text-foreground/80 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{isBoot ? (
|
||||||
|
<Bot
|
||||||
|
className={cn(
|
||||||
|
"size-3.5 shrink-0",
|
||||||
|
isActive ? "text-primary" : "text-muted-foreground/70",
|
||||||
|
)}
|
||||||
|
aria-label="智能体创建会话"
|
||||||
|
/>
|
||||||
|
) : projectInfo ? (
|
||||||
|
<MyProjectThreadIcon type={projectInfo.type} />
|
||||||
|
) : (
|
||||||
|
<img
|
||||||
|
src={historyAvatarForThread(thread.thread_id)}
|
||||||
|
alt=""
|
||||||
|
aria-hidden="true"
|
||||||
|
draggable={false}
|
||||||
|
className="size-5 shrink-0 object-contain"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{pinned && (
|
||||||
|
<Pin className="size-3 shrink-0 text-muted-foreground/70" aria-label="已置顶" />
|
||||||
|
)}
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
"min-w-0 flex-1",
|
||||||
|
projectInfo && "flex flex-col items-start gap-0.5",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="block w-full truncate">{title}</span>
|
||||||
|
{projectInfo && (
|
||||||
|
<MyProjectThreadBadge
|
||||||
|
className="mr-3 max-w-[calc(100%_-_0.75rem)]"
|
||||||
|
projectName={projectInfo.projectName}
|
||||||
|
type={projectInfo.type}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
{!isStatic && (
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={`${t.common.more}:${title}`}
|
||||||
|
className="absolute right-1 flex size-7 items-center justify-center rounded-lg text-muted-foreground opacity-0 outline-none transition-[opacity,background-color,color] duration-150 hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-primary/55 group-hover/item:opacity-100 group-focus-within/item:opacity-100 data-[state=open]:bg-background data-[state=open]:text-foreground data-[state=open]:opacity-100"
|
||||||
|
>
|
||||||
|
<MoreHorizontal className="size-4" />
|
||||||
|
</button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent className="w-48 rounded-lg" side="right" align="start">
|
||||||
|
<DropdownMenuItem
|
||||||
|
onSelect={() =>
|
||||||
|
handleRenameClick(thread.thread_id, titleOfThread(thread, t.pages.newChat))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Pencil className="text-muted-foreground" />
|
||||||
|
<span>{t.common.rename}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onSelect={() => togglePin(thread.thread_id, !pinned)}>
|
||||||
|
{pinned ? (
|
||||||
|
<PinOff className="text-muted-foreground" />
|
||||||
|
) : (
|
||||||
|
<Pin className="text-muted-foreground" />
|
||||||
|
)}
|
||||||
|
<span>{pinned ? t.common.unpin : t.common.pin}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onSelect={() => toggleFavorite(thread.thread_id, !favorited)}>
|
||||||
|
<Star
|
||||||
|
className={
|
||||||
|
favorited
|
||||||
|
? "fill-amber-400 text-amber-400"
|
||||||
|
: "text-muted-foreground"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<span>{favorited ? t.common.unfavorite : t.common.favorite}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onSelect={() => setShareThreadId(thread.thread_id)}>
|
||||||
|
<Share2 className="text-muted-foreground" />
|
||||||
|
<span>{t.common.share}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuSub>
|
||||||
|
<DropdownMenuSubTrigger>
|
||||||
|
<Download className="text-muted-foreground" />
|
||||||
|
<span>{t.common.export}</span>
|
||||||
|
</DropdownMenuSubTrigger>
|
||||||
|
<DropdownMenuSubContent>
|
||||||
|
<DropdownMenuItem onSelect={() => handleExport(thread, "markdown")}>
|
||||||
|
<FileText className="text-muted-foreground" />
|
||||||
|
<span>{t.common.exportAsMarkdown}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onSelect={() => handleExport(thread, "json")}>
|
||||||
|
<FileJson className="text-muted-foreground" />
|
||||||
|
<span>{t.common.exportAsJSON}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuSubContent>
|
||||||
|
</DropdownMenuSub>
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem onSelect={() => handleDelete(thread.thread_id)}>
|
||||||
|
<Trash2 className="text-muted-foreground" />
|
||||||
|
<span>{t.common.delete}</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// 背景走 sidebar token(浅主题=白、浅蓝主题=浅蓝);深蓝(.dark)主题下由 gq-sidebar
|
// 背景走 sidebar token(浅主题=白、浅蓝主题=浅蓝);深蓝(.dark)主题下由 gq-sidebar
|
||||||
// 改为「深蓝主题底图 + 半透明蓝罩」玻璃面板(见 globals.css),与右侧 workspace-chat-bg
|
// 改为「深蓝主题底图 + 半透明蓝罩」玻璃面板(见 globals.css),与右侧 workspace-chat-bg
|
||||||
@@ -710,191 +880,7 @@ export function GeneralQaSidebar({
|
|||||||
{query ? "没有匹配的会话" : t.chats.noChats}
|
{query ? "没有匹配的会话" : t.chats.noChats}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
filteredRecentItems.map((item) => {
|
filteredRecentItems.map(renderRecentHistoryItem)
|
||||||
if (item.kind === "strategy-project") {
|
|
||||||
const { project } = item;
|
|
||||||
const href = strategyProjectWorkbenchPath(
|
|
||||||
"/page/strategy/qa/projects",
|
|
||||||
project.id,
|
|
||||||
);
|
|
||||||
const isActive = href === pathname;
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={`strategy-project:${project.id}`}
|
|
||||||
className="group/item relative flex items-center"
|
|
||||||
>
|
|
||||||
<Link
|
|
||||||
href={href}
|
|
||||||
className={cn(
|
|
||||||
"gq-history-item relative flex min-h-12 min-w-0 flex-1 items-center gap-2 rounded-lg px-2.5 py-1.5 text-[13px] transition-colors",
|
|
||||||
isActive
|
|
||||||
? "gq-history-item--active border border-primary/40 bg-primary/5 font-medium text-primary"
|
|
||||||
: "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<MyProjectThreadIcon type="strategy" />
|
|
||||||
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
|
|
||||||
<span className="w-full truncate">
|
|
||||||
{desensitize(project.title)}
|
|
||||||
</span>
|
|
||||||
<MyProjectThreadBadge
|
|
||||||
className="mr-4 max-w-[calc(100%_-_1rem)]"
|
|
||||||
projectName={project.title}
|
|
||||||
type="strategy"
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
{isActive && (
|
|
||||||
<span className="absolute top-1/2 right-1 h-5 w-1 -translate-y-1/2 rounded-full bg-primary" />
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { thread } = item;
|
|
||||||
const href = buildFullChatNavigationPath(
|
|
||||||
pathForThread(thread),
|
|
||||||
currentSearch,
|
|
||||||
);
|
|
||||||
const isActive = href === pathname;
|
|
||||||
const isBoot = isBootstrapThread(thread);
|
|
||||||
const projectInfo = myProjectConversationInfoOfThread(
|
|
||||||
thread,
|
|
||||||
projectThreadNames,
|
|
||||||
);
|
|
||||||
const pinned = isThreadPinned(thread);
|
|
||||||
const favorited = isThreadFavorite(thread);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={`thread:${thread.thread_id}`}
|
|
||||||
className="group/item relative flex items-center"
|
|
||||||
>
|
|
||||||
<Link
|
|
||||||
href={href}
|
|
||||||
className={cn(
|
|
||||||
"gq-history-item relative flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg px-2.5 text-[13px] transition-colors",
|
|
||||||
projectInfo && "h-auto min-h-12 py-1.5",
|
|
||||||
isActive
|
|
||||||
? "gq-history-item--active border border-primary/40 bg-primary/5 font-medium text-primary"
|
|
||||||
: "text-muted-foreground hover:bg-accent/60 hover:text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{isBoot ? (
|
|
||||||
<Bot
|
|
||||||
className={cn(
|
|
||||||
"size-3.5 shrink-0",
|
|
||||||
isActive ? "text-primary" : "text-muted-foreground/70",
|
|
||||||
)}
|
|
||||||
aria-label="智能体创建会话"
|
|
||||||
/>
|
|
||||||
) : projectInfo ? (
|
|
||||||
<MyProjectThreadIcon type={projectInfo.type} />
|
|
||||||
) : (
|
|
||||||
<MessageSquare
|
|
||||||
className={cn(
|
|
||||||
"size-3.5 shrink-0",
|
|
||||||
isActive ? "text-primary" : "text-muted-foreground/70",
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{pinned && (
|
|
||||||
<Pin className="size-3 shrink-0 text-muted-foreground/70" />
|
|
||||||
)}
|
|
||||||
<span
|
|
||||||
className={cn(
|
|
||||||
"min-w-0 flex-1",
|
|
||||||
projectInfo && "flex flex-col items-start gap-0.5",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<span className="w-full truncate">
|
|
||||||
{desensitize(titleOfThread(thread, t.pages.newChat))}
|
|
||||||
</span>
|
|
||||||
{projectInfo && (
|
|
||||||
<MyProjectThreadBadge
|
|
||||||
className="mr-4 max-w-[calc(100%_-_1rem)]"
|
|
||||||
projectName={projectInfo.projectName}
|
|
||||||
type={projectInfo.type}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
{isActive && (
|
|
||||||
<span className="absolute top-1/2 right-1 h-5 w-1 -translate-y-1/2 rounded-full bg-primary" />
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
{!isStatic && (
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="absolute right-1 flex size-6 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-background group-hover/item:opacity-100 data-[state=open]:opacity-100"
|
|
||||||
>
|
|
||||||
<MoreHorizontal className="size-4" />
|
|
||||||
<span className="sr-only">{t.common.more}</span>
|
|
||||||
</button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent className="w-48 rounded-lg" side="right" align="start">
|
|
||||||
<DropdownMenuItem
|
|
||||||
onSelect={() =>
|
|
||||||
handleRenameClick(
|
|
||||||
thread.thread_id,
|
|
||||||
titleOfThread(thread, t.pages.newChat),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Pencil className="text-muted-foreground" />
|
|
||||||
<span>{t.common.rename}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onSelect={() => togglePin(thread.thread_id, !pinned)}>
|
|
||||||
{pinned ? (
|
|
||||||
<PinOff className="text-muted-foreground" />
|
|
||||||
) : (
|
|
||||||
<Pin className="text-muted-foreground" />
|
|
||||||
)}
|
|
||||||
<span>{pinned ? t.common.unpin : t.common.pin}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem
|
|
||||||
onSelect={() => toggleFavorite(thread.thread_id, !favorited)}
|
|
||||||
>
|
|
||||||
<Star
|
|
||||||
className={
|
|
||||||
favorited
|
|
||||||
? "fill-amber-400 text-amber-400"
|
|
||||||
: "text-muted-foreground"
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<span>{favorited ? t.common.unfavorite : t.common.favorite}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onSelect={() => setShareThreadId(thread.thread_id)}>
|
|
||||||
<Share2 className="text-muted-foreground" />
|
|
||||||
<span>{t.common.share}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuSub>
|
|
||||||
<DropdownMenuSubTrigger>
|
|
||||||
<Download className="text-muted-foreground" />
|
|
||||||
<span>{t.common.export}</span>
|
|
||||||
</DropdownMenuSubTrigger>
|
|
||||||
<DropdownMenuSubContent>
|
|
||||||
<DropdownMenuItem onSelect={() => handleExport(thread, "markdown")}>
|
|
||||||
<FileText className="text-muted-foreground" />
|
|
||||||
<span>{t.common.exportAsMarkdown}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
<DropdownMenuItem onSelect={() => handleExport(thread, "json")}>
|
|
||||||
<FileJson className="text-muted-foreground" />
|
|
||||||
<span>{t.common.exportAsJSON}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuSubContent>
|
|
||||||
</DropdownMenuSub>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<DropdownMenuItem onSelect={() => handleDelete(thread.thread_id)}>
|
|
||||||
<Trash2 className="text-muted-foreground" />
|
|
||||||
<span>{t.common.delete}</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})
|
|
||||||
)}
|
)}
|
||||||
{!query && (
|
{!query && (
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { ChatStatus } from "ai";
|
import type { ChatStatus } from "ai";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
import {
|
import {
|
||||||
BookMarkedIcon,
|
BookMarkedIcon,
|
||||||
BrainCircuitIcon,
|
BrainCircuitIcon,
|
||||||
@@ -85,6 +85,7 @@ import { desensitize } from "@/lib/desensitize";
|
|||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
import { AgentSelector } from "@/components/workspace/agents/agent-selector";
|
import { AgentSelector } from "@/components/workspace/agents/agent-selector";
|
||||||
|
import { BrowserSkillControl } from "@/components/workspace/browser-skill-control";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ModelSelector,
|
ModelSelector,
|
||||||
@@ -138,11 +139,15 @@ export function InputBox({
|
|||||||
agentSelector,
|
agentSelector,
|
||||||
knowledgeSelector,
|
knowledgeSelector,
|
||||||
knowledgeRetrieval,
|
knowledgeRetrieval,
|
||||||
|
browserSkill,
|
||||||
knowledgeSuggestedQuestions = [],
|
knowledgeSuggestedQuestions = [],
|
||||||
extraModels = [],
|
extraModels = [],
|
||||||
|
placeholder,
|
||||||
assistantId,
|
assistantId,
|
||||||
hideAdminRecommendedQuestions,
|
hideAdminRecommendedQuestions,
|
||||||
compact,
|
compact,
|
||||||
|
mirrorLandingFrame = false,
|
||||||
|
frameRadius = "default",
|
||||||
hideContextTools,
|
hideContextTools,
|
||||||
composerHeightPercent,
|
composerHeightPercent,
|
||||||
...props
|
...props
|
||||||
@@ -152,6 +157,13 @@ export function InputBox({
|
|||||||
/** 紧凑模式(正常 App)新对话落地态:去掉旋转彩边、用 CM 参考图的白卡输入框,
|
/** 紧凑模式(正常 App)新对话落地态:去掉旋转彩边、用 CM 参考图的白卡输入框,
|
||||||
* 并在推荐问题上方加「试试这些高频业务场景」标题。仅落地态生效,默认 false。 */
|
* 并在推荐问题上方加「试试这些高频业务场景」标题。仅落地态生效,默认 false。 */
|
||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
|
/**
|
||||||
|
* Reuse the non-compact new-chat visual frame for a conversation composer.
|
||||||
|
* This changes only the border shell; conversation behavior remains intact.
|
||||||
|
*/
|
||||||
|
mirrorLandingFrame?: boolean;
|
||||||
|
/** Visual-only radius variant for a mirrored landing frame. */
|
||||||
|
frameRadius?: "default" | "tight";
|
||||||
/** 隐藏输入框工具条上的「写作 / 参考文献」上下文开关按钮(任务深链工作区等
|
/** 隐藏输入框工具条上的「写作 / 参考文献」上下文开关按钮(任务深链工作区等
|
||||||
* 受控场景用;文件/模型等其他按钮不受影响)。 */
|
* 受控场景用;文件/模型等其他按钮不受影响)。 */
|
||||||
hideContextTools?: boolean;
|
hideContextTools?: boolean;
|
||||||
@@ -160,6 +172,10 @@ export function InputBox({
|
|||||||
* Other values scale the landing / compact-landing / conversation base.
|
* Other values scale the landing / compact-landing / conversation base.
|
||||||
*/
|
*/
|
||||||
composerHeightPercent?: number;
|
composerHeightPercent?: number;
|
||||||
|
browserSkill?: {
|
||||||
|
active: boolean;
|
||||||
|
onActiveChange: (active: boolean) => void;
|
||||||
|
};
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
context: Omit<
|
context: Omit<
|
||||||
AgentThreadContext,
|
AgentThreadContext,
|
||||||
@@ -227,6 +243,8 @@ export function InputBox({
|
|||||||
knowledgeSuggestedQuestions?: string[];
|
knowledgeSuggestedQuestions?: string[];
|
||||||
/** Page-scoped model choices implemented outside the DeerFlow model API. */
|
/** Page-scoped model choices implemented outside the DeerFlow model API. */
|
||||||
extraModels?: Model[];
|
extraModels?: Model[];
|
||||||
|
/** Page-specific prompt. Omit to keep the localized product default. */
|
||||||
|
placeholder?: string;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const [localSettings, setLocalSettings] = useLocalSettings();
|
const [localSettings, setLocalSettings] = useLocalSettings();
|
||||||
@@ -724,6 +742,7 @@ export function InputBox({
|
|||||||
maxHeight: `max(12rem, calc(${composerMinHeight} + 8rem))`,
|
maxHeight: `max(12rem, calc(${composerMinHeight} + 8rem))`,
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const usesGeminiFrame = !compact && (isNewThread || mirrorLandingFrame);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={promptRootRef} className="relative flex flex-col gap-6">
|
<div ref={promptRootRef} className="relative flex flex-col gap-6">
|
||||||
@@ -741,7 +760,7 @@ export function InputBox({
|
|||||||
<button
|
<button
|
||||||
key={question}
|
key={question}
|
||||||
type="button"
|
type="button"
|
||||||
className="max-w-full rounded-full border border-primary/20 bg-primary/5 px-4 py-2 text-left text-sm text-foreground transition-colors hover:bg-primary/10"
|
className="agent-suggested-chip max-w-full rounded-full border px-4 py-2 text-left text-sm text-foreground transition-colors"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
fillPromptForEditing(question);
|
fillPromptForEditing(question);
|
||||||
}}
|
}}
|
||||||
@@ -817,7 +836,12 @@ export function InputBox({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className={cn(isNewThread && !compact && "gemini-gradient-border gemini-shadow")}>
|
<div
|
||||||
|
className={cn(usesGeminiFrame && "gemini-gradient-border gemini-shadow")}
|
||||||
|
data-frame-radius={
|
||||||
|
usesGeminiFrame && frameRadius !== "default" ? frameRadius : undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
<PromptInput
|
<PromptInput
|
||||||
style={
|
style={
|
||||||
composerMinHeight ? { minHeight: composerMinHeight } : undefined
|
composerMinHeight ? { minHeight: composerMinHeight } : undefined
|
||||||
@@ -834,7 +858,7 @@ export function InputBox({
|
|||||||
? "rounded-2xl border border-gray-200/70 bg-white overflow-hidden shadow-[0_4.5px_22px_rgba(0,0,0,0.025)] transition-all duration-300 focus-within:border-[rgb(var(--legacy-primary-rgb)/35%)] focus-within:ring-4 focus-within:ring-[rgb(var(--legacy-primary-rgb)/5%)] focus-within:shadow-[0_10px_35px_rgb(var(--legacy-primary-rgb)/4%)] dark:border-slate-700 dark:bg-slate-800"
|
? "rounded-2xl border border-gray-200/70 bg-white overflow-hidden shadow-[0_4.5px_22px_rgba(0,0,0,0.025)] transition-all duration-300 focus-within:border-[rgb(var(--legacy-primary-rgb)/35%)] focus-within:ring-4 focus-within:ring-[rgb(var(--legacy-primary-rgb)/5%)] focus-within:shadow-[0_10px_35px_rgb(var(--legacy-primary-rgb)/4%)] dark:border-slate-700 dark:bg-slate-800"
|
||||||
: // landing 态:透明,让外层 gemini-gradient-border 提供白卡 + 旋转描边
|
: // landing 态:透明,让外层 gemini-gradient-border 提供白卡 + 旋转描边
|
||||||
// 对话态:常规白卡 + 中性边框 + 轻阴影
|
// 对话态:常规白卡 + 中性边框 + 轻阴影
|
||||||
isNewThread
|
usesGeminiFrame
|
||||||
? "rounded-3xl bg-transparent border-0 shadow-none ring-0"
|
? "rounded-3xl bg-transparent border-0 shadow-none ring-0"
|
||||||
: "rounded-3xl bg-background border border-border shadow-sm transition-shadow hover:shadow-md focus-within:border-ring/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-ring/20 dark:bg-slate-800 dark:border-slate-700",
|
: "rounded-3xl bg-background border border-border shadow-sm transition-shadow hover:shadow-md focus-within:border-ring/40 focus-within:shadow-md focus-within:ring-1 focus-within:ring-ring/20 dark:bg-slate-800 dark:border-slate-700",
|
||||||
className,
|
className,
|
||||||
@@ -861,7 +885,7 @@ export function InputBox({
|
|||||||
data-composer-height={composerMinHeight ? "" : undefined}
|
data-composer-height={composerMinHeight ? "" : undefined}
|
||||||
style={composerHeightStyle}
|
style={composerHeightStyle}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
placeholder={t.inputBox.placeholder}
|
placeholder={placeholder || t.inputBox.placeholder}
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
defaultValue={initialValue}
|
defaultValue={initialValue}
|
||||||
/>
|
/>
|
||||||
@@ -893,6 +917,14 @@ export function InputBox({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{!frontendRagActive && browserSkill && (
|
||||||
|
<BrowserSkillControl
|
||||||
|
active={browserSkill.active}
|
||||||
|
onActiveChange={browserSkill.onActiveChange}
|
||||||
|
disabled={disabled}
|
||||||
|
compact={compact}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{!frontendRagActive && !hideContextTools && <Tooltip
|
{!frontendRagActive && !hideContextTools && <Tooltip
|
||||||
content={
|
content={
|
||||||
context.writing_mode
|
context.writing_mode
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { BookMarked } from "lucide-react";
|
import { BookMarked } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { useKnowledgeActions } from "@/core/knowledge/hooks";
|
import { useKnowledgeActions } from "@/core/knowledge/hooks";
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ export function LlmWikiKnowledgeSelector({
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-8 max-w-52 gap-1.5 rounded-full border-0 bg-transparent px-2.5 text-muted-foreground shadow-none hover:bg-muted/70 hover:text-foreground",
|
"agent-composer-tool h-8 max-w-52 gap-1.5 rounded-full border-0 bg-transparent px-2.5 text-muted-foreground shadow-none hover:bg-muted/70 hover:text-foreground",
|
||||||
selectedCount > 0 && "bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary",
|
selectedCount > 0 && "bg-primary/8 text-primary hover:bg-primary/12 hover:text-primary",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
ThumbsUpIcon,
|
ThumbsUpIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Trash2Icon } from "lucide-react";
|
import { Trash2Icon } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
XCircleIcon,
|
XCircleIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ArtifactFileList } from "@/components/workspace/artifacts/artifact-file-list";
|
import { ArtifactFileList } from "@/components/workspace/artifacts/artifact-file-list";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { FileText, Loader2, MessagesSquare } from "lucide-react";
|
import { FileText, Loader2, MessagesSquare } from "lucide-react";
|
||||||
import { useState, type ComponentProps } from "react";
|
import { useState, type ComponentProps } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
NotebookPenIcon,
|
NotebookPenIcon,
|
||||||
SearchIcon,
|
SearchIcon,
|
||||||
SquareTerminalIcon,
|
SquareTerminalIcon,
|
||||||
|
ImageIcon,
|
||||||
WrenchIcon,
|
WrenchIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type AnchorHTMLAttributes } from "react";
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type AnchorHTMLAttributes } from "react";
|
||||||
@@ -47,6 +48,7 @@ import {
|
|||||||
namedStreamingWriteFilePath,
|
namedStreamingWriteFilePath,
|
||||||
} from "@/core/artifacts/streaming-write-preview";
|
} from "@/core/artifacts/streaming-write-preview";
|
||||||
import { listStreamingWriteFileCalls } from "@/core/artifacts/parse-partial-json";
|
import { listStreamingWriteFileCalls } from "@/core/artifacts/parse-partial-json";
|
||||||
|
import { urlOfArtifact } from "@/core/artifacts/utils";
|
||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
import {
|
import {
|
||||||
normalizeSearchResults,
|
normalizeSearchResults,
|
||||||
@@ -63,6 +65,10 @@ import { useLocalSettings } from "@/core/settings";
|
|||||||
import { useSkills } from "@/core/skills/hooks";
|
import { useSkills } from "@/core/skills/hooks";
|
||||||
import { useCitationDisplaySettings } from "@/core/system-settings/hooks";
|
import { useCitationDisplaySettings } from "@/core/system-settings/hooks";
|
||||||
import { isInternalToolCallName } from "@/core/tools/visibility";
|
import { isInternalToolCallName } from "@/core/tools/visibility";
|
||||||
|
import {
|
||||||
|
extractInvokedSkillName,
|
||||||
|
skillInvocationLabel,
|
||||||
|
} from "@/core/tools/skill-invocation";
|
||||||
import {
|
import {
|
||||||
applyInlineCitations,
|
applyInlineCitations,
|
||||||
buildSkillDisplayMap,
|
buildSkillDisplayMap,
|
||||||
@@ -229,6 +235,7 @@ export function MessageGroup({
|
|||||||
skillDisplayMap={skillDisplayMap}
|
skillDisplayMap={skillDisplayMap}
|
||||||
displaySources={displaySources}
|
displaySources={displaySources}
|
||||||
ragModeEnabled={ragModeEnabled}
|
ragModeEnabled={ragModeEnabled}
|
||||||
|
threadId={threadId}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
@@ -242,6 +249,7 @@ export function MessageGroup({
|
|||||||
skillDisplayMap={skillDisplayMap}
|
skillDisplayMap={skillDisplayMap}
|
||||||
displaySources={displaySources}
|
displaySources={displaySources}
|
||||||
ragModeEnabled={ragModeEnabled}
|
ragModeEnabled={ragModeEnabled}
|
||||||
|
threadId={threadId}
|
||||||
/>
|
/>
|
||||||
</FlipDisplay>
|
</FlipDisplay>
|
||||||
)}
|
)}
|
||||||
@@ -358,6 +366,7 @@ function ToolCall({
|
|||||||
skillDisplayMap = new Map(),
|
skillDisplayMap = new Map(),
|
||||||
displaySources = [],
|
displaySources = [],
|
||||||
ragModeEnabled = false,
|
ragModeEnabled = false,
|
||||||
|
threadId,
|
||||||
}: {
|
}: {
|
||||||
id?: string;
|
id?: string;
|
||||||
messageId?: string;
|
messageId?: string;
|
||||||
@@ -369,8 +378,13 @@ function ToolCall({
|
|||||||
skillDisplayMap?: ReturnType<typeof buildSkillDisplayMap>;
|
skillDisplayMap?: ReturnType<typeof buildSkillDisplayMap>;
|
||||||
displaySources?: RuntimeDisplaySource[];
|
displaySources?: RuntimeDisplaySource[];
|
||||||
ragModeEnabled?: boolean;
|
ragModeEnabled?: boolean;
|
||||||
|
threadId?: string;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const invokedSkillName = extractInvokedSkillName(name, args);
|
||||||
|
const invokedSkillLabel = invokedSkillName
|
||||||
|
? skillInvocationLabel(invokedSkillName)
|
||||||
|
: undefined;
|
||||||
const displayMatch =
|
const displayMatch =
|
||||||
result !== undefined && isDisplaySamplePayload(result)
|
result !== undefined && isDisplaySamplePayload(result)
|
||||||
? null
|
? null
|
||||||
@@ -437,6 +451,23 @@ function ToolCall({
|
|||||||
return <DeepResearchProgressStep id={id} args={args} />;
|
return <DeepResearchProgressStep id={id} args={args} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const screenshot = browserScreenshotResult(name, result);
|
||||||
|
if (screenshot && threadId) {
|
||||||
|
const imageUrl = urlOfArtifact({ filepath: screenshot.path, threadId });
|
||||||
|
return (
|
||||||
|
<ChainOfThoughtStep key={id} label="浏览器截图" icon={ImageIcon}>
|
||||||
|
<a href={imageUrl} target="_blank" rel="noopener noreferrer">
|
||||||
|
<img
|
||||||
|
alt="浏览器截图"
|
||||||
|
className="mt-2 max-h-[32rem] max-w-full rounded-lg border object-contain"
|
||||||
|
loading="lazy"
|
||||||
|
src={imageUrl}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</ChainOfThoughtStep>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const searchItems = normalizeSearchResults(result);
|
const searchItems = normalizeSearchResults(result);
|
||||||
if (ragModeEnabled && shouldUseDefaultCitationMode(name, result, args) && searchItems.length > 0) {
|
if (ragModeEnabled && shouldUseDefaultCitationMode(name, result, args) && searchItems.length > 0) {
|
||||||
const defaultItems = syncDisplaySourceIndexes(
|
const defaultItems = syncDisplaySourceIndexes(
|
||||||
@@ -566,7 +597,9 @@ function ToolCall({
|
|||||||
} else if (name === "read_file") {
|
} else if (name === "read_file") {
|
||||||
let description: string | undefined = (args as { description: string })
|
let description: string | undefined = (args as { description: string })
|
||||||
?.description;
|
?.description;
|
||||||
if (!description) {
|
if (invokedSkillLabel) {
|
||||||
|
description = invokedSkillLabel;
|
||||||
|
} else if (!description) {
|
||||||
description = t.toolCalls.readFile;
|
description = t.toolCalls.readFile;
|
||||||
}
|
}
|
||||||
const { path } = args as { path: string; content: string };
|
const { path } = args as { path: string; content: string };
|
||||||
@@ -598,11 +631,10 @@ function ToolCall({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else if (name === "bash") {
|
} else if (name === "bash") {
|
||||||
const description: string | undefined = (args as { description: string })
|
const description =
|
||||||
?.description;
|
invokedSkillLabel ||
|
||||||
if (!description) {
|
(args as { description?: string })?.description ||
|
||||||
return t.toolCalls.executeCommand;
|
t.toolCalls.executeCommand;
|
||||||
}
|
|
||||||
const command: string | undefined = (args as { command: string })?.command;
|
const command: string | undefined = (args as { command: string })?.command;
|
||||||
return (
|
return (
|
||||||
<ChainOfThoughtStep
|
<ChainOfThoughtStep
|
||||||
@@ -653,13 +685,36 @@ function ToolCall({
|
|||||||
return (
|
return (
|
||||||
<ChainOfThoughtStep
|
<ChainOfThoughtStep
|
||||||
key={id}
|
key={id}
|
||||||
label={description ?? t.toolCalls.useTool(name)}
|
label={invokedSkillLabel ?? description ?? t.toolCalls.useTool(name)}
|
||||||
icon={WrenchIcon}
|
icon={WrenchIcon}
|
||||||
></ChainOfThoughtStep>
|
></ChainOfThoughtStep>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function browserScreenshotResult(
|
||||||
|
name: string,
|
||||||
|
result: string | Record<string, unknown> | undefined,
|
||||||
|
): { path: string } | null {
|
||||||
|
if (name !== "browser_skill" || result == null) return null;
|
||||||
|
let parsed: unknown = result;
|
||||||
|
if (typeof result === "string") {
|
||||||
|
try {
|
||||||
|
parsed = JSON.parse(result);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!parsed || typeof parsed !== "object") return null;
|
||||||
|
const value = parsed as Record<string, unknown>;
|
||||||
|
return value.captured === true &&
|
||||||
|
value.display_to_user === true &&
|
||||||
|
typeof value.path === "string" &&
|
||||||
|
value.path.startsWith("/mnt/user-data/outputs/browser-screenshots/")
|
||||||
|
? { path: value.path }
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
function DeepResearchProgressStep({
|
function DeepResearchProgressStep({
|
||||||
id,
|
id,
|
||||||
args,
|
args,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ChevronDownIcon, DownloadIcon, EyeIcon, Loader2Icon } from "lucide-react";
|
import { ChevronDownIcon, DownloadIcon, EyeIcon, Loader2Icon } from "lucide-react";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ export function ModelNameSelect({
|
|||||||
title?: string;
|
title?: string;
|
||||||
}) {
|
}) {
|
||||||
const { models } = useModels();
|
const { models } = useModels();
|
||||||
|
// 后端约定:配置顺序的第一个模型即默认对话模型(models[0])。
|
||||||
|
const defaultModel = models[0];
|
||||||
|
const defaultModelLabel = defaultModel
|
||||||
|
? `${defaultModel.display_name || defaultModel.name}(默认)`
|
||||||
|
: defaultLabel;
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
value={value ?? DEFAULT_VALUE}
|
value={value ?? DEFAULT_VALUE}
|
||||||
@@ -46,10 +51,10 @@ export function ModelNameSelect({
|
|||||||
className={cn("h-8 gap-1.5 text-xs", triggerClassName, className)}
|
className={cn("h-8 gap-1.5 text-xs", triggerClassName, className)}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
<SelectValue placeholder={defaultLabel} />
|
<SelectValue placeholder={defaultModelLabel} />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent position="popper" side="bottom" sideOffset={4}>
|
<SelectContent position="popper" side="bottom" sideOffset={4}>
|
||||||
<SelectItem value={DEFAULT_VALUE}>{defaultLabel}</SelectItem>
|
<SelectItem value={DEFAULT_VALUE}>{defaultModelLabel}</SelectItem>
|
||||||
{models.map((m) => (
|
{models.map((m) => (
|
||||||
<SelectItem key={m.name} value={m.name}>
|
<SelectItem key={m.name} value={m.name}>
|
||||||
{m.display_name || m.name}
|
{m.display_name || m.name}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
XIcon,
|
XIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -27,21 +27,146 @@ const PANEL_GUTTER_MARGIN = 24;
|
|||||||
/** Questions needed before the navigator shows up at all. */
|
/** Questions needed before the navigator shows up at all. */
|
||||||
const MIN_QUESTIONS = 2;
|
const MIN_QUESTIONS = 2;
|
||||||
const COLLAPSE_STORAGE_KEY = "deerflow.question-navigator.collapsed";
|
const COLLAPSE_STORAGE_KEY = "deerflow.question-navigator.collapsed";
|
||||||
|
/** Matches `scroll-mt-20` so the target sits below the overlay chat header. */
|
||||||
|
const QUESTION_SCROLL_TOP_OFFSET = 80;
|
||||||
|
/** Re-apply after the drawer overlay unmounts; StickToBottom may snap on resize. */
|
||||||
|
const SHEET_SCROLL_RETRY_MS = 80;
|
||||||
|
|
||||||
|
function verticalOverflow(node: HTMLElement): string {
|
||||||
|
const style = window.getComputedStyle(node);
|
||||||
|
const overflowY = style.overflowY;
|
||||||
|
if (overflowY && overflowY !== "visible") return overflowY;
|
||||||
|
const parts = style.overflow.split(" ");
|
||||||
|
return parts[1] || parts[0] || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isVerticallyScrollable(node: HTMLElement): boolean {
|
||||||
|
const overflowY = verticalOverflow(node);
|
||||||
|
return overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay";
|
||||||
|
}
|
||||||
|
|
||||||
/** Walk up from a message anchor to the element that actually scrolls. */
|
/** Walk up from a message anchor to the element that actually scrolls. */
|
||||||
function findScrollParent(el: HTMLElement | null): HTMLElement | null {
|
function findScrollParent(el: HTMLElement | null): HTMLElement | null {
|
||||||
let node = el?.parentElement ?? null;
|
let node = el?.parentElement ?? null;
|
||||||
while (node) {
|
while (node && node !== document.body) {
|
||||||
const overflowY = window.getComputedStyle(node).overflowY;
|
if (isVerticallyScrollable(node) && node.scrollHeight > node.clientHeight + 1) {
|
||||||
if (
|
|
||||||
(overflowY === "auto" || overflowY === "scroll") &&
|
|
||||||
node.scrollHeight > node.clientHeight
|
|
||||||
) {
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
node = node.parentElement;
|
node = node.parentElement;
|
||||||
}
|
}
|
||||||
return null;
|
if (document.scrollingElement instanceof HTMLElement) {
|
||||||
|
return document.scrollingElement;
|
||||||
|
}
|
||||||
|
return document.documentElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
let questionScrollFrame = 0;
|
||||||
|
let questionScrollTarget: { scroller: HTMLElement; top: number } | null = null;
|
||||||
|
|
||||||
|
function prefersReducedMotion(): boolean {
|
||||||
|
try {
|
||||||
|
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Nested-container smooth scroll that Chrome 102 can actually run. */
|
||||||
|
function animateScrollTop(scroller: HTMLElement, top: number): void {
|
||||||
|
if (
|
||||||
|
questionScrollTarget?.scroller === scroller &&
|
||||||
|
Math.abs(questionScrollTarget.top - top) < 8
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (questionScrollFrame) cancelAnimationFrame(questionScrollFrame);
|
||||||
|
const from = scroller.scrollTop;
|
||||||
|
const delta = top - from;
|
||||||
|
questionScrollTarget = { scroller, top };
|
||||||
|
if (Math.abs(delta) < 1 || prefersReducedMotion()) {
|
||||||
|
scroller.scrollTop = top;
|
||||||
|
questionScrollFrame = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const duration = Math.min(480, Math.max(240, Math.abs(delta) * 0.45));
|
||||||
|
const start = performance.now();
|
||||||
|
const stopListening = () => {
|
||||||
|
scroller.removeEventListener("wheel", cancelOnUserScroll);
|
||||||
|
scroller.removeEventListener("touchmove", cancelOnUserScroll);
|
||||||
|
};
|
||||||
|
const cancelOnUserScroll = () => {
|
||||||
|
if (questionScrollFrame) cancelAnimationFrame(questionScrollFrame);
|
||||||
|
questionScrollFrame = 0;
|
||||||
|
questionScrollTarget = null;
|
||||||
|
stopListening();
|
||||||
|
};
|
||||||
|
const step = (now: number) => {
|
||||||
|
const t = Math.min(1, (now - start) / duration);
|
||||||
|
const eased = 1 - (1 - t) * (1 - t) * (1 - t);
|
||||||
|
scroller.scrollTop = from + delta * eased;
|
||||||
|
if (t < 1) {
|
||||||
|
questionScrollFrame = requestAnimationFrame(step);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
questionScrollFrame = 0;
|
||||||
|
stopListening();
|
||||||
|
};
|
||||||
|
scroller.addEventListener("wheel", cancelOnUserScroll, { passive: true });
|
||||||
|
scroller.addEventListener("touchmove", cancelOnUserScroll, { passive: true });
|
||||||
|
questionScrollFrame = requestAnimationFrame(step);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollChildIntoParent(
|
||||||
|
el: HTMLElement,
|
||||||
|
parent: HTMLElement,
|
||||||
|
topOffset = 0,
|
||||||
|
): void {
|
||||||
|
const parentRect = parent.getBoundingClientRect();
|
||||||
|
const elRect = el.getBoundingClientRect();
|
||||||
|
const nextTop = parent.scrollTop + (elRect.top - parentRect.top) - topOffset;
|
||||||
|
animateScrollTop(parent, Math.max(0, Math.min(nextTop, maxScrollTop(parent))));
|
||||||
|
}
|
||||||
|
|
||||||
|
function maxScrollTop(parent: HTMLElement): number {
|
||||||
|
return Math.max(0, parent.scrollHeight - parent.clientHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chrome 102 (and other nested-scroller hosts) often no-ops
|
||||||
|
* `scrollIntoView({ behavior: "smooth" })` when the conversation is not the
|
||||||
|
* document. Animate `scrollTop` on the real overflow container instead.
|
||||||
|
*/
|
||||||
|
function scrollElementIntoContainer(el: HTMLElement, topOffset = 0): void {
|
||||||
|
const scroller = findScrollParent(el);
|
||||||
|
if (!scroller || scroller === el) {
|
||||||
|
try {
|
||||||
|
el.scrollIntoView(true);
|
||||||
|
} catch {
|
||||||
|
// ignore hosts that reject the boolean form
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
scroller.dispatchEvent(
|
||||||
|
new WheelEvent("wheel", { deltaY: -1, bubbles: true }),
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
// WheelEvent is available on Chrome 102; keep scrollTop even if this fails.
|
||||||
|
}
|
||||||
|
scrollChildIntoParent(el, scroller, topOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollItemNearestInParent(
|
||||||
|
item: HTMLElement,
|
||||||
|
parent: HTMLElement,
|
||||||
|
): void {
|
||||||
|
const parentRect = parent.getBoundingClientRect();
|
||||||
|
const itemRect = item.getBoundingClientRect();
|
||||||
|
if (itemRect.top < parentRect.top) {
|
||||||
|
parent.scrollTop += itemRect.top - parentRect.top;
|
||||||
|
} else if (itemRect.bottom > parentRect.bottom) {
|
||||||
|
parent.scrollTop += itemRect.bottom - parentRect.bottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readCollapsedPreference(): boolean {
|
function readCollapsedPreference(): boolean {
|
||||||
@@ -113,6 +238,7 @@ export function QuestionNavigator({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const firstAnchor = document.getElementById(questions[0]!.anchorId);
|
const firstAnchor = document.getElementById(questions[0]!.anchorId);
|
||||||
|
if (!firstAnchor) return;
|
||||||
const scroller = findScrollParent(firstAnchor);
|
const scroller = findScrollParent(firstAnchor);
|
||||||
if (!scroller) return;
|
if (!scroller) return;
|
||||||
|
|
||||||
@@ -145,17 +271,20 @@ export function QuestionNavigator({
|
|||||||
|
|
||||||
const scrollToQuestion = useCallback((anchorId: string) => {
|
const scrollToQuestion = useCallback((anchorId: string) => {
|
||||||
const scroll = () => {
|
const scroll = () => {
|
||||||
document
|
const el = document.getElementById(anchorId);
|
||||||
.getElementById(anchorId)
|
if (!el) return false;
|
||||||
?.scrollIntoView({ behavior: "smooth", block: "start" });
|
scrollElementIntoContainer(el, QUESTION_SCROLL_TOP_OFFSET);
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
if (!document.getElementById(anchorId)) {
|
|
||||||
window.dispatchEvent(new Event(REVEAL_CHAT_HISTORY_EVENT));
|
|
||||||
requestAnimationFrame(() => requestAnimationFrame(scroll));
|
|
||||||
} else {
|
|
||||||
scroll();
|
|
||||||
}
|
|
||||||
setActiveId(anchorId);
|
setActiveId(anchorId);
|
||||||
|
if (scroll()) return;
|
||||||
|
window.dispatchEvent(new Event(REVEAL_CHAT_HISTORY_EVENT));
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (scroll()) return;
|
||||||
|
window.setTimeout(scroll, 50);
|
||||||
|
});
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toggleCollapsed = useCallback(() => {
|
const toggleCollapsed = useCallback(() => {
|
||||||
@@ -246,8 +375,12 @@ export function QuestionNavigator({
|
|||||||
questions={questions}
|
questions={questions}
|
||||||
activeId={activeId}
|
activeId={activeId}
|
||||||
onSelect={(anchorId) => {
|
onSelect={(anchorId) => {
|
||||||
setSheetOpen(false);
|
|
||||||
scrollToQuestion(anchorId);
|
scrollToQuestion(anchorId);
|
||||||
|
setSheetOpen(false);
|
||||||
|
window.setTimeout(
|
||||||
|
() => scrollToQuestion(anchorId),
|
||||||
|
SHEET_SCROLL_RETRY_MS,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
className="min-h-0 flex-1"
|
className="min-h-0 flex-1"
|
||||||
/>
|
/>
|
||||||
@@ -272,17 +405,22 @@ function QuestionCardList({
|
|||||||
className?: string;
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
const itemRefs = useRef(new Map<string, HTMLButtonElement>());
|
const itemRefs = useRef(new Map<string, HTMLButtonElement>());
|
||||||
|
const navRef = useRef<HTMLElement | null>(null);
|
||||||
|
|
||||||
// Keep the active card visible as the chat scrolls. `block: "nearest"` only
|
// Keep the active card visible as the chat scrolls. Scroll only this inner
|
||||||
// nudges this inner list — the card is already inside the on-screen panel,
|
// list — `scrollIntoView({ block: "nearest" })` on Chrome 102 also moves
|
||||||
// so no outer container moves.
|
// ancestor conversation scrollers, which undoes the jump to the question.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!activeId) return;
|
if (!activeId) return;
|
||||||
itemRefs.current.get(activeId)?.scrollIntoView({ block: "nearest" });
|
const item = itemRefs.current.get(activeId);
|
||||||
|
const nav = navRef.current;
|
||||||
|
if (!item || !nav) return;
|
||||||
|
scrollItemNearestInParent(item, nav);
|
||||||
}, [activeId]);
|
}, [activeId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
|
ref={navRef}
|
||||||
aria-label="问题导航"
|
aria-label="问题导航"
|
||||||
className={cn("flex flex-col gap-2 overflow-y-auto p-2", className)}
|
className={cn("flex flex-col gap-2 overflow-y-auto p-2", className)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -7,19 +7,19 @@ import {
|
|||||||
Download,
|
Download,
|
||||||
FileJson,
|
FileJson,
|
||||||
FileText,
|
FileText,
|
||||||
MessageSquare,
|
|
||||||
MoreHorizontal,
|
MoreHorizontal,
|
||||||
Pencil,
|
Pencil,
|
||||||
Pin,
|
Pin,
|
||||||
PinOff,
|
PinOff,
|
||||||
|
Search,
|
||||||
Share2,
|
Share2,
|
||||||
Star,
|
Star,
|
||||||
Trash2,
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useParams, usePathname, useRouter } from "next/navigation";
|
import { useParams, usePathname, useRouter } from "next/navigation";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -91,6 +91,8 @@ import {
|
|||||||
useRecentStrategyProjects,
|
useRecentStrategyProjects,
|
||||||
} from "@/strategy-selection/recent-projects";
|
} from "@/strategy-selection/recent-projects";
|
||||||
|
|
||||||
|
import { historyAvatarForThread } from "./chat-history-avatar";
|
||||||
|
|
||||||
export function RecentChatList({
|
export function RecentChatList({
|
||||||
compact = false,
|
compact = false,
|
||||||
limit,
|
limit,
|
||||||
@@ -137,6 +139,7 @@ export function RecentChatList({
|
|||||||
|
|
||||||
// Share dialog state — the conversation whose share code is being shown.
|
// Share dialog state — the conversation whose share code is being shown.
|
||||||
const [shareThreadId, setShareThreadId] = useState<string | null>(null);
|
const [shareThreadId, setShareThreadId] = useState<string | null>(null);
|
||||||
|
const [query, setQuery] = useState("");
|
||||||
|
|
||||||
const handleDelete = useCallback(
|
const handleDelete = useCallback(
|
||||||
(threadId: string) => {
|
(threadId: string) => {
|
||||||
@@ -218,10 +221,27 @@ export function RecentChatList({
|
|||||||
recentStrategyProjects,
|
recentStrategyProjects,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const shownItems = useMemo(() => {
|
||||||
|
const normalizedQuery = query.trim().toLowerCase();
|
||||||
|
const matchingItems = normalizedQuery
|
||||||
|
? recentItems.filter((item) =>
|
||||||
|
(item.kind === "thread"
|
||||||
|
? titleOfThread(item.thread, t.pages.newChat)
|
||||||
|
: item.project.title
|
||||||
|
)
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(normalizedQuery),
|
||||||
|
)
|
||||||
|
: recentItems;
|
||||||
|
return normalizedQuery || limit == null
|
||||||
|
? matchingItems
|
||||||
|
: matchingItems.slice(0, limit);
|
||||||
|
}, [limit, query, recentItems, t.pages.newChat]);
|
||||||
|
|
||||||
if (recentItems.length === 0) {
|
if (recentItems.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const shownItems = limit != null ? recentItems.slice(0, limit) : recentItems;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SidebarGroup
|
<SidebarGroup
|
||||||
@@ -259,26 +279,42 @@ export function RecentChatList({
|
|||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
|
<div className="relative mb-1.5 px-1">
|
||||||
|
<Search className="pointer-events-none absolute top-1/2 left-3.5 size-3.5 -translate-y-1/2 text-muted-foreground/60" />
|
||||||
|
<Input
|
||||||
|
type="search"
|
||||||
|
value={query}
|
||||||
|
onChange={(event) => setQuery(event.target.value)}
|
||||||
|
placeholder="搜索历史会话…"
|
||||||
|
aria-label="搜索历史会话"
|
||||||
|
className="h-8 rounded-xl border-border bg-card pl-8 pr-2 text-[12px] shadow-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="flex w-full flex-col gap-0.5">
|
<div className="flex w-full flex-col gap-0.5">
|
||||||
{shownItems.map((item) => {
|
{shownItems.length === 0 ? (
|
||||||
|
<div className="px-3 py-4 text-center text-[12px] text-muted-foreground/70">
|
||||||
|
没有匹配的会话
|
||||||
|
</div>
|
||||||
|
) : shownItems.map((item) => {
|
||||||
if (item.kind === "strategy-project") {
|
if (item.kind === "strategy-project") {
|
||||||
const { project } = item;
|
const { project } = item;
|
||||||
const href = strategyProjectWorkbenchPath(
|
const href = strategyProjectWorkbenchPath(
|
||||||
"/page/strategy/qa/projects",
|
"/page/strategy/qa/projects",
|
||||||
project.id,
|
project.id,
|
||||||
);
|
);
|
||||||
|
const isActive = href === pathname;
|
||||||
return (
|
return (
|
||||||
<SidebarMenuItem
|
<SidebarMenuItem
|
||||||
key={`strategy-project:${project.id}`}
|
key={`strategy-project:${project.id}`}
|
||||||
className="group/side-menu-item"
|
className="group/side-menu-item"
|
||||||
>
|
>
|
||||||
<SidebarMenuButton
|
<SidebarMenuButton
|
||||||
isActive={href === pathname}
|
isActive={isActive}
|
||||||
asChild
|
asChild
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-auto min-h-11 rounded-lg px-3 py-1.5 text-[13px] text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
|
"gq-history-item relative h-auto min-h-11 overflow-hidden rounded-xl px-3 py-1.5 text-[13px] text-foreground/80 transition-[background-color,color,box-shadow] duration-150 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
|
||||||
"data-[active=true]:bg-white data-[active=true]:text-foreground data-[active=true]:shadow-[0_1px_2px_rgba(15,23,42,0.05)]",
|
isActive && "gq-history-item--active",
|
||||||
"dark:data-[active=true]:bg-slate-700/80 dark:data-[active=true]:text-slate-100 dark:data-[active=true]:shadow-none",
|
"data-[active=true]:bg-primary/[0.11] data-[active=true]:font-medium data-[active=true]:text-primary data-[active=true]:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] data-[active=true]:hover:bg-primary/[0.15]",
|
||||||
compact &&
|
compact &&
|
||||||
"min-h-11 gap-2 rounded-md px-2.5 data-[active=true]:border data-[active=true]:border-border",
|
"min-h-11 gap-2 rounded-md px-2.5 data-[active=true]:border data-[active=true]:border-border",
|
||||||
)}
|
)}
|
||||||
@@ -292,7 +328,7 @@ export function RecentChatList({
|
|||||||
>
|
>
|
||||||
<MyProjectThreadIcon type="strategy" />
|
<MyProjectThreadIcon type="strategy" />
|
||||||
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
|
<span className="min-w-0 flex-1 flex flex-col items-start gap-0.5">
|
||||||
<span className="w-full truncate">
|
<span className="block w-full truncate">
|
||||||
{desensitize(project.title)}
|
{desensitize(project.title)}
|
||||||
</span>
|
</span>
|
||||||
<MyProjectThreadBadge
|
<MyProjectThreadBadge
|
||||||
@@ -326,9 +362,9 @@ export function RecentChatList({
|
|||||||
isActive={isActive}
|
isActive={isActive}
|
||||||
asChild
|
asChild
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-7 rounded-lg px-3 text-[13px] text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground",
|
"gq-history-item relative h-9 overflow-hidden rounded-xl px-3 text-[13px] text-foreground/80 transition-[background-color,color,box-shadow] duration-150 hover:bg-muted/80 hover:text-foreground hover:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/9%)]",
|
||||||
"data-[active=true]:bg-white data-[active=true]:text-foreground data-[active=true]:shadow-[0_1px_2px_rgba(15,23,42,0.05)]",
|
isActive && "gq-history-item--active",
|
||||||
"dark:data-[active=true]:bg-slate-700/80 dark:data-[active=true]:text-slate-100 dark:data-[active=true]:shadow-none",
|
"data-[active=true]:bg-primary/[0.11] data-[active=true]:font-medium data-[active=true]:text-primary data-[active=true]:shadow-[inset_0_0_0_1px_rgb(var(--legacy-primary-rgb)/22%),0_2px_8px_rgb(var(--legacy-primary-rgb)/7%)] data-[active=true]:hover:bg-primary/[0.15]",
|
||||||
compact &&
|
compact &&
|
||||||
"h-9 gap-2 rounded-md px-2.5 data-[active=true]:border data-[active=true]:border-border",
|
"h-9 gap-2 rounded-md px-2.5 data-[active=true]:border data-[active=true]:border-border",
|
||||||
projectInfo && "h-auto min-h-11 py-1.5",
|
projectInfo && "h-auto min-h-11 py-1.5",
|
||||||
@@ -352,16 +388,13 @@ export function RecentChatList({
|
|||||||
) : projectInfo ? (
|
) : projectInfo ? (
|
||||||
<MyProjectThreadIcon type={projectInfo.type} />
|
<MyProjectThreadIcon type={projectInfo.type} />
|
||||||
) : (
|
) : (
|
||||||
compact && (
|
<img
|
||||||
<MessageSquare
|
src={historyAvatarForThread(thread.thread_id)}
|
||||||
className={
|
alt=""
|
||||||
"size-3.5 shrink-0 " +
|
aria-hidden="true"
|
||||||
(isActive
|
draggable={false}
|
||||||
? "text-[var(--primary)]"
|
className="size-5 shrink-0 object-contain"
|
||||||
: "text-muted-foreground/70")
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
{pinned && (
|
{pinned && (
|
||||||
<Pin className="size-3 shrink-0 text-muted-foreground/70" />
|
<Pin className="size-3 shrink-0 text-muted-foreground/70" />
|
||||||
@@ -372,7 +405,7 @@ export function RecentChatList({
|
|||||||
projectInfo && "flex flex-col items-start gap-0.5",
|
projectInfo && "flex flex-col items-start gap-0.5",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span className="w-full truncate">
|
<span className="block w-full truncate">
|
||||||
{desensitize(titleOfThread(thread, t.pages.newChat))}
|
{desensitize(titleOfThread(thread, t.pages.newChat))}
|
||||||
</span>
|
</span>
|
||||||
{projectInfo && (
|
{projectInfo && (
|
||||||
@@ -485,7 +518,7 @@ export function RecentChatList({
|
|||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{moreHref && (
|
{moreHref && !query.trim() && (
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton
|
<SidebarMenuButton
|
||||||
asChild
|
asChild
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
Trash2Icon,
|
Trash2Icon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { confirmAction, toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -92,7 +92,11 @@ export function ShareRoundtableDraftDialog({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleRevoke() {
|
async function handleRevoke() {
|
||||||
if (!share || !window.confirm("撤销后此分享立即失效,确定吗?")) return;
|
if (!share || !(await confirmAction("撤销后此分享立即失效,确定吗?", {
|
||||||
|
title: "撤销分享?",
|
||||||
|
confirmText: "撤销分享",
|
||||||
|
danger: true,
|
||||||
|
}))) return;
|
||||||
try {
|
try {
|
||||||
await revokeShare.mutateAsync(share.share_code);
|
await revokeShare.mutateAsync(share.share_code);
|
||||||
toast.success("已撤销分享");
|
toast.success("已撤销分享");
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { CopyIcon, LogOutIcon, UserIcon } from "lucide-react";
|
import { CopyIcon, LogOutIcon, UserIcon } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Clock3Icon, DatabaseIcon, GlobeIcon, RefreshCwIcon, SaveIcon, SearchIcon } from "lucide-react";
|
import { Clock3Icon, DatabaseIcon, GlobeIcon, RefreshCwIcon, SaveIcon, SearchIcon } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ImageUp, Loader2, RotateCcw } from "lucide-react";
|
import { ImageUp, Loader2, RotateCcw } from "lucide-react";
|
||||||
import { useEffect, useMemo, useRef, useState, type ChangeEvent } from "react";
|
import {
|
||||||
import { toast } from "sonner";
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
type ChangeEvent,
|
||||||
|
type RefObject,
|
||||||
|
} from "react";
|
||||||
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
|
import defaultLightRedNavActive from "@/assets/img/nav-active-light-red.svg";
|
||||||
|
import defaultLightRedHeaderBackground from "@/assets/img/top-bg-light-red.svg";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -13,17 +22,35 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||||
import { useTheme } from "@/contexts/ThemeContext";
|
import { useTheme } from "@/contexts/ThemeContext";
|
||||||
import {
|
import {
|
||||||
getHeaderBrandAsset,
|
getHeaderBrandAsset,
|
||||||
getHeaderBrandFallback,
|
getHeaderBrandFallback,
|
||||||
} from "@/core/branding/brand-assets";
|
} from "@/core/branding/brand-assets";
|
||||||
import { resolveAppIdentityLogoUrl } from "@/core/system-settings/api";
|
import {
|
||||||
|
clearHeaderTitlePreview,
|
||||||
|
setHeaderTitlePreview,
|
||||||
|
} from "@/core/branding/header-title-preview";
|
||||||
|
import {
|
||||||
|
clearLightRedNavigationPreview,
|
||||||
|
setLightRedNavigationPreview,
|
||||||
|
} from "@/core/branding/light-red-navigation-preview";
|
||||||
|
import {
|
||||||
|
resolveAppIdentityAssetUrl,
|
||||||
|
resolveAppIdentityLogoUrl,
|
||||||
|
type AppIdentityHeaderTitleFontMode,
|
||||||
|
} from "@/core/system-settings/api";
|
||||||
import {
|
import {
|
||||||
useAppIdentitySettings,
|
useAppIdentitySettings,
|
||||||
useDeleteAppIdentitySettings,
|
useDeleteAppIdentitySettings,
|
||||||
useUpdateAppIdentitySettings,
|
useUpdateAppIdentitySettings,
|
||||||
} from "@/core/system-settings/hooks";
|
} from "@/core/system-settings/hooks";
|
||||||
|
import {
|
||||||
|
HEADER_TITLE_FIXED_MAX_FONT_SIZE,
|
||||||
|
HEADER_TITLE_FIXED_MIN_FONT_SIZE,
|
||||||
|
HEADER_TITLE_MAX_FONT_SIZE,
|
||||||
|
} from "@/strategy-components/header-title-fit";
|
||||||
|
|
||||||
import { SettingsSection } from "./settings-section";
|
import { SettingsSection } from "./settings-section";
|
||||||
|
|
||||||
@@ -33,6 +60,121 @@ const ACCEPTED_LOGO_TYPES = new Set([
|
|||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
"image/webp",
|
"image/webp",
|
||||||
]);
|
]);
|
||||||
|
const ACCEPTED_NAVIGATION_IMAGE_TYPES = new Set([
|
||||||
|
...ACCEPTED_LOGO_TYPES,
|
||||||
|
"image/svg+xml",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const isAcceptedNavigationImage = (file: File) =>
|
||||||
|
ACCEPTED_NAVIGATION_IMAGE_TYPES.has(file.type) ||
|
||||||
|
(file.type === "" && file.name.toLowerCase().endsWith(".svg"));
|
||||||
|
|
||||||
|
const clampHeaderTitleFontSize = (value: number) =>
|
||||||
|
Math.min(
|
||||||
|
HEADER_TITLE_FIXED_MAX_FONT_SIZE,
|
||||||
|
Math.max(HEADER_TITLE_FIXED_MIN_FONT_SIZE, Math.round(value)),
|
||||||
|
);
|
||||||
|
|
||||||
|
interface NavigationImageUploadCardProps {
|
||||||
|
inputId: string;
|
||||||
|
inputRef: RefObject<HTMLInputElement | null>;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
previewUrl: string;
|
||||||
|
previewAlt: string;
|
||||||
|
previewImageClassName: string;
|
||||||
|
pendingFile: File | null;
|
||||||
|
hasCustomImage: boolean;
|
||||||
|
restoringDefault: boolean;
|
||||||
|
disabled: boolean;
|
||||||
|
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
||||||
|
onRestoreDefault: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function NavigationImageUploadCard({
|
||||||
|
inputId,
|
||||||
|
inputRef,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
previewUrl,
|
||||||
|
previewAlt,
|
||||||
|
previewImageClassName,
|
||||||
|
pendingFile,
|
||||||
|
hasCustomImage,
|
||||||
|
restoringDefault,
|
||||||
|
disabled,
|
||||||
|
onChange,
|
||||||
|
onRestoreDefault,
|
||||||
|
}: NavigationImageUploadCardProps) {
|
||||||
|
return (
|
||||||
|
<div className="grid gap-4 rounded-lg border bg-muted/20 p-4 sm:grid-cols-[minmax(220px,2fr)_minmax(180px,1fr)]">
|
||||||
|
<div className="flex h-28 items-center justify-center overflow-hidden rounded-lg border border-dashed bg-slate-950/90 p-2">
|
||||||
|
<img
|
||||||
|
src={previewUrl}
|
||||||
|
alt={previewAlt}
|
||||||
|
className={previewImageClassName}
|
||||||
|
loading="lazy"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex min-w-0 flex-col justify-center gap-3">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">{title}</div>
|
||||||
|
<p className="mt-1 text-xs leading-5 text-muted-foreground">
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
ref={inputRef}
|
||||||
|
id={inputId}
|
||||||
|
type="file"
|
||||||
|
accept="image/png,image/jpeg,image/webp,image/svg+xml,.svg"
|
||||||
|
aria-label={`${title}文件`}
|
||||||
|
className="sr-only"
|
||||||
|
onChange={onChange}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
className="h-11"
|
||||||
|
onClick={() => inputRef.current?.click()}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<ImageUp aria-hidden />
|
||||||
|
{hasCustomImage || pendingFile ? "更换图片" : "上传图片"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
className="h-11"
|
||||||
|
onClick={onRestoreDefault}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(!hasCustomImage && !pendingFile) ||
|
||||||
|
(restoringDefault && !pendingFile)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
恢复默认
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{pendingFile && (
|
||||||
|
<p
|
||||||
|
className="truncate text-xs text-muted-foreground"
|
||||||
|
title={pendingFile.name}
|
||||||
|
>
|
||||||
|
待上传:{pendingFile.name}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{restoringDefault && !pendingFile && (
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
保存后使用当前内置图片。
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function AppIdentitySettingsPage() {
|
export function AppIdentitySettingsPage() {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
@@ -43,22 +185,72 @@ export function AppIdentitySettingsPage() {
|
|||||||
const updateIdentity = useUpdateAppIdentitySettings();
|
const updateIdentity = useUpdateAppIdentitySettings();
|
||||||
const deleteIdentity = useDeleteAppIdentitySettings();
|
const deleteIdentity = useDeleteAppIdentitySettings();
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const headerBackgroundInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const navActiveInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [systemName, setSystemName] = useState("");
|
const [systemName, setSystemName] = useState("");
|
||||||
|
const [headerTitleFontMode, setHeaderTitleFontMode] =
|
||||||
|
useState<AppIdentityHeaderTitleFontMode>("adaptive");
|
||||||
|
const [headerTitleFontSize, setHeaderTitleFontSize] = useState(
|
||||||
|
HEADER_TITLE_MAX_FONT_SIZE,
|
||||||
|
);
|
||||||
const [pendingLogo, setPendingLogo] = useState<File | null>(null);
|
const [pendingLogo, setPendingLogo] = useState<File | null>(null);
|
||||||
const [removeLogo, setRemoveLogo] = useState(false);
|
const [removeLogo, setRemoveLogo] = useState(false);
|
||||||
|
const [pendingHeaderBackground, setPendingHeaderBackground] =
|
||||||
|
useState<File | null>(null);
|
||||||
|
const [removeHeaderBackground, setRemoveHeaderBackground] = useState(false);
|
||||||
|
const [pendingNavActive, setPendingNavActive] = useState<File | null>(null);
|
||||||
|
const [removeNavActive, setRemoveNavActive] = useState(false);
|
||||||
|
const [navigationImagesTouched, setNavigationImagesTouched] = useState(false);
|
||||||
const [resetOpen, setResetOpen] = useState(false);
|
const [resetOpen, setResetOpen] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSystemName(identity?.system_name ?? "");
|
setSystemName(identity?.system_name ?? "");
|
||||||
|
setHeaderTitleFontMode(identity?.header_title_font_mode ?? "adaptive");
|
||||||
|
setHeaderTitleFontSize(
|
||||||
|
clampHeaderTitleFontSize(
|
||||||
|
identity?.header_title_font_size ?? HEADER_TITLE_MAX_FONT_SIZE,
|
||||||
|
),
|
||||||
|
);
|
||||||
setPendingLogo(null);
|
setPendingLogo(null);
|
||||||
setRemoveLogo(false);
|
setRemoveLogo(false);
|
||||||
|
setPendingHeaderBackground(null);
|
||||||
|
setRemoveHeaderBackground(false);
|
||||||
|
setPendingNavActive(null);
|
||||||
|
setRemoveNavActive(false);
|
||||||
|
setNavigationImagesTouched(false);
|
||||||
if (fileInputRef.current) fileInputRef.current.value = "";
|
if (fileInputRef.current) fileInputRef.current.value = "";
|
||||||
}, [identity?.system_name, identity?.logo_version, identity?.has_logo]);
|
if (headerBackgroundInputRef.current) {
|
||||||
|
headerBackgroundInputRef.current.value = "";
|
||||||
|
}
|
||||||
|
if (navActiveInputRef.current) navActiveInputRef.current.value = "";
|
||||||
|
}, [
|
||||||
|
identity?.system_name,
|
||||||
|
identity?.header_title_font_mode,
|
||||||
|
identity?.header_title_font_size,
|
||||||
|
identity?.logo_version,
|
||||||
|
identity?.has_logo,
|
||||||
|
identity?.light_red_header_background_version,
|
||||||
|
identity?.has_light_red_header_background,
|
||||||
|
identity?.light_red_nav_active_version,
|
||||||
|
identity?.has_light_red_nav_active,
|
||||||
|
]);
|
||||||
|
|
||||||
const previewUrl = useMemo(
|
const previewUrl = useMemo(
|
||||||
() => (pendingLogo ? URL.createObjectURL(pendingLogo) : undefined),
|
() => (pendingLogo ? URL.createObjectURL(pendingLogo) : undefined),
|
||||||
[pendingLogo],
|
[pendingLogo],
|
||||||
);
|
);
|
||||||
|
const headerBackgroundPreviewUrl = useMemo(
|
||||||
|
() =>
|
||||||
|
pendingHeaderBackground
|
||||||
|
? URL.createObjectURL(pendingHeaderBackground)
|
||||||
|
: undefined,
|
||||||
|
[pendingHeaderBackground],
|
||||||
|
);
|
||||||
|
const navActivePreviewUrl = useMemo(
|
||||||
|
() =>
|
||||||
|
pendingNavActive ? URL.createObjectURL(pendingNavActive) : undefined,
|
||||||
|
[pendingNavActive],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
@@ -67,16 +259,86 @@ export function AppIdentitySettingsPage() {
|
|||||||
[previewUrl],
|
[previewUrl],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
if (headerBackgroundPreviewUrl) {
|
||||||
|
URL.revokeObjectURL(headerBackgroundPreviewUrl);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[headerBackgroundPreviewUrl],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
if (navActivePreviewUrl) URL.revokeObjectURL(navActivePreviewUrl);
|
||||||
|
},
|
||||||
|
[navActivePreviewUrl],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
clearHeaderTitlePreview();
|
||||||
|
clearLightRedNavigationPreview();
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
const savedLogoUrl = removeLogo
|
const savedLogoUrl = removeLogo
|
||||||
? undefined
|
? undefined
|
||||||
: resolveAppIdentityLogoUrl(identity?.logo_url);
|
: resolveAppIdentityLogoUrl(identity?.logo_url);
|
||||||
const displayedLogoUrl = previewUrl ?? savedLogoUrl;
|
const displayedLogoUrl = previewUrl ?? savedLogoUrl;
|
||||||
|
const savedHeaderBackgroundUrl = removeHeaderBackground
|
||||||
|
? undefined
|
||||||
|
: resolveAppIdentityAssetUrl(
|
||||||
|
identity?.light_red_header_background_url,
|
||||||
|
);
|
||||||
|
const savedNavActiveUrl = removeNavActive
|
||||||
|
? undefined
|
||||||
|
: resolveAppIdentityAssetUrl(identity?.light_red_nav_active_url);
|
||||||
|
const displayedHeaderBackgroundUrl =
|
||||||
|
headerBackgroundPreviewUrl ??
|
||||||
|
savedHeaderBackgroundUrl ??
|
||||||
|
defaultLightRedHeaderBackground;
|
||||||
|
const displayedNavActiveUrl =
|
||||||
|
navActivePreviewUrl ?? savedNavActiveUrl ?? defaultLightRedNavActive;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!navigationImagesTouched) return;
|
||||||
|
setLightRedNavigationPreview({
|
||||||
|
headerBackgroundUrl:
|
||||||
|
headerBackgroundPreviewUrl ?? savedHeaderBackgroundUrl ?? null,
|
||||||
|
navActiveUrl: navActivePreviewUrl ?? savedNavActiveUrl ?? null,
|
||||||
|
});
|
||||||
|
}, [
|
||||||
|
headerBackgroundPreviewUrl,
|
||||||
|
navigationImagesTouched,
|
||||||
|
navActivePreviewUrl,
|
||||||
|
savedHeaderBackgroundUrl,
|
||||||
|
savedNavActiveUrl,
|
||||||
|
]);
|
||||||
|
|
||||||
const normalizedName = systemName.trim().replace(/\s+/g, " ");
|
const normalizedName = systemName.trim().replace(/\s+/g, " ");
|
||||||
const hasChanges =
|
const hasChanges =
|
||||||
normalizedName !== (identity?.system_name ?? "") ||
|
normalizedName !== (identity?.system_name ?? "") ||
|
||||||
|
headerTitleFontMode !==
|
||||||
|
(identity?.header_title_font_mode ?? "adaptive") ||
|
||||||
|
clampHeaderTitleFontSize(headerTitleFontSize) !==
|
||||||
|
(identity?.header_title_font_size ?? HEADER_TITLE_MAX_FONT_SIZE) ||
|
||||||
Boolean(pendingLogo) ||
|
Boolean(pendingLogo) ||
|
||||||
removeLogo;
|
removeLogo ||
|
||||||
const customized = Boolean(identity?.system_name || identity?.has_logo);
|
Boolean(pendingHeaderBackground) ||
|
||||||
|
removeHeaderBackground ||
|
||||||
|
Boolean(pendingNavActive) ||
|
||||||
|
removeNavActive;
|
||||||
|
const customized = Boolean(
|
||||||
|
identity?.system_name ||
|
||||||
|
identity?.has_logo ||
|
||||||
|
identity?.has_light_red_header_background ||
|
||||||
|
identity?.has_light_red_nav_active ||
|
||||||
|
(identity?.header_title_font_mode ?? "adaptive") !== "adaptive" ||
|
||||||
|
(identity?.header_title_font_size ?? HEADER_TITLE_MAX_FONT_SIZE) !==
|
||||||
|
HEADER_TITLE_MAX_FONT_SIZE,
|
||||||
|
);
|
||||||
const busy = updateIdentity.isPending || deleteIdentity.isPending;
|
const busy = updateIdentity.isPending || deleteIdentity.isPending;
|
||||||
|
|
||||||
const handleLogoChange = (event: ChangeEvent<HTMLInputElement>) => {
|
const handleLogoChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
@@ -102,26 +364,82 @@ export function AppIdentitySettingsPage() {
|
|||||||
if (fileInputRef.current) fileInputRef.current.value = "";
|
if (fileInputRef.current) fileInputRef.current.value = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleHeaderBackgroundChange = (
|
||||||
|
event: ChangeEvent<HTMLInputElement>,
|
||||||
|
) => {
|
||||||
|
const file = event.target.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
if (!isAcceptedNavigationImage(file)) {
|
||||||
|
toast.error("导航栏背景图仅支持 PNG、JPG、WebP 或 SVG 图片");
|
||||||
|
event.target.value = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPendingHeaderBackground(file);
|
||||||
|
setRemoveHeaderBackground(false);
|
||||||
|
setNavigationImagesTouched(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNavActiveChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const file = event.target.files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
if (!isAcceptedNavigationImage(file)) {
|
||||||
|
toast.error("菜单选中样式图仅支持 PNG、JPG、WebP 或 SVG 图片");
|
||||||
|
event.target.value = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPendingNavActive(file);
|
||||||
|
setRemoveNavActive(false);
|
||||||
|
setNavigationImagesTouched(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUseDefaultHeaderBackground = () => {
|
||||||
|
setPendingHeaderBackground(null);
|
||||||
|
setRemoveHeaderBackground(true);
|
||||||
|
setNavigationImagesTouched(true);
|
||||||
|
if (headerBackgroundInputRef.current) {
|
||||||
|
headerBackgroundInputRef.current.value = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUseDefaultNavActive = () => {
|
||||||
|
setPendingNavActive(null);
|
||||||
|
setRemoveNavActive(true);
|
||||||
|
setNavigationImagesTouched(true);
|
||||||
|
if (navActiveInputRef.current) navActiveInputRef.current.value = "";
|
||||||
|
};
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
try {
|
try {
|
||||||
await updateIdentity.mutateAsync({
|
await updateIdentity.mutateAsync({
|
||||||
systemName: normalizedName,
|
systemName: normalizedName,
|
||||||
|
headerTitleFontMode,
|
||||||
|
headerTitleFontSize: clampHeaderTitleFontSize(headerTitleFontSize),
|
||||||
logo: pendingLogo,
|
logo: pendingLogo,
|
||||||
removeLogo,
|
removeLogo,
|
||||||
|
lightRedHeaderBackground: pendingHeaderBackground,
|
||||||
|
removeLightRedHeaderBackground: removeHeaderBackground,
|
||||||
|
lightRedNavActive: pendingNavActive,
|
||||||
|
removeLightRedNavActive: removeNavActive,
|
||||||
});
|
});
|
||||||
toast.success("系统名称已保存", {
|
setNavigationImagesTouched(false);
|
||||||
description: "导航、侧栏和欢迎区会使用这里的名称和 Logo。",
|
clearHeaderTitlePreview();
|
||||||
|
clearLightRedNavigationPreview();
|
||||||
|
toast.success("系统名称配置已保存", {
|
||||||
|
description: "导航名称、Logo 与红色主题图片已更新。",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(error instanceof Error ? error.message : "系统名称保存失败");
|
toast.error(error instanceof Error ? error.message : "系统名称配置保存失败");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReset = async () => {
|
const handleReset = async () => {
|
||||||
try {
|
try {
|
||||||
await deleteIdentity.mutateAsync();
|
await deleteIdentity.mutateAsync();
|
||||||
|
setNavigationImagesTouched(false);
|
||||||
|
clearHeaderTitlePreview();
|
||||||
|
clearLightRedNavigationPreview();
|
||||||
setResetOpen(false);
|
setResetOpen(false);
|
||||||
toast.success("已恢复默认系统名称和 Logo");
|
toast.success("已恢复默认系统名称、Logo、字号模式和导航图片");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(error instanceof Error ? error.message : "清除系统名称失败");
|
toast.error(error instanceof Error ? error.message : "清除系统名称失败");
|
||||||
}
|
}
|
||||||
@@ -131,7 +449,7 @@ export function AppIdentitySettingsPage() {
|
|||||||
<>
|
<>
|
||||||
<SettingsSection
|
<SettingsSection
|
||||||
title="系统名称"
|
title="系统名称"
|
||||||
description="修改本系统导航栏、侧栏和欢迎区显示的名称与 Logo。名称留空时继续使用现有名称;没有上传 Logo 时继续使用内置静态图片。这里不会改「生成网页标识」。"
|
description="修改本系统导航栏、侧栏和欢迎区显示的名称与 Logo,并设置顶部导航中的名称字号及红色主题图片。未上传自定义图片时继续使用当前内置图片。这里不会改「生成网页标识」。"
|
||||||
>
|
>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -152,6 +470,131 @@ export function AppIdentitySettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">导航栏名称字号</div>
|
||||||
|
<p className="mt-1 text-xs leading-5 text-muted-foreground">
|
||||||
|
自适应会根据导航栏凹槽的可用宽度自动调整;固定大小始终使用指定字号。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<ToggleGroup
|
||||||
|
type="single"
|
||||||
|
value={headerTitleFontMode}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
if (value) {
|
||||||
|
const mode = value as AppIdentityHeaderTitleFontMode;
|
||||||
|
setHeaderTitleFontMode(mode);
|
||||||
|
setHeaderTitlePreview({
|
||||||
|
mode,
|
||||||
|
fontSize: clampHeaderTitleFontSize(headerTitleFontSize),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
variant="outline"
|
||||||
|
aria-label="导航栏名称字号模式"
|
||||||
|
disabled={isPending || busy}
|
||||||
|
className="w-full sm:w-fit"
|
||||||
|
>
|
||||||
|
<ToggleGroupItem
|
||||||
|
value="adaptive"
|
||||||
|
className="h-11 flex-1 px-5 sm:flex-none"
|
||||||
|
>
|
||||||
|
自适应
|
||||||
|
</ToggleGroupItem>
|
||||||
|
<ToggleGroupItem
|
||||||
|
value="fixed"
|
||||||
|
className="h-11 flex-1 px-5 sm:flex-none"
|
||||||
|
>
|
||||||
|
固定大小
|
||||||
|
</ToggleGroupItem>
|
||||||
|
</ToggleGroup>
|
||||||
|
|
||||||
|
{headerTitleFontMode === "fixed" ? (
|
||||||
|
<div className="grid gap-3 rounded-lg border bg-muted/20 p-4 sm:grid-cols-[minmax(0,1fr)_112px] sm:items-center">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label
|
||||||
|
htmlFor="app-identity-header-font-size-range"
|
||||||
|
className="text-sm font-medium"
|
||||||
|
>
|
||||||
|
固定字号
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="app-identity-header-font-size-range"
|
||||||
|
type="range"
|
||||||
|
min={HEADER_TITLE_FIXED_MIN_FONT_SIZE}
|
||||||
|
max={HEADER_TITLE_FIXED_MAX_FONT_SIZE}
|
||||||
|
step={1}
|
||||||
|
value={clampHeaderTitleFontSize(headerTitleFontSize)}
|
||||||
|
onChange={(event) => {
|
||||||
|
const fontSize = Number(event.target.value);
|
||||||
|
setHeaderTitleFontSize(fontSize);
|
||||||
|
setHeaderTitlePreview({
|
||||||
|
mode: headerTitleFontMode,
|
||||||
|
fontSize,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
disabled={isPending || busy}
|
||||||
|
className="h-11 w-full cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50"
|
||||||
|
aria-valuetext={`${clampHeaderTitleFontSize(headerTitleFontSize)} 像素`}
|
||||||
|
/>
|
||||||
|
<div className="flex justify-between text-xs tabular-nums text-muted-foreground">
|
||||||
|
<span>{HEADER_TITLE_FIXED_MIN_FONT_SIZE}px</span>
|
||||||
|
<span>{HEADER_TITLE_FIXED_MAX_FONT_SIZE}px</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label
|
||||||
|
htmlFor="app-identity-header-font-size"
|
||||||
|
className="text-sm font-medium"
|
||||||
|
>
|
||||||
|
字号数值
|
||||||
|
</label>
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
id="app-identity-header-font-size"
|
||||||
|
type="number"
|
||||||
|
min={HEADER_TITLE_FIXED_MIN_FONT_SIZE}
|
||||||
|
max={HEADER_TITLE_FIXED_MAX_FONT_SIZE}
|
||||||
|
step={1}
|
||||||
|
value={headerTitleFontSize}
|
||||||
|
onChange={(event) => {
|
||||||
|
const value = Number(event.target.value);
|
||||||
|
if (Number.isFinite(value)) {
|
||||||
|
setHeaderTitleFontSize(value);
|
||||||
|
setHeaderTitlePreview({
|
||||||
|
mode: headerTitleFontMode,
|
||||||
|
fontSize: clampHeaderTitleFontSize(value),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
const fontSize =
|
||||||
|
clampHeaderTitleFontSize(headerTitleFontSize);
|
||||||
|
setHeaderTitleFontSize(fontSize);
|
||||||
|
setHeaderTitlePreview({
|
||||||
|
mode: headerTitleFontMode,
|
||||||
|
fontSize,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
disabled={isPending || busy}
|
||||||
|
className="h-11 pr-9 tabular-nums"
|
||||||
|
/>
|
||||||
|
<span className="pointer-events-none absolute inset-y-0 right-3 flex items-center text-sm text-muted-foreground">
|
||||||
|
px
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs leading-5 text-muted-foreground sm:col-span-2">
|
||||||
|
拖动滑杆时顶部导航会同步预览。固定模式不会随分辨率缩放;名称过长时仍保持单行并完整显示,可能超出装饰区域。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<p className="rounded-lg border border-dashed bg-muted/10 px-4 py-3 text-xs leading-5 text-muted-foreground">
|
||||||
|
当前使用自适应模式:最大 30px,空间不足时逐步缩小,最小 24px。
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<div>
|
<div>
|
||||||
<div className="text-sm font-medium">系统 Logo</div>
|
<div className="text-sm font-medium">系统 Logo</div>
|
||||||
@@ -226,6 +669,47 @@ export function AppIdentitySettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">红色主题导航图片</div>
|
||||||
|
<p className="mt-1 text-xs leading-5 text-muted-foreground">
|
||||||
|
分别配置顶部导航栏背景和菜单选中样式。选择图片或恢复默认时,页面顶部会立即同步预览;保存后对所有用户生效。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<NavigationImageUploadCard
|
||||||
|
inputId="app-identity-light-red-header-background"
|
||||||
|
inputRef={headerBackgroundInputRef}
|
||||||
|
title="导航栏背景图"
|
||||||
|
description="支持 PNG、JPG、WebP、SVG;不限制文件大小。建议使用 1920×64 或相同比例的横向通栏图片。"
|
||||||
|
previewUrl={displayedHeaderBackgroundUrl}
|
||||||
|
previewAlt="红色导航栏背景图预览"
|
||||||
|
previewImageClassName="h-full w-full object-cover"
|
||||||
|
pendingFile={pendingHeaderBackground}
|
||||||
|
hasCustomImage={Boolean(
|
||||||
|
identity?.has_light_red_header_background,
|
||||||
|
)}
|
||||||
|
restoringDefault={removeHeaderBackground}
|
||||||
|
disabled={isPending || busy}
|
||||||
|
onChange={handleHeaderBackgroundChange}
|
||||||
|
onRestoreDefault={handleUseDefaultHeaderBackground}
|
||||||
|
/>
|
||||||
|
<NavigationImageUploadCard
|
||||||
|
inputId="app-identity-light-red-nav-active"
|
||||||
|
inputRef={navActiveInputRef}
|
||||||
|
title="菜单选中样式图"
|
||||||
|
description="支持 PNG、JPG、WebP、SVG;不限制文件大小。建议使用与当前 152×42 比例接近的透明图片。"
|
||||||
|
previewUrl={displayedNavActiveUrl}
|
||||||
|
previewAlt="红色导航菜单选中样式图预览"
|
||||||
|
previewImageClassName="max-h-full max-w-full object-contain"
|
||||||
|
pendingFile={pendingNavActive}
|
||||||
|
hasCustomImage={Boolean(identity?.has_light_red_nav_active)}
|
||||||
|
restoringDefault={removeNavActive}
|
||||||
|
disabled={isPending || busy}
|
||||||
|
onChange={handleNavActiveChange}
|
||||||
|
onRestoreDefault={handleUseDefaultNavActive}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-5">
|
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-5">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -244,7 +728,7 @@ export function AppIdentitySettingsPage() {
|
|||||||
disabled={!hasChanges || isPending || busy}
|
disabled={!hasChanges || isPending || busy}
|
||||||
>
|
>
|
||||||
{updateIdentity.isPending && <Loader2 className="animate-spin" aria-hidden />}
|
{updateIdentity.isPending && <Loader2 className="animate-spin" aria-hidden />}
|
||||||
{updateIdentity.isPending ? "保存中..." : "保存系统名称"}
|
{updateIdentity.isPending ? "保存中..." : "保存配置"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -253,10 +737,10 @@ export function AppIdentitySettingsPage() {
|
|||||||
<Dialog open={resetOpen} onOpenChange={setResetOpen}>
|
<Dialog open={resetOpen} onOpenChange={setResetOpen}>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>清除系统名称和 Logo?</DialogTitle>
|
<DialogTitle>清除系统名称配置?</DialogTitle>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
清除后,导航和欢迎区恢复为原来的名称,Logo 恢复为内置静态图片。
|
清除后,导航和欢迎区恢复为原来的名称,Logo 与红色主题导航图片恢复为内置静态图片,名称字号恢复为自适应。
|
||||||
</p>
|
</p>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button type="button" variant="outline" onClick={() => setResetOpen(false)}>
|
<Button type="button" variant="outline" onClick={() => setResetOpen(false)}>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useMemo, useState, type ComponentType, type SVGProps } from "react";
|
import { useEffect, useMemo, useState, type ComponentType, type SVGProps } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { useTheme, type ThemeType } from "@/contexts/ThemeContext";
|
import { useTheme, type ThemeType } from "@/contexts/ThemeContext";
|
||||||
|
|
||||||
@@ -42,6 +42,7 @@ import { isIsolatedSession, setIsolatedSession } from "@/core/embed/embed-sessio
|
|||||||
import { enUS, isLocale, zhCN, type Locale } from "@/core/i18n";
|
import { enUS, isLocale, zhCN, type Locale } from "@/core/i18n";
|
||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
import { useLocalSettings } from "@/core/settings";
|
import { useLocalSettings } from "@/core/settings";
|
||||||
|
import { resolveAgentGridLayout } from "@/core/settings/agent-grid";
|
||||||
import {
|
import {
|
||||||
AGENT_COMPOSER_WIDTH_MAX,
|
AGENT_COMPOSER_WIDTH_MAX,
|
||||||
AGENT_COMPOSER_WIDTH_MIN,
|
AGENT_COMPOSER_WIDTH_MIN,
|
||||||
@@ -92,6 +93,7 @@ import PrivateSquareSettingsPage from "@/pages/PrivateSquareSettingsPage";
|
|||||||
import PublishSquaresSettingsPage from "@/pages/PublishSquaresSettingsPage";
|
import PublishSquaresSettingsPage from "@/pages/PublishSquaresSettingsPage";
|
||||||
import PromptPrefixSettingsPage from "@/pages/PromptPrefixSettingsPage";
|
import PromptPrefixSettingsPage from "@/pages/PromptPrefixSettingsPage";
|
||||||
import SkillCompressionSettingsPage from "@/pages/SkillCompressionSettingsPage";
|
import SkillCompressionSettingsPage from "@/pages/SkillCompressionSettingsPage";
|
||||||
|
import SkillVersioningSettingsPage from "@/pages/SkillVersioningSettingsPage";
|
||||||
|
|
||||||
import { CustomThemeLibrarySettings } from "./custom-theme-library-settings";
|
import { CustomThemeLibrarySettings } from "./custom-theme-library-settings";
|
||||||
import { SettingsSection } from "./settings-section";
|
import { SettingsSection } from "./settings-section";
|
||||||
@@ -499,6 +501,13 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
|
|||||||
const globalDefault = appearance?.default_theme ?? "light";
|
const globalDefault = appearance?.default_theme ?? "light";
|
||||||
const globalSkillView = appearance?.default_skill_view ?? "list";
|
const globalSkillView = appearance?.default_skill_view ?? "list";
|
||||||
const globalAgentView = appearance?.default_agent_view ?? "card";
|
const globalAgentView = appearance?.default_agent_view ?? "card";
|
||||||
|
const agentGrid = resolveAgentGridLayout(settings.display, appearance);
|
||||||
|
const agentGridSummary = agentGrid.adaptive
|
||||||
|
? "自适应(普通屏 4 列,3K 以上 5 列)"
|
||||||
|
: `固定每行 ${agentGrid.columns} 张`;
|
||||||
|
const adminGridSummary = agentGrid.adminAdaptive
|
||||||
|
? "自适应(普通屏 4 列,3K 以上 5 列)"
|
||||||
|
: `固定每行 ${agentGrid.adminColumns} 张`;
|
||||||
const globalLayoutMode = appearance?.default_layout_mode ?? "compact";
|
const globalLayoutMode = appearance?.default_layout_mode ?? "compact";
|
||||||
const globalDefaultLabel = useMemo(() => {
|
const globalDefaultLabel = useMemo(() => {
|
||||||
const customTheme = (appearance?.custom_themes ?? []).find(
|
const customTheme = (appearance?.custom_themes ?? []).find(
|
||||||
@@ -1211,6 +1220,175 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">智能体卡片每行数量(个人)</div>
|
||||||
|
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
|
||||||
|
{agentGrid.followingAdmin
|
||||||
|
? `列表当前按管理员设置显示:${adminGridSummary}。只影响本浏览器。`
|
||||||
|
: `列表当前使用个人设置:${agentGridSummary},没有采用管理员的${adminGridSummary}。打开右侧开关后立即改回管理员设置。`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
|
<span className="text-xs text-muted-foreground">跟随管理员</span>
|
||||||
|
<Switch
|
||||||
|
checked={agentGrid.followingAdmin}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
if (checked) {
|
||||||
|
setSettings("display", {
|
||||||
|
agentGridFollowAdmin: undefined,
|
||||||
|
agentGridAdaptive: undefined,
|
||||||
|
agentGridColumns: undefined,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSettings("display", {
|
||||||
|
agentGridFollowAdmin: false,
|
||||||
|
agentGridAdaptive: agentGrid.adminAdaptive,
|
||||||
|
agentGridColumns: agentGrid.adminAdaptive
|
||||||
|
? undefined
|
||||||
|
: agentGrid.adminColumns,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
aria-label="跟随管理员的智能体卡片列数"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{!agentGrid.followingAdmin && (
|
||||||
|
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">个人自适应</div>
|
||||||
|
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
|
||||||
|
开启后按窗口宽度排列(普通屏 4 列、3K 以上 5 列)。关闭后使用下方固定列数。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={agentGrid.adaptive}
|
||||||
|
onCheckedChange={(checked) =>
|
||||||
|
setSettings("display", {
|
||||||
|
agentGridFollowAdmin: false,
|
||||||
|
agentGridAdaptive: checked,
|
||||||
|
agentGridColumns: checked ? undefined : agentGrid.columns,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
aria-label="个人自适应列数"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!agentGrid.followingAdmin && !agentGrid.adaptive && (
|
||||||
|
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">每行卡片数(个人固定)</div>
|
||||||
|
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
|
||||||
|
卡片视图固定使用该列数(1-8),只影响本浏览器。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
className="size-8"
|
||||||
|
aria-label="减少每行卡片数"
|
||||||
|
disabled={agentGrid.columns <= 1}
|
||||||
|
onClick={() =>
|
||||||
|
setSettings("display", {
|
||||||
|
agentGridFollowAdmin: false,
|
||||||
|
agentGridAdaptive: false,
|
||||||
|
agentGridColumns: Math.max(1, agentGrid.columns - 1),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
-
|
||||||
|
</Button>
|
||||||
|
<span className="w-8 text-center text-sm font-semibold tabular-nums">
|
||||||
|
{agentGrid.columns}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
className="size-8"
|
||||||
|
aria-label="增加每行卡片数"
|
||||||
|
disabled={agentGrid.columns >= 8}
|
||||||
|
onClick={() =>
|
||||||
|
setSettings("display", {
|
||||||
|
agentGridFollowAdmin: false,
|
||||||
|
agentGridAdaptive: false,
|
||||||
|
agentGridColumns: Math.min(8, agentGrid.columns + 1),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
+
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{isAdmin && (
|
||||||
|
<div className="flex items-start justify-between gap-4 rounded-lg border border-primary/25 bg-primary/[0.03] p-4">
|
||||||
|
<div>
|
||||||
|
<div className="text-sm font-medium">智能体卡片网格默认值(管理员)</div>
|
||||||
|
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
|
||||||
|
关闭自适应后,智能体卡片页按这里的固定列数排列。已经关掉「跟随管理员」的浏览器仍用自己的列数。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex shrink-0 flex-col items-end gap-2">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="text-xs text-muted-foreground">自适应</span>
|
||||||
|
<Switch
|
||||||
|
checked={appearance?.default_agent_grid_adaptive ?? true}
|
||||||
|
disabled={updateAppearance.isPending}
|
||||||
|
onCheckedChange={(checked) =>
|
||||||
|
void updateAppearance.mutateAsync({
|
||||||
|
default_agent_grid_adaptive: checked,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
aria-label="默认自适应列数"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{!((appearance?.default_agent_grid_adaptive ?? true)) && (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="text-xs text-muted-foreground">固定列数</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
className="size-8"
|
||||||
|
aria-label="减少默认每行卡片数"
|
||||||
|
disabled={(appearance?.default_agent_grid_columns ?? 4) <= 1 || updateAppearance.isPending}
|
||||||
|
onClick={() =>
|
||||||
|
void updateAppearance.mutateAsync({
|
||||||
|
default_agent_grid_columns: Math.max(
|
||||||
|
1,
|
||||||
|
(appearance?.default_agent_grid_columns ?? 4) - 1,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
-
|
||||||
|
</Button>
|
||||||
|
<span className="w-8 text-center text-sm font-semibold tabular-nums">
|
||||||
|
{appearance?.default_agent_grid_columns ?? 4}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
className="size-8"
|
||||||
|
aria-label="增加默认每行卡片数"
|
||||||
|
disabled={(appearance?.default_agent_grid_columns ?? 4) >= 8 || updateAppearance.isPending}
|
||||||
|
onClick={() =>
|
||||||
|
void updateAppearance.mutateAsync({
|
||||||
|
default_agent_grid_columns: Math.min(
|
||||||
|
8,
|
||||||
|
(appearance?.default_agent_grid_columns ?? 4) + 1,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
+
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
</>
|
</>
|
||||||
@@ -1557,6 +1735,8 @@ export function AppearanceSettingsPage({ onClose }: { onClose?: () => void }) {
|
|||||||
<PublishSquaresSettingsPage embedded />
|
<PublishSquaresSettingsPage embedded />
|
||||||
<Separator />
|
<Separator />
|
||||||
<SkillCompressionSettingsPage embedded />
|
<SkillCompressionSettingsPage embedded />
|
||||||
|
<Separator />
|
||||||
|
<SkillVersioningSettingsPage embedded />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { BarChart3Icon, Loader2Icon } from "lucide-react";
|
||||||
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import {
|
||||||
|
useCallMetricsSettings,
|
||||||
|
useUpdateCallMetricsSettings,
|
||||||
|
} from "@/core/system-settings/hooks";
|
||||||
|
|
||||||
|
export function CallMetricsSettingsPage() {
|
||||||
|
const { data, isError, isLoading } = useCallMetricsSettings();
|
||||||
|
const update = useUpdateCallMetricsSettings();
|
||||||
|
const enabled = data?.enabled ?? true;
|
||||||
|
|
||||||
|
const handleChange = async (checked: boolean) => {
|
||||||
|
try {
|
||||||
|
await update.mutateAsync({ enabled: checked });
|
||||||
|
toast.success(checked ? "工具与技能调用统计已开启" : "工具与技能调用统计已关闭");
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "保存失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="space-y-6">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h3 className="flex items-center gap-2 text-lg font-semibold">
|
||||||
|
<BarChart3Icon className="size-5" />
|
||||||
|
工具与技能调用统计
|
||||||
|
</h3>
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
为综合管理中的“最常用工具”和“最常用技能”记录数据来源。统计会记录调用名称、
|
||||||
|
技能名称、耗时、状态及失败时的简短错误摘要,不记录工具参数或输出内容。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between gap-6 rounded-lg border p-4">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="font-medium">记录工具与技能调用</div>
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
关闭后停止写入新的统计记录;已有记录仍可在综合管理中查看。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{isLoading ? (
|
||||||
|
<Loader2Icon className="text-muted-foreground size-5 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Switch
|
||||||
|
checked={enabled}
|
||||||
|
disabled={isError || update.isPending}
|
||||||
|
onCheckedChange={handleChange}
|
||||||
|
aria-label="记录工具与技能调用统计"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isError && (
|
||||||
|
<p className="text-destructive text-sm">
|
||||||
|
无法读取调用统计开关,系统将按当前部署配置执行。
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<p className="text-muted-foreground text-xs">
|
||||||
|
保存后对下一次工具调用立即生效,无需重启后台;正在执行中的调用不会中途切换。
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
|
|||||||
import { getStoredAuth } from "@/core/auth";
|
import { getStoredAuth } from "@/core/auth";
|
||||||
import { apiFetch } from "@/core/api";
|
import { apiFetch } from "@/core/api";
|
||||||
import { getBackendBaseURL } from "@/core/config";
|
import { getBackendBaseURL } from "@/core/config";
|
||||||
|
import { confirmAction } from "@/core/ui/feedback";
|
||||||
import {
|
import {
|
||||||
ACTIVE_ARCHIVE_JOB_STATUSES as ACTIVE,
|
ACTIVE_ARCHIVE_JOB_STATUSES as ACTIVE,
|
||||||
archiveMonthDisplayStatus,
|
archiveMonthDisplayStatus,
|
||||||
@@ -144,7 +145,11 @@ export function ChatArchiveSettingsPage() {
|
|||||||
const confirmation = action === "purge"
|
const confirmation = action === "purge"
|
||||||
? "确认清理该月已归档的 PostgreSQL 数据?系统会逐会话重新校验 SQLite 备份,只清理校验通过的会话;失败、未归档和正在运行的会话不会清理。"
|
? "确认清理该月已归档的 PostgreSQL 数据?系统会逐会话重新校验 SQLite 备份,只清理校验通过的会话;失败、未归档和正在运行的会话不会清理。"
|
||||||
: "确认回滚到 PostgreSQL?月度 SQLite 文件中的归档记录会保留。";
|
: "确认回滚到 PostgreSQL?月度 SQLite 文件中的归档记录会保留。";
|
||||||
if (action !== "archive" && !window.confirm(confirmation)) return;
|
if (action !== "archive" && !(await confirmAction(confirmation, {
|
||||||
|
title: action === "purge" ? "清理 PostgreSQL 归档数据?" : "回滚归档数据?",
|
||||||
|
confirmText: action === "purge" ? "确认清理" : "确认回滚",
|
||||||
|
danger: action === "purge",
|
||||||
|
}))) return;
|
||||||
setBusyMonth(month.month);
|
setBusyMonth(month.month);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ListOrderedIcon, Loader2Icon, ShrinkIcon } from "lucide-react";
|
import { ListOrderedIcon, Loader2Icon, ShrinkIcon } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useId, useMemo, useState, type CSSProperties } from "react";
|
import { useEffect, useId, useMemo, useState, type CSSProperties } from "react";
|
||||||
import { ColorPickerPanel } from "tdesign-react";
|
import { ColorPickerPanel } from "tdesign-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
|||||||
@@ -0,0 +1,200 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { AlertCircleIcon, Loader2Icon } from "lucide-react";
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { buildWikiKnowledgeBaseCreateInput } from "@/core/llmwiki/knowledge-base-form";
|
||||||
|
import {
|
||||||
|
useLlmWikiActions,
|
||||||
|
useLlmWikiEmbeddingModels,
|
||||||
|
} from "@/strategy-components/api/llmwiki";
|
||||||
|
|
||||||
|
import { SettingsSection } from "./settings-section";
|
||||||
|
|
||||||
|
type BatchCreateResult = {
|
||||||
|
createdNames: string[];
|
||||||
|
failed: Array<{ name: string; message: string }>;
|
||||||
|
};
|
||||||
|
|
||||||
|
function messageOf(error: unknown): string {
|
||||||
|
return error instanceof Error ? error.message : "操作失败,请稍后重试";
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseKnowledgeBaseNames(value: string): string[] {
|
||||||
|
const seen = new Set<string>();
|
||||||
|
return value
|
||||||
|
.split(/[,,\n\r]+/)
|
||||||
|
.map((name) => name.trim())
|
||||||
|
.filter((name) => {
|
||||||
|
if (!name || seen.has(name)) return false;
|
||||||
|
seen.add(name);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function KnowledgeBatchCreateSettingsPage() {
|
||||||
|
const actions = useLlmWikiActions();
|
||||||
|
const [namesText, setNamesText] = useState("");
|
||||||
|
const [embeddingModelId, setEmbeddingModelId] = useState("");
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [result, setResult] = useState<BatchCreateResult | null>(null);
|
||||||
|
const embeddingModels = useLlmWikiEmbeddingModels();
|
||||||
|
const availableEmbeddingModels = useMemo(
|
||||||
|
() => (embeddingModels.data?.models ?? []).filter((model) => model.available !== false),
|
||||||
|
[embeddingModels.data?.models],
|
||||||
|
);
|
||||||
|
const names = useMemo(() => parseKnowledgeBaseNames(namesText), [namesText]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!embeddingModels.data || availableEmbeddingModels.length === 0) return;
|
||||||
|
if (availableEmbeddingModels.some((model) => model.id === embeddingModelId)) return;
|
||||||
|
const defaultId = embeddingModels.data.default_model_id;
|
||||||
|
setEmbeddingModelId(
|
||||||
|
availableEmbeddingModels.some((model) => model.id === defaultId)
|
||||||
|
? defaultId!
|
||||||
|
: availableEmbeddingModels[0]!.id,
|
||||||
|
);
|
||||||
|
}, [availableEmbeddingModels, embeddingModelId, embeddingModels.data]);
|
||||||
|
|
||||||
|
const modelSelectionUnavailable =
|
||||||
|
embeddingModels.isLoading || embeddingModels.isError || !embeddingModelId;
|
||||||
|
const modelLabel = (model: (typeof availableEmbeddingModels)[number]) => {
|
||||||
|
const suffix = [model.provider?.trim(), model.model_name?.trim()]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" · ");
|
||||||
|
return suffix ? `${model.name}(${suffix})` : model.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCreate = async () => {
|
||||||
|
if (names.length === 0 || modelSelectionUnavailable) return;
|
||||||
|
setSubmitting(true);
|
||||||
|
setResult(null);
|
||||||
|
actions.create.reset();
|
||||||
|
|
||||||
|
const nextResult: BatchCreateResult = { createdNames: [], failed: [] };
|
||||||
|
for (const name of names) {
|
||||||
|
try {
|
||||||
|
await actions.create.mutateAsync(buildWikiKnowledgeBaseCreateInput({
|
||||||
|
name,
|
||||||
|
description: "",
|
||||||
|
embeddingModelId,
|
||||||
|
wikiConfig: {},
|
||||||
|
}));
|
||||||
|
nextResult.createdNames.push(name);
|
||||||
|
} catch (error) {
|
||||||
|
nextResult.failed.push({ name, message: messageOf(error) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setResult(nextResult);
|
||||||
|
setSubmitting(false);
|
||||||
|
if (nextResult.createdNames.length > 0) {
|
||||||
|
toast.success(`已创建 ${nextResult.createdNames.length} 个知识库`);
|
||||||
|
}
|
||||||
|
if (nextResult.failed.length > 0) {
|
||||||
|
setNamesText(nextResult.failed.map((item) => item.name).join(","));
|
||||||
|
toast.error(`${nextResult.failed.length} 个知识库创建失败,可修改后重试`);
|
||||||
|
} else {
|
||||||
|
setNamesText("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SettingsSection
|
||||||
|
title="批量新增知识库"
|
||||||
|
description="输入多个知识库名称后,系统会在浏览器端按顺序逐个创建到你的个人知识库。"
|
||||||
|
>
|
||||||
|
<div className="space-y-4 rounded-lg border p-4">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium" htmlFor="knowledge-batch-names">
|
||||||
|
知识库名称
|
||||||
|
</label>
|
||||||
|
<Textarea
|
||||||
|
id="knowledge-batch-names"
|
||||||
|
value={namesText}
|
||||||
|
onChange={(event) => setNamesText(event.target.value)}
|
||||||
|
rows={7}
|
||||||
|
maxLength={10000}
|
||||||
|
disabled={submitting}
|
||||||
|
placeholder="例如:产品手册,项目资料库,常见问题"
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
使用中文逗号、英文逗号或换行分隔;重复名称会自动忽略。已识别 {names.length} 个名称。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium" htmlFor="knowledge-batch-embedding-model">
|
||||||
|
原文向量模型
|
||||||
|
</label>
|
||||||
|
{embeddingModels.isLoading ? (
|
||||||
|
<div className="flex h-9 items-center rounded-md border px-3 text-sm text-muted-foreground">
|
||||||
|
<Loader2Icon className="mr-2 size-4 animate-spin" />正在读取知识服务模型
|
||||||
|
</div>
|
||||||
|
) : embeddingModels.isError ? (
|
||||||
|
<div className="rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-xs text-destructive" role="alert">
|
||||||
|
<p>模型读取失败:{messageOf(embeddingModels.error)}</p>
|
||||||
|
<Button type="button" variant="ghost" size="sm" className="mt-1 h-7 px-2" onClick={() => void embeddingModels.refetch()}>
|
||||||
|
重新读取
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : availableEmbeddingModels.length ? (
|
||||||
|
<Select value={embeddingModelId} onValueChange={setEmbeddingModelId} disabled={submitting}>
|
||||||
|
<SelectTrigger id="knowledge-batch-embedding-model" className="w-full">
|
||||||
|
<SelectValue placeholder="请选择向量模型" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent position="popper">
|
||||||
|
{availableEmbeddingModels.map((model) => (
|
||||||
|
<SelectItem key={model.id} value={model.id}>
|
||||||
|
{modelLabel(model)}{model.is_default ? " · 默认" : ""}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
) : (
|
||||||
|
<div className="rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-muted-foreground">
|
||||||
|
知识服务中没有可用的 Embedding 模型,请先在知识服务中启用向量模型。
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{result && (
|
||||||
|
<div
|
||||||
|
className={result.failed.length
|
||||||
|
? "rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive"
|
||||||
|
: "rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-3 text-sm text-emerald-700 dark:text-emerald-300"}
|
||||||
|
role={result.failed.length ? "alert" : "status"}
|
||||||
|
>
|
||||||
|
{result.createdNames.length > 0 && <p className="font-medium">已创建 {result.createdNames.length} 个知识库</p>}
|
||||||
|
{result.failed.length > 0 && (
|
||||||
|
<>
|
||||||
|
<p className="flex items-center gap-2 font-medium"><AlertCircleIcon className="size-4" />{result.failed.length} 个名称未创建</p>
|
||||||
|
<ul className="mt-1 list-disc space-y-1 pl-5 text-xs leading-5">
|
||||||
|
{result.failed.slice(0, 5).map((item) => <li key={item.name}>{item.name}:{item.message}</li>)}
|
||||||
|
{result.failed.length > 5 && <li>其余 {result.failed.length - 5} 个失败项已保留在输入框中。</li>}
|
||||||
|
</ul>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="flex justify-end">
|
||||||
|
<Button type="button" onClick={() => void handleCreate()} disabled={submitting || names.length === 0 || modelSelectionUnavailable}>
|
||||||
|
{submitting && <Loader2Icon className="mr-2 size-4 animate-spin" />}
|
||||||
|
{submitting ? "正在创建" : `创建${names.length ? `(${names.length})` : ""}`}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</SettingsSection>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Loader2Icon, SearchIcon } from "lucide-react";
|
import { Loader2Icon, SearchIcon } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { DatabaseIcon, Loader2Icon, SaveIcon } from "lucide-react";
|
||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/components/ui/select";
|
||||||
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
import {
|
||||||
|
type LocalWikiAutoSyncSettings,
|
||||||
|
useLocalWikiAutoSyncSettings,
|
||||||
|
useLocalWikiAutoSyncSettingsActions,
|
||||||
|
} from "@/strategy-components/api/llmwiki";
|
||||||
|
|
||||||
|
import { SettingsSection } from "./settings-section";
|
||||||
|
|
||||||
|
const HOURS = Array.from({ length: 24 }, (_, hour) => hour);
|
||||||
|
|
||||||
|
function hourLabel(hour: number) {
|
||||||
|
return `${String(hour).padStart(2, "0")}:00`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LocalWikiAutoSyncSettingsPage() {
|
||||||
|
const settings = useLocalWikiAutoSyncSettings();
|
||||||
|
const actions = useLocalWikiAutoSyncSettingsActions();
|
||||||
|
const [draft, setDraft] = useState<LocalWikiAutoSyncSettings | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (settings.data) setDraft(settings.data);
|
||||||
|
}, [settings.data]);
|
||||||
|
|
||||||
|
const isDirty = useMemo(
|
||||||
|
() => !!draft && JSON.stringify(draft) !== JSON.stringify(settings.data),
|
||||||
|
[draft, settings.data],
|
||||||
|
);
|
||||||
|
|
||||||
|
const updateDraft = (patch: Partial<LocalWikiAutoSyncSettings>) => {
|
||||||
|
setDraft((current) => current ? { ...current, ...patch } : current);
|
||||||
|
};
|
||||||
|
|
||||||
|
const save = async () => {
|
||||||
|
if (!draft) return;
|
||||||
|
try {
|
||||||
|
await actions.save.mutateAsync(draft);
|
||||||
|
toast.success(draft.enabled ? "知识库自动同步设置已保存" : "知识库自动同步已关闭");
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error instanceof Error ? error.message : "保存失败,请稍后重试");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (settings.isLoading || !draft) {
|
||||||
|
return (
|
||||||
|
<div className="flex min-h-36 items-center justify-center text-sm text-muted-foreground">
|
||||||
|
<Loader2Icon className="mr-2 size-4 animate-spin" />正在读取自动同步设置…
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SettingsSection
|
||||||
|
title="本地 Wiki 自动同步"
|
||||||
|
description="设置 DeerFlow 本地 Wiki 镜像的后台同步时间。执行时间以服务器本地时间为准。"
|
||||||
|
>
|
||||||
|
<div className="space-y-4 rounded-lg border p-4">
|
||||||
|
<div className="flex items-start justify-between gap-6">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label className="flex items-center gap-2 font-medium" htmlFor="local-wiki-auto-sync-enabled">
|
||||||
|
<DatabaseIcon className="size-4" />自动同步
|
||||||
|
</label>
|
||||||
|
<p id="local-wiki-auto-sync-description" className="text-sm text-muted-foreground">
|
||||||
|
关闭后不再后台扫描所有知识库;单个知识库的手动同步和向量化不受影响。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
id="local-wiki-auto-sync-enabled"
|
||||||
|
aria-describedby="local-wiki-auto-sync-description"
|
||||||
|
checked={draft.enabled}
|
||||||
|
disabled={settings.isError || actions.save.isPending}
|
||||||
|
onCheckedChange={(enabled) => updateDraft({ enabled })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{draft.enabled && (
|
||||||
|
<div className="grid gap-4 border-t pt-4 sm:grid-cols-2">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium" htmlFor="local-wiki-auto-sync-schedule">
|
||||||
|
同步周期
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
value={draft.schedule}
|
||||||
|
disabled={actions.save.isPending}
|
||||||
|
onValueChange={(schedule: "hourly" | "daily") => updateDraft({ schedule })}
|
||||||
|
>
|
||||||
|
<SelectTrigger id="local-wiki-auto-sync-schedule">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="hourly">每小时整点</SelectItem>
|
||||||
|
<SelectItem value="daily">每天固定时间</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{draft.schedule === "daily" && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium" htmlFor="local-wiki-auto-sync-hour">
|
||||||
|
每日执行时间
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
value={String(draft.hour)}
|
||||||
|
disabled={actions.save.isPending}
|
||||||
|
onValueChange={(value) => updateDraft({ hour: Number(value) })}
|
||||||
|
>
|
||||||
|
<SelectTrigger id="local-wiki-auto-sync-hour">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{HOURS.map((hour) => (
|
||||||
|
<SelectItem key={hour} value={String(hour)}>{hourLabel(hour)}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{settings.isError && (
|
||||||
|
<p className="text-destructive text-sm" role="alert">
|
||||||
|
无法读取自动同步设置,请刷新后重试。
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="flex justify-end border-t pt-4">
|
||||||
|
<Button type="button" onClick={() => void save()} disabled={!isDirty || settings.isError || actions.save.isPending}>
|
||||||
|
{actions.save.isPending ? <Loader2Icon className="mr-2 size-4 animate-spin" /> : <SaveIcon className="mr-2 size-4" />}
|
||||||
|
保存设置
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</SettingsSection>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { BrainIcon, Loader2Icon } from "lucide-react";
|
import { BrainIcon, Loader2Icon } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { PenLineIcon, PlusIcon, SearchIcon, Trash2Icon, Heart, BookOpen, Map, Zap, Target, ShieldAlert, Briefcase, UserRound, Sparkles, Clock, History, Archive } from "lucide-react";
|
import { PenLineIcon, PlusIcon, SearchIcon, Trash2Icon, Heart, BookOpen, Map, Zap, Target, ShieldAlert, Briefcase, UserRound, Sparkles, Clock, History, Archive } from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useState, type FormEvent } from "react";
|
import { useState, type FormEvent } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { HistoryIcon, Loader2Icon } from "lucide-react";
|
import { HistoryIcon, Loader2Icon } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Clock3Icon, FileOutputIcon, ListOrderedIcon, Loader2Icon, UsersIcon } from "lucide-react";
|
import { Clock3Icon, FileOutputIcon, ListOrderedIcon, Loader2Icon, UsersIcon } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
@@ -25,6 +25,9 @@ export function RoundtableRoomSettingsPage() {
|
|||||||
const [maxHoldMinutes, setMaxHoldMinutes] = useState(
|
const [maxHoldMinutes, setMaxHoldMinutes] = useState(
|
||||||
String(data?.max_hold_minutes ?? 30),
|
String(data?.max_hold_minutes ?? 30),
|
||||||
);
|
);
|
||||||
|
const [leaseMinutes, setLeaseMinutes] = useState(
|
||||||
|
String(data?.lease_minutes ?? 5),
|
||||||
|
);
|
||||||
const [maxCycles, setMaxCycles] = useState(String(data?.max_cycles ?? 8));
|
const [maxCycles, setMaxCycles] = useState(String(data?.max_cycles ?? 8));
|
||||||
const [activeCount, setActiveCount] = useState<number | null>(null);
|
const [activeCount, setActiveCount] = useState<number | null>(null);
|
||||||
|
|
||||||
@@ -38,6 +41,12 @@ export function RoundtableRoomSettingsPage() {
|
|||||||
}
|
}
|
||||||
}, [data?.max_hold_minutes]);
|
}, [data?.max_hold_minutes]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data?.lease_minutes != null) {
|
||||||
|
setLeaseMinutes(String(data.lease_minutes));
|
||||||
|
}
|
||||||
|
}, [data?.lease_minutes]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.max_cycles != null) setMaxCycles(String(data.max_cycles));
|
if (data?.max_cycles != null) setMaxCycles(String(data.max_cycles));
|
||||||
}, [data?.max_cycles]);
|
}, [data?.max_cycles]);
|
||||||
@@ -65,6 +74,7 @@ export function RoundtableRoomSettingsPage() {
|
|||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
max_rooms?: number;
|
max_rooms?: number;
|
||||||
max_hold_minutes?: number;
|
max_hold_minutes?: number;
|
||||||
|
lease_minutes?: number;
|
||||||
max_cycles?: number;
|
max_cycles?: number;
|
||||||
write_file_compatibility_enabled?: boolean;
|
write_file_compatibility_enabled?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -94,6 +104,15 @@ export function RoundtableRoomSettingsPage() {
|
|||||||
void save({ max_hold_minutes: parsed });
|
void save({ max_hold_minutes: parsed });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const saveLeaseMinutes = () => {
|
||||||
|
const parsed = Number(leaseMinutes);
|
||||||
|
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 60) {
|
||||||
|
toast.error("房间租约请填写 1 到 60 的整数");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void save({ lease_minutes: parsed });
|
||||||
|
};
|
||||||
|
|
||||||
const saveMaxCycles = () => {
|
const saveMaxCycles = () => {
|
||||||
const parsed = Number(maxCycles);
|
const parsed = Number(maxCycles);
|
||||||
if (!Number.isInteger(parsed) || parsed < 2 || parsed > 100) {
|
if (!Number.isInteger(parsed) || parsed < 2 || parsed > 100) {
|
||||||
@@ -111,7 +130,7 @@ export function RoundtableRoomSettingsPage() {
|
|||||||
会商并发与收口
|
会商并发与收口
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-muted-foreground text-sm">
|
<p className="text-muted-foreground text-sm">
|
||||||
配置第二步的全站并发名额、最长占用时间和总控强制收口轮数。所有账号共用房间名额;仅打开页面或查看历史记录不占用。
|
配置第二步的全站并发名额、房间租约、最长占用时间和总控强制收口轮数。所有账号共用房间名额;仅打开页面或查看历史记录不占用。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -187,6 +206,39 @@ export function RoundtableRoomSettingsPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap items-end justify-between gap-4 rounded-lg border p-4">
|
||||||
|
<label className="space-y-1">
|
||||||
|
<span className="flex items-center gap-2 font-medium">
|
||||||
|
<Clock3Icon className="size-4" />
|
||||||
|
房间租约
|
||||||
|
</span>
|
||||||
|
<p className="text-muted-foreground text-sm">
|
||||||
|
默认 5 分钟,可改为 1 到 60 分钟。页面大约每 15 秒续一次;超过这个时间没有续上,房间会释放。保存后,下一次准入和心跳立即按新时长续租。它不会延长单个房间的最长占用时间。
|
||||||
|
</p>
|
||||||
|
<div className="mt-2 flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min={1}
|
||||||
|
max={60}
|
||||||
|
value={leaseMinutes}
|
||||||
|
disabled={isError || update.isPending}
|
||||||
|
onChange={(event) => setLeaseMinutes(event.target.value)}
|
||||||
|
className="border-input bg-background h-9 w-24 rounded-md border px-3 text-sm"
|
||||||
|
aria-label="会商房间租约分钟数"
|
||||||
|
/>
|
||||||
|
<span className="text-muted-foreground text-sm">分钟</span>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="sm"
|
||||||
|
disabled={isError || update.isPending}
|
||||||
|
onClick={saveLeaseMinutes}
|
||||||
|
>
|
||||||
|
保存租约
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-wrap items-end justify-between gap-4 rounded-lg border p-4">
|
<div className="flex flex-wrap items-end justify-between gap-4 rounded-lg border p-4">
|
||||||
<label className="space-y-1">
|
<label className="space-y-1">
|
||||||
<span className="flex items-center gap-2 font-medium">
|
<span className="flex items-center gap-2 font-medium">
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BellIcon,
|
BarChart3Icon,
|
||||||
BrainIcon,
|
BrainIcon,
|
||||||
|
BookPlusIcon,
|
||||||
CpuIcon,
|
CpuIcon,
|
||||||
DatabaseIcon,
|
DatabaseIcon,
|
||||||
ArchiveIcon,
|
ArchiveIcon,
|
||||||
@@ -32,6 +33,7 @@ import { AccountSettingsPage } from "@/components/workspace/settings/account-set
|
|||||||
import { AppearanceSettingsPage } from "@/components/workspace/settings/appearance-settings-page";
|
import { AppearanceSettingsPage } from "@/components/workspace/settings/appearance-settings-page";
|
||||||
import { AppIdentitySettingsPage } from "@/components/workspace/settings/app-identity-settings-page";
|
import { AppIdentitySettingsPage } from "@/components/workspace/settings/app-identity-settings-page";
|
||||||
import { ContextWindowSettingsPage } from "@/components/workspace/settings/context-window-settings-page";
|
import { ContextWindowSettingsPage } from "@/components/workspace/settings/context-window-settings-page";
|
||||||
|
import { CallMetricsSettingsPage } from "@/components/workspace/settings/call-metrics-settings-page";
|
||||||
import { ModelPromptSettingsPage } from "@/components/workspace/settings/model-prompt-settings-page";
|
import { ModelPromptSettingsPage } from "@/components/workspace/settings/model-prompt-settings-page";
|
||||||
import { WorkerPoolSettingsPage } from "@/components/workspace/settings/worker-pool-settings-page";
|
import { WorkerPoolSettingsPage } from "@/components/workspace/settings/worker-pool-settings-page";
|
||||||
import { ApiReadCacheSettingsPage } from "@/components/workspace/settings/api-read-cache-settings-page";
|
import { ApiReadCacheSettingsPage } from "@/components/workspace/settings/api-read-cache-settings-page";
|
||||||
@@ -39,6 +41,8 @@ import { ChatArchiveSettingsPage } from "@/components/workspace/settings/chat-ar
|
|||||||
import { RoundtableRoomSettingsPage } from "@/components/workspace/settings/roundtable-room-settings-page";
|
import { RoundtableRoomSettingsPage } from "@/components/workspace/settings/roundtable-room-settings-page";
|
||||||
import { RetryKeepPartialSettingsPage } from "@/components/workspace/settings/retry-keep-partial-settings-page";
|
import { RetryKeepPartialSettingsPage } from "@/components/workspace/settings/retry-keep-partial-settings-page";
|
||||||
import { KnowledgeRetrievalSettingsPage } from "@/components/workspace/settings/knowledge-retrieval-settings-page";
|
import { KnowledgeRetrievalSettingsPage } from "@/components/workspace/settings/knowledge-retrieval-settings-page";
|
||||||
|
import { KnowledgeBatchCreateSettingsPage } from "@/components/workspace/settings/knowledge-batch-create-settings-page";
|
||||||
|
import { LocalWikiAutoSyncSettingsPage } from "@/components/workspace/settings/local-wiki-auto-sync-settings-page";
|
||||||
import { MemoryRuntimeSettingsPage } from "@/components/workspace/settings/memory-runtime-settings-page";
|
import { MemoryRuntimeSettingsPage } from "@/components/workspace/settings/memory-runtime-settings-page";
|
||||||
import { ToolSettingsPage } from "@/components/workspace/settings/tool-settings-page";
|
import { ToolSettingsPage } from "@/components/workspace/settings/tool-settings-page";
|
||||||
import { UploadSettingsPage } from "@/components/workspace/settings/upload-settings-page";
|
import { UploadSettingsPage } from "@/components/workspace/settings/upload-settings-page";
|
||||||
@@ -60,9 +64,12 @@ type SettingsSection =
|
|||||||
| "chat-archive"
|
| "chat-archive"
|
||||||
| "roundtable-rooms"
|
| "roundtable-rooms"
|
||||||
| "knowledge-retrieval"
|
| "knowledge-retrieval"
|
||||||
|
| "knowledge-batch-create"
|
||||||
|
| "local-wiki-auto-sync"
|
||||||
| "appIdentity"
|
| "appIdentity"
|
||||||
| "memory"
|
| "memory"
|
||||||
| "fileWriting"
|
| "fileWriting"
|
||||||
|
| "callMetrics"
|
||||||
| "retryKeepPartial"
|
| "retryKeepPartial"
|
||||||
| "uploads"
|
| "uploads"
|
||||||
| "tools"
|
| "tools"
|
||||||
@@ -112,13 +119,16 @@ export function SettingsDialog(props: SettingsDialogProps) {
|
|||||||
{ id: "chat-archive", label: "聊天记录归档", icon: ArchiveIcon },
|
{ id: "chat-archive", label: "聊天记录归档", icon: ArchiveIcon },
|
||||||
{ id: "roundtable-rooms", label: "会商并发", icon: UsersIcon },
|
{ id: "roundtable-rooms", label: "会商并发", icon: UsersIcon },
|
||||||
{ id: "knowledge-retrieval", label: "知识检索", icon: SearchIcon },
|
{ id: "knowledge-retrieval", label: "知识检索", icon: SearchIcon },
|
||||||
|
{ id: "local-wiki-auto-sync", label: "知识库同步", icon: DatabaseIcon },
|
||||||
{ id: "appIdentity", label: "系统名称", icon: TypeIcon },
|
{ id: "appIdentity", label: "系统名称", icon: TypeIcon },
|
||||||
{ id: "memory", label: "问答记忆", icon: BrainIcon },
|
{ id: "memory", label: "问答记忆", icon: BrainIcon },
|
||||||
{ id: "fileWriting", label: "文件流式兼容", icon: FileOutputIcon },
|
{ id: "fileWriting", label: "文件流式兼容", icon: FileOutputIcon },
|
||||||
|
{ id: "callMetrics", label: "调用统计", icon: BarChart3Icon },
|
||||||
{ id: "retryKeepPartial", label: "保留中间正文", icon: HistoryIcon },
|
{ id: "retryKeepPartial", label: "保留中间正文", icon: HistoryIcon },
|
||||||
{ id: "uploads", label: "上传设置", icon: UploadCloudIcon },
|
{ id: "uploads", label: "上传设置", icon: UploadCloudIcon },
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
|
{ id: "knowledge-batch-create", label: "批量新增知识库", icon: BookPlusIcon },
|
||||||
{ id: "tools", label: t.settings.sections.tools, icon: WrenchIcon },
|
{ id: "tools", label: t.settings.sections.tools, icon: WrenchIcon },
|
||||||
...(isAdmin
|
...(isAdmin
|
||||||
? [{ id: "encoder", label: "Wiki 镜像编码器", icon: CpuIcon }]
|
? [{ id: "encoder", label: "Wiki 镜像编码器", icon: CpuIcon }]
|
||||||
@@ -210,6 +220,12 @@ export function SettingsDialog(props: SettingsDialogProps) {
|
|||||||
{activeSection === "knowledge-retrieval" && isAdmin && (
|
{activeSection === "knowledge-retrieval" && isAdmin && (
|
||||||
<KnowledgeRetrievalSettingsPage />
|
<KnowledgeRetrievalSettingsPage />
|
||||||
)}
|
)}
|
||||||
|
{activeSection === "local-wiki-auto-sync" && isAdmin && (
|
||||||
|
<LocalWikiAutoSyncSettingsPage />
|
||||||
|
)}
|
||||||
|
{activeSection === "knowledge-batch-create" && (
|
||||||
|
<KnowledgeBatchCreateSettingsPage />
|
||||||
|
)}
|
||||||
{activeSection === "appIdentity" && isAdmin && (
|
{activeSection === "appIdentity" && isAdmin && (
|
||||||
<AppIdentitySettingsPage />
|
<AppIdentitySettingsPage />
|
||||||
)}
|
)}
|
||||||
@@ -219,6 +235,9 @@ export function SettingsDialog(props: SettingsDialogProps) {
|
|||||||
{activeSection === "fileWriting" && isAdmin && (
|
{activeSection === "fileWriting" && isAdmin && (
|
||||||
<WriteFileCompatibilitySettingsPage />
|
<WriteFileCompatibilitySettingsPage />
|
||||||
)}
|
)}
|
||||||
|
{activeSection === "callMetrics" && isAdmin && (
|
||||||
|
<CallMetricsSettingsPage />
|
||||||
|
)}
|
||||||
{activeSection === "retryKeepPartial" && isAdmin && (
|
{activeSection === "retryKeepPartial" && isAdmin && (
|
||||||
<RetryKeepPartialSettingsPage />
|
<RetryKeepPartialSettingsPage />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import {
|
|||||||
Anchor,
|
Anchor,
|
||||||
ArchiveIcon,
|
ArchiveIcon,
|
||||||
ArrowDownUpIcon,
|
ArrowDownUpIcon,
|
||||||
|
BarChart3Icon,
|
||||||
|
DatabaseIcon,
|
||||||
|
MessageSquareTextIcon,
|
||||||
|
MousePointerClickIcon,
|
||||||
BookmarkIcon,
|
BookmarkIcon,
|
||||||
CheckCircle2,
|
CheckCircle2,
|
||||||
ChevronLeftIcon,
|
ChevronLeftIcon,
|
||||||
@@ -28,11 +32,19 @@ import {
|
|||||||
TrendingUpIcon,
|
TrendingUpIcon,
|
||||||
Upload,
|
Upload,
|
||||||
UserIcon,
|
UserIcon,
|
||||||
|
WorkflowIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
import {
|
||||||
|
DateRangePicker,
|
||||||
|
Dialog as TDesignDialog,
|
||||||
|
MessagePlugin,
|
||||||
|
type DateRangePickerProps,
|
||||||
|
type DateRangeValue,
|
||||||
|
} from "tdesign-react";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -74,6 +86,7 @@ import { getStoredAuth } from "@/core/auth";
|
|||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
import { MINIMAL_SKILL_MD_EXAMPLE } from "@/core/skill-example";
|
import { MINIMAL_SKILL_MD_EXAMPLE } from "@/core/skill-example";
|
||||||
import type { ValidateSkillUploadResponse } from "@/core/skills/api";
|
import type { ValidateSkillUploadResponse } from "@/core/skills/api";
|
||||||
|
import { filterSkillsByCreatedAt } from "@/core/skill-created-at-filter";
|
||||||
import {
|
import {
|
||||||
useDeleteBuiltinSkill,
|
useDeleteBuiltinSkill,
|
||||||
useDeleteCustomSkill,
|
useDeleteCustomSkill,
|
||||||
@@ -99,6 +112,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
usePublishSquares,
|
usePublishSquares,
|
||||||
useSkillCompressionSettings,
|
useSkillCompressionSettings,
|
||||||
|
useSkillVersioningSettings,
|
||||||
useViewMode,
|
useViewMode,
|
||||||
} from "@/core/system-settings/hooks";
|
} from "@/core/system-settings/hooks";
|
||||||
import {
|
import {
|
||||||
@@ -155,6 +169,19 @@ type SkillSort =
|
|||||||
| "name_asc"
|
| "name_asc"
|
||||||
| "name_desc";
|
| "name_desc";
|
||||||
|
|
||||||
|
function formatLocalCalendarDate(date: Date) {
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(date.getDate()).padStart(2, "0");
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function recentCalendarRange(days: number, now = new Date()): [string, string] {
|
||||||
|
const start = new Date(now);
|
||||||
|
start.setDate(start.getDate() - Math.max(1, days) + 1);
|
||||||
|
return [formatLocalCalendarDate(start), formatLocalCalendarDate(now)];
|
||||||
|
}
|
||||||
|
|
||||||
/** 重新扫描成功 toast:仅暗色模式使用,浅色走 Sonner 默认样式 */
|
/** 重新扫描成功 toast:仅暗色模式使用,浅色走 Sonner 默认样式 */
|
||||||
const rescanSuccessToastDarkOptions = {
|
const rescanSuccessToastDarkOptions = {
|
||||||
classNames: {
|
classNames: {
|
||||||
@@ -205,6 +232,7 @@ function SkillSettingsList({
|
|||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [tagIds, setTagIds] = useState<string[]>([]);
|
const [tagIds, setTagIds] = useState<string[]>([]);
|
||||||
const [sort, setSort] = useState<SkillSort>("time_desc");
|
const [sort, setSort] = useState<SkillSort>("time_desc");
|
||||||
|
const [createdAtRange, setCreatedAtRange] = useState<DateRangeValue>([]);
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
// Publisher filter: click a skill's 发布者 to keep only that user's skills.
|
// Publisher filter: click a skill's 发布者 to keep only that user's skills.
|
||||||
// {id} is owner_user_id; {label} the desensitized display name.
|
// {id} is owner_user_id; {label} the desensitized display name.
|
||||||
@@ -227,6 +255,19 @@ function SkillSettingsList({
|
|||||||
const storedAuth = useMemo(() => getStoredAuth(), []);
|
const storedAuth = useMemo(() => getStoredAuth(), []);
|
||||||
const currentUserId = storedAuth?.user_id ?? null;
|
const currentUserId = storedAuth?.user_id ?? null;
|
||||||
const isAdmin = storedAuth?.system_role === "admin";
|
const isAdmin = storedAuth?.system_role === "admin";
|
||||||
|
const createdAtPresets = useMemo<DateRangePickerProps["presets"]>(() => {
|
||||||
|
const now = new Date();
|
||||||
|
const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
|
||||||
|
return {
|
||||||
|
今天: recentCalendarRange(1, now),
|
||||||
|
最近7天: recentCalendarRange(7, now),
|
||||||
|
最近30天: recentCalendarRange(30, now),
|
||||||
|
本月: [
|
||||||
|
formatLocalCalendarDate(monthStart),
|
||||||
|
formatLocalCalendarDate(now),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Name + tag filtering is resolved server-side via the /api/skills query.
|
// Name + tag filtering is resolved server-side via the /api/skills query.
|
||||||
// A 岗位 (position) no longer *restricts* the list — it grants skills into the
|
// A 岗位 (position) no longer *restricts* the list — it grants skills into the
|
||||||
@@ -238,8 +279,16 @@ function SkillSettingsList({
|
|||||||
tagIds,
|
tagIds,
|
||||||
sort,
|
sort,
|
||||||
scope: isAdmin ? undefined : "mine",
|
scope: isAdmin ? undefined : "mine",
|
||||||
|
// The same catalogue query is also used while chatting. Always refetch
|
||||||
|
// when Skill Management mounts so a just-invoked skill's counter is fresh.
|
||||||
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const skillsInCreatedAtRange = useMemo(
|
||||||
|
() => filterSkillsByCreatedAt(skills, createdAtRange),
|
||||||
|
[skills, createdAtRange],
|
||||||
|
);
|
||||||
|
|
||||||
// 把可见技能分类成 UI 关心的几个桶。
|
// 把可见技能分类成 UI 关心的几个桶。
|
||||||
// "All" = 内置 + 已发布的技能(仅 active 状态);自己的技能也要自己发布了才出现。
|
// "All" = 内置 + 已发布的技能(仅 active 状态);自己的技能也要自己发布了才出现。
|
||||||
// "Mine" = 严格属于我自己的自定义技能(仅 active 状态)。
|
// "Mine" = 严格属于我自己的自定义技能(仅 active 状态)。
|
||||||
@@ -248,7 +297,7 @@ function SkillSettingsList({
|
|||||||
const mine: Skill[] = [];
|
const mine: Skill[] = [];
|
||||||
const stale: Skill[] = [];
|
const stale: Skill[] = [];
|
||||||
const archived: Skill[] = [];
|
const archived: Skill[] = [];
|
||||||
for (const skill of skills) {
|
for (const skill of skillsInCreatedAtRange) {
|
||||||
const state = skill.state ?? "active";
|
const state = skill.state ?? "active";
|
||||||
const isCustom = skill.category === "custom";
|
const isCustom = skill.category === "custom";
|
||||||
const isOwnedByMe =
|
const isOwnedByMe =
|
||||||
@@ -279,7 +328,7 @@ function SkillSettingsList({
|
|||||||
staleVisible: stale,
|
staleVisible: stale,
|
||||||
archivedVisible: archived,
|
archivedVisible: archived,
|
||||||
};
|
};
|
||||||
}, [skills, currentUserId]);
|
}, [skillsInCreatedAtRange, currentUserId]);
|
||||||
|
|
||||||
// "mine" tab shows my own skills; every other tab value is a square id whose
|
// "mine" tab shows my own skills; every other tab value is a square id whose
|
||||||
// public skills come from the published pool.
|
// public skills come from the published pool.
|
||||||
@@ -334,7 +383,7 @@ function SkillSettingsList({
|
|||||||
}, [page, totalPages]);
|
}, [page, totalPages]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setPage(1);
|
setPage(1);
|
||||||
}, [search, tagIds, sort, publisher?.id, filter]);
|
}, [search, tagIds, sort, publisher?.id, filter, createdAtRange]);
|
||||||
|
|
||||||
// If the active square tab disappears (admin removed that square), fall back
|
// If the active square tab disappears (admin removed that square), fall back
|
||||||
// to "我的" so the page never points at a dead tab.
|
// to "我的" so the page never points at a dead tab.
|
||||||
@@ -423,11 +472,11 @@ function SkillSettingsList({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full flex-col gap-4">
|
<div className="lb-surface flex w-full flex-col gap-4">
|
||||||
<header className="flex flex-wrap items-center justify-between gap-3">
|
<header className="flex flex-wrap items-center justify-between gap-3">
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
<Tabs value={filter} onValueChange={setFilter}>
|
<Tabs value={filter} onValueChange={setFilter}>
|
||||||
<TabsList variant="line" className="flex-wrap">
|
<TabsList className="flex-wrap">
|
||||||
{restrictWxTypes ? (
|
{restrictWxTypes ? (
|
||||||
<>
|
<>
|
||||||
<TabsTrigger value="mine">{t.settings.skills.tabMine}</TabsTrigger>
|
<TabsTrigger value="mine">{t.settings.skills.tabMine}</TabsTrigger>
|
||||||
@@ -446,45 +495,68 @@ function SkillSettingsList({
|
|||||||
)}
|
)}
|
||||||
</TabsList>
|
</TabsList>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
{!isLoading && !error && (
|
||||||
|
<span className="text-muted-foreground text-sm tabular-nums">
|
||||||
|
共 {orderedSkills.length} 个技能
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||||
|
<div
|
||||||
|
role="group"
|
||||||
|
aria-label="技能状态"
|
||||||
|
className="flex items-center rounded-[6px] border border-border/80 bg-muted/35 p-0.5 shadow-xs"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
|
className="h-8 gap-1.5 rounded-[4px] px-2.5 text-muted-foreground hover:bg-background hover:text-foreground"
|
||||||
disabled={staleCount === 0}
|
disabled={staleCount === 0}
|
||||||
onClick={() => setStaleSheetOpen(true)}
|
onClick={() => setStaleSheetOpen(true)}
|
||||||
title={t.settings.skills.badgeStaleTitle}
|
title={t.settings.skills.badgeStaleTitle}
|
||||||
>
|
>
|
||||||
<ClockIcon className="size-4" />
|
<ClockIcon className="size-3.5" />
|
||||||
{t.settings.skills.entryStale.replace("{count}", String(staleCount))}
|
{t.settings.skills.entryStale.replace("{count}", String(staleCount))}
|
||||||
</Button>
|
</Button>
|
||||||
|
<div aria-hidden="true" className="h-4 w-px bg-border/70" />
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
|
className="h-8 gap-1.5 rounded-[4px] px-2.5 text-muted-foreground hover:bg-background hover:text-foreground"
|
||||||
disabled={archivedCount === 0}
|
disabled={archivedCount === 0}
|
||||||
onClick={() => setArchiveSheetOpen(true)}
|
onClick={() => setArchiveSheetOpen(true)}
|
||||||
title={t.settings.skills.badgeArchivedTitle}
|
title={t.settings.skills.badgeArchivedTitle}
|
||||||
>
|
>
|
||||||
<ArchiveIcon className="size-4" />
|
<ArchiveIcon className="size-3.5" />
|
||||||
{t.settings.skills.entryArchived.replace(
|
{t.settings.skills.entryArchived.replace(
|
||||||
"{count}",
|
"{count}",
|
||||||
String(archivedCount),
|
String(archivedCount),
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-wrap gap-2">
|
|
||||||
|
<div
|
||||||
|
role="group"
|
||||||
|
aria-label="技能维护操作"
|
||||||
|
className="flex items-center rounded-[6px] border border-border/80 bg-background p-0.5 shadow-xs"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
|
className="h-8 gap-1.5 rounded-[4px] px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onClose?.();
|
onClose?.();
|
||||||
router.push("/page/workspace/skills/evolution");
|
router.push("/page/workspace/skills/evolution");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TrendingUpIcon className="size-4" />
|
<TrendingUpIcon className="size-3.5" />
|
||||||
{t.settings.skills.goToEvolution}
|
{t.settings.skills.goToEvolution}
|
||||||
</Button>
|
</Button>
|
||||||
|
<div aria-hidden="true" className="h-4 w-px bg-border/70" />
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
|
className="h-8 gap-1.5 rounded-[4px] px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
onClick={() => void handleRescan()}
|
onClick={() => void handleRescan()}
|
||||||
disabled={
|
disabled={
|
||||||
reconcileMutation.isPending ||
|
reconcileMutation.isPending ||
|
||||||
@@ -493,29 +565,21 @@ function SkillSettingsList({
|
|||||||
title={t.settings.skills.rescanSkills}
|
title={t.settings.skills.rescanSkills}
|
||||||
>
|
>
|
||||||
{reconcileMutation.isPending ? (
|
{reconcileMutation.isPending ? (
|
||||||
<Loader2 className="size-4 animate-spin" />
|
<Loader2 className="size-3.5 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
<RefreshCwIcon className="size-4" />
|
<RefreshCwIcon className="size-3.5" />
|
||||||
)}
|
)}
|
||||||
{reconcileMutation.isPending
|
{reconcileMutation.isPending
|
||||||
? t.settings.skills.rescanSkillsRunning
|
? t.settings.skills.rescanSkillsRunning
|
||||||
: t.settings.skills.rescanSkills}
|
: t.settings.skills.rescanSkills}
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<>
|
|
||||||
<ModelNameSelect
|
|
||||||
value={fillModel}
|
|
||||||
onChange={setFillModel}
|
|
||||||
disabled={
|
|
||||||
fillNamesMutation.isPending ||
|
|
||||||
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true"
|
|
||||||
}
|
|
||||||
triggerClassName="h-8 w-[9.5rem]"
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="ghost"
|
||||||
className="gap-1.5 border-violet-300 bg-violet-50 font-medium text-violet-700 hover:bg-violet-100 hover:text-violet-800 dark:border-violet-500/40 dark:bg-violet-500/15 dark:text-violet-300 dark:hover:bg-violet-500/25"
|
className="h-9 gap-2 rounded-[6px] border border-violet-200/90 bg-violet-50 px-3 font-medium text-violet-700 shadow-xs hover:bg-violet-100 hover:text-violet-800 dark:border-violet-500/40 dark:bg-violet-500/15 dark:text-violet-300 dark:hover:bg-violet-500/25"
|
||||||
onClick={() => void handleFillNames()}
|
onClick={() => void handleFillNames()}
|
||||||
disabled={
|
disabled={
|
||||||
fillNamesMutation.isPending ||
|
fillNamesMutation.isPending ||
|
||||||
@@ -530,11 +594,11 @@ function SkillSettingsList({
|
|||||||
)}
|
)}
|
||||||
{fillNamesMutation.isPending ? "补充中…" : "一键补充中文名"}
|
{fillNamesMutation.isPending ? "补充中…" : "一键补充中文名"}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
className="h-9 gap-2 rounded-[6px] border-border/80 bg-background px-3 shadow-xs hover:border-primary/30"
|
||||||
onClick={() => setInstallOpen(true)}
|
onClick={() => setInstallOpen(true)}
|
||||||
disabled={env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true"}
|
disabled={env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true"}
|
||||||
>
|
>
|
||||||
@@ -543,6 +607,7 @@ function SkillSettingsList({
|
|||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
|
className="h-9 gap-2 rounded-[6px] px-4 shadow-sm hover:shadow-md"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onClose?.();
|
onClose?.();
|
||||||
router.push("/page/workspace/chats/new?mode=skill");
|
router.push("/page/workspace/chats/new?mode=skill");
|
||||||
@@ -562,11 +627,34 @@ function SkillSettingsList({
|
|||||||
tagIds={tagIds}
|
tagIds={tagIds}
|
||||||
onTagIdsChange={setTagIds}
|
onTagIdsChange={setTagIds}
|
||||||
actions={
|
actions={
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex w-full flex-wrap items-center justify-end gap-2 sm:w-auto">
|
||||||
<ViewModeToggle value={viewMode} onChange={setViewMode} />
|
<DateRangePicker
|
||||||
|
className="lb-h9 w-full sm:w-[300px]"
|
||||||
|
value={createdAtRange}
|
||||||
|
valueType="YYYY-MM-DD"
|
||||||
|
format="YYYY-MM-DD"
|
||||||
|
placeholder={["开始日期", "结束日期"]}
|
||||||
|
presets={createdAtPresets}
|
||||||
|
presetsPlacement="bottom"
|
||||||
|
clearable
|
||||||
|
rangeInputProps={{ label: "创建时间" }}
|
||||||
|
popupProps={{ overlayClassName: "skill-created-at-range-popup" }}
|
||||||
|
onChange={setCreatedAtRange}
|
||||||
|
/>
|
||||||
|
{isAdmin && (
|
||||||
|
<ModelNameSelect
|
||||||
|
value={fillModel}
|
||||||
|
onChange={setFillModel}
|
||||||
|
disabled={
|
||||||
|
fillNamesMutation.isPending ||
|
||||||
|
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true"
|
||||||
|
}
|
||||||
|
triggerClassName="lb-h9 w-[9.5rem] rounded-[5px]"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Select value={sort} onValueChange={(v) => setSort(v as SkillSort)}>
|
<Select value={sort} onValueChange={(v) => setSort(v as SkillSort)}>
|
||||||
<SelectTrigger
|
<SelectTrigger
|
||||||
className="h-9 w-full gap-2 px-3 text-xs sm:w-[148px]"
|
className="h-9 w-full gap-2 rounded-[5px] px-3 text-xs sm:w-[148px]"
|
||||||
title="排序"
|
title="排序"
|
||||||
>
|
>
|
||||||
<ArrowDownUpIcon className="text-muted-foreground size-3.5" />
|
<ArrowDownUpIcon className="text-muted-foreground size-3.5" />
|
||||||
@@ -583,14 +671,10 @@ function SkillSettingsList({
|
|||||||
<SelectItem value="name_desc">名称 Z-A</SelectItem>
|
<SelectItem value="name_desc">名称 Z-A</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
<ViewModeToggle value={viewMode} onChange={setViewMode} className="rounded-[5px]" />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{!isLoading && !error && (
|
|
||||||
<div className="text-muted-foreground flex justify-end text-sm tabular-nums">
|
|
||||||
共 {orderedSkills.length} 个技能
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{publisher && (
|
{publisher && (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-muted-foreground text-xs">筛选发布者:</span>
|
<span className="text-muted-foreground text-xs">筛选发布者:</span>
|
||||||
@@ -616,8 +700,8 @@ function SkillSettingsList({
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
viewMode === "card"
|
viewMode === "card"
|
||||||
? "grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3"
|
? "grid grid-cols-1 gap-5 sm:grid-cols-2 xl:grid-cols-3"
|
||||||
: "flex flex-col gap-3",
|
: "flex flex-col gap-5",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{pagedSkills.map((skill) => (
|
{pagedSkills.map((skill) => (
|
||||||
@@ -747,14 +831,14 @@ export function SkillRow({
|
|||||||
async function handleSetEnabled(enabled: boolean) {
|
async function handleSetEnabled(enabled: boolean) {
|
||||||
try {
|
try {
|
||||||
await setEnabled.mutateAsync({ skillName: skill.name, enabled });
|
await setEnabled.mutateAsync({ skillName: skill.name, enabled });
|
||||||
toast.success(
|
void MessagePlugin.success(
|
||||||
enabled
|
enabled
|
||||||
? t.settings.skills.onlineSuccess
|
? t.settings.skills.onlineSuccess
|
||||||
: t.settings.skills.offlineSuccess,
|
: t.settings.skills.offlineSuccess,
|
||||||
);
|
);
|
||||||
setConfirmOfflineOpen(false);
|
setConfirmOfflineOpen(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(err instanceof Error ? err.message : String(err));
|
void MessagePlugin.error(err instanceof Error ? err.message : String(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,7 +955,12 @@ export function SkillRow({
|
|||||||
|
|
||||||
const badgeGroup = (
|
const badgeGroup = (
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<span className={cn(isCard && "truncate font-medium")}>
|
<span
|
||||||
|
className={cn(
|
||||||
|
"min-w-0 text-[15px] font-semibold tracking-[-0.01em] text-card-foreground",
|
||||||
|
isCard && "truncate",
|
||||||
|
)}
|
||||||
|
>
|
||||||
{skill.name_zh?.trim() ? skill.name_zh : desensitize(skill.name)}
|
{skill.name_zh?.trim() ? skill.name_zh : desensitize(skill.name)}
|
||||||
</span>
|
</span>
|
||||||
{skill.name_zh?.trim() && (
|
{skill.name_zh?.trim() && (
|
||||||
@@ -1002,6 +1091,7 @@ export function SkillRow({
|
|||||||
|
|
||||||
const metaNodes = (
|
const metaNodes = (
|
||||||
<>
|
<>
|
||||||
|
<div className="mt-1.5 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground">
|
||||||
{!isBuiltin && skill.owner_username && (
|
{!isBuiltin && skill.owner_username && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -1015,7 +1105,7 @@ export function SkillRow({
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-muted-foreground mt-1 flex max-w-full items-center gap-1 text-sm font-medium",
|
"flex max-w-full items-center gap-1 text-xs font-medium",
|
||||||
skill.owner_user_id && onPublisherClick &&
|
skill.owner_user_id && onPublisherClick &&
|
||||||
"hover:text-primary cursor-pointer transition-colors hover:underline",
|
"hover:text-primary cursor-pointer transition-colors hover:underline",
|
||||||
)}
|
)}
|
||||||
@@ -1030,23 +1120,25 @@ export function SkillRow({
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{skill.use_count !== undefined && (
|
{skill.use_count !== undefined && (
|
||||||
<div className="text-muted-foreground mt-1 text-xs">
|
<div className="flex items-center gap-1">
|
||||||
|
<MousePointerClickIcon className="size-3.5 shrink-0" />
|
||||||
|
<span>
|
||||||
{skill.use_count > 0
|
{skill.use_count > 0
|
||||||
? t.settings.skills.useCountInline.replace(
|
? t.settings.skills.useCountInline.replace(
|
||||||
"{count}",
|
"{count}",
|
||||||
String(skill.use_count),
|
String(skill.use_count),
|
||||||
)
|
)
|
||||||
: t.settings.skills.useCountInlineZero}
|
: t.settings.skills.useCountInlineZero}
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{formatDateTime(skill.created_at) && (
|
|
||||||
<div className="text-muted-foreground mt-1 flex items-center gap-1 text-xs">
|
|
||||||
<ClockIcon className="size-3.5 shrink-0" />
|
|
||||||
<span className="truncate">
|
|
||||||
创建时间:{formatDateTime(skill.created_at)}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{formatDateTime(skill.created_at) && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<ClockIcon className="size-3.5 shrink-0" />
|
||||||
|
<span>创建时间:{formatDateTime(skill.created_at)}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
{(skill.tags?.length ?? 0) > 0 && (
|
{(skill.tags?.length ?? 0) > 0 && (
|
||||||
<TagChipList tags={skill.tags!} className="mt-2" />
|
<TagChipList tags={skill.tags!} className="mt-2" />
|
||||||
)}
|
)}
|
||||||
@@ -1057,11 +1149,13 @@ export function SkillRow({
|
|||||||
<>
|
<>
|
||||||
{canToggleAvailability && (
|
{canToggleAvailability && (
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="icon"
|
||||||
variant={isOffline ? "default" : "outline"}
|
variant="ghost"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-8 shrink-0 gap-1.5 px-2.5",
|
"h-8 w-8 shrink-0 rounded-[5px]",
|
||||||
!isOffline && "text-destructive hover:text-destructive",
|
isOffline
|
||||||
|
? "text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600"
|
||||||
|
: "text-muted-foreground hover:bg-destructive/10 hover:text-destructive",
|
||||||
)}
|
)}
|
||||||
disabled={
|
disabled={
|
||||||
setEnabled.isPending ||
|
setEnabled.isPending ||
|
||||||
@@ -1079,6 +1173,11 @@ export function SkillRow({
|
|||||||
? t.settings.skills.onlineAction
|
? t.settings.skills.onlineAction
|
||||||
: t.settings.skills.offlineAction
|
: t.settings.skills.offlineAction
|
||||||
}
|
}
|
||||||
|
aria-label={
|
||||||
|
isOffline
|
||||||
|
? t.settings.skills.onlineAction
|
||||||
|
: t.settings.skills.offlineAction
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{setEnabled.isPending ? (
|
{setEnabled.isPending ? (
|
||||||
<Loader2 className="size-3.5 animate-spin" />
|
<Loader2 className="size-3.5 animate-spin" />
|
||||||
@@ -1087,15 +1186,12 @@ export function SkillRow({
|
|||||||
) : (
|
) : (
|
||||||
<PowerOff className="size-3.5" />
|
<PowerOff className="size-3.5" />
|
||||||
)}
|
)}
|
||||||
{isOffline
|
|
||||||
? t.settings.skills.onlineAction
|
|
||||||
: t.settings.skills.offlineAction}
|
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="h-8 w-8 shrink-0"
|
className="h-8 w-8 shrink-0 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
onClick={() => setTagPickerOpen(true)}
|
onClick={() => setTagPickerOpen(true)}
|
||||||
title={t.adminTags.manageTags}
|
title={t.adminTags.manageTags}
|
||||||
>
|
>
|
||||||
@@ -1106,7 +1202,7 @@ export function SkillRow({
|
|||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-8 w-8 shrink-0",
|
"h-8 w-8 shrink-0 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||||
skill.featured && "text-amber-600 hover:text-amber-700",
|
skill.featured && "text-amber-600 hover:text-amber-700",
|
||||||
)}
|
)}
|
||||||
disabled={setFeatured.isPending}
|
disabled={setFeatured.isPending}
|
||||||
@@ -1127,7 +1223,7 @@ export function SkillRow({
|
|||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-8 w-8 shrink-0",
|
"h-8 w-8 shrink-0 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||||
skill.pinned && "text-emerald-600 hover:text-emerald-700",
|
skill.pinned && "text-emerald-600 hover:text-emerald-700",
|
||||||
)}
|
)}
|
||||||
disabled={setPinned.isPending}
|
disabled={setPinned.isPending}
|
||||||
@@ -1148,7 +1244,7 @@ export function SkillRow({
|
|||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-8 w-8 shrink-0",
|
"h-8 w-8 shrink-0 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground",
|
||||||
skill.always_on && "text-amber-600 hover:text-amber-700",
|
skill.always_on && "text-amber-600 hover:text-amber-700",
|
||||||
)}
|
)}
|
||||||
disabled={setAlwaysOn.isPending}
|
disabled={setAlwaysOn.isPending}
|
||||||
@@ -1168,7 +1264,7 @@ export function SkillRow({
|
|||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="h-8 w-8 shrink-0"
|
className="h-8 w-8 shrink-0 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
disabled={setPublished.isPending}
|
disabled={setPublished.isPending}
|
||||||
onClick={() => void handleTogglePublished(!skill.published)}
|
onClick={() => void handleTogglePublished(!skill.published)}
|
||||||
title={
|
title={
|
||||||
@@ -1187,7 +1283,7 @@ export function SkillRow({
|
|||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="h-8 w-8 shrink-0"
|
className="h-8 w-8 shrink-0 rounded-[5px] text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||||
disabled={duplicateSkillMutation.isPending}
|
disabled={duplicateSkillMutation.isPending}
|
||||||
onClick={handleOpenDuplicate}
|
onClick={handleOpenDuplicate}
|
||||||
title="复制为新技能"
|
title="复制为新技能"
|
||||||
@@ -1198,7 +1294,7 @@ export function SkillRow({
|
|||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="text-destructive hover:text-destructive h-8 w-8 shrink-0"
|
className="h-8 w-8 shrink-0 rounded-[5px] text-destructive hover:bg-destructive/10 hover:text-destructive"
|
||||||
onClick={() => setConfirmDeleteOpen(true)}
|
onClick={() => setConfirmDeleteOpen(true)}
|
||||||
title={t.settings.skills.deleteAction}
|
title={t.settings.skills.deleteAction}
|
||||||
>
|
>
|
||||||
@@ -1208,34 +1304,80 @@ export function SkillRow({
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 图标配色:柔和浅底 + 饱和前景(参考应用市场风格),不再使用实色重底。
|
||||||
|
// 图标多样化:按名称关键词匹配语义图标,未命中则按名称哈希从图标族轮换;
|
||||||
|
// 配色沿用柔和浅底 + 饱和前景(参考应用市场风格),同技能稳定不闪变。
|
||||||
|
const iconPalette = [
|
||||||
|
{ Icon: GlobeIcon, className: "bg-emerald-50 text-emerald-600 ring-1 ring-emerald-100 dark:bg-emerald-400/10 dark:text-emerald-300 dark:ring-emerald-400/20", card: "bg-gradient-to-br from-emerald-50/60 via-card to-card dark:from-emerald-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: FileArchive, className: "bg-violet-50 text-violet-600 ring-1 ring-violet-100 dark:bg-violet-400/10 dark:text-violet-300 dark:ring-violet-400/20", card: "bg-gradient-to-br from-violet-50/60 via-card to-card dark:from-violet-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: WorkflowIcon, className: "bg-sky-50 text-sky-600 ring-1 ring-sky-100 dark:bg-sky-400/10 dark:text-sky-300 dark:ring-sky-400/20", card: "bg-gradient-to-br from-sky-50/60 via-card to-card dark:from-sky-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: Upload, className: "bg-amber-50 text-amber-600 ring-1 ring-amber-100 dark:bg-amber-400/10 dark:text-amber-300 dark:ring-amber-400/20", card: "bg-gradient-to-br from-amber-50/60 via-card to-card dark:from-amber-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: BarChart3Icon, className: "bg-teal-50 text-teal-600 ring-1 ring-teal-100 dark:bg-teal-400/10 dark:text-teal-300 dark:ring-teal-400/20", card: "bg-gradient-to-br from-teal-50/60 via-card to-card dark:from-teal-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: MessageSquareTextIcon, className: "bg-rose-50 text-rose-600 ring-1 ring-rose-100 dark:bg-rose-400/10 dark:text-rose-300 dark:ring-rose-400/20", card: "bg-gradient-to-br from-rose-50/60 via-card to-card dark:from-rose-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: DatabaseIcon, className: "bg-indigo-50 text-indigo-600 ring-1 ring-indigo-100 dark:bg-indigo-400/10 dark:text-indigo-300 dark:ring-indigo-400/20", card: "bg-gradient-to-br from-indigo-50/60 via-card to-card dark:from-indigo-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
{ Icon: ClockIcon, className: "bg-orange-50 text-orange-600 ring-1 ring-orange-100 dark:bg-orange-400/10 dark:text-orange-300 dark:ring-orange-400/20", card: "bg-gradient-to-br from-orange-50/60 via-card to-card dark:from-orange-400/[0.05] dark:via-card dark:to-card" },
|
||||||
|
];
|
||||||
|
const iconKeywords: Array<{ match: RegExp; icon: number }> = [
|
||||||
|
{ match: /web|search|crawl|spider/i, icon: 0 },
|
||||||
|
{ match: /doc|file|archive|report|md/i, icon: 1 },
|
||||||
|
{ match: /workflow|agent|pipeline|flow/i, icon: 2 },
|
||||||
|
{ match: /upload|install|package/i, icon: 3 },
|
||||||
|
{ match: /chart|analysis|stat|visual/i, icon: 4 },
|
||||||
|
{ match: /chat|message|qa|对话|问答/i, icon: 5 },
|
||||||
|
{ match: /data|database|db|sql/i, icon: 6 },
|
||||||
|
{ match: /time|timing|schedule|cron/i, icon: 7 },
|
||||||
|
];
|
||||||
|
const nameHash = [...skill.name].reduce((acc, ch) => acc + ch.charCodeAt(0), 0);
|
||||||
|
const keywordIcon = iconKeywords.find(({ match }) => match.test(skill.name) || match.test(skill.description ?? ""));
|
||||||
|
const iconStyle = keywordIcon
|
||||||
|
? iconPalette[keywordIcon.icon]
|
||||||
|
: iconPalette[nameHash % iconPalette.length];
|
||||||
|
const SkillIcon = iconStyle.Icon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isCard ? (
|
{isCard ? (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex h-full min-w-0 flex-col rounded-lg border p-3 transition-shadow hover:shadow-sm dark:border-[#213D5E] dark:bg-[#02244C] dark:text-white",
|
"flex h-full min-w-0 flex-col rounded-[5px] p-4 shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-shadow hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)]",
|
||||||
isOffline && "bg-muted/60 border-dashed dark:bg-[#071D36]",
|
isOffline
|
||||||
|
? "border border-dashed border-border/60 bg-muted/50"
|
||||||
|
: iconStyle.card,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="min-w-0 flex-1 cursor-pointer"
|
className="min-w-0 flex-1 cursor-pointer"
|
||||||
onClick={() => setDetailOpen(true)}
|
onClick={() => setDetailOpen(true)}
|
||||||
>
|
>
|
||||||
|
<div className="flex items-start gap-3.5">
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex size-12 shrink-0 items-center justify-center rounded-full",
|
||||||
|
iconStyle.className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<SkillIcon className="size-6" />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 flex-1">
|
||||||
{badgeGroup}
|
{badgeGroup}
|
||||||
<p className="text-muted-foreground mt-1 line-clamp-3 text-sm">
|
<p className="text-muted-foreground mt-1.5 line-clamp-3 text-sm leading-6">
|
||||||
{desensitize(skill.description ?? "")}
|
{desensitize(skill.description ?? "")}
|
||||||
</p>
|
</p>
|
||||||
{metaNodes}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 flex flex-wrap items-center justify-end gap-1 border-t pt-2 dark:border-[#213D5E]">
|
</div>
|
||||||
|
<div className="mt-3">{metaNodes}</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4 flex flex-wrap items-center justify-end gap-1 border-t border-border/70 pt-3">
|
||||||
{actionButtons}
|
{actionButtons}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Item
|
<Item
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full dark:border-[#213D5E] dark:bg-[#02244C] dark:text-white",
|
"group/skill-card w-full rounded-[5px] border-0 px-5 py-3 shadow-[0_2px_8px_rgba(15,23,42,0.06)] transition-shadow hover:shadow-[0_4px_14px_rgba(15,23,42,0.10)]",
|
||||||
isOffline && "bg-muted/60 border-dashed dark:bg-[#071D36]",
|
isOffline
|
||||||
|
? "border border-dashed border-border/60 bg-muted/50"
|
||||||
|
: iconStyle.card,
|
||||||
)}
|
)}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
>
|
>
|
||||||
@@ -1243,11 +1385,23 @@ export function SkillRow({
|
|||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
onClick={() => setDetailOpen(true)}
|
onClick={() => setDetailOpen(true)}
|
||||||
>
|
>
|
||||||
|
<div className="flex min-w-0 items-center gap-4">
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex size-12 shrink-0 items-center justify-center rounded-full",
|
||||||
|
iconStyle.className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<SkillIcon className="size-6" />
|
||||||
|
</div>
|
||||||
|
<div className="min-w-0 flex-1 pt-0.5">
|
||||||
<ItemTitle>{badgeGroup}</ItemTitle>
|
<ItemTitle>{badgeGroup}</ItemTitle>
|
||||||
<ItemDescription className="line-clamp-4">
|
<ItemDescription className="mt-1.5 line-clamp-2 leading-5">
|
||||||
{desensitize(skill.description ?? "")}
|
{desensitize(skill.description ?? "")}
|
||||||
</ItemDescription>
|
</ItemDescription>
|
||||||
{metaNodes}
|
<div className="mt-2">{metaNodes}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>{actionButtons}</ItemActions>
|
<ItemActions>{actionButtons}</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
@@ -1319,37 +1473,30 @@ export function SkillRow({
|
|||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<Dialog open={confirmOfflineOpen} onOpenChange={setConfirmOfflineOpen}>
|
<TDesignDialog
|
||||||
<DialogContent>
|
visible={confirmOfflineOpen}
|
||||||
<DialogHeader>
|
header={t.settings.skills.offlineConfirmTitle}
|
||||||
<DialogTitle>{t.settings.skills.offlineConfirmTitle}</DialogTitle>
|
body={t.settings.skills.offlineConfirmDescription.replace(
|
||||||
<DialogDescription>
|
|
||||||
{t.settings.skills.offlineConfirmDescription.replace(
|
|
||||||
"{name}",
|
"{name}",
|
||||||
desensitize(skill.name),
|
desensitize(skill.name),
|
||||||
)}
|
)}
|
||||||
</DialogDescription>
|
theme="danger"
|
||||||
</DialogHeader>
|
placement="center"
|
||||||
<DialogFooter>
|
cancelBtn={{
|
||||||
<Button
|
children: t.common.cancel,
|
||||||
variant="outline"
|
disabled: setEnabled.isPending,
|
||||||
onClick={() => setConfirmOfflineOpen(false)}
|
}}
|
||||||
disabled={setEnabled.isPending}
|
confirmBtn={{
|
||||||
>
|
children: t.settings.skills.offlineAction,
|
||||||
{t.common.cancel}
|
theme: "danger",
|
||||||
</Button>
|
}}
|
||||||
<Button
|
confirmLoading={setEnabled.isPending}
|
||||||
variant="destructive"
|
closeBtn={!setEnabled.isPending}
|
||||||
onClick={() => void handleSetEnabled(false)}
|
closeOnEscKeydown={!setEnabled.isPending}
|
||||||
disabled={setEnabled.isPending}
|
closeOnOverlayClick={!setEnabled.isPending}
|
||||||
>
|
onClose={() => setConfirmOfflineOpen(false)}
|
||||||
{setEnabled.isPending
|
onConfirm={() => void handleSetEnabled(false)}
|
||||||
? t.common.loading
|
/>
|
||||||
: t.settings.skills.offlineAction}
|
|
||||||
</Button>
|
|
||||||
</DialogFooter>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
<TagPickerDialog
|
<TagPickerDialog
|
||||||
open={tagPickerOpen}
|
open={tagPickerOpen}
|
||||||
onOpenChange={setTagPickerOpen}
|
onOpenChange={setTagPickerOpen}
|
||||||
@@ -1418,6 +1565,7 @@ function InstallSkillDialog({
|
|||||||
const [nameZhModel, setNameZhModel] = useState<string | null>(null);
|
const [nameZhModel, setNameZhModel] = useState<string | null>(null);
|
||||||
const validateMutation = useValidateSkillUpload();
|
const validateMutation = useValidateSkillUpload();
|
||||||
const installMutation = useInstallSkillUpload();
|
const installMutation = useInstallSkillUpload();
|
||||||
|
const { data: skillVersioning } = useSkillVersioningSettings();
|
||||||
const setNameZhMutation = useSetSkillNameZh();
|
const setNameZhMutation = useSetSkillNameZh();
|
||||||
const generateNameZhMutation = useGenerateSkillNameZh();
|
const generateNameZhMutation = useGenerateSkillNameZh();
|
||||||
|
|
||||||
@@ -1506,10 +1654,18 @@ function InstallSkillDialog({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleInstall = useCallback(
|
const handleInstall = useCallback(
|
||||||
async (overwrite: boolean) => {
|
async (
|
||||||
|
overwrite: boolean,
|
||||||
|
installMode?: "iterate" | "overwrite",
|
||||||
|
) => {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
try {
|
try {
|
||||||
const result = await installMutation.mutateAsync({ file, overwrite, targetCategory });
|
const result = await installMutation.mutateAsync({
|
||||||
|
file,
|
||||||
|
overwrite,
|
||||||
|
targetCategory,
|
||||||
|
installMode,
|
||||||
|
});
|
||||||
toast.success(
|
toast.success(
|
||||||
(result.overwritten ? dialog.installSuccessReplaced : dialog.installSuccess).replace(
|
(result.overwritten ? dialog.installSuccessReplaced : dialog.installSuccess).replace(
|
||||||
"{name}",
|
"{name}",
|
||||||
@@ -1564,6 +1720,10 @@ function InstallSkillDialog({
|
|||||||
const canInstall = !!validation && !validationError && validation.can_install_as_is;
|
const canInstall = !!validation && !validationError && validation.can_install_as_is;
|
||||||
const canOverwrite = !!validation && !validationError && validation.can_overwrite;
|
const canOverwrite = !!validation && !validationError && validation.can_overwrite;
|
||||||
const ownCustomCanOverwrite = !!isCustomConflict && !!validation?.owned_by_me && canOverwrite;
|
const ownCustomCanOverwrite = !!isCustomConflict && !!validation?.owned_by_me && canOverwrite;
|
||||||
|
const showIterationChoices =
|
||||||
|
skillVersioning?.enabled === true &&
|
||||||
|
targetCategory === "custom" &&
|
||||||
|
ownCustomCanOverwrite;
|
||||||
const otherCustomConflict = !!isCustomConflict && !!validation?.owned_by_other;
|
const otherCustomConflict = !!isCustomConflict && !!validation?.owned_by_other;
|
||||||
// On-disk leftover with no ownership record: replaceable by whoever uploads it.
|
// On-disk leftover with no ownership record: replaceable by whoever uploads it.
|
||||||
const unclaimedCustomConflict =
|
const unclaimedCustomConflict =
|
||||||
@@ -1789,6 +1949,12 @@ function InstallSkillDialog({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{showIterationChoices && (
|
||||||
|
<div className="bg-muted/40 mt-1 rounded-md border px-3 py-2 text-xs leading-relaxed">
|
||||||
|
<span className="font-medium">请选择更新方式:</span>
|
||||||
|
迭代会保留旧版本并把本次上传设为最新版;直接覆盖会清除旧版本链,从本次上传重新作为第 1 版记录。两种方式都不会清零技能调用次数。
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{isPublicConflict && (
|
{isPublicConflict && (
|
||||||
<div className={cn("mt-1 flex items-start gap-2 text-xs", adminCanOverwritePublic ? "text-amber-600" : "text-destructive")}>
|
<div className={cn("mt-1 flex items-start gap-2 text-xs", adminCanOverwritePublic ? "text-amber-600" : "text-destructive")}>
|
||||||
<AlertCircle className="mt-0.5 size-3.5 shrink-0" />
|
<AlertCircle className="mt-0.5 size-3.5 shrink-0" />
|
||||||
@@ -1810,20 +1976,37 @@ function InstallSkillDialog({
|
|||||||
>
|
>
|
||||||
{dialog.cancel}
|
{dialog.cancel}
|
||||||
</Button>
|
</Button>
|
||||||
{canOverwrite && (
|
{showIterationChoices && (
|
||||||
<Button
|
<Button
|
||||||
variant="destructive"
|
onClick={() => void handleInstall(true, "iterate")}
|
||||||
onClick={() => handleInstall(true)}
|
|
||||||
disabled={installMutation.isPending}
|
disabled={installMutation.isPending}
|
||||||
>
|
>
|
||||||
{installMutation.isPending && (
|
{installMutation.isPending && (
|
||||||
<Loader2 className="size-4 animate-spin" />
|
<Loader2 className="size-4 animate-spin" />
|
||||||
)}
|
)}
|
||||||
{dialog.replace}
|
迭代为新版本
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{canOverwrite && (
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleInstall(false)}
|
variant="destructive"
|
||||||
|
onClick={() =>
|
||||||
|
void handleInstall(
|
||||||
|
true,
|
||||||
|
showIterationChoices ? "overwrite" : undefined,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
disabled={installMutation.isPending}
|
||||||
|
>
|
||||||
|
{installMutation.isPending && (
|
||||||
|
<Loader2 className="size-4 animate-spin" />
|
||||||
|
)}
|
||||||
|
{showIterationChoices ? "直接覆盖" : dialog.replace}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{!showIterationChoices && (
|
||||||
|
<Button
|
||||||
|
onClick={() => void handleInstall(false)}
|
||||||
disabled={!canInstall || installMutation.isPending}
|
disabled={!canInstall || installMutation.isPending}
|
||||||
>
|
>
|
||||||
{installMutation.isPending && (
|
{installMutation.isPending && (
|
||||||
@@ -1831,6 +2014,7 @@ function InstallSkillDialog({
|
|||||||
)}
|
)}
|
||||||
{installMutation.isPending ? dialog.installing : dialog.install}
|
{installMutation.isPending ? dialog.installing : dialog.install}
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ArchiveIcon, ClockIcon, MoreHorizontalIcon, RotateCcwIcon, Trash2Icon } from "lucide-react";
|
import { ArchiveIcon, ClockIcon, MoreHorizontalIcon, RotateCcwIcon, Trash2Icon } from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { Pencil, Plus, Trash2 } from "lucide-react";
|
import { Pencil, Plus, Trash2 } from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "@/core/ui/feedback";
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|||||||