diff --git a/.DS_Store b/.DS_Store
index ec943fa..05fc10e 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/KB_TEMPLATE_SELECTION_IMPLEMENTATION.md b/KB_TEMPLATE_SELECTION_IMPLEMENTATION.md
new file mode 100644
index 0000000..ca05ee3
--- /dev/null
+++ b/KB_TEMPLATE_SELECTION_IMPLEMENTATION.md
@@ -0,0 +1,246 @@
+# 知识库新增页面 - 模版选择功能实现总结
+
+## 功能概述
+在知识库新增流程的第二步"自定义提示词"中添加了模版选择功能,用户可以选择预设的模版来生成知识库内容。
+
+## 实现的功能点
+
+### 1. 添加状态管理 ✅
+**文件**: `frontend/src/pages/KnowledgeBasePage.jsx`
+
+添加了两个新的 state:
+```javascript
+const [availablePrompts, setAvailablePrompts] = useState([]); // 可用的提示词模版列表
+const [selectedPromptId, setSelectedPromptId] = useState(null); // 选中的提示词模版ID
+```
+
+### 2. 获取模版列表 ✅
+**文件**: `frontend/src/pages/KnowledgeBasePage.jsx`
+
+新增方法 `fetchAvailablePrompts()`:
+```javascript
+const fetchAvailablePrompts = async () => {
+ try {
+ const response = await apiClient.get(buildApiUrl(API_ENDPOINTS.PROMPTS.ACTIVE('KNOWLEDGE_TASK')));
+ const promptsList = response.data.prompts || [];
+ setAvailablePrompts(promptsList);
+
+ // 自动选中默认模版
+ const defaultPrompt = promptsList.find(p => p.is_default);
+ if (defaultPrompt) {
+ setSelectedPromptId(defaultPrompt.id);
+ }
+ } catch (error) {
+ console.error("Error fetching available prompts:", error);
+ setAvailablePrompts([]);
+ }
+};
+```
+
+**调用时机**:
+- 在 `handleOpenCreateModal()` 中调用,当用户打开新增知识库弹窗时获取模版列表
+- 自动选中默认模版,无需用户手动选择
+
+### 3. UI 实现 ✅
+**文件**: `frontend/src/pages/KnowledgeBasePage.jsx`
+
+在第二步(`createStep === 2`)中添加模版选择下拉框:
+
+```jsx
+{/* 模版选择 */}
+{availablePrompts.length > 0 && (
+
- {['mobile', 'desktop'].map(type => {
+ {['mobile', 'desktop', 'terminal'].map(type => {
const typeClients = groupedClients[type];
if (typeClients.length === 0 && filterPlatformType && filterPlatformType !== type) {
return null;
}
+ const typeConfig = {
+ mobile: { icon:
, label: '移动端' },
+ desktop: { icon:
, label: '桌面端' },
+ terminal: { icon:
, label: '专用终端' }
+ };
+
return (
- {type === 'mobile' ? : }
- {type === 'mobile' ? '移动端' : '桌面端'}
+ {typeConfig[type].icon}
+ {typeConfig[type].label}
({typeClients.length})
@@ -484,6 +503,7 @@ const ClientManagement = ({ user }) => {
>
+
diff --git a/src/pages/Dashboard.jsx b/src/pages/Dashboard.jsx
index 37443d4..67a0a24 100644
--- a/src/pages/Dashboard.jsx
+++ b/src/pages/Dashboard.jsx
@@ -12,6 +12,7 @@ import PageLoading from '../components/PageLoading';
import ScrollToTop from '../components/ScrollToTop';
import Dropdown from '../components/Dropdown';
import meetingCacheService from '../services/meetingCacheService';
+import menuService from '../services/menuService';
import './Dashboard.css';
const Dashboard = ({ user, onLogout }) => {
@@ -39,10 +40,14 @@ const Dashboard = ({ user, onLogout }) => {
const [voiceprintLoading, setVoiceprintLoading] = useState(true);
const [showDeleteVoiceprintDialog, setShowDeleteVoiceprintDialog] = useState(false);
+ // 菜单权限相关状态
+ const [userMenus, setUserMenus] = useState([]);
+
useEffect(() => {
fetchUserData();
fetchMeetingsStats();
fetchVoiceprintData();
+ fetchUserMenus();
// 开发环境下,在控制台添加缓存调试命令
if (process.env.NODE_ENV === 'development') {
@@ -96,6 +101,76 @@ const Dashboard = ({ user, onLogout }) => {
}
};
+ const fetchUserMenus = async () => {
+ try {
+ console.log('[Dashboard] 开始获取用户菜单...');
+ const response = await menuService.getUserMenus();
+ console.log('[Dashboard] 菜单API响应:', response);
+
+ if (response.code === '200') {
+ const menus = response.data.menus || [];
+ console.log('[Dashboard] 用户菜单获取成功,菜单数量:', menus.length, '菜单内容:', menus);
+ setUserMenus(menus);
+ } else {
+ console.error('[Dashboard] 获取用户菜单失败:', response.message);
+ // 使用默认菜单作为fallback
+ setUserMenus(getDefaultMenus());
+ }
+ } catch (err) {
+ console.error('[Dashboard] 获取用户菜单异常:', err);
+ // 使用默认菜单作为fallback
+ setUserMenus(getDefaultMenus());
+ }
+ };
+
+ // 获取默认菜单(fallback)
+ const getDefaultMenus = () => {
+ const defaultMenus = [
+ { menu_code: 'change_password', menu_name: '修改密码', menu_type: 'action', sort_order: 1 },
+ { menu_code: 'prompt_management', menu_name: '提示词仓库', menu_type: 'link', menu_url: '/prompt-management', sort_order: 2 },
+ { menu_code: 'logout', menu_name: '退出登录', menu_type: 'action', sort_order: 99 }
+ ];
+
+ // 如果是管理员,添加平台管理菜单
+ if (user.role_id === 1) {
+ defaultMenus.splice(2, 0, {
+ menu_code: 'platform_admin',
+ menu_name: '平台管理',
+ menu_type: 'link',
+ menu_url: '/admin/management',
+ sort_order: 3
+ });
+ }
+
+ console.log('[Dashboard] 使用默认菜单:', defaultMenus);
+ return defaultMenus;
+ };
+
+ // 将菜单code映射到图标和行为
+ const getMenuItemConfig = (menu) => {
+ const iconMap = {
+ 'change_password':
,
+ 'prompt_management':
,
+ 'platform_admin':
,
+ 'logout':
+ };
+
+ const actionMap = {
+ 'change_password': () => setShowChangePasswordModal(true),
+ 'prompt_management': () => window.location.href = '/prompt-management',
+ 'platform_admin': () => window.location.href = '/admin/management',
+ 'logout': onLogout
+ };
+
+ return {
+ icon: iconMap[menu.menu_code] || null,
+ label: menu.menu_name,
+ onClick: menu.menu_type === 'link' && menu.menu_url
+ ? () => window.location.href = menu.menu_url
+ : actionMap[menu.menu_code] || (() => {})
+ };
+ };
+
// 过滤会议
useEffect(() => {
fetchMeetings(1, false);
@@ -359,28 +434,7 @@ const Dashboard = ({ user, onLogout }) => {
}
- items={[
- {
- icon: