diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json new file mode 100644 index 0000000..df30d26 --- /dev/null +++ b/src-tauri/capabilities/default.json @@ -0,0 +1,12 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "u-ppt 主窗口默认能力:IPC 命令调用 + AI 流式事件订阅", + "windows": ["main"], + "permissions": [ + "core:default", + "core:event:default", + "core:event:allow-listen", + "core:event:allow-unlisten" + ] +} diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 26a97e5..0ad4196 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -205,8 +205,11 @@ pub async fn ai_proxy_stream( .map_err(|e| format!("请求失败: {}", e))?; if !resp.status().is_success() { + let status = resp.status().as_u16(); let text = resp.text().await.unwrap_or_default(); - return Ok(text); + // 错误体带状态码前缀,前端按「接口返回 N」格式提示 + let _ = app.emit("ai-error", &text); + return Err(format!("__HTTP_{}__{}", status, text)); } // 流式读取 SSE diff --git a/src/components/ai/AiPanel.vue b/src/components/ai/AiPanel.vue index a05d34b..e63ec48 100644 --- a/src/components/ai/AiPanel.vue +++ b/src/components/ai/AiPanel.vue @@ -3,74 +3,14 @@ 发送/停止/生成整套/润色本页/流式渲染/操作应用 ===================================================================== -->