/** * 中断组件扩展示例 * * 本文件展示如何添加新的中断类型组件 */ // ============================================ // 示例 1: 创建短信验证中断组件 // ============================================ /** * 文件: SmsVerificationInterrupt.vue * * * * * * * 短信验证 * {{ data.content?.title }} * * * {{ getStatusText(data.toolStatus) }} * * * * * * * {{ data.content?.description }} * * * * 验证码将发送至 * {{ data.content.phone }} * * * * * 发送验证码 * * * * * * * * 验证 * * 取消 * * * * * * */ // ============================================ // 示例 2: 在 index.ts 中注册 // ============================================ /** * 在 src/views/ai/interrupt/index.ts 中添加: * * import SmsVerificationInterrupt from './SmsVerificationInterrupt.vue'; * * const interruptComponentMap = new Map([ * ['APPROVAL', ApprovalInterrupt], * ['CONFIRMATION', ConfirmationInterrupt], * ['SMS_VERIFICATION', SmsVerificationInterrupt], // 新增这一行 * ]); */ // ============================================ // 示例 3: 后端返回数据格式 // ============================================ /** * { * "extra": { * "type": "SMS_VERIFICATION", * "interruptId": "abc-123-def", * "toolStatus": "interrupted", * "content": { * "title": "身份验证", * "description": "为了保障账户安全,请完成短信验证", * "phone": "138****8888" * } * } * } */ // ============================================ // 示例 4: 处理验证事件 // ============================================ /** * 在 AiChat.vue 或父组件中: * * * * const handleSmsVerification = async (interruptId: string, code: string) => { * try { * // 调用后端验证接口 * await aiApi.verifySmsCode.request({ * interruptId, * code * }); * * // 更新本地状态 * updateInterruptStatus(interruptId, 'verified'); * } catch (error) { * ElMessage.error('验证失败'); * } * }; */ export {};