Skip to content

Commit

Permalink
Merge pull request #67 from EOEFANS/main
Browse files Browse the repository at this point in the history
修改eu都在溜什么的接口
  • Loading branch information
master1lan authored and GitHub Enterprise committed Apr 9, 2023
2 parents ab203af + 9e7c877 commit 0011b63
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 47 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions config/vite.dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
73 changes: 40 additions & 33 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion src/routers/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ export default function ErrorPage() {
🤯🤯🤯有什么出错了
</h1>
<p>
当您看到这个页面时,表示您进入了一个不存在的页面,网站目前仅开放
当您看到这则提示时,表示您遇到了一个bug。网站目前仅开放
<Link to={"/"}>
<Button>首页</Button>
</Link>
<Link to={"/video"}>
<Button>视频页</Button>
</Link>
<Link to={"/online"}>
<Button>eu都在溜什么页</Button>
</Link>
<Link to={"/photo"}>
<Button>图片页</Button>
Expand Down
18 changes: 10 additions & 8 deletions src/utils/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ 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";
/**
* @description 大部分请求都用这个,除非是eu都在溜什么
*/
export const BackEndAxios = axios.create({
baseURL: Host_Url,
timeout: 9000,
timeout: 20000,
transformResponse: [
(data) => {
try {
Expand All @@ -30,7 +34,7 @@ export const BackEndAxios = axios.create({
});
const EUWhatLookAxios = axios.create({
baseURL: EUWhatLookIng_Url,
timeout: 10000,
timeout: 20000,
transformResponse: [
(data) => {
try {
Expand All @@ -54,7 +58,6 @@ BackEndAxios.interceptors.request.use((config) => {
});
//AbortController对象
const AbortSource: { [k: string]: AbortController | null } = {};
// let VideoSource: AbortController | null = null;

/**
* video视频数据获取接口
Expand Down Expand Up @@ -106,7 +109,6 @@ export async function fetchVideos(
};
}
}
// let PhotoSource: AbortController | null = null;
/**
* photo图片数据获取接口
*/
Expand Down Expand Up @@ -152,9 +154,9 @@ export async function fetchPhotos(
}
}

// let EUSource: AbortController | null = null;
/**
* eu都在溜什么的接口
* 2023/4/9 使用适配器模式修改
*/
export async function fetchEUWhatLookIng(
params: IFetchEUWhatLookIngParmas
Expand All @@ -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") {
Expand Down
55 changes: 53 additions & 2 deletions src/utils/fetch/tool.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 0011b63

Please sign in to comment.