From a76c02aa4fb091b46b33929f27d84bea37c73ceb Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Sun, 9 Apr 2023 10:49:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:technologist:=20chore(custom):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9eu=E9=83=BD=E5=9C=A8=E6=BA=9C=E4=BB=80=E4=B9=88?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/vite.dev.config.ts | 4 +-- src/utils/fetch/index.ts | 18 +++++++------ src/utils/fetch/tool.ts | 55 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/config/vite.dev.config.ts b/config/vite.dev.config.ts index a223c11..5fce769 100644 --- a/config/vite.dev.config.ts +++ b/config/vite.dev.config.ts @@ -37,8 +37,8 @@ export default defineConfig({ target: "https://api.vtb.link/eoefans-api", changeOrigin: true, }, - "/eoefans-video-rank/v1": { - target: "https://api.eoefans.com", + "/vtb-rank/v1": { + target: "https://gateway.vtb.link", changeOrigin: true, }, }, diff --git a/src/utils/fetch/index.ts b/src/utils/fetch/index.ts index c4e7ca1..ccd98bb 100644 --- a/src/utils/fetch/index.ts +++ b/src/utils/fetch/index.ts @@ -9,7 +9,11 @@ import { RFetchVideoRes, IFetchPhotoParams, } from "./fetchtype"; -import { EUWhatLookIng_Url, Host_Url } from "./tool"; +import { + EUWhatLookIng_Url, + Host_Url, + transForEUWhatLookIngResData, +} from "./tool"; import { Omit } from "../index"; import { IFetchEUWhatLookIngParmas, RFetchEUWhatLookIngRes } from "./eu6type"; /** @@ -17,7 +21,7 @@ import { IFetchEUWhatLookIngParmas, RFetchEUWhatLookIngRes } from "./eu6type"; */ export const BackEndAxios = axios.create({ baseURL: Host_Url, - timeout: 9000, + timeout: 20000, transformResponse: [ (data) => { try { @@ -30,7 +34,7 @@ export const BackEndAxios = axios.create({ }); const EUWhatLookAxios = axios.create({ baseURL: EUWhatLookIng_Url, - timeout: 10000, + timeout: 20000, transformResponse: [ (data) => { try { @@ -54,7 +58,6 @@ BackEndAxios.interceptors.request.use((config) => { }); //AbortController对象 const AbortSource: { [k: string]: AbortController | null } = {}; -// let VideoSource: AbortController | null = null; /** * video视频数据获取接口 @@ -106,7 +109,6 @@ export async function fetchVideos( }; } } -// let PhotoSource: AbortController | null = null; /** * photo图片数据获取接口 */ @@ -152,9 +154,9 @@ export async function fetchPhotos( } } -// let EUSource: AbortController | null = null; /** * eu都在溜什么的接口 + * 2023/4/9 使用适配器模式修改 */ export async function fetchEUWhatLookIng( params: IFetchEUWhatLookIngParmas @@ -164,14 +166,14 @@ export async function fetchEUWhatLookIng( } AbortSource.EUSource = new AbortController(); try { - const res = await EUWhatLookAxios.get(`/rank`, { + const res = await EUWhatLookAxios.get(`/video-rank`, { signal: AbortSource.EUSource.signal, params: { by: params, }, }); AbortSource.EUSource = null; - return res.data; + return transForEUWhatLookIngResData(res.data); } catch (err) { if (axios.isAxiosError(err)) { if (err.code === "ERR_CANCELED") { diff --git a/src/utils/fetch/tool.ts b/src/utils/fetch/tool.ts index 91c2a30..6f8bf5a 100644 --- a/src/utils/fetch/tool.ts +++ b/src/utils/fetch/tool.ts @@ -1,7 +1,58 @@ +import { Pick } from ".."; +import { RFetchEUWhatLookIngRes } from "./eu6type"; + 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`; + ? "/vtb-rank/v1" + : `https://gateway.vtb.link/vtb-rank/v1`; + +// 新eu都在溜什么的接口类型 +type RNewEUWhatLookIng = { + code: 0; + msg: "success"; + data: { + ctime: number; + list: { + aid: number; + bvid: string; + pic: string; + title: string; + pubdate: 1680273934; + state: 0; + duration: string; + mid: number; + name: string; + face: string; + view: number; + danmaku: number; + reply: number; + favorite: number; + coin: number; + share: number; + like: number; + total_number: string; + }[]; + }; +}; +//eu都在溜什么 接口模式修改 +export function transForEUWhatLookIngResData( + newTypeData: RNewEUWhatLookIng +): RFetchEUWhatLookIngRes { + const list = newTypeData.data.list.map((item) => ({ + ...Pick(item, "bvid", "pic", "title", "duration"), + owner: Pick(item, "name", "face", "mid"), + stat: Pick(item, "view", "danmaku", "favorite", "coin", "share", "like"), + total_number_text: item.total_number, + })); + const Res: RFetchEUWhatLookIngRes = { + code: newTypeData.code, + data: { + ctime: newTypeData.data.ctime, + list: list, + }, + }; + return Res; +} From 61b7509959687593cd230be90a4397216360092a Mon Sep 17 00:00:00 2001 From: master1lan <278457198@qq.com> Date: Sun, 9 Apr 2023 11:44:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:bug:=20fix(custom):=20=E4=BF=AE=E5=A4=8Dse?= =?UTF-8?q?ntry=E6=8F=90=E4=BA=A4=E8=87=AA=E8=BA=AB=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.tsx | 73 ++++++++++++++++++++++++------------------- src/routers/error.tsx | 6 +++- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index 7e21f66..a87fa61 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -31,40 +31,47 @@ import { BrowserTracing } from "@sentry/tracing"; import SearchPage, { loader as SearchLoader } from "@routers/search"; import { RecoilRoot } from "recoil"; import React from "react"; -if (!isdev && isrelease) { - Sentry.init({ - dsn: "https://086f27258cce4d28aacc8c2719a683fb@sentry.vtb.link/3", - beforeSend(event, hint) { - if (event.exception) { - Sentry.showReportDialog({ eventId: event.event_id }); - } - return event; - }, - integrations: [ - new BrowserTracing({ - routingInstrumentation: Sentry.reactRouterV6Instrumentation( - React.useEffect, - useLocation, - useNavigationType, - createRoutesFromChildren, - matchRoutes - ), - }), - new Sentry.Replay({ - // Additional SDK configuration goes in here, for example: - maskAllText: true, - blockAllMedia: true, - }), - ], +Sentry.init({ + dsn: "https://086f27258cce4d28aacc8c2719a683fb@sentry.vtb.link/3", + environment: isdev ? "development" : isrelease ? "production" : "cloudflare", + beforeSend(event, hint) { + //这里是过滤掉sentry自身的报错 + if ( + event.level === "error" && + event.breadcrumbs?.some((item) => item.category === "sentry.event") + ) { + return null; + } + //遇到意外错误时 + if (event.exception) { + Sentry.showReportDialog({ eventId: event.event_id }); + } + return event; + }, + integrations: [ + new BrowserTracing({ + routingInstrumentation: Sentry.reactRouterV6Instrumentation( + React.useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes + ), + }), + new Sentry.Replay({ + // Additional SDK configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, - }); -} + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, + replaysSessionSampleRate: 0.1, + replaysOnErrorSampleRate: 1.0, +}); const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter); diff --git a/src/routers/error.tsx b/src/routers/error.tsx index 8eed330..b131952 100644 --- a/src/routers/error.tsx +++ b/src/routers/error.tsx @@ -21,7 +21,7 @@ export default function ErrorPage() { 🤯🤯🤯有什么出错了
- 当您看到这个页面时,表示您进入了一个不存在的页面,网站目前仅开放
+ 当您看到这则提示时,表示您遇到了一个bug。网站目前仅开放
@@ -29,6 +29,10 @@ export default function ErrorPage() {
+ 、
+
+
+
和
From 9e7c877da3eaf7ce0f5868af64c8ed2a6903e00b Mon Sep 17 00:00:00 2001
From: master1lan