From 70aa014d3374826535fc596c2a4fe36115ce63bf Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Wed, 29 Mar 2023 23:15:53 +0800 Subject: [PATCH] =?UTF-8?q?:monocle=5Fface:=20test(custom):=20eu=E9=83=BD?= =?UTF-8?q?=E5=9C=A8=E6=BA=9C=E4=BB=80=E4=B9=88=E6=B5=8B=E8=AF=95=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 目前已知道的缺点有:页面太卡 --- config/vite.dev.config.ts | 4 + package.json | 3 +- pnpm-lock.yaml | 23 +++++ src/main.tsx | 11 +- src/routers/layout/index.tsx | 17 --- src/routers/layout/logo/index.tsx | 8 +- src/routers/layout/rightMore/euLink.tsx | 73 +++++++++++++ src/routers/layout/rightMore/index.tsx | 8 +- src/routers/layout/routernav/index.tsx | 27 ++--- src/routers/layout/search/pc/pc.module.less | 2 +- src/routers/online/content.tsx | 62 +++++++++++ src/routers/online/index.tsx | 11 ++ src/routers/online/item/index.tsx | 57 ++++++++++ src/routers/online/item/item.module.less | 77 ++++++++++++++ src/routers/online/item/onlineInfo.tsx | 109 ++++++++++++++++++++ src/routers/photo/item/index.tsx | 4 +- src/routers/video/item/videodata.tsx | 5 +- src/routers/video/video.module.less | 2 +- src/store/euWhatLook/index.tsx | 85 +++++++++++++++ src/utils/fetch/eu6type.ts | 31 ++++++ src/utils/fetch/fetchtype.ts | 2 +- src/utils/fetch/index.ts | 59 ++++++++++- src/utils/fetch/tool.ts | 5 + 23 files changed, 636 insertions(+), 49 deletions(-) create mode 100644 src/routers/layout/rightMore/euLink.tsx create mode 100644 src/routers/online/content.tsx create mode 100644 src/routers/online/index.tsx create mode 100644 src/routers/online/item/index.tsx create mode 100644 src/routers/online/item/item.module.less create mode 100644 src/routers/online/item/onlineInfo.tsx create mode 100644 src/store/euWhatLook/index.tsx create mode 100644 src/utils/fetch/eu6type.ts diff --git a/config/vite.dev.config.ts b/config/vite.dev.config.ts index 27b9a86..a223c11 100644 --- a/config/vite.dev.config.ts +++ b/config/vite.dev.config.ts @@ -37,6 +37,10 @@ export default defineConfig({ target: "https://api.vtb.link/eoefans-api", changeOrigin: true, }, + "/eoefans-video-rank/v1": { + target: "https://api.eoefans.com", + changeOrigin: true, + }, }, }, }); diff --git a/package.json b/package.json index 4b1e638..ee19291 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,8 @@ "react-photo-view": "^1.2.3", "react-redux": "^8.0.5", "react-router-dom": "^6.9.0", - "react-use": "^17.4.0" + "react-use": "^17.4.0", + "recoil": "^0.7.7" }, "devDependencies": { "@babel/core": "^7.21.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e353dc..1903248 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,6 +49,7 @@ specifiers: react-redux: ^8.0.5 react-router-dom: ^6.9.0 react-use: ^17.4.0 + recoil: ^0.7.7 rollup-plugin-visualizer: ^5.9.0 standard-version: ^9.5.0 tailwindcss: ^3.3.0 @@ -89,6 +90,7 @@ dependencies: react-redux: 8.0.5_a5pki22omvhg66elofc4io3beq react-router-dom: 6.9.0_biqbaboplfbrettd7655fr4n2y react-use: 17.4.0_biqbaboplfbrettd7655fr4n2y + recoil: 0.7.7_biqbaboplfbrettd7655fr4n2y devDependencies: '@babel/core': 7.21.3 @@ -4072,6 +4074,10 @@ packages: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} dev: true + /hamt_plus/1.0.2: + resolution: {integrity: sha512-t2JXKaehnMb9paaYA7J0BX8QQAY8lwfQ9Gjf4pg/mk4krt+cmwmU652HOoWonf+7+EQV97ARPMhhVgU1ra2GhA==} + dev: false + /handlebars/4.7.7: resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==} engines: {node: '>=0.4.7'} @@ -5570,6 +5576,23 @@ packages: picomatch: 2.3.1 dev: true + /recoil/0.7.7_biqbaboplfbrettd7655fr4n2y: + resolution: {integrity: sha512-8Og5KPQW9LwC577Vc7Ug2P0vQshkv1y3zG3tSSkWMqkWSwHmE+by06L8JtnGocjW6gcCvfwB3YtrJG6/tWivNQ==} + peerDependencies: + react: '>=16.13.1' + react-dom: '*' + react-native: '*' + peerDependenciesMeta: + react-dom: + optional: true + react-native: + optional: true + dependencies: + hamt_plus: 1.0.2 + react: 18.2.0 + react-dom: 18.2.0_react@18.2.0 + dev: false + /redent/3.0.0: resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==} engines: {node: '>=8'} diff --git a/src/main.tsx b/src/main.tsx index 63a6556..8a3f0ac 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -5,6 +5,7 @@ import VideoPage from "./routers/video"; import Layout from "./routers/layout"; import PhotoPage from "./routers/photo"; import ErrorPage from "./routers/error"; +import OnlinePage from "./routers/online"; //preview import ScreenProview from "@components/proview/screenSize"; import MUIThemePreview from "@components/proview/themePreview"; @@ -21,6 +22,7 @@ import "./index.less"; import * as Sentry from "@sentry/react"; import { BrowserTracing } from "@sentry/tracing"; import SearchPage, { loader as SearchLoader } from "@routers/search"; +import { RecoilRoot } from "recoil"; if (!isdev && isrelease) { Sentry.init({ dsn: "https://086f27258cce4d28aacc8c2719a683fb@sentry.vtb.link/3", @@ -82,6 +84,11 @@ const router = createBrowserRouter([ element: , loader: SearchLoader, }, + { + //eu都在溜什么的页面 + path: "online", + element: , + }, ], }, ], @@ -93,7 +100,9 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - + + + diff --git a/src/routers/layout/index.tsx b/src/routers/layout/index.tsx index ffdf07c..97df7a3 100644 --- a/src/routers/layout/index.tsx +++ b/src/routers/layout/index.tsx @@ -23,9 +23,6 @@ export default function Layout() { }, }} > -
- -
@@ -53,17 +50,3 @@ const FixedNav = () => { ); }; - -export const ImportTantInfo = () => ( - <> - - 征集小队长生贺视频 - - - -); diff --git a/src/routers/layout/logo/index.tsx b/src/routers/layout/logo/index.tsx index 9d68c5b..3005e4c 100644 --- a/src/routers/layout/logo/index.tsx +++ b/src/routers/layout/logo/index.tsx @@ -51,7 +51,7 @@ const LGRouterListAndQA = () => { aria-haspopup='true' aria-expanded={open ? "true" : undefined} onClick={handleClick} - className='hover:bg-gray-200' + className='hover:bg-gray-200 text-gray-800 text-base' > 导航 @@ -62,15 +62,15 @@ const LGRouterListAndQA = () => { onClose={handleClose} elevation={2} > - {RouterList.slice(0, 2).map((item) => ( + {RouterList.slice(0, 3).map((item) => ( + + ))} + + ); +}; +type OrderItem = { + label: string; + param: IFetchEUWhatLookIngParmas; +}; +const OrderItemLists: OrderItem[] = [ + { + label: "在线人数", + param: "online", + }, + { + label: "投稿时间", + param: "pubdate", + }, +]; +const OrderSort = () => { + const curParmas = useGetEuFetchParmas(); + const filterItem = OrderItemLists.filter((item) => item.param !== curParmas); + const curItem = OrderItemLists.filter((item) => item.param === curParmas); + const updateParamer = useSetEuFetchParamas(), + handleUpdateParmas = () => updateParamer(filterItem[0].param); + return ( +
+ {curItem.map((item) => ( + + ))} +
+ ); +}; diff --git a/src/routers/layout/rightMore/index.tsx b/src/routers/layout/rightMore/index.tsx index 9d8991c..c05e47b 100644 --- a/src/routers/layout/rightMore/index.tsx +++ b/src/routers/layout/rightMore/index.tsx @@ -3,15 +3,16 @@ import MoreVertIcon from "@mui/icons-material/MoreVert"; import LaunchIcon from "@mui/icons-material/Launch"; import { Button, Link, Popover } from "@mui/material"; import { TabProps } from "../routernav"; -import { AboutUSButton } from "../logo"; import { usePopoverConfig } from "@utils/hooks/popover"; +import { AboutUSButton } from "../logo"; +import EuLink from "./euLink"; export default function PCRightMore() { const { open, anchorEl, handleClick, handleClose } = usePopoverConfig(); return (
-
+
+ + + 敬请期待 diff --git a/src/routers/layout/routernav/index.tsx b/src/routers/layout/routernav/index.tsx index f4e672c..12c9217 100644 --- a/src/routers/layout/routernav/index.tsx +++ b/src/routers/layout/routernav/index.tsx @@ -1,21 +1,27 @@ import { Drawer } from "@mui/material"; -import PhotoIcon from "@mui/icons-material/Photo"; -import VideoLibraryIcon from "@mui/icons-material/VideoLibrary"; +import InsertPhotoOutlinedIcon from "@mui/icons-material/InsertPhotoOutlined"; +import VideoLibraryOutlinedIcon from "@mui/icons-material/VideoLibraryOutlined"; import { useState, FC, ReactElement } from "react"; import { Link, useMatch } from "react-router-dom"; import CloseIcon from "@mui/icons-material/Close"; +import NewReleasesOutlinedIcon from "@mui/icons-material/NewReleasesOutlined"; import Header_Nav from "../nav"; -import { ImportTantInfo } from ".."; + export const RouterList: (TabProps & { startICon: ReactElement })[] = [ { label: "视频", to: "/video", - startICon: , + startICon: , }, { label: "图片", to: "/photo", - startICon: , + startICon: , + }, + { + label: "Eu都在溜什么", + to: "/online", + startICon: , }, ]; @@ -46,11 +52,6 @@ export default function RouterNav() { onClick={handlerChangeShow} />
- -
- -
-
> = ( {label} @@ -113,7 +114,7 @@ const DrawerHrefLink: FC> = ( const DrawerHrefItem: FC = ({ title, data, onClose }) => ( -
+
{data.map((item, key) => ( ))} diff --git a/src/routers/layout/search/pc/pc.module.less b/src/routers/layout/search/pc/pc.module.less index d828f32..827d727 100644 --- a/src/routers/layout/search/pc/pc.module.less +++ b/src/routers/layout/search/pc/pc.module.less @@ -77,5 +77,5 @@ } .suggestMaxHeight { - max-height: calc(100vh - 200px); + max-height: calc(100vh - 160px); } \ No newline at end of file diff --git a/src/routers/online/content.tsx b/src/routers/online/content.tsx new file mode 100644 index 0000000..7ac4584 --- /dev/null +++ b/src/routers/online/content.tsx @@ -0,0 +1,62 @@ +import { Skeleton, Unstable_Grid2 as Grid } from "@mui/material"; +import { FC, memo } from "react"; +import OnlineItem, { OnlineItemProps } from "./item"; +import { useGetEuData } from "@store/euWhatLook/index"; +export default function Index() { + //todo 测试 + const { isLoading, data } = useGetEuData(10000000); + return ( + + {isLoading && + Array.from({ length: 20 }).map((item, key) => ( + + ))} + {!isLoading && data.map((item) => )} + + ); +} +const MemoItem: FC = memo((props) => ( + + + +)); +const LoadingItem = () => ( + +
+ + + +
+ +
+ + +
+
+
+
+); diff --git a/src/routers/online/index.tsx b/src/routers/online/index.tsx new file mode 100644 index 0000000..6630595 --- /dev/null +++ b/src/routers/online/index.tsx @@ -0,0 +1,11 @@ +/** + * + */ +import Content from "./content"; +export default function Index() { + return ( +
+ +
+ ); +} diff --git a/src/routers/online/item/index.tsx b/src/routers/online/item/index.tsx new file mode 100644 index 0000000..93148aa --- /dev/null +++ b/src/routers/online/item/index.tsx @@ -0,0 +1,57 @@ +import OnlineInfo from "./onlineInfo"; +import VideoItemStyles from "@routers/video/item/item.module.less"; +import styles from "./item.module.less"; +import { REuWhatLookIngItem } from "@utils/fetch/eu6type"; +import { useScreenSize } from "@components/proview/screenSize"; +import { Link } from "@mui/material"; +import { ImageBasic } from "@components/image"; +import { VideoData } from "@routers/video/item/videodata"; +import { Pick } from "@utils/index"; +import { useImgUrlLoading } from "@routers/photo/item/index"; +export type OnlineItemProps = REuWhatLookIngItem; +export default function Index(props: OnlineItemProps) { + const { pic, bvid } = props; + const { md } = useScreenSize(); + const fixedPic = `${pic}${ + md ? `@480w_270h_1c` : `@672w_378h_1c_!web-search-common-cover` + }`; + const isImgLoading = useImgUrlLoading(fixedPic); + return ( +
+ + +
+ +
+
+ + +
+ ); +} diff --git a/src/routers/online/item/item.module.less b/src/routers/online/item/item.module.less new file mode 100644 index 0000000..e819887 --- /dev/null +++ b/src/routers/online/item/item.module.less @@ -0,0 +1,77 @@ +.online-section { + gap: 5px; + + .online-info { + flex: 1; + flex-shrink: 0; + flex-basis: 80px; + flex-grow: 1; + display: flex; + gap: 4px; + flex-flow: column nowrap; + justify-content: space-between; + + .online-title { + font-size: 15px; + cursor: pointer; + transition: color .2s linear; + overflow: hidden; + display: -webkit-box; + -webkit-box-orient: vertical; + vertical-align: baseline; + text-overflow: ellipsis; + line-break: anywhere; + -webkit-line-clamp: 2; + word-break: break-all; + + &:hover, + &:active { + color: #00aeec; + } + } + + img { + aspect-ratio: 1/1; + } + + .online-show-data { + display: flex; + align-items: center; + gap: 4px; + + @media(max-width:600px) { + font-size: 13px; + } + + @media(max-width:350px) { + &>p:not(:first-of-type) { + display: none; + } + + font-size: 14px; + } + + &>p { + display: flex; + align-items: center; + } + } + + .online-up-name { + cursor: pointer; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + flex-shrink: 1; + + &:hover, + &:active { + color: #00aeec; + } + + @media(max-width:600px) { + font-size: 13px; + } + } + } +} \ No newline at end of file diff --git a/src/routers/online/item/onlineInfo.tsx b/src/routers/online/item/onlineInfo.tsx new file mode 100644 index 0000000..c3fe13d --- /dev/null +++ b/src/routers/online/item/onlineInfo.tsx @@ -0,0 +1,109 @@ +import { Link } from "@mui/material"; +import { REuWhatLookIngItem } from "@utils/fetch/eu6type"; +import { Omit, Pick } from "@utils/index"; +import { FC } from "react"; +import styles from "./item.module.less"; +import PermIdentityRoundedIcon from "@mui/icons-material/PermIdentityRounded"; +import ThumbUpRoundedIcon from "@mui/icons-material/ThumbUpRounded"; +import { CoinIcon } from "@routers/video/item/icon"; +import { useImgUrlLoading } from "@routers/photo/item"; +type OnlineInfoProps = OnlineTitleProps & OnlineUpProps; +export default function Index(props: OnlineInfoProps) { + return ( +
+ + +
+ ); +} +type OnlineTitleProps = { + title: string; + bvid: string; +}; +const OnlineTitle: FC = ({ bvid, title }) => ( + +

+ {title} +

+ +); +type OnlineUpProps = OnlineVideoDataProps & + OnlineUpIcoProps & + Pick; +const OnlineUp: FC = (props) => { + return ( +
+ +
+ + {props.name} + + +
+
+ ); +}; + +//作者头像 +type OnlineUpIcoProps = Pick; +const OnlineUpIco: FC = ({ face }) => { + const isLoading = useImgUrlLoading(face); + return ( +
+ + +
+ ); +}; + +//视频数据 +type OnlineVideoDataProps = Pick & + Pick; +const OnlineVideoData: FC = ({ + like, + coin, + total_number_text, +}) => { + const fixedLikeNum = + like > 10000 ? `${(like / 10000).toFixed(1)}w` : like.toString(); + return ( +
+

+ + {total_number_text} +

+

+ + {fixedLikeNum} +

+

+ + {coin} +

+
+ ); +}; diff --git a/src/routers/photo/item/index.tsx b/src/routers/photo/item/index.tsx index 32fca6c..6390449 100644 --- a/src/routers/photo/item/index.tsx +++ b/src/routers/photo/item/index.tsx @@ -12,7 +12,7 @@ import { getImageSize } from "@components/image/tool"; type CardType = { data: PhotoRouterImageCardType; }; -const useLoading = (url: string) => { +export const useImgUrlLoading = (url: string) => { const [isLoading, set] = useState(true); useMemo(async () => { await getImageSize(url); @@ -26,7 +26,7 @@ export default function PhotoCard(props: CardType) { handlerChangeOpen = () => set((open) => !open); const modalPorps = { open, images, onClose: handlerChangeOpen, dynamic_id }, url = `${images[0].src}@${250}w.webp`; - const isLoading = useLoading(url); + const isLoading = useImgUrlLoading(url); return (
({ - padding: "16px 8px 6px", + padding: "16px 12px 10px", borderBottomLeftRadius: "8px", borderBottomRightRadius: "8px", - [theme.breakpoints.down("sm")]: { - padding: "8px 6px 4px", - }, })); const SizeSpan = styled("span")(({ theme }) => ({ fontSize: "13px", diff --git a/src/routers/video/video.module.less b/src/routers/video/video.module.less index afd3a99..997d778 100644 --- a/src/routers/video/video.module.less +++ b/src/routers/video/video.module.less @@ -23,7 +23,7 @@ } img+div { - padding: 8px; + span { font-size: 14px !important; diff --git a/src/store/euWhatLook/index.tsx b/src/store/euWhatLook/index.tsx new file mode 100644 index 0000000..22d7890 --- /dev/null +++ b/src/store/euWhatLook/index.tsx @@ -0,0 +1,85 @@ +/** + * 这个状态管理将采用recoil + * ps:因为recoil太tm好用了! + * pps:但是我不想改原来的状态管理 + */ +import { + atom, + selector, + selectorFamily, + useRecoilState, + useRecoilValue, + useSetRecoilState, +} from "recoil"; +import { + IFetchEUWhatLookIngParmas, + REuWhatLookIngItem, + RFetchEUWhatLookIngRes, +} from "@utils/fetch/eu6type"; +import { fetchEUWhatLookIng } from "@utils/fetch"; +import { useEffect, useState, useCallback } from "react"; +import message from "@components/message"; +const EuFetchParmasState = atom({ + key: "euFetchParmasKey", + default: "online", +}); +//获取eu接口的当前参数 +export const useGetEuFetchParmas = () => useRecoilValue(EuFetchParmasState); +//修改eu接口的参数 +export const useSetEuFetchParamas = () => useSetRecoilState(EuFetchParmasState); +//轮询的atom +const EuIntervalAtom = atom({ + key: "EuIntervalAtomKey", + default: 0, +}); +//接口加载情况 +const EuFetchLoading = atom({ + key: "EuFetchLoadingKey", + default: false, +}); +const EuFetchResSelector = selector({ + key: "EuFetchParmasSelectorKey", + get: async ({ get }) => { + const _ = get(EuIntervalAtom); + const params = get(EuFetchParmasState); + const res = await fetchEUWhatLookIng(params); + return res; + }, +}); +/** + * @description 顶层hooks,自动实现了获取参数、网络请求以及轮询,返回是否正在加载以及数据 + */ +export const useGetEuData = (IntervalTime = 10000) => { + const [data, setData] = useState([]); + const params = useRecoilValue(EuFetchParmasState); + const [isLoading, handleChangeLoading] = useRecoilState(EuFetchLoading); + const fetcherCallback = useCallback(async () => { + const res = await fetchEUWhatLookIng(params); + if (res.code === -1) { + message.info("服务器返回出错,请等待服务器修复"); + return; + } + if (res.data.ctime === -1) { + message.info("请求时间过长,请检查当前网络情况"); + return; + } + const resData = res.data.list; + setData(() => resData); + if (params === "online") { + message.info("已按照观看人数排序"); + } else { + message.info("已按照投稿时间排序"); + } + }, [params, setData]); + useEffect(handleChangeLoading.bind(null, true), [params]); + useEffect(() => { + fetcherCallback().then(() => handleChangeLoading(() => false)); + }, [params]); + // useEffect(() => { + // let SetId = setInterval(() => { + // fetcherCallback(); + // }, IntervalTime); + // return () => clearInterval(SetId); + // }, [params]); + return { isLoading, data }; +}; diff --git a/src/utils/fetch/eu6type.ts b/src/utils/fetch/eu6type.ts new file mode 100644 index 0000000..05e36a2 --- /dev/null +++ b/src/utils/fetch/eu6type.ts @@ -0,0 +1,31 @@ +import { RFetchVideoResResult } from "./fetchtype"; + +type ErrorFetchRes = { + message: "not found"; + code: -1; +}; +type CustomFetchRes = { + code: 0; + data: { + list: T; + ctime: number; + }; +}; +/** + * 类型太多了,我直接省略一大堆 + */ +export type REuWhatLookIngItem = Pick< + RFetchVideoResResult, + "bvid" | "pic" | "title" | "duration" +> & { + owner: Record<"name" | "face", string> & Record<"mid", number>; + stat: Record< + "view" | "danmaku" | "favorite" | "coin" | "share" | "like", + number + >; + total_number_text: string; +}; +export type RFetchEUWhatLookIngRes = + | CustomFetchRes + | ErrorFetchRes; +export type IFetchEUWhatLookIngParmas = "online" | "pubdate"; diff --git a/src/utils/fetch/fetchtype.ts b/src/utils/fetch/fetchtype.ts index 238986a..52f66ca 100644 --- a/src/utils/fetch/fetchtype.ts +++ b/src/utils/fetch/fetchtype.ts @@ -47,7 +47,7 @@ export interface IFetchVideoParams { | "other"; } -interface RFetchVideoResResult { +export interface RFetchVideoResResult { /** * @description 视频的bv号 * @example "BV1dY41127BZ" diff --git a/src/utils/fetch/index.ts b/src/utils/fetch/index.ts index 38a872d..10cb404 100644 --- a/src/utils/fetch/index.ts +++ b/src/utils/fetch/index.ts @@ -9,9 +9,12 @@ import { RFetchVideoRes, IFetchPhotoParams, } from "./fetchtype"; -import { Host_Url } from "./tool"; +import { EUWhatLookIng_Url, Host_Url } from "./tool"; import { Omit } from "../index"; - +import { IFetchEUWhatLookIngParmas, RFetchEUWhatLookIngRes } from "./eu6type"; +/** + * @description 大部分请求都用这个,除非是eu都在溜什么 + */ export const BackEndAxios = axios.create({ baseURL: Host_Url, timeout: 9000, @@ -25,6 +28,19 @@ export const BackEndAxios = axios.create({ }, ], }); +const EUWhatLookAxios = axios.create({ + baseURL: EUWhatLookIng_Url, + timeout: 10000, + transformResponse: [ + (data) => { + try { + return JSONBigInt.parse(data); + } catch (err) { + return data; + } + }, + ], +}); /** * 后端接口配置 */ @@ -134,3 +150,42 @@ export async function fetchPhotos( }; } } + +let EUSource: AbortController | null = null; +/** + * eu都在溜什么的接口 + */ +export async function fetchEUWhatLookIng( + params: IFetchEUWhatLookIngParmas +): Promise { + if (EUSource) { + EUSource.abort(); + } + EUSource = new AbortController(); + try { + const res = await EUWhatLookAxios.get(`/rank`, { + signal: EUSource.signal, + params: { + by: params, + }, + }); + EUSource.abort(); + return res.data; + } catch (err) { + if (axios.isAxiosError(err)) { + if (err.code === "ERR_CANCELED") { + return { + code: 0, + data: { + list: [], + ctime: -1, + }, + }; + } + } + return { + code: -1, + message: "not found", + }; + } +} diff --git a/src/utils/fetch/tool.ts b/src/utils/fetch/tool.ts index 708c192..91c2a30 100644 --- a/src/utils/fetch/tool.ts +++ b/src/utils/fetch/tool.ts @@ -1,2 +1,7 @@ export const Host_Url = isdev ? "/v1" : `https://api.vtb.link/eoefans-api/v1`; `https://api.eoe.best/eoefans-api/v1`; + +//eu都在溜什么的url +export const EUWhatLookIng_Url = isdev + ? "/eoefans-video-rank/v1" + : `https://api.eoefans.com/eoefans-video-rank/v1`;