mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-31 02:19:35 +08:00
- 新增 History 组件用于展示生成历史记录 - 调整 HomeLayout 布局,增加 History 侧边栏 - 优化 NoteHistory 组件样式和布局- 更新首页样式,调整各个组件的位置和样式
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { FC, useEffect, useState } from 'react'
|
|
import HomeLayout from '@/layouts/HomeLayout.tsx'
|
|
import NoteForm from '@/pages/HomePage/components/NoteForm.tsx'
|
|
import MarkdownViewer from '@/pages/HomePage/components/MarkdownViewer.tsx'
|
|
import { useTaskStore } from '@/store/taskStore'
|
|
import History from '@/pages/HomePage/components/History.tsx'
|
|
type ViewStatus = 'idle' | 'loading' | 'success' | 'failed'
|
|
export const HomePage: FC = () => {
|
|
const tasks = useTaskStore(state => state.tasks)
|
|
const currentTaskId = useTaskStore(state => state.currentTaskId)
|
|
|
|
const currentTask = tasks.find(t => t.id === currentTaskId)
|
|
|
|
const [status, setStatus] = useState<ViewStatus>('idle')
|
|
|
|
const content = currentTask?.markdown || ''
|
|
|
|
useEffect(() => {
|
|
if (!currentTask) {
|
|
setStatus('idle')
|
|
} else if (currentTask.status === 'PENDING') {
|
|
setStatus('loading')
|
|
} else if (currentTask.status === 'SUCCESS') {
|
|
setStatus('success')
|
|
} else if (currentTask.status === 'FAILED') {
|
|
setStatus('failed')
|
|
}
|
|
}, [currentTask])
|
|
|
|
// useEffect( () => {
|
|
// get_task_status('d4e87938-c066-48a0-bbd5-9bec40d53354').then(res=>{
|
|
// console.log('res1',res)
|
|
// setContent(res.data.result.markdown)
|
|
// })
|
|
// }, [tasks]);
|
|
return (
|
|
<HomeLayout
|
|
NoteForm={<NoteForm />}
|
|
Preview={<MarkdownViewer status={status} content={content} />}
|
|
History={<History />}
|
|
/>
|
|
)
|
|
}
|