diff --git a/resources/assets/js/components/AIAssistant/welcome-prompts.js b/resources/assets/js/components/AIAssistant/welcome-prompts.js index a01ccb296..1d0a73c6a 100644 --- a/resources/assets/js/components/AIAssistant/welcome-prompts.js +++ b/resources/assets/js/components/AIAssistant/welcome-prompts.js @@ -39,6 +39,12 @@ const SVG_ICONS = { clock: '', // 完成/勾选 check: '', + // 重点/推进/优先级 + flag: '', + // 清单/行动项/纪要 + clipboard: '', + // 链接/关联 + link: '', }; /** @@ -52,11 +58,30 @@ function getText(textObj) { return isZh ? textObj.zh : textObj.en; } +/** + * 从数组中随机选择指定数量的元素 + * @param {Array} arr - 源数组 + * @param {number} count - 选择数量 + * @returns {Array} 随机选择的元素 + */ +function getRandomItems(arr, count) { + if (arr.length <= count) { + return arr; + } + const shuffled = [...arr]; + // Fisher-Yates 洗牌算法(只洗前 count 个) + for (let i = 0; i < count; i++) { + const j = i + Math.floor(Math.random() * (shuffled.length - i)); + [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; + } + return shuffled.slice(0, count); +} + /** * 获取当前场景的快捷提示列表 * @param {Object} store - Vuex store 实例 * @param {Object} routeParams - 路由参数 - * @returns {Array} 快捷提示列表 [{ text, svg }] + * @returns {Array} 快捷提示列表 [{ text, svg }],随机显示 3-6 个 */ export function getWelcomePrompts(store, routeParams = {}) { const routeName = store.state.routeName; @@ -81,8 +106,12 @@ export function getWelcomePrompts(store, routeParams = {}) { const getPrompts = promptsMap[routeName]; const rawPrompts = getPrompts ? getPrompts(store, routeParams) : getDefaultPrompts(); + // 随机选择 3-6 个提示词 + const displayCount = Math.floor(Math.random() * 4) + 3; // 3, 4, 5, 或 6 + const selectedPrompts = getRandomItems(rawPrompts, displayCount); + // 转换文本为当前语言 - return rawPrompts.map(item => ({ + return selectedPrompts.map(item => ({ text: getText(item.text), svg: item.svg, })); @@ -101,37 +130,55 @@ function getDashboardPrompts(store) { // 根据实际数据动态调整提示 if (overdueCount > 0) { prompts.push({ - text: { - zh: `列出我的 ${overdueCount} 个逾期任务`, - en: `List my ${overdueCount} overdue tasks`, - }, + text: { zh: `列出我的 ${overdueCount} 个逾期任务`, en: `List my ${overdueCount} overdue tasks` }, svg: SVG_ICONS.alert, }); } if (todayCount > 0) { prompts.push({ - text: { - zh: `今天要完成哪些任务?`, - en: `What tasks are due today?`, - }, + text: { zh: '今天到期任务有哪些?', en: 'What tasks are due today?' }, svg: SVG_ICONS.calendar, }); } - // 补充通用提示 + // 补充通用提示(项目管理视角:现状 -> 风险 -> 推进 -> 同步) prompts.push( { - text: { zh: '我本周有哪些任务?', en: 'What are my tasks this week?' }, + text: { zh: '按优先级排今天任务', en: 'Prioritize my tasks for today' }, + svg: SVG_ICONS.flag, + }, + { + text: { zh: '汇总逾期任务并给方案', en: 'Summarize overdue tasks with actions' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '本周到期任务有哪些?', en: 'What tasks are due this week?' }, svg: SVG_ICONS.list, }, { - text: { zh: '哪些任务需要我协助?', en: 'Which tasks need my assistance?' }, + text: { zh: '找出最近停滞的任务', en: 'Find recently stalled tasks' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '哪些任务缺负责人或截止?', en: 'Which tasks lack owner or due date?' }, + svg: SVG_ICONS.edit, + }, + { + text: { zh: '我需要协助的任务清单', en: 'Tasks that need my assistance' }, svg: SVG_ICONS.user, }, + { + text: { zh: '生成今日工作同步文案', en: 'Draft today status update' }, + svg: SVG_ICONS.message, + }, + { + text: { zh: '生成本周周报草稿', en: 'Generate weekly report draft' }, + svg: SVG_ICONS.document, + }, ); - return prompts.slice(0, 4); + return prompts.slice(0, 10); } /** @@ -144,46 +191,96 @@ function getProjectPrompts(store) { // 项目列表页 return [ { - text: { zh: '我参与了哪些项目?', en: 'Which projects am I involved in?' }, + text: { zh: '我参与的项目有哪些?', en: 'Which projects am I involved in?' }, svg: SVG_ICONS.folder, }, { - text: { zh: '哪个项目有逾期任务?', en: 'Which project has overdue tasks?' }, + text: { zh: '按关键词搜索项目', en: 'Search projects by keyword' }, + svg: SVG_ICONS.search, + }, + { + text: { zh: '哪些项目逾期最严重?', en: 'Which projects have the most overdue tasks?' }, svg: SVG_ICONS.alert, }, + { + text: { zh: '对比项目健康度', en: 'Compare project health' }, + svg: SVG_ICONS.chart, + }, + { + text: { zh: '生成项目概览简报', en: 'Generate a project overview brief' }, + svg: SVG_ICONS.document, + }, + { + text: { zh: '帮我创建一个新项目', en: 'Help me create a new project' }, + svg: SVG_ICONS.plus, + }, ]; } // 项目详情页 - 提供具体操作 - const projectName = project.name || ''; return [ { text: { - zh: '这个项目还有多少未完成的任务?', - en: 'How many incomplete tasks in this project?', + zh: '项目未完成任务清单', + en: 'List incomplete tasks in this project', }, svg: SVG_ICONS.list, }, { text: { - zh: '帮我在这个项目创建一个任务', - en: 'Help me create a task in this project', - }, - svg: SVG_ICONS.plus, - }, - { - text: { - zh: '这个项目有哪些逾期任务?', - en: 'What tasks are overdue in this project?', + zh: '项目逾期任务与原因概览', + en: 'Overdue tasks & reasons overview', }, svg: SVG_ICONS.alert, }, { text: { - zh: '查看项目成员的任务分配', - en: 'View task assignments by member', + zh: '查看项目看板列配置', + en: 'View board columns configuration', }, - svg: SVG_ICONS.user, + svg: SVG_ICONS.list, + }, + { + text: { + zh: '成员负载与分配建议', + en: 'Member workload & assignment suggestions', + }, + svg: SVG_ICONS.chart, + }, + { + text: { + zh: '创建任务并指派负责人', + en: 'Create a task and assign an owner', + }, + svg: SVG_ICONS.plus, + }, + { + text: { + zh: '把需求拆成可执行任务', + en: 'Break a requirement into tasks', + }, + svg: SVG_ICONS.edit, + }, + { + text: { + zh: '汇总项目风险与阻塞项', + en: 'Summarize risks and blockers', + }, + svg: SVG_ICONS.alert, + }, + { + text: { + zh: '生成本周项目推进简报', + en: 'Generate this week project update', + }, + svg: SVG_ICONS.document, + }, + { + text: { + zh: '搜索项目相关资料', + en: 'Search project related docs', + }, + svg: SVG_ICONS.search, }, ]; } @@ -196,43 +293,85 @@ function getMessengerPrompts(store) { const dialogs = store.state.cacheDialogs || []; const dialog = dialogs.find(d => d.id === dialogId); + // 从私聊列表中随机获取一个用户名(用于个性化提示) + const userDialogs = dialogs.filter(d => d.type === 'user' && d.name && !d.bot); + const userName = userDialogs.length > 0 ? userDialogs[Math.floor(Math.random() * userDialogs.length)].name : null; + if (!dialog) { // 消息列表页 return [ { - text: { zh: '给某人发送一条消息', en: 'Send a message to someone' }, + text: { zh: '按名称找对话', en: 'Find a chat by name' }, + svg: SVG_ICONS.search, + }, + { + text: { zh: '按名字/邮箱找人', en: 'Find a person by name/email' }, + svg: SVG_ICONS.user, + }, + { + text: userName + ? { zh: `给 ${userName} 发送一条消息`, en: `Send a message to ${userName}` } + : { zh: '给某人发送一条消息', en: 'Send a message to someone' }, svg: SVG_ICONS.send, }, { - text: { zh: '搜索包含关键词的聊天', en: 'Search chats containing keyword' }, + text: { zh: '搜索关键词消息', en: 'Search messages by keyword' }, svg: SVG_ICONS.search, }, + { + text: { zh: '生成礼貌催办话术', en: 'Draft a polite follow-up message' }, + svg: SVG_ICONS.edit, + }, + { + text: { zh: '生成进度同步文案', en: 'Draft a progress update message' }, + svg: SVG_ICONS.document, + }, ]; } // 对话详情页 - const dialogName = dialog.name || ''; return [ { text: { - zh: '查看这个对话最近的消息', - en: 'View recent messages in this chat', + zh: '总结近期对话要点与结论', + en: 'Summarize recent chat highlights', }, - svg: SVG_ICONS.message, + svg: SVG_ICONS.document, }, { text: { - zh: '搜索对话中的文件', - en: 'Search files in this chat', + zh: '提取对话待办并建任务', + en: 'Extract to-dos and create tasks', + }, + svg: SVG_ICONS.task, + }, + { + text: { + zh: '列出对话里的文件与链接', + en: 'List files and links in this chat', + }, + svg: SVG_ICONS.link, + }, + { + text: { + zh: '搜索对话关键词并摘要', + en: 'Search chat keyword with context', }, svg: SVG_ICONS.search, }, { text: { - zh: '给对方发一条消息', - en: 'Send a message', + zh: '给我三种推进回复版本', + en: 'Give 3 reply options to move forward', }, - svg: SVG_ICONS.send, + svg: SVG_ICONS.message, + }, + { + text: { + zh: '生成会议纪要(可直接发)', + en: 'Generate meeting notes to send', + }, + svg: SVG_ICONS.clipboard, }, ]; } @@ -243,33 +382,76 @@ function getMessengerPrompts(store) { function getCalendarPrompts() { return [ { - text: { zh: '今天有哪些任务到期?', en: 'What tasks are due today?' }, + text: { zh: '今天到期任务清单', en: 'Tasks due today' }, svg: SVG_ICONS.calendar, }, { - text: { zh: '本周有哪些任务要完成?', en: 'What tasks are due this week?' }, + text: { zh: '本周到期任务清单', en: 'Tasks due this week' }, svg: SVG_ICONS.list, }, { - text: { zh: '下周的任务安排', en: 'Tasks scheduled for next week' }, + text: { zh: '下周任务安排建议', en: 'Suggestions for next week plan' }, svg: SVG_ICONS.clock, }, + { + text: { zh: '截止日期冲突排查', en: 'Check due-date conflicts' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '逾期任务怎么重排期', en: 'Reschedule overdue tasks' }, + svg: SVG_ICONS.calendar, + }, + { + text: { zh: '未来两周风险预警点', en: 'Risks in the next two weeks' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '生成下周工作计划草案', en: 'Draft next week work plan' }, + svg: SVG_ICONS.document, + }, ]; } /** * 文件页提示 - 聚焦文件查找 */ -function getFilePrompts() { +function getFilePrompts(store) { + // 从今日任务中随机获取一个任务名称(用于个性化提示) + const dashboardTask = store.getters.dashboardTask || {}; + const todayTasks = (dashboardTask.today || []).filter(t => t.name); + const taskName = todayTasks.length > 0 ? todayTasks[Math.floor(Math.random() * todayTasks.length)].name : null; + return [ { - text: { zh: '搜索文件名包含...', en: 'Search files named...' }, + text: { zh: '搜索文件(名称/关键词)', en: 'Search files by name/keyword' }, svg: SVG_ICONS.search, }, { - text: { zh: '查看我最近的文件', en: 'View my recent files' }, + text: { zh: '查看共享文件列表', en: 'View shared files' }, svg: SVG_ICONS.folder, }, + { + text: taskName + ? { zh: `查找「${taskName}」的附件`, en: `Find attachments of "${taskName}"` } + : { zh: '查找某个任务的附件', en: 'Find attachments of a task' }, + svg: SVG_ICONS.task, + }, + { + text: { zh: '阅读文件并总结要点', en: 'Read a file and summarize' }, + svg: SVG_ICONS.document, + }, + { + text: { zh: '从文件提取行动项清单', en: 'Extract action items from files' }, + svg: SVG_ICONS.clipboard, + }, + { + text: { zh: '生成文件转发说明文案', en: 'Draft a file sharing note' }, + svg: SVG_ICONS.send, + }, + { + text: { zh: '搜索项目相关资料', en: 'Search project related docs' }, + svg: SVG_ICONS.search, + }, ]; } @@ -279,19 +461,39 @@ function getFilePrompts() { function getSingleTaskPrompts() { return [ { - text: { zh: '帮我添加一个子任务', en: 'Help me add a subtask' }, + text: { zh: '补全任务信息与验收标准', en: 'Fill task details and acceptance criteria' }, + svg: SVG_ICONS.edit, + }, + { + text: { zh: '把任务拆成子任务清单', en: 'Break down into subtasks' }, + svg: SVG_ICONS.list, + }, + { + text: { zh: '立刻添加一个子任务', en: 'Add a subtask now' }, svg: SVG_ICONS.plus, }, { - text: { zh: '修改这个任务的截止时间', en: 'Change the due date of this task' }, + text: { zh: '调整负责人/协助人', en: 'Adjust owner/assignees' }, + svg: SVG_ICONS.user, + }, + { + text: { zh: '修改开始与截止时间', en: 'Change start and due dates' }, svg: SVG_ICONS.clock, }, { - text: { zh: '将这个任务标记为完成', en: 'Mark this task as complete' }, + text: { zh: '把任务移动到看板列', en: 'Move task to a board column' }, + svg: SVG_ICONS.list, + }, + { + text: { zh: '将任务标记为完成', en: 'Mark this task as complete' }, svg: SVG_ICONS.check, }, { - text: { zh: '查看这个任务的附件', en: 'View attachments of this task' }, + text: { zh: '生成任务进展同步文案', en: 'Draft a task progress update' }, + svg: SVG_ICONS.message, + }, + { + text: { zh: '查看这个任务的附件列表', en: 'View task attachments' }, svg: SVG_ICONS.folder, }, ]; @@ -303,12 +505,28 @@ function getSingleTaskPrompts() { function getSingleDialogPrompts() { return [ { - text: { zh: '查看最近的消息记录', en: 'View recent messages' }, + text: { zh: '总结对话重点与待办', en: 'Summarize highlights and to-dos' }, + svg: SVG_ICONS.document, + }, + { + text: { zh: '提取待办并创建任务', en: 'Extract to-dos and create tasks' }, + svg: SVG_ICONS.task, + }, + { + text: { zh: '列出对话中的文件', en: 'List files in this chat' }, + svg: SVG_ICONS.folder, + }, + { + text: { zh: '帮我写推进回复', en: 'Draft a reply to move forward' }, svg: SVG_ICONS.message, }, { - text: { zh: '发送一条消息', en: 'Send a message' }, - svg: SVG_ICONS.send, + text: { zh: '生成对话纪要摘要', en: 'Generate chat summary notes' }, + svg: SVG_ICONS.clipboard, + }, + { + text: { zh: '搜索对话关键词并结论', en: 'Search keyword and summarize findings' }, + svg: SVG_ICONS.search, }, ]; } @@ -319,13 +537,29 @@ function getSingleDialogPrompts() { function getSingleFilePrompts() { return [ { - text: { zh: '查看这个文件的详情', en: 'View file details' }, + text: { zh: '总结文件要点与结论', en: 'Summarize key points and conclusions' }, svg: SVG_ICONS.document, }, { - text: { zh: '搜索类似的文件', en: 'Search similar files' }, + text: { zh: '从文件提取任务清单', en: 'Extract tasks from this file' }, + svg: SVG_ICONS.task, + }, + { + text: { zh: '生成文件分享说明', en: 'Draft a file sharing note' }, + svg: SVG_ICONS.send, + }, + { + text: { zh: '搜索相似文件并对比', en: 'Find similar files and compare' }, svg: SVG_ICONS.search, }, + { + text: { zh: '查找关联的任务/项目', en: 'Find related tasks/projects' }, + svg: SVG_ICONS.list, + }, + { + text: { zh: '列出需要确认的问题', en: 'List questions to clarify' }, + svg: SVG_ICONS.alert, + }, ]; } @@ -335,12 +569,28 @@ function getSingleFilePrompts() { function getSingleFileTaskPrompts() { return [ { - text: { zh: '查看这个任务的所有附件', en: 'View all attachments of this task' }, + text: { zh: '查看该任务全部附件', en: 'View all attachments' }, svg: SVG_ICONS.folder, }, { - text: { zh: '查看任务详情', en: 'View task details' }, - svg: SVG_ICONS.task, + text: { zh: '总结附件要点与风险', en: 'Summarize attachment highlights and risks' }, + svg: SVG_ICONS.document, + }, + { + text: { zh: '从附件提取行动项', en: 'Extract action items from attachments' }, + svg: SVG_ICONS.clipboard, + }, + { + text: { zh: '用附件内容完善任务描述', en: 'Improve task description from attachments' }, + svg: SVG_ICONS.edit, + }, + { + text: { zh: '生成验收检查清单', en: 'Generate acceptance checklist' }, + svg: SVG_ICONS.check, + }, + { + text: { zh: '基于附件拆分子任务', en: 'Create subtasks based on attachments' }, + svg: SVG_ICONS.plus, }, ]; } @@ -351,17 +601,41 @@ function getSingleFileTaskPrompts() { function getSingleReportEditPrompts() { return [ { - text: { zh: '根据本周任务生成周报', en: 'Generate weekly report from tasks' }, + text: { zh: '基于本周任务生成周报', en: 'Generate weekly report from tasks' }, svg: SVG_ICONS.document, }, { - text: { zh: '根据今天任务生成日报', en: 'Generate daily report from tasks' }, + text: { zh: '基于今天任务生成日报', en: 'Generate daily report from tasks' }, svg: SVG_ICONS.calendar, }, { text: { zh: '查看我上周的汇报', en: 'View my last week\'s report' }, svg: SVG_ICONS.search, }, + { + text: { zh: '汇总本周已完成事项', en: 'Summarize completed items this week' }, + svg: SVG_ICONS.check, + }, + { + text: { zh: '汇总本周未完成与原因', en: 'Summarize unfinished items and reasons' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '补充风险与需要支持', en: 'Add risks and needed support' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '生成下周计划与重点', en: 'Generate next week plan and focus' }, + svg: SVG_ICONS.list, + }, + { + text: { zh: '润色为更专业表达', en: 'Polish for more professional tone' }, + svg: SVG_ICONS.edit, + }, + { + text: { zh: '提交汇报给指定同事', en: 'Submit report to specified people' }, + svg: SVG_ICONS.send, + }, ]; } @@ -370,12 +644,32 @@ function getSingleReportEditPrompts() { */ function getSingleReportDetailPrompts() { return [ + { + text: { zh: '总结这份汇报关键点', en: 'Summarize key points of this report' }, + svg: SVG_ICONS.document, + }, + { + text: { zh: '提取汇报里的待办事项', en: 'Extract action items from this report' }, + svg: SVG_ICONS.clipboard, + }, + { + text: { zh: '找出汇报提到的任务', en: 'Find tasks mentioned in this report' }, + svg: SVG_ICONS.task, + }, + { + text: { zh: '生成一条回复评论文案', en: 'Draft a reply/comment' }, + svg: SVG_ICONS.message, + }, { text: { zh: '标记为已读', en: 'Mark as read' }, svg: SVG_ICONS.check, }, { - text: { zh: '查看这个人的其他汇报', en: 'View other reports from this person' }, + text: { zh: '标记为未读', en: 'Mark as unread' }, + svg: SVG_ICONS.alert, + }, + { + text: { zh: '查看TA的其他汇报', en: 'View other reports from this person' }, svg: SVG_ICONS.list, }, ]; @@ -387,16 +681,28 @@ function getSingleReportDetailPrompts() { function getDefaultPrompts() { return [ { - text: { zh: '我有哪些未完成的任务?', en: 'What tasks do I have pending?' }, + text: { zh: '我有哪些未完成任务?', en: 'What tasks do I have pending?' }, svg: SVG_ICONS.task, }, { - text: { zh: '搜索任务或项目', en: 'Search tasks or projects' }, + text: { zh: '全局智能搜索(任务/项目/文件)', en: 'Global smart search (tasks/projects/files)' }, svg: SVG_ICONS.search, }, + { + text: { zh: '帮我创建一个任务', en: 'Help me create a task' }, + svg: SVG_ICONS.plus, + }, + { + text: { zh: '查看我的项目列表', en: 'View my projects' }, + svg: SVG_ICONS.folder, + }, { text: { zh: '帮我写一份工作汇报', en: 'Help me write a work report' }, svg: SVG_ICONS.document, }, + { + text: { zh: '给某人发消息并说明背景', en: 'Send a message with context' }, + svg: SVG_ICONS.send, + }, ]; }