From 4dcbd71983f5cdf2cd033d2f5dad9f054ce43f4d Mon Sep 17 00:00:00 2001 From: Hakadao Date: Tue, 20 Dec 2022 23:57:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=8E=A8=E4=BB=8B=E5=BD=B1=E7=89=87=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=B0=87=E5=AF=AB=E6=B3=95=E8=AA=BF=E6=95=B4=E7=82=BA?= =?UTF-8?q?=20Composition=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background/apis/videos.ts | 13 +- src/components/{ => VideoCard}/VideoCard.vue | 167 ++++++++--------- src/components/VideoCard/types.ts | 19 ++ .../views/Home/RecommendContent.vue | 170 ++++++------------ 4 files changed, 161 insertions(+), 208 deletions(-) rename src/components/{ => VideoCard}/VideoCard.vue (75%) create mode 100644 src/components/VideoCard/types.ts diff --git a/src/background/apis/videos.ts b/src/background/apis/videos.ts index 85ea829b..54c66bd0 100644 --- a/src/background/apis/videos.ts +++ b/src/background/apis/videos.ts @@ -1,12 +1,19 @@ import browser from 'webextension-polyfill' -import { APP_URL } from '.' +import { API_URL, APP_URL } from '.' export const setupVideosAPIs = () => { browser.runtime.onMessage.addListener((message) => { /** Recommend Videos */ + // if (message.contentScriptQuery === 'getRecommendVideos') { + // // https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E8%8E%B7%E5%8F%96%E9%A6%96%E9%A1%B5%E5%86%85%E5%AE%B9 + // const url = `${APP_URL}/x/feed/index?build=1&idx=${message.idx}&appkey=27eb53fc9058f8c3&access_key=${message.accessKey}` + // return fetch(url) + // .then(response => response.json()) + // .then(data => data) + // .catch(error => console.error(error)) + // } if (message.contentScriptQuery === 'getRecommendVideos') { - // https://github.com/indefined/UserScripts/blob/master/bilibiliHome/bilibiliHome.API.md#%E8%8E%B7%E5%8F%96%E9%A6%96%E9%A1%B5%E5%86%85%E5%AE%B9 - const url = `${APP_URL}/x/feed/index?build=1&idx=${message.idx}&appkey=27eb53fc9058f8c3&access_key=${message.accessKey}` + const url = `${API_URL}/x/web-interface/index/top/feed/rcmd?fresh_idx=${message.refreshIdx}&feed_version=V1&fresh_type=4&ps=30&plat=1` return fetch(url) .then(response => response.json()) .then(data => data) diff --git a/src/components/VideoCard.vue b/src/components/VideoCard/VideoCard.vue similarity index 75% rename from src/components/VideoCard.vue rename to src/components/VideoCard/VideoCard.vue index 2eb97e8a..0e7ec3e5 100644 --- a/src/components/VideoCard.vue +++ b/src/components/VideoCard/VideoCard.vue @@ -1,23 +1,11 @@