|
@@ -81,6 +81,17 @@ function findSelectedKey(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* ================= 最近编辑跳转地址 ================= */
|
|
|
|
|
+
|
|
|
|
|
+// 巴利三藏文本类型(chapter/para 等)路由位于 /workspace/tipitaka 下
|
|
|
|
|
+const TIPITAKA_TYPES = new Set(["chapter", "para"]);
|
|
|
|
|
+
|
|
|
|
|
+function recentPath(type: string, id: string): string {
|
|
|
|
|
+ return TIPITAKA_TYPES.has(type)
|
|
|
|
|
+ ? `/workspace/tipitaka/${type}/${id}`
|
|
|
|
|
+ : `/workspace/${type}/${id}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* ================= 找展开父级keys ================= */
|
|
/* ================= 找展开父级keys ================= */
|
|
|
|
|
|
|
|
function findOpenKeys(
|
|
function findOpenKeys(
|
|
@@ -121,9 +132,9 @@ const Widget = ({ onSearch }: Props) => {
|
|
|
const [openSetting, setOpenSetting] = useState(false);
|
|
const [openSetting, setOpenSetting] = useState(false);
|
|
|
|
|
|
|
|
const recentList: MenuItem[] = data
|
|
const recentList: MenuItem[] = data
|
|
|
- ? data?.data.rows.map((item, id) => {
|
|
|
|
|
|
|
+ ? data?.data.rows.map((item) => {
|
|
|
return {
|
|
return {
|
|
|
- key: `recent-${id}`,
|
|
|
|
|
|
|
+ key: `recent-${item.id}`,
|
|
|
label: item.title,
|
|
label: item.title,
|
|
|
};
|
|
};
|
|
|
})
|
|
})
|
|
@@ -348,6 +359,12 @@ const Widget = ({ onSearch }: Props) => {
|
|
|
} else if (key === "/workspace/setting") {
|
|
} else if (key === "/workspace/setting") {
|
|
|
setOpenSetting(true);
|
|
setOpenSetting(true);
|
|
|
return;
|
|
return;
|
|
|
|
|
+ } else if (key.startsWith("recent-")) {
|
|
|
|
|
+ const row = data?.data.rows.find((item) => `recent-${item.id}` === key);
|
|
|
|
|
+ if (row) {
|
|
|
|
|
+ navigate(recentPath(row.type, row.article_id));
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
navigate(key);
|
|
navigate(key);
|
|
|
};
|
|
};
|
|
@@ -369,8 +386,9 @@ const Widget = ({ onSearch }: Props) => {
|
|
|
if (e.ctrlKey || e.metaKey) {
|
|
if (e.ctrlKey || e.metaKey) {
|
|
|
window.open("");
|
|
window.open("");
|
|
|
} else {
|
|
} else {
|
|
|
- navigate(`/workspace/${row.type}/${row.articleId}`);
|
|
|
|
|
|
|
+ navigate(recentPath(row.type, row.articleId));
|
|
|
}
|
|
}
|
|
|
|
|
+ setRecentOpen(false);
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
<SettingModal open={openSetting} onClose={() => setOpenSetting(false)} />
|
|
<SettingModal open={openSetting} onClose={() => setOpenSetting(false)} />
|