mirror of
https://github.com/BewlyBewly/BewlyBewly.git
synced 2025-04-14 13:15:29 +00:00
refactor: message listeners (#447)
* Refactor API imports and update API endpoints * Fix variable naming in FavoritesPop and Favorites components * Fix variable naming inconsistency in getHistoryList function * Fix API parameter naming conventions * Refactor API_AUTH afterHandle functions * Add API documentation links and add function to be the api item * Refactor API body and params * Remove unused getAccessKey function in auth.ts --------- Co-authored-by: pengyunfei <pengyunfei@360.cn> Co-authored-by: Hakadao <a578457889743@gmail.com>
This commit is contained in:
@@ -75,7 +75,7 @@ async function getFavoriteCategories() {
|
||||
await browser.runtime
|
||||
.sendMessage({
|
||||
contentScriptQuery: 'getFavoriteCategories',
|
||||
mid: getUserID(),
|
||||
up_mid: getUserID(),
|
||||
})
|
||||
.then((res: FavoritesCategoryResult) => {
|
||||
if (res.code === 0) {
|
||||
@@ -99,19 +99,19 @@ async function getFavoriteCategories() {
|
||||
* @param keyword
|
||||
*/
|
||||
async function getFavoriteResources(
|
||||
mediaId: number,
|
||||
pageNum: number,
|
||||
media_id: number,
|
||||
pn: number,
|
||||
keyword = '' as string,
|
||||
) {
|
||||
if (pageNum === 1)
|
||||
if (pn === 1)
|
||||
isFullPageLoading.value = true
|
||||
isLoading.value = true
|
||||
try {
|
||||
const res: FavoritesResult = await browser.runtime
|
||||
.sendMessage({
|
||||
contentScriptQuery: 'getFavoriteResources',
|
||||
mediaId,
|
||||
pageNum,
|
||||
media_id,
|
||||
pn,
|
||||
keyword,
|
||||
})
|
||||
|
||||
@@ -160,7 +160,7 @@ function handleUnfavorite(favoriteResource: FavoriteResource) {
|
||||
browser.runtime.sendMessage({
|
||||
contentScriptQuery: 'patchDelFavoriteResources',
|
||||
resources: `${favoriteResource.id}:${favoriteResource.type}`,
|
||||
mediaId: selectedCategory.value?.id,
|
||||
media_id: selectedCategory.value?.id,
|
||||
csrf: getCSRF(),
|
||||
}).then((res) => {
|
||||
if (res.code === 0)
|
||||
|
||||
@@ -59,7 +59,7 @@ function getHistoryList() {
|
||||
.sendMessage({
|
||||
contentScriptQuery: 'getHistoryList',
|
||||
type: 'all',
|
||||
viewAt:
|
||||
view_at:
|
||||
historyList.length > 0
|
||||
? historyList[historyList.length - 1].view_at
|
||||
: 0,
|
||||
|
||||
@@ -79,7 +79,7 @@ async function getFollowedUsersVideos() {
|
||||
contentScriptQuery: 'getMoments',
|
||||
type: 'video',
|
||||
offset: offset.value,
|
||||
updateBaseline: updateBaseline.value,
|
||||
update_baseline: updateBaseline.value,
|
||||
})
|
||||
|
||||
if (response.code === -101) {
|
||||
|
||||
@@ -117,7 +117,7 @@ async function getRecommendVideos() {
|
||||
try {
|
||||
const response: forYouResult = await browser.runtime.sendMessage({
|
||||
contentScriptQuery: 'getRecommendVideos',
|
||||
refreshIdx: refreshIdx.value++,
|
||||
fresh_idx: refreshIdx.value++,
|
||||
})
|
||||
|
||||
if (!response.data) {
|
||||
@@ -157,9 +157,9 @@ async function getAppRecommendVideos() {
|
||||
try {
|
||||
const response: AppForYouResult = await browser.runtime.sendMessage({
|
||||
contentScriptQuery: 'getAppRecommendVideos',
|
||||
accessKey: accessKey.value,
|
||||
sLocale: settings.value.language !== LanguageType.Mandarin_CN ? 'zh-Hant_TW' : 'zh-Hans_CN',
|
||||
cLocale: settings.value.language !== LanguageType.Mandarin_CN ? 'zh-Hant_TW' : 'zh-Hans_CN',
|
||||
access_key: accessKey.value,
|
||||
s_locale: settings.value.language !== LanguageType.Mandarin_CN ? 'zh-Hant_TW' : 'zh-Hans_CN',
|
||||
c_locale: settings.value.language !== LanguageType.Mandarin_CN ? 'zh-Hant_TW' : 'zh-Hans_CN',
|
||||
appkey: TVAppKey.appkey,
|
||||
idx: appVideoList.length > 0 ? appVideoList[appVideoList.length - 1].idx : 1,
|
||||
})
|
||||
|
||||
@@ -140,7 +140,7 @@ function getRankingPgc() {
|
||||
isLoading.value = true
|
||||
browser.runtime.sendMessage({
|
||||
contentScriptQuery: 'getRankingPgc',
|
||||
seasonType: activatedRankingType.value.seasonType,
|
||||
season_type: activatedRankingType.value.seasonType,
|
||||
}).then((response: RankingPgcResult) => {
|
||||
if (response.code === 0)
|
||||
Object.assign(PgcList, response.result.list)
|
||||
|
||||
@@ -84,7 +84,7 @@ async function getFollowedUsersVideos() {
|
||||
contentScriptQuery: 'getMoments',
|
||||
type: 'pgc',
|
||||
offset: offset.value,
|
||||
updateBaseline: updateBaseline.value,
|
||||
update_baseline: updateBaseline.value,
|
||||
})
|
||||
|
||||
if (response.code === -101) {
|
||||
|
||||
Reference in New Issue
Block a user