Просмотр исходного кода

Merge pull request #2411 from visuddhinanda/development

add open.in.library
visuddhinanda 2 дней назад
Родитель
Сommit
f12ad0c02a
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      dashboard-v6/src/components/article/TypePali.tsx

+ 15 - 0
dashboard-v6/src/components/article/TypePali.tsx

@@ -29,6 +29,8 @@ import TocPath from "../tipitaka/TocPath";
 import ParagraphNode from "../tipitaka/ParagraphNode";
 import "./article.css";
 
+import { useIntl } from "react-intl";
+
 export interface ISearchParams {
   key: string;
   value: string;
@@ -68,6 +70,8 @@ const TypePali = ({
   hideNav = false,
   onArticleChange,
 }: IWidget) => {
+  const intl = useIntl();
+
   const user = useAppSelector(currentUser);
   const channels = channelId?.split("_");
 
@@ -177,10 +181,21 @@ const TypePali = ({
               items: [
                 { key: "tpl", label: "获取模板" },
                 { key: "task", label: "生成任务" },
+                {
+                  key: "library",
+                  label: intl.formatMessage({ id: "buttons.open.in.library" }),
+                },
               ],
               onClick: ({ key }) => {
                 if (key === "task") setTaskBuilderModalOpen(true);
                 if (key === "tpl") setTplOpen(true);
+                if (key === "library" && channels) {
+                  window.open(
+                    import.meta.env.VITE_APP_API_SERVER +
+                      `/library/tipitaka/${id}/read?channel=${channels[0]}`,
+                    "_blank"
+                  );
+                }
               },
             }}
             placement="bottomRight"