Connect front web app to workbench APIs
This commit is contained in:
@@ -146,7 +146,7 @@ async function handleGenerateDatabase() {
|
||||
}
|
||||
|
||||
generating.value = true
|
||||
errorMessage.value = ''
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
const id = await ensureProject()
|
||||
const result = await generateDatabase(id, {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user