From 246e8a14061eb1e11ff5a5400909374b89d6d8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=80=9D=E8=AF=BA=E7=89=B9?= Date: Sun, 27 Apr 2025 21:55:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(layout):=20=E4=BC=98=E5=8C=96=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E5=B8=83=E5=B1=80=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=8F=AF?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=9D=A2=E6=9D=BF=20fixes=20#123?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 react-resizable-panels 实现可调整大小的面板 - 重新布局首页结构,分为左、中、右三个可调整区域 - 更新 NoteForm 和 NoteHistory 组件以适应新布局 - 调整 History 组件样式,优化滚动体验 - 更新项目依赖,添加 react-resizable-panels --- BillNote_frontend/package.json | 1 + .../src/components/ui/resizable.tsx | 54 ++ BillNote_frontend/src/index.css | 4 +- BillNote_frontend/src/layouts/HomeLayout.tsx | 91 ++-- .../src/pages/HomePage/components/History.tsx | 2 +- .../pages/HomePage/components/NoteForm.tsx | 499 +++++++++--------- .../pages/HomePage/components/NoteHistory.tsx | 2 +- 7 files changed, 355 insertions(+), 298 deletions(-) create mode 100644 BillNote_frontend/src/components/ui/resizable.tsx diff --git a/BillNote_frontend/package.json b/BillNote_frontend/package.json index 7ab46a7..f38bae3 100644 --- a/BillNote_frontend/package.json +++ b/BillNote_frontend/package.json @@ -39,6 +39,7 @@ "react-hook-form": "^7.55.0", "react-hot-toast": "^2.5.2", "react-markdown": "^10.1.0", + "react-resizable-panels": "^2.1.8", "react-router-dom": "^7.5.1", "react-syntax-highlighter": "^15.6.1", "remark-gfm": "1.0.0", diff --git a/BillNote_frontend/src/components/ui/resizable.tsx b/BillNote_frontend/src/components/ui/resizable.tsx new file mode 100644 index 0000000..569328f --- /dev/null +++ b/BillNote_frontend/src/components/ui/resizable.tsx @@ -0,0 +1,54 @@ +import * as React from "react" +import { GripVerticalIcon } from "lucide-react" +import * as ResizablePrimitive from "react-resizable-panels" + +import { cn } from "@/lib/utils" + +function ResizablePanelGroup({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function ResizablePanel({ + ...props +}: React.ComponentProps) { + return +} + +function ResizableHandle({ + withHandle, + className, + ...props +}: React.ComponentProps & { + withHandle?: boolean +}) { + return ( + div]:rotate-90", + className + )} + {...props} + > + {withHandle && ( +
+ +
+ )} +
+ ) +} + +export { ResizablePanelGroup, ResizablePanel, ResizableHandle } diff --git a/BillNote_frontend/src/index.css b/BillNote_frontend/src/index.css index 2f2aaed..d1bcf28 100644 --- a/BillNote_frontend/src/index.css +++ b/BillNote_frontend/src/index.css @@ -2,10 +2,10 @@ @import 'tw-animate-css'; @custom-variant dark (&:is(.dark *)); -html,body{ +html, body, #root { height: 100%; - width: 100%; } + /* 修改滚动条轨道颜色 */ ::-webkit-scrollbar { width: 8px; /* 控制滚动条的宽度 */ diff --git a/BillNote_frontend/src/layouts/HomeLayout.tsx b/BillNote_frontend/src/layouts/HomeLayout.tsx index 8aa300c..7bb55f5 100644 --- a/BillNote_frontend/src/layouts/HomeLayout.tsx +++ b/BillNote_frontend/src/layouts/HomeLayout.tsx @@ -9,6 +9,7 @@ import { import { useState } from 'react' import { Link } from 'react-router-dom' +import { ResizablePanel, ResizablePanelGroup, ResizableHandle } from '@/components/ui/resizable' interface IProps { NoteForm: React.ReactNode @@ -19,59 +20,53 @@ const HomeLayout: FC = ({ NoteForm, Preview, History }) => { const [, setShowSettings] = useState(false) return ( -
-
- {/* 左侧部分:Header + 表单 */} - + - {/* 表单内容 */} -
- {/**/} - {NoteForm} -
- - + {/* 中间历史 */} + + + - {/* 右侧预览区域 */} -
- {/**/} - {Preview} -
-
+ - {/* 页脚 */} - {/*
*/} - {/* © 2025 BiliNote. All rights reserved.*/} - {/*
*/} + {/* 右边预览 */} + +
{Preview}
+
+
) } diff --git a/BillNote_frontend/src/pages/HomePage/components/History.tsx b/BillNote_frontend/src/pages/HomePage/components/History.tsx index 6f33d35..3f34ae8 100644 --- a/BillNote_frontend/src/pages/HomePage/components/History.tsx +++ b/BillNote_frontend/src/pages/HomePage/components/History.tsx @@ -13,7 +13,7 @@ const History = () => {

生成历史

- + {/*
*/} {/*
*/} diff --git a/BillNote_frontend/src/pages/HomePage/components/NoteForm.tsx b/BillNote_frontend/src/pages/HomePage/components/NoteForm.tsx index 04934cb..1aef1bb 100644 --- a/BillNote_frontend/src/pages/HomePage/components/NoteForm.tsx +++ b/BillNote_frontend/src/pages/HomePage/components/NoteForm.tsx @@ -34,6 +34,7 @@ import NoteHistory from '@/pages/HomePage/components/NoteHistory.tsx' import { useModelStore } from '@/store/modelStore' import { Alert } from 'antd' import { Textarea } from '@/components/ui/textarea.tsx' +import { ScrollArea } from '@/components/ui/scroll-area.tsx' // ✅ 定义表单 schema const formSchema = z.object({ video_url: z.string().url('请输入正确的视频链接'), @@ -150,263 +151,269 @@ const NoteForm = () => { }, []) return ( -
-
- -
-
-

视频链接

- - - - - - -

输入视频链接,支持哔哩哔哩、YouTube等平台

-
-
-
-
+
+
+ +
+ + + +
+
+

视频链接

+ + + + + + +

输入视频链接,支持哔哩哔哩、YouTube等平台

+
+
+
+
-
- {/* 平台选择 */} - ( - - - - - )} - /> - - {/* 视频地址 */} - ( - - - - - - - )} - /> -
- {/*

*/} - {/* 支持哔哩哔哩视频链接,例如:*/} - {/* https://www.bilibili.com/video/BV1vc25YQE9X/*/} - {/*

*/} - ( - -
-

音频质量

- - - - - - -

质量越高,下载体积越大,速度越慢

-
-
-
-
- - {/**/} - {/* 质量越高,下载体积越大,速度越慢*/} - {/**/} - -
- )} - /> - - ( - -
-

模型选择

- - - - - - -

不同模型返回质量不同,可自行测试

-
-
-
-
- - {/**/} - {/* 质量越高,下载体积越大,速度越慢*/} - {/**/} - -
- )} - /> -
- - ( - -
-

笔记风格

- - - - - - -

选择你希望生成的笔记风格

-
-
-
-
- - - - -
- )} - /> - - ( - -
-

笔记格式

- - - - - - -

选择要包含的笔记元素,比如时间戳、截图提示或总结

-
-
-
-
- - -
- {noteFormats.map(item => ( - - ))} -
-
+
+ {/* 平台选择 */} ( -
-

备注

- - - - - - -

会把这段加入到Prompt最后 可自行测试

-
-
-
-
-