Przeglądaj źródła

把排序url函数放到utils.ts

visuddhinanda 2 lat temu
rodzic
commit
e58278a24c

+ 1 - 1
dashboard/src/components/channel/ChannelTable.tsx

@@ -25,7 +25,7 @@ import { EResType } from "../../components/share/Share";
 import StudioName, { IStudio } from "../../components/auth/StudioName";
 import StudioSelect from "../../components/channel/StudioSelect";
 import { IChannel } from "./Channel";
-import { getSorterUrl } from "../../pages/admin/relation/list";
+import { getSorterUrl } from "../../utils";
 
 const { Text } = Typography;
 

+ 1 - 1
dashboard/src/components/dict/UserDictList.tsx

@@ -26,8 +26,8 @@ import { delete_2, get } from "../../request";
 import { useRef, useState } from "react";
 import DictEdit from "../../components/dict/DictEdit";
 import { IDeleteResponse } from "../../components/api/Article";
-import { getSorterUrl } from "../../pages/admin/relation/list";
 import TimeShow from "../general/TimeShow";
+import { getSorterUrl } from "../../utils";
 
 const { Link } = Typography;
 

+ 2 - 1
dashboard/src/pages/admin/nissaya-ending/list.tsx

@@ -20,10 +20,11 @@ import NissayaEndingEdit from "../../../components/admin/relation/NissayaEndingE
 import { LangValueEnum } from "../../../components/general/LangSelect";
 import { NissayaCardModal } from "../../../components/general/NissayaCard";
 import DataImport from "../../../components/admin/relation/DataImport";
-import { getSorterUrl, IFrom } from "../relation/list";
 import TermModal from "../../../components/term/TermModal";
 import { ITermDataResponse } from "../../../components/api/Term";
 import TimeShow from "../../../components/general/TimeShow";
+import { IFrom } from "../relation/list";
+import { getSorterUrl } from "../../../utils";
 
 export interface INissayaEndingRequest {
   id?: string;

+ 1 - 17
dashboard/src/pages/admin/relation/list.tsx

@@ -19,26 +19,10 @@ import { useRef } from "react";
 import { IUser } from "../../../reducers/current-user";
 import RelationEdit from "../../../components/admin/relation/RelationEdit";
 import DataImport from "../../../components/admin/relation/DataImport";
-import { SortOrder } from "antd/lib/table/interface";
 import TimeShow from "../../../components/general/TimeShow";
 import { ITerm } from "../../../components/term/TermEdit";
 import TermModal from "../../../components/term/TermModal";
-
-export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
-  let url: string = "";
-  for (const key in sorter) {
-    if (Object.prototype.hasOwnProperty.call(sorter, key)) {
-      const element = sorter[key];
-      const dir = element === "ascend" ? "asc" : "desc";
-      let orderby = key;
-      if (orderby === "updatedAt") {
-        orderby = "updated_at";
-      }
-      url = `&order=${orderby}&dir=${dir}`;
-    }
-  }
-  return url;
-};
+import { getSorterUrl } from "../../../utils";
 
 export interface IRelationRequest {
   id?: string;

+ 18 - 0
dashboard/src/utils.ts

@@ -1,3 +1,5 @@
+import { SortOrder } from "antd/lib/table/interface";
+
 export function fullUrl(url: string): string {
   return window.location.origin + process.env.PUBLIC_URL + url;
 }
@@ -31,3 +33,19 @@ export function PaliReal(inStr: string | undefined | null): string {
   }
   return output;
 }
+
+export const getSorterUrl = (sorter?: Record<string, SortOrder>): string => {
+  let url: string = "";
+  for (const key in sorter) {
+    if (Object.prototype.hasOwnProperty.call(sorter, key)) {
+      const element = sorter[key];
+      const dir = element === "ascend" ? "asc" : "desc";
+      let orderby = key;
+      if (orderby === "updatedAt") {
+        orderby = "updated_at";
+      }
+      url = `&order=${orderby}&dir=${dir}`;
+    }
+  }
+  return url;
+};