mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-02 11:09:36 +08:00
- 新增关于页面组件,介绍项目背景、功能和使用方法 - 重构笔记生成逻辑,支持多版本笔记 - 新增笔记版本选择、复制和导出功能 -优化笔记界面布局和交互 - 调整部分组件样式,提升用户体验
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} />}
|
|
History={<History />}
|
|
/>
|
|
)
|
|
}
|