diff --git a/CHANGELOG.md b/CHANGELOG.md index 03d2598..55a432a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## 1.4.3 (2023-04-09) + + +### 🐛 Bug Fixes + +* **custom**: 修复sentry提交自身报错信息 ([61b7509](https://vlink.dev/EOEFANS/eoefans-web/commits/61b7509)) + + + ## 1.4.2 (2023-04-04) 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/package.json b/package.json index 245bf02..7a0e7bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eoefans-web", - "version": "1.4.2", + "version": "1.4.3", "type": "module", "scripts": { "dev": "vite --config ./config/vite.dev.config.ts", 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() { + 、 + + + 和 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; +}