From 8e263a1d7657b6b23cf7d1aeaad707d1b9847adf Mon Sep 17 00:00:00 2001
From: sophie <16087569+sophie_liang@user.noreply.gitee.com>
Date: Thu, 21 May 2026 15:14:56 +0800
Subject: [PATCH] fix: update ui
---
docs/GIT_HOOKS.md | 221 ++++++++++++
docs/新人环境搭建与配置文档.md | 20 +-
frontend/src/components/kb/KbAdminPanel.vue | 354 +++++++++++++++++++
frontend/src/config.ts | 1 +
frontend/src/i18n.ts | 22 +-
frontend/src/router/index.ts | 5 +-
frontend/src/views/AdminView.vue | 28 +-
frontend/src/views/ChatView.vue | 6 +-
frontend/src/views/KbAdminView.vue | 360 --------------------
9 files changed, 617 insertions(+), 400 deletions(-)
create mode 100644 docs/GIT_HOOKS.md
create mode 100644 frontend/src/components/kb/KbAdminPanel.vue
delete mode 100644 frontend/src/views/KbAdminView.vue
diff --git a/docs/GIT_HOOKS.md b/docs/GIT_HOOKS.md
new file mode 100644
index 00000000..b1bbb961
--- /dev/null
+++ b/docs/GIT_HOOKS.md
@@ -0,0 +1,221 @@
+# Git Hooks 团队启用指南
+
+> 更新时间:2026-05-21
+> 适用对象:全体开发同学
+> 相关脚本:`.githooks/`、`scripts/install_git_hooks.sh`、`scripts/ci_frontend_build.sh`
+
+团队启用 Git Hook 分两步:**仓库里已有 `.githooks/`(`git pull` 即有)**,**每人本机执行一次安装**。
+
+---
+
+## 1. 策略概览
+
+本地两层 Hook + 远程 Jenkins CI,避免「日常只跑 `npm run dev`、上线 Jenkins `npm run build` 才报错」。
+
+| 层级 | 时机 | 谁生效 | 检查内容 |
+|------|------|--------|----------|
+| **pre-commit** | `git commit` | 已安装 Hook 的本机 | models 须带 migration;暂存 `frontend/` 时跑 `vue-tsc` |
+| **pre-push** | `git push` | 已安装 Hook 的本机 | 本次推送含 `frontend/` 变更时跑 `npm run build` |
+| **Jenkins CI** | push 触发流水线 | 全员(不装 Hook 也跑) | `npm ci && npm run build`(`scripts/ci_frontend_build.sh`) |
+
+- Hook **不会**随 `git clone` 自动启用,需每人配置 `core.hooksPath=.githooks`。
+- 没装 Hook 时,主要靠 Jenkins **Frontend Build (CI)** 阶段兜底。
+- 日常开发仍用 `npm run dev`;Hook 只在 commit / push 时额外检查。
+
+---
+
+## 2. 确认仓库里已有钩子文件
+
+在项目根目录(与 `frontend`、`backend` 同级):
+
+**PowerShell:**
+
+```powershell
+cd D:\path\to\hxops
+git pull
+dir .githooks
+```
+
+**Git Bash:**
+
+```bash
+cd /path/to/hxops
+git pull
+ls -la .githooks
+```
+
+应能看到:
+
+- `pre-commit`
+- `pre-push`
+- `_common.sh`
+
+若目录不存在,先 `git pull` 到包含这些文件的版本。
+
+---
+
+## 3. 本机启用(每人、每个 clone 做一次)
+
+### 3.1 方式 A:安装脚本(推荐)
+
+在 **Git Bash** 或 **WSL** 中:
+
+```bash
+cd /path/to/hxops
+chmod +x scripts/install_git_hooks.sh
+./scripts/install_git_hooks.sh
+```
+
+成功输出示例:
+
+```text
+[hook-install] Installed Git hooks successfully.
+[hook-install] pre-commit: models 变更需带 migration;frontend 暂存时跑 vue-tsc
+[hook-install] pre-push: 推送含 frontend 变更时跑 npm run build
+[hook-install] core.hooksPath=.githooks
+```
+
+### 3.2 方式 B:PowerShell / CMD
+
+不跑 bash 脚本时,在仓库根执行:
+
+```powershell
+cd D:\path\to\hxops
+git config core.hooksPath .githooks
+```
+
+若 commit/push 时提示无执行权限,在 Git Bash 中补充:
+
+```bash
+chmod +x .githooks/pre-commit .githooks/pre-push
+```
+
+### 3.3 方式 C:hxops_menu 菜单
+
+在 Git Bash 中运行 `hxops_menu.sh`,选择 **`hook`** 或 **`43`**,确认安装。
+
+---
+
+## 4. 验证是否生效
+
+```powershell
+git config --get core.hooksPath
+```
+
+应输出:`.githooks`
+
+安装前端依赖(Hook 跑检查前必需):
+
+```powershell
+cd frontend
+npm install
+```
+
+可选自测:暂存一个 `frontend/` 下的小改动后 `git commit`(会触发 `vue-tsc`),测完 `git reset` 即可。
+
+---
+
+## 5. 装好后会自动做什么
+
+### 5.1 pre-commit
+
+| 条件 | 行为 |
+|------|------|
+| 暂存了 `backend/app/models.py`,但未暂存 `backend/migrations/versions/*.py` | **拒绝 commit** |
+| 暂存路径含 `frontend/` | 运行 `npx vue-tsc -b`(需已有 `node_modules`) |
+| 未暂存 `frontend/` | 不跑前端检查 |
+
+`SKIP_FRONTEND_HOOKS` **不能**跳过 models/migration 检查。
+
+### 5.2 pre-push
+
+| 条件 | 行为 |
+|------|------|
+| 本次 push 的提交 diff 含 `frontend/` | 运行 `npm run build`(`vue-tsc -b && vite build`) |
+| 无 `frontend/` 变更 | 直接通过 |
+
+### 5.3 Jenkins CI
+
+- 在 **Detect Changes** 之后、**Deploy** 之前执行。
+- 仅当 `FRONTEND_CHANGED=true` 时在 `node:22-alpine` 容器内执行 `scripts/ci_frontend_build.sh`。
+
+---
+
+## 6. 团队落地清单(可转发)
+
+1. **新同事**:`git clone` → `cd frontend && npm install` → 按本文 **§3** 安装 Hook → **§4** 验证。
+2. **老同事**:`git pull` 后若从未装过,补做一次安装。
+3. **换电脑 / 新 clone**:每个新目录都要再装一次(`core.hooksPath` 写在本地 `.git/config`,不随 push 同步)。
+4. **Windows**:建议用 Git for Windows 自带的 Git Bash 执行 commit/push;PowerShell 可用 **§3.2** 仅完成 Hook 路径配置。
+
+---
+
+## 7. 应急跳过(不要常态化)
+
+### 7.1 只跳过前端检查
+
+migration 规则在 pre-commit 中仍会执行。
+
+**Git Bash:**
+
+```bash
+SKIP_FRONTEND_HOOKS=1 git commit -m "your message"
+SKIP_FRONTEND_HOOKS=1 git push
+```
+
+**PowerShell(当前终端会话):**
+
+```powershell
+$env:SKIP_FRONTEND_HOOKS = "1"
+git commit -m "your message"
+git push
+```
+
+### 7.2 跳过全部 Hook
+
+```bash
+git commit --no-verify
+git push --no-verify
+```
+
+同时跳过 migration、vue-tsc、build 等所有 Hook。
+
+### 7.3 环境变量说明
+
+| 变量 | 默认值 | 生效条件 |
+|------|--------|----------|
+| `SKIP_FRONTEND_HOOKS` | 未设置 | 设为 `1` 时跳过前端 vue-tsc / build |
+| `SKIP_GIT_HOOKS` | 未设置 | 设为 `1` 时跳过前端检查(与上一项在前端逻辑等价) |
+
+仓库内**没有**预置这些变量的配置文件,仅在单次命令前临时设置。
+
+---
+
+## 8. 常见问题
+
+| 现象 | 处理 |
+|------|------|
+| `dir .githooks` 找不到 | `git pull`;确认在仓库根目录 |
+| `missing hook file` | 同上,确保 `.githooks` 已拉取 |
+| `frontend/node_modules 不存在` | `cd frontend && npm install` |
+| PowerShell 无法执行 `.sh` | 用 **§3.2** 的 `git config`,或改用 Git Bash |
+| 装了 Hook 仍不拦截 | 确认 `git config --get core.hooksPath`;是否用了 `--no-verify` |
+| 想取消 Hook | `git config --unset core.hooksPath` |
+
+---
+
+## 9. 相关文件
+
+| 路径 | 说明 |
+|------|------|
+| `.githooks/pre-commit` | 提交时检查 |
+| `.githooks/pre-push` | 推送时检查 |
+| `.githooks/_common.sh` | 共用逻辑 |
+| `scripts/install_git_hooks.sh` | 一键安装 |
+| `scripts/ci_frontend_build.sh` | Jenkins / 本地 CI 同款 build |
+| `Jenkinsfile` | `Frontend Build (CI)` 阶段 |
+| `docs/新人环境搭建与配置文档.md` | 新人环境 §4.2 简要说明 |
+
+---
+
+维护建议:调整 Hook 规则或 Jenkins 构建步骤后,请同步更新本文档。
diff --git a/docs/新人环境搭建与配置文档.md b/docs/新人环境搭建与配置文档.md
index 504666ba..ba0cc1be 100644
--- a/docs/新人环境搭建与配置文档.md
+++ b/docs/新人环境搭建与配置文档.md
@@ -65,31 +65,21 @@ cd hxops
### 4.2 安装 Git Hooks(推荐,每人 clone 后执行一次)
-仓库根目录的 `.githooks/` 会随代码拉取;**不会自动生效**,需在本机启用:
+完整说明见 **[Git Hooks 团队启用指南](./GIT_HOOKS.md)**(策略、安装步骤、验证、跳过方式、常见问题)。
-| Hook | 时机 | 检查内容 |
-|------|------|----------|
-| `pre-commit` | `git commit` | 改 `models.py` 须同时提交 migration;暂存 `frontend/` 时跑 `vue-tsc` |
-| `pre-push` | `git push` | 本次推送含 `frontend/` 变更时跑 `npm run build`(与 Jenkins 部署一致) |
-
-**Git Bash / WSL:**
+快速安装:
```bash
-chmod +x scripts/install_git_hooks.sh .githooks/pre-commit .githooks/pre-push
+# Git Bash / WSL
./scripts/install_git_hooks.sh
```
-**PowerShell(仅启用钩子目录):**
-
```powershell
+# PowerShell
git config core.hooksPath .githooks
```
-验证:`git config --get core.hooksPath` 应输出 `.githooks`。
-
-前置:已执行 `cd frontend && npm install`。应急跳过前端检查:`$env:SKIP_FRONTEND_HOOKS="1"`(bash 为 `SKIP_FRONTEND_HOOKS=1`)。
-
-Jenkins 在检测到 `frontend/` 变更时会再跑一遍同款构建(`scripts/ci_frontend_build.sh`),作为 Hook 被跳过时的兜底。
+验证:`git config --get core.hooksPath` → `.githooks`;前置:`cd frontend && npm install`。
### 4.3 常用 Git 操作示例
diff --git a/frontend/src/components/kb/KbAdminPanel.vue b/frontend/src/components/kb/KbAdminPanel.vue
new file mode 100644
index 00000000..677d059a
--- /dev/null
+++ b/frontend/src/components/kb/KbAdminPanel.vue
@@ -0,0 +1,354 @@
+
+
+
+
+
+
+
知识库管理
+
+ 第一阶段先承接分组、任务和 Dify 管理入口,后续再接入清洗链路。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ formTitle }}
+
{{ formDescription }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ feedback }}
+
+
+
+
+
+
+
+
知识库分组概览
+ {{ isRefreshing ? '加载中...' : '/api/kb/groups' }}
+
+
+ 当前暂无分组,或知识库接口尚未联调完成。
+
+
+
+
+
+
{{ group.name }}
+
{{ group.description || '暂无描述' }}
+
+
+ {{ group.document_count ?? 0 }} 文档
+
+
+
+
+ 更新时间:{{ group.updated_at || '--' }}
+
+
+
+
+
+
+
+
+
+
任务队列占位
+ /api/kb/jobs
+
+
+ 暂无任务。第二阶段会在这里接入清洗、同步和重试任务。
+
+
+
+
+
+
{{ job.job_type }}
+
{{ job.created_at || '--' }}
+
+ {{ job.message || '暂无任务说明' }}
+
+
+ 文档:{{ job.document_id ?? '--' }} · 版本:{{ job.document_version_id ?? '--' }} · 进度:{{ job.progress ?? 0 }}%
+
+
+
+ {{ job.status }}
+
+
+
+
+
+
+
+
+
+
+
+
+ { feedback = message; feedbackType = 'success'; void loadData(); }"
+ @error="(message) => { feedback = message; feedbackType = 'error'; }"
+ />
+ { feedback = message; feedbackType = 'error'; }"
+ />
+
diff --git a/frontend/src/config.ts b/frontend/src/config.ts
index 21b7019a..43ccaebe 100644
--- a/frontend/src/config.ts
+++ b/frontend/src/config.ts
@@ -54,6 +54,7 @@ export const config = {
users: true, // 用户管理
departments: true, // 部门管理
agents: true, // 应用管理
+ knowledge_base: true, // 知识库管理
announcements: true, // 公告管理
questions: true, // 常用问题
wecom: true, // 企业微信
diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts
index bbe9fa49..f004e8bc 100644
--- a/frontend/src/i18n.ts
+++ b/frontend/src/i18n.ts
@@ -112,9 +112,9 @@ const messages = {
},
landing: {
hero: {
- prefix: 'Unleash the Power of',
- highlight: 'Generative AI',
- subtitle: 'Access a suite of powerful AI agents tailored for your enterprise needs. Secure, scalable, and intelligent.'
+ prefix: 'Hexin Precision',
+ highlight: 'AI Agent Application Platform',
+ subtitle: 'In the world of AI, we hope you enjoy your work and live happily.'
},
agent: {
role: 'AI Assistant'
@@ -245,6 +245,7 @@ const messages = {
users: 'User Maintenance',
departments: 'Departments',
agents: 'Agent Management',
+ knowledgeBase: 'Knowledge Base',
announcements: 'Announcements',
questions: 'Common Questions',
wecom: 'WeCom',
@@ -1133,6 +1134,7 @@ const messages = {
users: '用户管理',
departments: '部门管理',
agents: '应用管理',
+ knowledgeBase: '知识库管理',
announcements: '公告管理',
questions: '常用问题',
wecom: '企业微信',
@@ -1856,9 +1858,9 @@ const messages = {
},
landing: {
hero: {
- prefix: '釋放',
- highlight: '生成式 AI 的力量',
- subtitle: '訪問為您企業量身定制的強大 AI 助手套件。安全、可擴展、智能。'
+ prefix: '和信精密',
+ highlight: 'AI 智能體 應用平台',
+ subtitle: 'AI 的世界,期望讓你開心工作,快樂生活。'
},
agent: {
role: 'AI 助手'
@@ -1984,6 +1986,7 @@ const messages = {
users: '用戶管理',
departments: '部門管理',
agents: '應用管理',
+ knowledgeBase: '知識庫管理',
announcements: '公告管理',
questions: '常用問題',
wecom: '企業微信',
@@ -2712,9 +2715,9 @@ const messages = {
},
landing: {
hero: {
- prefix: 'ปลดปล่อยพลังของ',
- highlight: 'Generative AI',
- subtitle: 'เข้าถึงชุดผู้ช่วย AI ที่ทรงพลังซึ่งปรับแต่งมาเพื่อความต้องการขององค์กรของคุณ ปลอดภัย ปรับขนาดได้ และชาญฉลาด'
+ prefix: '和信精密',
+ highlight: 'แพลตฟอร์มแอปพลิเคชัน AI Agent',
+ subtitle: 'ในโลกของ AI เราหวังว่าคุณจะทำงานอย่างมีความสุข และใช้ชีวิตอย่างสนุกสนาน'
},
agent: {
role: 'ผู้ช่วย AI'
@@ -2840,6 +2843,7 @@ const messages = {
users: 'การจัดการผู้ใช้',
departments: 'การจัดการแผนก',
agents: 'การจัดการตัวแทน',
+ knowledgeBase: 'การจัดการคลังความรู้',
announcements: 'การจัดการประกาศ',
questions: 'คำถามทั่วไป',
wecom: 'WeCom',
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 2af810a5..2e7ca496 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -6,7 +6,6 @@ import ChatView from '../views/ChatView.vue';
import AdminView from '../views/AdminView.vue';
import ResetPasswordView from '../views/ResetPasswordView.vue';
import KbWorkspaceView from '../views/KbWorkspaceView.vue';
-import KbAdminView from '../views/KbAdminView.vue';
import { config } from '../config';
import { getStoredAuthUser } from '../utils/auth';
@@ -50,9 +49,7 @@ const routes = [
},
{
path: '/kb/admin',
- name: 'KbAdmin',
- component: KbAdminView,
- meta: { title: '知识库管理台' }
+ redirect: { path: '/admin', query: { module: 'knowledge_base' } }
},
];
diff --git a/frontend/src/views/AdminView.vue b/frontend/src/views/AdminView.vue
index eb2e18d0..d2bd68f8 100644
--- a/frontend/src/views/AdminView.vue
+++ b/frontend/src/views/AdminView.vue
@@ -11,7 +11,8 @@
* - 该页面后续可继续优化按模块懒加载数据
*/
import { ref, onMounted, watch, computed } from 'vue';
-import { useRouter } from 'vue-router';
+import { useRoute, useRouter } from 'vue-router';
+import KbAdminPanel from '../components/kb/KbAdminPanel.vue';
import { useI18n } from 'vue-i18n';
import { config } from '../config';
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
@@ -68,6 +69,7 @@ const sidebarItems = computed(() => {
{ id: 'users', icon: UserCog, label: t('admin.nav.users') },
{ id: 'departments', icon: Building, label: t('admin.nav.departments') },
{ id: 'agents', icon: Bot, label: t('admin.nav.agents') },
+ { id: 'knowledge_base', icon: FileText, label: t('admin.nav.knowledgeBase') },
{ id: 'schedules', icon: Settings2, label: '排程管理' },
{ id: 'announcements', icon: Megaphone, label: t('admin.nav.announcements') },
{ id: 'questions', icon: MessageCircleQuestion, label: t('admin.nav.questions') },
@@ -235,9 +237,10 @@ interface WecomIntegrationManifest {
// 获取路由实例,用于页面跳转
const router = useRouter();
+const route = useRoute();
// 当前左侧菜单激活的模块:dashboard / agents / permissions
-const activeModule = ref<'dashboard' | 'agents' | 'announcements' | 'permissions' | 'requests' | 'reports' | 'approvals' | 'users' | 'departments' | 'questions' | 'wecom' | 'schedules'>('dashboard');
+const activeModule = ref<'dashboard' | 'agents' | 'announcements' | 'permissions' | 'requests' | 'reports' | 'approvals' | 'users' | 'departments' | 'questions' | 'wecom' | 'schedules' | 'knowledge_base'>('dashboard');
const expandedReports = ref(true);
// agents:管理员视角下的所有 Agent 列表
@@ -2106,6 +2109,15 @@ onMounted(async () => {
return;
}
+ const moduleQuery = typeof route.query.module === 'string' ? route.query.module : '';
+ const allowedModules = sidebarItems.value.map((item) => item.id);
+ if (moduleQuery && allowedModules.includes(moduleQuery)) {
+ activeModule.value = moduleQuery as typeof activeModule.value;
+ if (route.query.module) {
+ router.replace({ path: '/admin' });
+ }
+ }
+
isLoading.value = true;
await Promise.all([
loadAgents(),
@@ -3343,13 +3355,6 @@ const handlePermissionImport = async (event: Event) => {
-
@@ -3776,6 +3781,11 @@ const handlePermissionImport = async (event: Event) => {
+
+
+
diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue
index cfaee995..20863d93 100644
--- a/frontend/src/views/ChatView.vue
+++ b/frontend/src/views/ChatView.vue
@@ -1872,16 +1872,16 @@ const showChatRating = ref(false);
智能体
-
+
diff --git a/frontend/src/views/KbAdminView.vue b/frontend/src/views/KbAdminView.vue
deleted file mode 100644
index b1403123..00000000
--- a/frontend/src/views/KbAdminView.vue
+++ /dev/null
@@ -1,360 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
知识库管理台
-
- 第一阶段先承接分组、任务和 Dify 管理入口,后续再接入清洗链路。
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{ formTitle }}
-
{{ formDescription }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ feedback }}
-
-
-
-
-
-
-
-
知识库分组概览
- {{ isRefreshing ? '加载中...' : '`/api/kb/groups`' }}
-
-
- 当前暂无分组,或知识库接口尚未联调完成。
-
-
-
-
-
-
{{ group.name }}
-
{{ group.description || '暂无描述' }}
-
-
- {{ group.document_count ?? 0 }} 文档
-
-
-
-
- 更新时间:{{ group.updated_at || '--' }}
-
-
-
-
-
-
-
-
-
-
任务队列占位
- `/api/kb/jobs`
-
-
- 暂无任务。第二阶段会在这里接入清洗、同步和重试任务。
-
-
-
-
-
-
{{ job.job_type }}
-
{{ job.created_at || '--' }}
-
- {{ job.message || '暂无任务说明' }}
-
-
- 文档:{{ job.document_id ?? '--' }} · 版本:{{ job.document_version_id ?? '--' }} · 进度:{{ job.progress ?? 0 }}%
-
-
-
- {{ job.status }}
-
-
-
-
-
-
-
-
-
-
-
-
- { feedback = message; feedbackType = 'success'; void loadData(); }"
- @error="(message) => { feedback = message; feedbackType = 'error'; }"
- />
- { feedback = message; feedbackType = 'error'; }"
- />
-