Connect front web app to workbench APIs

This commit is contained in:
王鹏
2026-05-22 16:43:55 +08:00
parent d39eeca8a9
commit 625489e77c
6 changed files with 82 additions and 5 deletions

View File

@@ -146,7 +146,7 @@ async function handleGenerateDatabase() {
}
generating.value = true
errorMessage.value = ''
errorMessage.value = ''
try {
const id = await ensureProject()
const result = await generateDatabase(id, {

View File

@@ -67,6 +67,14 @@ function normalizeNodes(nodes, prefix = '') {
})
}
function pickCodeContent(data) {
if (typeof data === 'string') return data
if (!data || typeof data !== 'object') return ''
if (typeof data.content === 'string') return data.content
const firstValue = Object.values(data).find((value) => typeof value === 'string')
return firstValue || ''
}
async function loadType(type) {
const result = await getProjectStructure(projectId.value, type)
const data = unwrap(result)
@@ -96,7 +104,7 @@ async function handleFileSelect(file) {
category: file.category || file.path || file.label
})
const data = unwrap(result)
code.value = typeof data === 'string' ? data : data.content || ''
code.value = pickCodeContent(data)
} catch (error) {
ElMessage.error(error.message || '加载文件内容失败')
} finally {