feat: expose onCodeComplete callback in prompt store

This commit is contained in:
2026-03-09 10:50:17 +08:00
parent 4774c05809
commit 725fad4a55

View File

@@ -14,6 +14,7 @@ export const conversationId = ref<string>("")
export const connected = ref(false) export const connected = ref(false)
export const streaming = ref(false) export const streaming = ref(false)
export const streamingContent = ref("") export const streamingContent = ref("")
export let onCodeComplete: ((code: { html: string | null; css: string | null; js: string | null }) => void) | null = null
let ws: WebSocket | null = null let ws: WebSocket | null = null
@@ -54,6 +55,9 @@ export function connectPrompt(taskId: number) {
// Apply code to editors // Apply code to editors
if (data.code) { if (data.code) {
applyCode(data.code) applyCode(data.code)
if (onCodeComplete) {
onCodeComplete(data.code)
}
} }
} else if (data.type === "error") { } else if (data.type === "error") {
streaming.value = false streaming.value = false
@@ -80,6 +84,7 @@ export function disconnectPrompt() {
connected.value = false connected.value = false
streaming.value = false streaming.value = false
streamingContent.value = "" streamingContent.value = ""
onCodeComplete = null
} }
export function sendPrompt(content: string) { export function sendPrompt(content: string) {