update
This commit is contained in:
@@ -21,6 +21,7 @@ const emit = defineEmits<{
|
||||
|
||||
const phase = ref<Phase>('theme')
|
||||
const theme = ref(props.defaultTheme ?? '')
|
||||
const count = ref(18)
|
||||
const outlineText = ref('')
|
||||
const outlineError = ref<string | null>(null)
|
||||
|
||||
@@ -45,7 +46,7 @@ async function handleGenerateOutline(): Promise<void> {
|
||||
phase.value = 'outline-loading'
|
||||
outlineError.value = null
|
||||
try {
|
||||
const result = await booksApi.generateOutline(theme.value.trim())
|
||||
const result = await booksApi.generateOutline(theme.value.trim(), count.value)
|
||||
outlineText.value = result.titles.join('\n')
|
||||
phase.value = 'outline'
|
||||
} catch (error) {
|
||||
@@ -63,6 +64,7 @@ function handleStart(): void {
|
||||
function handleClose(): void {
|
||||
phase.value = 'theme'
|
||||
theme.value = props.defaultTheme ?? ''
|
||||
count.value = 18
|
||||
outlineText.value = ''
|
||||
outlineError.value = null
|
||||
emit('close')
|
||||
@@ -84,6 +86,10 @@ function handleClose(): void {
|
||||
placeholder="例如:Web 前端开发项目式教学"
|
||||
@keydown.enter="handleGenerateOutline"
|
||||
/>
|
||||
<label class="batch-count-field">
|
||||
生成数量
|
||||
<input v-model.number="count" type="number" min="1" max="50" />
|
||||
</label>
|
||||
<div class="dialog-actions">
|
||||
<button type="button" :disabled="!theme.trim()" @click="handleGenerateOutline">生成大纲</button>
|
||||
<button type="button" @click="handleClose">取消</button>
|
||||
|
||||
@@ -55,6 +55,9 @@ export function generateLesson(topic: string, signal?: AbortSignal): Promise<Gen
|
||||
return authedFetch('/api/generate', { method: 'POST', body: JSON.stringify({ topic }), signal })
|
||||
}
|
||||
|
||||
export function generateOutline(theme: string): Promise<{ titles: string[] }> {
|
||||
return authedFetch('/api/generate/outline', { method: 'POST', body: JSON.stringify({ theme }) })
|
||||
export function generateOutline(theme: string, count = 18): Promise<{ titles: string[] }> {
|
||||
return authedFetch('/api/generate/outline', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ theme, count }),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -849,6 +849,20 @@ table {
|
||||
border-color: var(--green-600);
|
||||
}
|
||||
|
||||
.batch-count-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.batch-count-field input {
|
||||
flex: 0 0 auto;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.batch-topics-count {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
|
||||
Reference in New Issue
Block a user