Explorar o código

用 fullUrl 函数获取url

visuddhinanda %!s(int64=2) %!d(string=hai) anos
pai
achega
1134f835e6

+ 2 - 5
dashboard/src/components/anthology/AnthologyList.tsx

@@ -23,6 +23,7 @@ import Share, { EResType } from "../share/Share";
 
 import StudioName, { IStudio } from "../auth/StudioName";
 import { IResNumberResponse, renderBadge } from "../channel/ChannelTable";
+import { fullUrl } from "../../utils";
 
 const { Text } = Typography;
 
@@ -255,11 +256,7 @@ const AnthologyListWidget = ({
                   onClick: (e) => {
                     switch (e.key) {
                       case "open":
-                        const fullUrl =
-                          process.env.REACT_APP_WEB_HOST +
-                          process.env.PUBLIC_URL +
-                          `/anthology/${row.id}`;
-                        window.open(fullUrl, "_blank");
+                        window.open(fullUrl(`/anthology/${row.id}`), "_blank");
                         break;
                       case "share":
                         console.log("share");

+ 2 - 5
dashboard/src/components/anthology/EditableTocTree.tsx

@@ -20,6 +20,7 @@ import EditableTree, {
 } from "../article/EditableTree";
 import ArticleEditDrawer from "../article/ArticleEditDrawer";
 import ArticleDrawer from "../article/ArticleDrawer";
+import { fullUrl } from "../../utils";
 
 interface IWidget {
   anthologyId?: string;
@@ -157,11 +158,7 @@ const EditableTocTreeWidget = ({
           node: TreeNodeData
         ) => {
           if (e.ctrlKey || e.metaKey) {
-            const fullUrl =
-              process.env.REACT_APP_WEB_HOST +
-              process.env.PUBLIC_URL +
-              `/article/article/${node.key}`;
-            window.open(fullUrl, "_blank");
+            window.open(fullUrl(`/article/article/${node.key}`), "_blank");
           } else {
             setViewArticleId(node.key);
             setOpenViewer(true);

+ 2 - 5
dashboard/src/components/article/ToolButtonNav.tsx

@@ -8,6 +8,7 @@ import { useAppSelector } from "../../hooks";
 import { sentenceList } from "../../reducers/sentence";
 import ToolButtonNavMore from "./ToolButtonNavMore";
 import ToolButtonNavSliceTitle from "./ToolButtonNavSliceTitle";
+import { fullUrl } from "../../utils";
 
 const { Text } = Typography;
 
@@ -152,11 +153,7 @@ const ToolButtonNavWidget = ({ type, articleId }: IWidget) => {
 
                   switch (key) {
                     case "copy-link":
-                      const fullUrl =
-                        process.env.REACT_APP_WEB_HOST +
-                        process.env.PUBLIC_URL +
-                        url;
-                      navigator.clipboard.writeText(fullUrl).then(() => {
+                      navigator.clipboard.writeText(fullUrl(url)).then(() => {
                         message.success("链接地址已经拷贝到剪贴板");
                       });
 

+ 0 - 23
dashboard/src/components/template/SentEdit/SentTab.tsx

@@ -97,29 +97,6 @@ const SentTabWidget = ({
               link="none"
               data={mPath}
               trigger={path ? path.length > 0 ? path[0].title : <></> : <></>}
-              onChange={(
-                para: ITocPathNode,
-                e: React.MouseEvent<
-                  HTMLSpanElement | HTMLAnchorElement,
-                  MouseEvent
-                >
-              ) => {
-                //点击章节目录
-                if (para.book && para.paragraph) {
-                  const type = para.level
-                    ? para.level < 8
-                      ? "chapter"
-                      : "para"
-                    : "para";
-                  store.dispatch(
-                    change({
-                      book: para.book,
-                      para: para.paragraph,
-                      type: type,
-                    })
-                  );
-                }
-              }}
             />
             <Text copyable={{ text: `{{${sentId[0]}}}` }}>{sentId[0]}</Text>
             <SentMenu

+ 5 - 5
dashboard/src/components/template/Term.tsx

@@ -12,6 +12,7 @@ import { changedTerm, refresh } from "../../reducers/term-change";
 import { useAppSelector } from "../../hooks";
 import { get } from "../../request";
 import { Link, useNavigate } from "react-router-dom";
+import { fullUrl } from "../../utils";
 
 const { Text, Title } = Typography;
 
@@ -88,11 +89,10 @@ const TermCtl = ({
               <Space>
                 <Button
                   onClick={() => {
-                    const fullUrl =
-                      process.env.REACT_APP_WEB_HOST +
-                      process.env.PUBLIC_URL +
-                      `/term/list/${termData.word}`;
-                    window.open(fullUrl, "_blank");
+                    window.open(
+                      fullUrl(`/term/list/${termData.word}`),
+                      "_blank"
+                    );
                   }}
                   type="link"
                   size="small"

+ 2 - 10
dashboard/src/pages/library/article/show.tsx

@@ -220,11 +220,7 @@ const Widget = () => {
                       : "";
                     url += param.param?.para ? `&par=${param.param?.para}` : "";
                     if (event.ctrlKey || event.metaKey) {
-                      const fullUrl =
-                        process.env.REACT_APP_WEB_HOST +
-                        process.env.PUBLIC_URL +
-                        url;
-                      window.open(fullUrl, "_blank");
+                      window.open(fullUrl(url), "_blank");
                     } else {
                       navigate(url);
                     }
@@ -318,11 +314,7 @@ const Widget = () => {
                   }
                 });
                 if (event.ctrlKey || event.metaKey) {
-                  const fullUrl =
-                    process.env.REACT_APP_WEB_HOST +
-                    process.env.PUBLIC_URL +
-                    url;
-                  window.open(fullUrl, "_blank");
+                  window.open(fullUrl(url), "_blank");
                 } else {
                   navigate(url);
                 }

+ 2 - 5
dashboard/src/pages/library/palicanon/bypath.tsx

@@ -11,6 +11,7 @@ import BookViewer from "../../../components/corpus/BookViewer";
 import { IChapterClickEvent } from "../../../components/corpus/PaliChapterList";
 import { IPaliBookListResponse } from "../../../components/api/Corpus";
 import Recent from "../../../components/corpus/Recent";
+import { fullUrl } from "../../../utils";
 
 const Widget = () => {
   const { root, path } = useParams();
@@ -127,11 +128,7 @@ const Widget = () => {
                 onChapterClick={(e: IChapterClickEvent) => {
                   if (e.event.ctrlKey) {
                     const url = `/palicanon/chapter/${e.para.Book}-${e.para.Paragraph}`;
-                    const fullUrl =
-                      process.env.REACT_APP_WEB_HOST +
-                      process.env.PUBLIC_URL +
-                      url;
-                    window.open(fullUrl, "_blank");
+                    window.open(fullUrl(url), "_blank");
                   } else {
                     setIsModalOpen(true);
                     setOpenPara({ book: e.para.Book, para: e.para.Paragraph });

+ 2 - 5
dashboard/src/pages/studio/channel/show.tsx

@@ -13,6 +13,7 @@ import { useIntl } from "react-intl";
 import { EResType } from "../../../components/share/Share";
 import { IArticleParam } from "../recent/list";
 import ArticleDrawer from "../../../components/article/ArticleDrawer";
+import { fullUrl } from "../../../utils";
 
 const Widget = () => {
   const { channelId } = useParams(); //url 参数
@@ -65,11 +66,7 @@ const Widget = () => {
                     url += chapter?.channelId
                       ? `&channel=${chapter.channelId}`
                       : "";
-                    const fullUrl =
-                      process.env.REACT_APP_WEB_HOST +
-                      process.env.PUBLIC_URL +
-                      url;
-                    window.open(fullUrl, "_blank");
+                    window.open(fullUrl(url), "_blank");
                   } else {
                     setParam(chapter);
                     setArticleOpen(true);

+ 3 - 3
dashboard/src/pages/studio/recent/list.tsx

@@ -6,6 +6,7 @@ import { useAppSelector } from "../../../hooks";
 import { currentUser as _currentUser } from "../../../reducers/current-user";
 import ArticleDrawer from "../../../components/article/ArticleDrawer";
 import RecentList from "../../../components/recent/RecentList";
+import { fullUrl } from "../../../utils";
 
 export interface IRecentRequest {
   type: ArticleType;
@@ -73,9 +74,8 @@ const Widget = () => {
               : "";
             url += param.param?.book ? `&book=${param.param?.book}` : "";
             url += param.param?.para ? `&par=${param.param?.para}` : "";
-            const fullUrl =
-              process.env.REACT_APP_WEB_HOST + process.env.PUBLIC_URL + url;
-            window.open(fullUrl, "_blank");
+
+            window.open(fullUrl(url), "_blank");
           } else {
             setParam({
               type: param.type,