Browse Source

apifetch -> get

visuddhinanda 3 years ago
parent
commit
8e0ecb1a42

+ 3 - 3
dashboard/src/components/channel/ChannelList.tsx

@@ -2,8 +2,8 @@ import { useState, useEffect } from "react";
 import { List } from "antd";
 import ChannelListItem from "./ChannelListItem";
 import type { ChannelInfoProps } from "../api/Channel";
-import { ApiFetch } from "../../utils";
 import { IApiResponseChannelList } from "../api/Corpus";
+import { get } from "../../request";
 
 export interface ChannelFilterProps {
 	chapterProgress: number;
@@ -25,8 +25,8 @@ const Widget = ({ filter = defaultChannelFilterProps }: IWidgetChannelList) => {
 
 	useEffect(() => {
 		console.log("palichapterlist useEffect");
-		let url = `/progress?view=channel&channel_type=${filter.channelType}&lang=${filter.lang}&progress=${filter.chapterProgress}`;
-		ApiFetch(url).then(function (myJson) {
+		let url = `/v2/progress?view=channel&channel_type=${filter.channelType}&lang=${filter.lang}&progress=${filter.chapterProgress}`;
+		get(url).then(function (myJson) {
 			console.log("ajex", myJson);
 			const data = myJson as unknown as IApiResponseChannelList;
 			const newData: ChannelInfoProps[] = data.data.rows.map((item) => {

+ 10 - 5
dashboard/src/components/corpus/BookTree.tsx

@@ -5,7 +5,7 @@ import { Layout, Space, Tree } from "antd";
 import { Select } from "antd";
 import { Typography } from "antd";
 import type { TreeProps } from "antd/es/tree";
-import { ApiFetch } from "../../utils";
+import { get } from "../../request";
 
 const { Text } = Typography;
 
@@ -46,11 +46,12 @@ const Widget = (prop: IWidgetBookTree) => {
 				title: params.name,
 				key: params.tag.join(),
 				tag: params.tag,
-				children: Array.isArray(params.children) ? params.children.map(treeMap) : [],
+				children: Array.isArray(params.children)
+					? params.children.map(treeMap)
+					: [],
 			};
 		}
-		let url = `/palibook/${value}`;
-		ApiFetch(url).then((response) => {
+		get(`/v2/palibook/${value}`).then((response) => {
 			const myJson = response as unknown as OrgTree[];
 			let newTree = myJson.map(treeMap);
 			setTreeData(newTree);
@@ -66,7 +67,11 @@ const Widget = (prop: IWidgetBookTree) => {
 		<Layout>
 			<Space>
 				<Text>目录风格</Text>
-				<Select defaultValue={prop.root} loading={false} onChange={handleChange}>
+				<Select
+					defaultValue={prop.root}
+					loading={false}
+					onChange={handleChange}
+				>
 					<Option value="defualt">Defualt</Option>
 					<Option value="cscd">CSCD</Option>
 				</Select>

+ 2 - 2
dashboard/src/components/corpus/ChapterTagList.tsx

@@ -1,6 +1,6 @@
 import { message, Tag, Button } from "antd";
 import { useState, useEffect } from "react";
-import { ApiFetch } from "../../utils";
+import { get } from "../../request";
 import { IApiChapterTag, IApiResponseChapterTagList } from "../api/Corpus";
 
 interface ITagData {
@@ -21,7 +21,7 @@ const Widget = (prop: IWidgetChapterTagList) => {
 	}, []);
 
 	function fetchData() {
-		ApiFetch(`/progress?view=chapter-tag`)
+		get(`/v2/progress?view=chapter-tag`)
 			.then((response) => {
 				const json = response as unknown as IApiResponseChapterTagList;
 				const tags: IApiChapterTag[] = json.data.rows;

+ 21 - 19
dashboard/src/components/corpus/PaliChapterChannelList.tsx

@@ -1,5 +1,5 @@
 import { useState, useEffect } from "react";
-import { ApiFetch } from "../../utils";
+import { get } from "../../request";
 import { IApiResponseChapterChannelList } from "../api/Corpus";
 import { IParagraph } from "./BookViewer";
 import ChapterInChannel, { IChapterChannelData } from "./ChapterInChannel";
@@ -13,26 +13,28 @@ const Widget = (prop: IWidgetPaliChapterChannelList) => {
 
 	useEffect(() => {
 		console.log("palichapterlist useEffect");
-		let url = `/progress?view=chapter_channels&book=${prop.para.book}&par=${prop.para.para}`;
-		ApiFetch(url).then(function (myJson) {
+		let url = `/v2/progress?view=chapter_channels&book=${prop.para.book}&par=${prop.para.para}`;
+		get(url).then(function (myJson) {
 			console.log("ajex", myJson);
 			const data = myJson as unknown as IApiResponseChapterChannelList;
-			const newData: IChapterChannelData[] = data.data.rows.map((item) => {
-				return {
-					channel: {
-						ChannelName: item.channel.name,
-						ChannelId: item.channel.uid,
-						ChannelType: item.channel.type,
-						StudioName: "V",
-						StudioId: "123",
-						StudioType: "p",
-					},
-					progress: Math.ceil(item.progress * 100),
-					hit: item.views,
-					like: 0,
-					updatedAt: item.updated_at,
-				};
-			});
+			const newData: IChapterChannelData[] = data.data.rows.map(
+				(item) => {
+					return {
+						channel: {
+							ChannelName: item.channel.name,
+							ChannelId: item.channel.uid,
+							ChannelType: item.channel.type,
+							StudioName: "V",
+							StudioId: "123",
+							StudioType: "p",
+						},
+						progress: Math.ceil(item.progress * 100),
+						hit: item.views,
+						like: 0,
+						updatedAt: item.updated_at,
+					};
+				}
+			);
 			setTableData(newData);
 		});
 	}, [prop.para]);

+ 3 - 3
dashboard/src/components/corpus/PaliChapterHead.tsx

@@ -4,7 +4,7 @@ import ChapterHead, { IChapterInfo } from "./ChapterHead";
 import { IParagraph } from "./BookViewer";
 import TocPath, { ITocPathNode } from "./TocPath";
 import { IApiResponcePaliChapter } from "../api/Corpus";
-import { ApiFetch } from "../../utils";
+import { get } from "../../request";
 
 interface IWidgetPaliChapterHead {
 	para: IParagraph;
@@ -29,8 +29,8 @@ const Widget = (prop: IWidgetPaliChapterHead) => {
 	}, [prop.para]);
 
 	function fetchData(para: IParagraph) {
-		let url = `/palitext?view=paragraph&book=${para.book}&para=${para.para}`;
-		ApiFetch(url).then(function (myJson) {
+		let url = `/v2/palitext?view=paragraph&book=${para.book}&para=${para.para}`;
+		get(url).then(function (myJson) {
 			console.log("ajex", myJson);
 			const data = myJson as unknown as IApiResponcePaliChapter;
 			let path: ITocPathNode[] = JSON.parse(data.data.path);

+ 3 - 3
dashboard/src/components/corpus/PaliChapterListByPara.tsx

@@ -1,5 +1,5 @@
 import { useState, useEffect } from "react";
-import { ApiFetch } from "../../utils";
+import { get } from "../../request";
 import { IApiResponcePaliChapterList } from "../api/Corpus";
 import { IParagraph } from "./BookViewer";
 import { IPaliChapterData } from "./PaliChapterCard";
@@ -15,8 +15,8 @@ const Widget = (prop: IWidgetPaliChapterListByPara) => {
 
 	useEffect(() => {
 		console.log("palichapterlist useEffect");
-		let url = `/palitext?view=chapter_children&book=${prop.para.book}&para=${prop.para.para}`;
-		ApiFetch(url).then(function (myJson) {
+		let url = `/v2/palitext?view=chapter_children&book=${prop.para.book}&para=${prop.para.para}`;
+		get(url).then(function (myJson) {
 			console.log("ajex", myJson);
 			const data = myJson as unknown as IApiResponcePaliChapterList;
 			let newTree: IPaliChapterData[] = data.data.rows.map((item) => {

+ 3 - 3
dashboard/src/components/corpus/PaliChapterListByTag.tsx

@@ -1,5 +1,5 @@
 import { useState, useEffect } from "react";
-import { ApiFetch } from "../../utils";
+import { get } from "../../request";
 import { IApiResponcePaliChapterList } from "../api/Corpus";
 import { IPaliChapterData } from "./PaliChapterCard";
 import PaliChapterList, { IChapterClickEvent } from "./PaliChapterList";
@@ -14,9 +14,9 @@ const Widget = (prop: IWidgetPaliChapterListByTag) => {
 
 	useEffect(() => {
 		console.log("palichapterlist useEffect");
-		let url = `/palitext?view=chapter&tags=${prop.tag.join()}`;
+		let url = `/v2/palitext?view=chapter&tags=${prop.tag.join()}`;
 		console.log("tag url", url);
-		ApiFetch(url).then(function (myJson) {
+		get(url).then(function (myJson) {
 			console.log("ajex", myJson);
 			const data = myJson as unknown as IApiResponcePaliChapterList;
 			let newTree: IPaliChapterData[] = data.data.rows.map((item) => {

+ 7 - 5
dashboard/src/components/dict/DictSearch.tsx

@@ -1,8 +1,10 @@
 import { useState, useEffect } from "react";
-
 import DictContent from "./DictContent";
-import { ApiFetch } from "../../utils";
-import type { IWidgetDictContentData, IApiDictContentData } from "./DictContent";
+import type {
+	IWidgetDictContentData,
+	IApiDictContentData,
+} from "./DictContent";
+import { get } from "../../request";
 
 interface IWidgetDictSearch {
 	word: string | undefined;
@@ -18,9 +20,9 @@ const Widget = (prop: IWidgetDictSearch) => {
 
 	useEffect(() => {
 		console.log("useEffect");
-		const url = `/dict?word=${prop.word}`;
+		const url = `/v2/dict?word=${prop.word}`;
 		console.log("url", url);
-		ApiFetch(url)
+		get(url)
 			.then((response) => {
 				const json = response as unknown as IApiDictContentData;
 				console.log("data", json);