fix(studio): 笔记切换页面不刷新 + 侧边栏错误提示友好化
- WorkspaceRoutes 给 StudioNotebookDetailPage 加 key={notebookId},切换笔记时强制重新挂载
- createSearchSpace 接口失败时解析响应体 detail 字段,直接展示服务端错误信息
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
73700cca54
commit
613cece224
3 files changed
+12
-5
No files matched your search
@@ -34,8 +34,6 @@ const NAV_ITEM_CLASS =
|
|||||||
"data-[active=true]:bg-primary/15 data-[active=true]:text-primary data-[active=true]:shadow-none " +
|
"data-[active=true]:bg-primary/15 data-[active=true]:text-primary data-[active=true]:shadow-none " +
|
||||||
"dark:hover:bg-primary/15 dark:data-[active=true]:bg-primary/25 dark:data-[active=true]:text-primary-foreground";
|
"dark:hover:bg-primary/15 dark:data-[active=true]:bg-primary/25 dark:data-[active=true]:text-primary-foreground";
|
||||||
|
|
||||||
const SIDEBAR_PREVIEW_COUNT = 5;
|
|
||||||
|
|
||||||
export function WorkspaceNavStudio() {
|
export function WorkspaceNavStudio() {
|
||||||
const { notebooks, isLoading, isError } = useStudioNotebooks();
|
const { notebooks, isLoading, isError } = useStudioNotebooks();
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
@@ -71,6 +69,7 @@ export function WorkspaceNavStudio() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SIDEBAR_PREVIEW_COUNT = 2;
|
||||||
const preview = notebooks.slice(0, SIDEBAR_PREVIEW_COUNT);
|
const preview = notebooks.slice(0, SIDEBAR_PREVIEW_COUNT);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -46,7 +46,10 @@ export async function createSearchSpace(
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({ name, description: "", citations_enabled: true }),
|
body: JSON.stringify({ name, description: "", citations_enabled: true }),
|
||||||
});
|
});
|
||||||
if (!res.ok) throw new Error(`创建失败:${res.status}`);
|
if (!res.ok) {
|
||||||
|
const body = await res.json().catch(() => null);
|
||||||
|
throw new Error(body?.detail || `创建失败:${res.status}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadSourceText(
|
export async function uploadSourceText(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { CSSProperties, ReactNode } from "react";
|
import type { CSSProperties, ReactNode } from "react";
|
||||||
import { Navigate, Route, Routes } from "react-router-dom";
|
import { Navigate, Route, Routes, useParams } from "react-router-dom";
|
||||||
|
|
||||||
import { getStoredAuth } from "@/core/auth";
|
import { getStoredAuth } from "@/core/auth";
|
||||||
|
|
||||||
@@ -39,6 +39,11 @@ import AIWritingPage from "@/open-canvas/pages/AIWritingPage";
|
|||||||
import StudioNotebooksPage from "./StudioNotebooksPage";
|
import StudioNotebooksPage from "./StudioNotebooksPage";
|
||||||
import StudioNotebookDetailPage from "./StudioNotebookDetailPage";
|
import StudioNotebookDetailPage from "./StudioNotebookDetailPage";
|
||||||
import RoundtablePlanningPage from "@/roundtable-planning/pages/RoundtablePlanningPage";
|
import RoundtablePlanningPage from "@/roundtable-planning/pages/RoundtablePlanningPage";
|
||||||
|
|
||||||
|
function NotebookDetailPageWithKey() {
|
||||||
|
const { notebookId } = useParams<{ notebookId: string }>();
|
||||||
|
return <StudioNotebookDetailPage key={notebookId} />;
|
||||||
|
}
|
||||||
import "@/roundtable-planning/styles/roundtable-planning.css";
|
import "@/roundtable-planning/styles/roundtable-planning.css";
|
||||||
|
|
||||||
export function WorkspaceLayout({
|
export function WorkspaceLayout({
|
||||||
@@ -219,7 +224,7 @@ export default function WorkspaceRoutes({
|
|||||||
element={
|
element={
|
||||||
<WorkspaceLayout {...layoutProps}>
|
<WorkspaceLayout {...layoutProps}>
|
||||||
<ChatRuntime>
|
<ChatRuntime>
|
||||||
<StudioNotebookDetailPage />
|
<NotebookDetailPageWithKey />
|
||||||
</ChatRuntime>
|
</ChatRuntime>
|
||||||
</WorkspaceLayout>
|
</WorkspaceLayout>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user