merge: integrate backtests with main dataset catalog and sequence migration 0004
This commit is contained in:
+80
-44
@@ -13,6 +13,7 @@ import zhCN from "@douyinfe/semi-ui-19/lib/es/locale/source/zh_CN";
|
||||
import { api, post } from "./api";
|
||||
import type { Account, Job } from "./types";
|
||||
import { AccountPage } from "./pages/AccountPage";
|
||||
import { DatasetPage } from "./pages/DatasetPage";
|
||||
import { AlphaPage } from "./pages/AlphaPage";
|
||||
import { JobPanel } from "./components/JobPanel";
|
||||
import { BacktestPage } from "./backtests/BacktestPage";
|
||||
@@ -26,9 +27,11 @@ export default function App() {
|
||||
const [page, setPage] = useState(
|
||||
location.hash === "#backtests"
|
||||
? "backtests"
|
||||
: location.hash === "#account"
|
||||
? "account"
|
||||
: "alphas",
|
||||
: location.hash === "#datasets"
|
||||
? "datasets"
|
||||
: location.hash === "#account"
|
||||
? "account"
|
||||
: "alphas",
|
||||
);
|
||||
const [visitedBacktests, setVisitedBacktests] = useState(
|
||||
page === "backtests",
|
||||
@@ -36,6 +39,7 @@ export default function App() {
|
||||
useEffect(() => {
|
||||
if (page === "backtests") setVisitedBacktests(true);
|
||||
}, [page]);
|
||||
const [catalogModal, setCatalogModal] = useState(false);
|
||||
const [showJobs, setShowJobs] = useState(false);
|
||||
const [refreshKey, setRefreshKey] = useState(0);
|
||||
const [pollError, setPollError] = useState("");
|
||||
@@ -101,9 +105,11 @@ export default function App() {
|
||||
setPage(
|
||||
location.hash === "#backtests"
|
||||
? "backtests"
|
||||
: location.hash === "#account"
|
||||
? "account"
|
||||
: "alphas",
|
||||
: location.hash === "#datasets"
|
||||
? "datasets"
|
||||
: location.hash === "#account"
|
||||
? "account"
|
||||
: "alphas",
|
||||
);
|
||||
window.addEventListener("hashchange", hash);
|
||||
return () => {
|
||||
@@ -174,7 +180,11 @@ export default function App() {
|
||||
/>
|
||||
) : (
|
||||
<div className="workspace">
|
||||
<aside className="sidebar" inert={chatOpen && viewport < 1440}>
|
||||
<aside
|
||||
className="sidebar"
|
||||
inert={(chatOpen && viewport < 1440) || catalogModal}
|
||||
aria-hidden={catalogModal || undefined}
|
||||
>
|
||||
<div className="brand">
|
||||
<span className="brand-mark">α</span>
|
||||
<div>Alpha 研究</div>
|
||||
@@ -187,6 +197,14 @@ export default function App() {
|
||||
>
|
||||
Alpha 管理
|
||||
</button>
|
||||
<button
|
||||
aria-label="数据集"
|
||||
className={`nav-item ${page === "datasets" ? "active" : ""}`}
|
||||
aria-current={page === "datasets" ? "page" : undefined}
|
||||
onClick={() => changePage("datasets")}
|
||||
>
|
||||
数据集
|
||||
</button>
|
||||
<button
|
||||
aria-label="个人信息"
|
||||
className={`nav-item ${page === "account" ? "active" : ""}`}
|
||||
@@ -218,7 +236,11 @@ export default function App() {
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
<div className="main-shell" inert={chatOpen && viewport < 1440}>
|
||||
<div
|
||||
className="main-shell"
|
||||
inert={(chatOpen && viewport < 1440) || catalogModal}
|
||||
aria-hidden={catalogModal || undefined}
|
||||
>
|
||||
<header className="topbar">
|
||||
<div className="breadcrumbs">研究工作空间</div>
|
||||
<div className="top-actions">
|
||||
@@ -277,6 +299,18 @@ export default function App() {
|
||||
onTask={taskCreated}
|
||||
/>
|
||||
</div>
|
||||
<div className="alpha-page-view" hidden={page !== "datasets"}>
|
||||
<DatasetPage
|
||||
account={account}
|
||||
jobs={jobs}
|
||||
active={page === "datasets"}
|
||||
version={`${refreshKey}:${completedVersion}`}
|
||||
suspended={showJobs || chatOpen}
|
||||
onTask={taskCreated}
|
||||
onModal={setCatalogModal}
|
||||
onChat={() => setChatOpen(true)}
|
||||
/>
|
||||
</div>
|
||||
<div className="alpha-page-view" hidden={page !== "alphas"}>
|
||||
<AlphaPage
|
||||
taskPanelOpen={showJobs}
|
||||
@@ -330,7 +364,7 @@ export default function App() {
|
||||
changePage("account");
|
||||
}}
|
||||
/>
|
||||
{!chatOpen && (
|
||||
{!chatOpen && !catalogModal && (
|
||||
<Button
|
||||
className="ai-launcher"
|
||||
aria-label="打开研究助手"
|
||||
@@ -348,41 +382,43 @@ export default function App() {
|
||||
onClick={() => setChatOpen(false)}
|
||||
/>
|
||||
)}
|
||||
<ChatPanel
|
||||
jobs={jobs}
|
||||
open={chatOpen}
|
||||
width={chatWidth}
|
||||
onWidth={setChatWidth}
|
||||
onClose={() => setChatOpen(false)}
|
||||
context={
|
||||
page === "alphas"
|
||||
? alphaContext
|
||||
: page === "backtests"
|
||||
? backtestContext
|
||||
: { page: "account" }
|
||||
}
|
||||
timezone={account?.timezone}
|
||||
onSettings={() => {
|
||||
focusBusiness();
|
||||
changePage("account");
|
||||
requestAnimationFrame(() =>
|
||||
document
|
||||
.getElementById("model-settings")
|
||||
?.scrollIntoView({ block: "start" }),
|
||||
);
|
||||
}}
|
||||
onChanged={actionDone}
|
||||
onAction={(action) => {
|
||||
focusBusiness();
|
||||
changePage(
|
||||
action.type === "open_backtest" ||
|
||||
action.type === "open_backtest_preview"
|
||||
? "backtests"
|
||||
: "alphas",
|
||||
);
|
||||
setAIAction(action);
|
||||
}}
|
||||
/>
|
||||
<div inert={catalogModal && !chatOpen}>
|
||||
<ChatPanel
|
||||
jobs={jobs}
|
||||
open={chatOpen}
|
||||
width={chatWidth}
|
||||
onWidth={setChatWidth}
|
||||
onClose={() => setChatOpen(false)}
|
||||
context={
|
||||
page === "alphas"
|
||||
? alphaContext
|
||||
: page === "backtests"
|
||||
? backtestContext
|
||||
: { page: page === "datasets" ? "datasets" : "account" }
|
||||
}
|
||||
timezone={account?.timezone}
|
||||
onSettings={() => {
|
||||
focusBusiness();
|
||||
changePage("account");
|
||||
requestAnimationFrame(() =>
|
||||
document
|
||||
.getElementById("model-settings")
|
||||
?.scrollIntoView({ block: "start" }),
|
||||
);
|
||||
}}
|
||||
onChanged={actionDone}
|
||||
onAction={(action) => {
|
||||
focusBusiness();
|
||||
changePage(
|
||||
action.type === "open_backtest" ||
|
||||
action.type === "open_backtest_preview"
|
||||
? "backtests"
|
||||
: "alphas",
|
||||
);
|
||||
setAIAction(action);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</LocaleProvider>
|
||||
|
||||
Reference in New Issue
Block a user