refactor: Add cSpell words and update API calls

This commit is contained in:
Hakadao
2024-04-02 19:07:45 +08:00
parent 5ec6079973
commit 1d90292cb4
12 changed files with 39 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import emitter from '~/utils/mitt'
import { settings } from '~/logic'
import type { Media as FavoriteItem, FavoritesResult } from '~/models/video/favorite'
import type { List as CategoryItem, FavoritesCategoryResult } from '~/models/video/favoriteCategory'
import API from '~/background/msg.define'
const { t } = useI18n()
@@ -74,7 +75,7 @@ function initPageAction() {
async function getFavoriteCategories() {
await browser.runtime
.sendMessage({
contentScriptQuery: 'getFavoriteCategories',
contentScriptQuery: API.FAVORITE.GET_FAVORITE_CATEGORIES,
up_mid: getUserID(),
})
.then((res: FavoritesCategoryResult) => {
@@ -109,7 +110,7 @@ async function getFavoriteResources(
try {
const res: FavoritesResult = await browser.runtime
.sendMessage({
contentScriptQuery: 'getFavoriteResources',
contentScriptQuery: API.FAVORITE.GET_FAVORITE_RESOURCES,
media_id,
pn,
keyword,
@@ -158,7 +159,7 @@ function jumpToLoginPage() {
function handleUnfavorite(favoriteResource: FavoriteResource) {
browser.runtime.sendMessage({
contentScriptQuery: 'patchDelFavoriteResources',
contentScriptQuery: API.FAVORITE.PATCH_DEL_FAVORITE_RESOURCES,
resources: `${favoriteResource.id}:${favoriteResource.type}`,
media_id: selectedCategory.value?.id,
csrf: getCSRF(),

View File

@@ -7,6 +7,7 @@ import { calcCurrentTime } from '~/utils/dataFormatter'
import { Business } from '~/models/video/history'
import type { List as HistoryItem, HistoryResult } from '~/models/video/history'
import type { List as HistorySearchItem, HistorySearchResult } from '~/models/video/historySearch'
import API from '~/background/msg.define'
const { t } = useI18n()
@@ -57,7 +58,7 @@ function getHistoryList() {
isLoading.value = true
browser.runtime
.sendMessage({
contentScriptQuery: 'getHistoryList',
contentScriptQuery: API.HISTORY.GET_HISTORY_LIST,
type: 'all',
view_at:
historyList.length > 0
@@ -85,7 +86,7 @@ function searchHistoryList() {
isLoading.value = true
browser.runtime
.sendMessage({
contentScriptQuery: 'searchHistoryList',
contentScriptQuery: API.HISTORY.SEARCH_HISTORY_LIST,
pn: currentPageNum.value++,
keyword: keyword.value,
})
@@ -119,7 +120,7 @@ function handleSearch() {
function deleteHistoryItem(index: number, historyItem: HistoryItem) {
browser.runtime
.sendMessage({
contentScriptQuery: 'deleteHistoryItem',
contentScriptQuery: API.HISTORY.DELETE_HISTORY_ITEM,
kid: `${historyItem.history.business}_${historyItem.history.oid}`,
csrf: getCSRF(),
})
@@ -169,7 +170,7 @@ function getHistoryItemCover(item: HistoryItem) {
function getHistoryPauseStatus() {
browser.runtime
.sendMessage({
contentScriptQuery: 'getHistoryPauseStatus',
contentScriptQuery: API.HISTORY.GET_HISTORY_PAUSE_STATUS,
})
.then((res) => {
if (res.code === 0)
@@ -180,7 +181,7 @@ function getHistoryPauseStatus() {
function setHistoryPauseStatus(isPause: boolean) {
browser.runtime
.sendMessage({
contentScriptQuery: 'setHistoryPauseStatus',
contentScriptQuery: API.HISTORY.SET_HISTORY_PAUSE_STATUS,
csrf: getCSRF(),
switch: isPause,
})
@@ -193,7 +194,7 @@ function setHistoryPauseStatus(isPause: boolean) {
function clearAllHistory() {
browser.runtime
.sendMessage({
contentScriptQuery: 'clearAllHistory',
contentScriptQuery: API.HISTORY.CLEAR_ALL_HISTORY,
csrf: getCSRF(),
})
.then((res) => {

View File

@@ -2,6 +2,7 @@
import type { Ref } from 'vue'
import type { GridLayout } from '~/logic'
import type { DataItem as MomentItem, MomentResult } from '~/models/moment/moment'
import API from '~/background/msg.define'
const props = defineProps<{
gridLayout: GridLayout
@@ -82,7 +83,7 @@ async function getFollowedUsersVideos() {
isLoading.value = true
try {
const response: MomentResult = await browser.runtime.sendMessage({
contentScriptQuery: 'getMoments',
contentScriptQuery: API.MOMENT.GET_MOMENTS,
type: 'video',
offset: offset.value,
update_baseline: updateBaseline.value,

View File

@@ -7,6 +7,7 @@ import type { GridLayout } from '~/logic'
import { accessKey, settings } from '~/logic'
import { LanguageType } from '~/enums/appEnums'
import { TVAppKey } from '~/utils/authProvider'
import API from '~/background/msg.define'
const props = defineProps<{
gridLayout: GridLayout
@@ -103,7 +104,7 @@ async function getRecommendVideos() {
isLoading.value = true
try {
const response: forYouResult = await browser.runtime.sendMessage({
contentScriptQuery: 'getRecommendVideos',
contentScriptQuery: API.VIDEO.GET_RECOMMEND_VIDEOS,
fresh_idx: refreshIdx.value++,
})
@@ -143,7 +144,7 @@ async function getAppRecommendVideos() {
isLoading.value = true
try {
const response: AppForYouResult = await browser.runtime.sendMessage({
contentScriptQuery: 'getAppRecommendVideos',
contentScriptQuery: API.VIDEO.GET_APP_RECOMMEND_VIDEOS,
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',

View File

@@ -6,6 +6,7 @@ import type { List as RankingPgcItem, RankingPgcResult } from '~/models/video/ra
import type { GridLayout } from '~/logic'
import { settings } from '~/logic'
import emitter from '~/utils/mitt'
import API from '~/background/msg.define'
const props = defineProps<{
gridLayout: GridLayout
@@ -129,7 +130,7 @@ function getRankingVideos() {
emit('beforeLoading')
isLoading.value = true
browser.runtime.sendMessage({
contentScriptQuery: 'getRankingVideos',
contentScriptQuery: API.RANKING.GET_RANKING_VIDEOS,
rid: activatedRankingType.value.rid,
type: 'type' in activatedRankingType.value ? activatedRankingType.value.type : 'all',
}).then((response: RankingResult) => {
@@ -147,7 +148,7 @@ function getRankingPgc() {
PgcList.length = 0
isLoading.value = true
browser.runtime.sendMessage({
contentScriptQuery: 'getRankingPgc',
contentScriptQuery: API.RANKING.GET_RANKING_PGC,
season_type: activatedRankingType.value.seasonType,
}).then((response: RankingPgcResult) => {
if (response.code === 0)

View File

@@ -2,6 +2,7 @@
import type { Ref } from 'vue'
import type { GridLayout } from '~/logic'
import type { DataItem as MomentItem, MomentResult } from '~/models/moment/moment'
import API from '~/background/msg.define'
const props = defineProps<{
gridLayout: GridLayout
@@ -86,7 +87,7 @@ async function getFollowedUsersVideos() {
isLoading.value = true
try {
const response: MomentResult = await browser.runtime.sendMessage({
contentScriptQuery: 'getMoments',
contentScriptQuery: API.MOMENT.GET_MOMENTS,
type: 'pgc',
offset: offset.value,
update_baseline: updateBaseline.value,

View File

@@ -2,6 +2,7 @@
import type { Ref } from 'vue'
import type { GridLayout } from '~/logic'
import type { TrendingResult, List as VideoItem } from '~/models/video/trending'
import API from '~/background/msg.define'
const props = defineProps<{
gridLayout: GridLayout
@@ -66,7 +67,7 @@ async function getTrendingVideos() {
isLoading.value = true
try {
const response: TrendingResult = await browser.runtime.sendMessage({
contentScriptQuery: 'getPopularVideos',
contentScriptQuery: API.VIDEO.GET_POPULAR_VIDEOS,
pn: pn.value++,
ps: 30,
})

View File

@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'
import { getCSRF, openLinkToNewTab, removeHttpFromUrl } from '~/utils/main'
import { calcCurrentTime } from '~/utils/dataFormatter'
import type { List as VideoItem, WatchLaterResult } from '~/models/video/watchLater'
import API from '~/background/msg.define'
const { t } = useI18n()
@@ -35,7 +36,7 @@ function getAllWatchLaterList() {
watchLaterList.length = 0
browser.runtime
.sendMessage({
contentScriptQuery: 'getAllWatchLaterList',
contentScriptQuery: API.WATCHLATER.GET_ALL_WATCHLATER_LIST,
})
.then((res: WatchLaterResult) => {
if (res.code === 0)
@@ -48,7 +49,7 @@ function getAllWatchLaterList() {
function deleteWatchLaterItem(index: number, aid: number) {
browser.runtime
.sendMessage({
contentScriptQuery: 'removeFromWatchLater',
contentScriptQuery: API.WATCHLATER.REMOVE_FROM_WATCHLATER,
aid,
csrf: getCSRF(),
})
@@ -65,7 +66,7 @@ function handleClearAllWatchLater() {
if (result) {
isLoading.value = true
browser.runtime.sendMessage({
contentScriptQuery: 'clearAllWatchLater',
contentScriptQuery: API.WATCHLATER.CLEAR_ALL_WATCHLATER,
csrf: getCSRF(),
}).then((res) => {
if (res.code === 0)
@@ -83,7 +84,7 @@ function handleRemoveWatchedVideos() {
if (result) {
browser.runtime
.sendMessage({
contentScriptQuery: 'removeFromWatchLater',
contentScriptQuery: API.WATCHLATER.REMOVE_FROM_WATCHLATER,
viewed: true,
csrf: getCSRF(),
})