(requestId: string)
| 35 | * 批准请求 |
| 36 | */ |
| 37 | const approve = async (requestId: string) => { |
| 38 | const request = pendingApprovals.value.get(requestId); |
| 39 | if (!request) { |
| 40 | console.warn(`Approval request ${requestId} not found`); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | // 记录到历史 |
| 45 | approvalHistory.value.push({ |
| 46 | ...request, |
| 47 | decision: "approved", |
| 48 | decidedAt: Date.now(), |
| 49 | }); |
| 50 | |
| 51 | // 发送到后端 |
| 52 | const { getInstance } = useWebSocket(); |
| 53 | const ws = getInstance(); |
| 54 | if (ws) { |
| 55 | ws.send({ |
| 56 | type: "permission_decision", |
| 57 | payload: { |
| 58 | request_id: requestId, |
| 59 | decision: "approve", |
| 60 | }, |
| 61 | }); |
| 62 | } else { |
| 63 | console.error("WebSocket not connected, cannot send approval decision"); |
| 64 | } |
| 65 | |
| 66 | // 从待审批列表中移除 |
| 67 | pendingApprovals.value.delete(requestId); |
| 68 | }; |
| 69 | |
| 70 | /** |
| 71 | * 拒绝请求 |
nothing calls this directly
no test coverage detected