Răsfoiți Sursa

fix(dashboard-v6): 修复最近编辑菜单与弹窗的跳转和展示问题

- 弹窗距顶部 10px,并限制高度不超出屏幕
- 弹窗标题使用与菜单一致的 i18n (columns.studio.recent.title)
- 最近编辑子菜单可正常跳转(含 chapter/para 走 tipitaka 路由)
- 点击弹窗标题后关闭弹窗
visuddhinanda 5 zile în urmă
părinte
comite
3d07154da7

+ 21 - 3
dashboard-v6/src/components/navigation/MainMenu.tsx

@@ -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 ================= */
 
 function findOpenKeys(
@@ -121,9 +132,9 @@ const Widget = ({ onSearch }: Props) => {
   const [openSetting, setOpenSetting] = useState(false);
 
   const recentList: MenuItem[] = data
-    ? data?.data.rows.map((item, id) => {
+    ? data?.data.rows.map((item) => {
         return {
-          key: `recent-${id}`,
+          key: `recent-${item.id}`,
           label: item.title,
         };
       })
@@ -348,6 +359,12 @@ const Widget = ({ onSearch }: Props) => {
     } else if (key === "/workspace/setting") {
       setOpenSetting(true);
       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);
   };
@@ -369,8 +386,9 @@ const Widget = ({ onSearch }: Props) => {
           if (e.ctrlKey || e.metaKey) {
             window.open("");
           } else {
-            navigate(`/workspace/${row.type}/${row.articleId}`);
+            navigate(recentPath(row.type, row.articleId));
           }
+          setRecentOpen(false);
         }}
       />
       <SettingModal open={openSetting} onClose={() => setOpenSetting(false)} />

+ 8 - 1
dashboard-v6/src/components/recent/RecentModal.tsx

@@ -45,13 +45,20 @@ const RecentModal = ({
       <Modal
         width={"80%"}
         title={intl.formatMessage({
-          id: `labels.recent-scan`,
+          id: `columns.studio.recent.title`,
         })}
         footer={false}
         open={isModalOpen}
         onOk={handleOk}
         onCancel={handleCancel}
         destroyOnHidden
+        style={{ top: 10 }}
+        styles={{
+          body: {
+            maxHeight: "calc(100vh - 160px)",
+            overflowY: "auto",
+          },
+        }}
       >
         <RecentList onSelect={onSelect} />
       </Modal>