Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 308 additions & 28 deletions BillNote_frontend/package-lock.json

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions BillNote_frontend/src/hooks/useTaskPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import toast from 'react-hot-toast'
export const useTaskPolling = (interval = 3000) => {
const tasks = useTaskStore(state => state.tasks)
const updateTaskContent = useTaskStore(state => state.updateTaskContent)
const updateTaskStatus = useTaskStore(state => state.updateTaskStatus)
const removeTask = useTaskStore(state => state.removeTask)

const tasksRef = useRef(tasks)

Expand Down Expand Up @@ -48,8 +46,7 @@ export const useTaskPolling = (interval = 3000) => {
}
}
} catch (e) {
console.error('❌ 任务轮询失败:', e)
updateTaskContent(task.id, { status: 'FAILED' })
console.error('❌ 任务轮询失败,保留当前状态等待下次轮询:', e)
}
}
}, interval)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ interface MarkdownViewerProps {
}

const steps = [
{ label: '排队中', key: 'PENDING' },
{ label: '解析链接', key: 'PARSING' },
{ label: '下载音频', key: 'DOWNLOADING' },
{ label: '转写文字', key: 'TRANSCRIBING' },
{ label: '总结内容', key: 'SUMMARIZING' },
{ label: '保存结果', key: 'SAVING' },
{ label: '保存完成', key: 'SUCCESS' },
]

Expand Down
21 changes: 16 additions & 5 deletions BillNote_frontend/src/pages/HomePage/components/NoteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
FormMessage,
} from '@/components/ui/form.tsx'
import { useEffect,useState } from 'react'
import { useForm, useWatch } from 'react-hook-form'
import { FieldErrors, useForm, useWatch } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { z } from 'zod'

Expand Down Expand Up @@ -162,9 +162,15 @@ const NoteForm = () => {
/* ---- 副作用 ---- */
useEffect(() => {
loadEnabledModels()

return
}, [])

useEffect(() => {
if (currentTask || modelList.length === 0) return
const currentModel = form.getValues('model_name')
if (!currentModel || !modelList.some(m => m.model_name === currentModel)) {
form.setValue('model_name', modelList[0].model_name, { shouldValidate: true })
}
}, [currentTask, form, modelList])
useEffect(() => {
if (!currentTask) return
const { formData } = currentTask
Expand Down Expand Up @@ -217,10 +223,15 @@ const NoteForm = () => {
}

const onSubmit = async (values: NoteFormValues) => {
console.log('Not even go here')
const provider = modelList.find(m => m.model_name === values.model_name)
if (!provider) {
form.setError('model_name', { type: 'manual', message: '请选择模型' })
return
}

const payload: NoteFormValues = {
...values,
provider_id: modelList.find(m => m.model_name === values.model_name)!.provider_id,
provider_id: provider.provider_id,
task_id: currentTaskId || '',
}
if (currentTaskId) {
Expand Down
3 changes: 2 additions & 1 deletion BillNote_frontend/src/pages/HomePage/components/StepBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ interface StepBarProps {
}

const StepBar: FC<StepBarProps> = ({ steps, currentStep }) => {
const currentIndex = steps.findIndex(step => step.key === currentStep)
const rawIndex = steps.findIndex(step => step.key === currentStep)
const currentIndex = rawIndex >= 0 ? rawIndex : 0

return (
<div className="flex w-full items-center justify-between">
Expand Down
3 changes: 0 additions & 3 deletions BillNote_frontend/src/services/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export const get_task_status = async (task_id: string) => {
} catch (e) {
console.error('❌ 请求出错', e)

// 错误提示
toast.error('笔记生成失败,请稍后重试')

throw e // 抛出错误以便调用方处理
}
}
11 changes: 10 additions & 1 deletion BillNote_frontend/src/store/taskStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,16 @@ import { v4 as uuidv4 } from 'uuid'
import toast from 'react-hot-toast'


export type TaskStatus = 'PENDING' | 'RUNNING' | 'SUCCESS' | 'FAILD'
export type TaskStatus =
| 'PENDING'
| 'PARSING'
| 'DOWNLOADING'
| 'TRANSCRIBING'
| 'SUMMARIZING'
| 'FORMATTING'
| 'SAVING'
| 'SUCCESS'
| 'FAILED'

export interface AudioMeta {
cover_url: string
Expand Down
Loading