refactor: ts types renaming

This commit is contained in:
Hakadao
2023-10-16 18:12:51 +08:00
parent 5e64df329b
commit 12e623eae0
2 changed files with 35 additions and 22 deletions

View File

@@ -1,18 +1,18 @@
<script setup lang="ts">
import type { Ref } from 'vue'
import type { AppVideoModel, VideoModel } from '../types'
import type { AppForYouVideoModel, ForYouVideoModel } from '../types'
import emitter from '~/utils/mitt'
import { accessKey, settings } from '~/logic'
import { LanguageType } from '~/enums/appEnums'
const videoList = reactive<VideoModel[]>([])
const appVideoList = reactive<AppVideoModel[]>([])
const videoList = reactive<ForYouVideoModel[]>([])
const appVideoList = reactive<AppForYouVideoModel[]>([])
const isLoading = ref<boolean>(false)
const needToLoginFirst = ref<boolean>(false)
const containerRef = ref<HTMLElement>() as Ref<HTMLElement>
const refreshIdx = ref<number>(1)
watch(() => settings.value.recommendationMode, (newValue, oldValue) => {
watch(() => settings.value.recommendationMode, (newValue) => {
videoList.length = 0
appVideoList.length = 0
if (newValue === 'web') {
@@ -65,9 +65,9 @@ async function getRecommendVideos() {
})
if (response.code === 0) {
const resData = [] as VideoModel[]
const resData = [] as ForYouVideoModel[]
response.data.item.forEach((item: VideoModel) => {
response.data.item.forEach((item: ForYouVideoModel) => {
resData.push(item)
})
@@ -101,9 +101,9 @@ async function getAppRecommendVideos() {
})
if (response.code === 0) {
const resData = [] as AppVideoModel[]
const resData = [] as AppForYouVideoModel[]
response.data.items.forEach((item: AppVideoModel) => {
response.data.items.forEach((item: AppForYouVideoModel) => {
// Remove banner & ad cards
if (!item.card_type.includes('banner') && item.card_type !== 'cm_v1')
resData.push(item)

View File

@@ -10,28 +10,44 @@ export enum HomeSubPage {
Ranking = 'Ranking',
}
export interface VideoModel {
export interface ForYouVideoModel {
id: number
bvid: string
cid: number
goto: string
uri: string
pic: string
pic_4_3: string
title: string
duration: number
pubdate: number
owner: {
face: string
mid: number
name: string
face: string
}
is_followed: boolean
pic: string
pubdate: number
stat: {
danmaku: number
like: number
view: number
like: number
danmaku: number
vt: number
}
title: string
uri: string
duration: number
// av_feature: null
is_followed: number
rcmd_reason: {
reason_type: number
}
show_info: number
pos: number
// room_info: null
// ogv_info: null
// business_info: null
is_stock: number
enable_vt: number
vt_display: string
}
export interface AppVideoModel {
export interface AppForYouVideoModel {
card_type: string
card_goto: string
goto: string
@@ -118,7 +134,6 @@ export interface AppVideoModel {
}
export interface MomentModel {
basic: {
comment_id_str: string
comment_type: number
@@ -246,7 +261,6 @@ export interface MomentModel {
label: string
type: string
}[]
}
module_stat: {
comment: {
@@ -266,7 +280,6 @@ export interface MomentModel {
}
type: string
visible: boolean
}
export interface PopularVideoModel {