fix live detail loading

This commit is contained in:
2023-12-22 15:37:26 +08:00
parent 0c62ad8685
commit ee93182b54
9 changed files with 56 additions and 44 deletions

View File

@@ -34,6 +34,7 @@ import {
NSwitch, NSwitch,
NTag, NTag,
NTooltip, NTooltip,
NVirtualList,
} from 'naive-ui' } from 'naive-ui'
import { computed, nextTick, onMounted, ref, watch } from 'vue' import { computed, nextTick, onMounted, ref, watch } from 'vue'
import LiveInfoContainer from './LiveInfoContainer.vue' import LiveInfoContainer from './LiveInfoContainer.vue'
@@ -326,16 +327,6 @@ onMounted(() => {
<NModal v-model:show="showModal" @after-leave="userDanmakus = undefined" preset="card" :style="'width: 600px;max-width: 90vw;max-height: 90vh;'" content-style="overflow-y: auto"> <NModal v-model:show="showModal" @after-leave="userDanmakus = undefined" preset="card" :style="'width: 600px;max-width: 90vw;max-height: 90vh;'" content-style="overflow-y: auto">
<template #header> <template #header>
{{ userDanmakus?.[0].uName }} {{ userDanmakus?.[0].uName }}
<NPopover>
<template #trigger>
<NButton text @click="ToUserSpace(userDanmakus?.[0].uId ?? 0)">
<template #icon>
<NIcon :component="Search24Filled" />
</template>
</NButton>
</template>
查询发言记录
</NPopover>
</template> </template>
<template #header-extra> <template #header-extra>
<NSwitch v-model:value="modalShowTools" size="small"> <NSwitch v-model:value="modalShowTools" size="small">

View File

@@ -118,7 +118,7 @@ watch(
<NNumberAnimation :from="0" :to="live.totalIncomeWithGuard" show-separator /> <NNumberAnimation :from="0" :to="live.totalIncomeWithGuard" show-separator />
</span> </span>
</template> </template>
<NNumberAnimation :from="0" :to="live.totalIncome" show-separator /> {{ live.totalIncome }}
</NTooltip> </NTooltip>
</NStatistic> </NStatistic>
</transition> </transition>

View File

@@ -1,9 +1,9 @@
import { EventDataTypes, EventModel, OpenLiveInfo } from '@/api/api-models' import { EventDataTypes, EventModel, OpenLiveInfo } from '@/api/api-models'
import { QueryGetAPI, QueryPostAPI } from '@/api/query' import { QueryGetAPI, QueryPostAPI } from '@/api/query'
import ChatClientDirectOpenLive from '@/data/chat/ChatClientDirectOpenLive.js' import ChatClientDirectOpenLive from '@/data/chat/ChatClientDirectOpenLive.js'
import { ref } from 'vue'
import { clearInterval, setInterval } from 'worker-timers'
import { OPEN_LIVE_API_URL } from './constants' import { OPEN_LIVE_API_URL } from './constants'
import { ref, toRef } from 'vue'
import { setInterval, clearInterval } from 'worker-timers'
export interface DanmakuInfo { export interface DanmakuInfo {
room_id: number room_id: number
@@ -268,7 +268,7 @@ export default class DanmakuClient {
emoji: data.dm_type == 1 ? data.emoji_img_url : undefined, emoji: data.dm_type == 1 ? data.emoji_img_url : undefined,
avatar: data.uface, avatar: data.uface,
}, },
command command,
) )
}) })
} }
@@ -294,7 +294,7 @@ export default class DanmakuClient {
fans_medal_wearing_status: data.fans_medal_wearing_status, fans_medal_wearing_status: data.fans_medal_wearing_status,
avatar: data.uface, avatar: data.uface,
}, },
command command,
) )
}) })
} }
@@ -319,7 +319,7 @@ export default class DanmakuClient {
fans_medal_wearing_status: data.fans_medal_wearing_status, fans_medal_wearing_status: data.fans_medal_wearing_status,
avatar: data.uface, avatar: data.uface,
}, },
command command,
) )
}) })
} }
@@ -344,7 +344,7 @@ export default class DanmakuClient {
fans_medal_wearing_status: data.fans_medal_wearing_status, fans_medal_wearing_status: data.fans_medal_wearing_status,
avatar: data.user_info.uface, avatar: data.user_info.uface,
}, },
command command,
) )
}) })
} }

View File

@@ -1,6 +1,4 @@
import * as base from './ChatClientOfficialBase' import ChatClientOfficialBase, * as base from './ChatClientOfficialBase'
import ChatClientOfficialBase from './ChatClientOfficialBase'
export default class ChatClientDirectOpenLive extends ChatClientOfficialBase { export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
constructor(authInfo) { constructor(authInfo) {

View File

@@ -235,7 +235,6 @@ const routes: Array<RouteRecordRaw> = [
component: () => import('@/views/manage/LiveDetailManage.vue'), component: () => import('@/views/manage/LiveDetailManage.vue'),
meta: { meta: {
title: '直播详情', title: '直播详情',
keepAlive: true,
}, },
}, },
{ {

View File

@@ -264,8 +264,8 @@ async function ChangeBili() {
</NSpace> </NSpace>
<NDivider /> <NDivider />
<NSpace justify="center"> <NSpace justify="center">
<NButton type="info" @click="resetNameModalVisiable = true"> 修改用户名 </NButton>
<NButton type="warning" @click="resetPasswordModalVisiable = true"> 修改密码 </NButton> <NButton type="warning" @click="resetPasswordModalVisiable = true"> 修改密码 </NButton>
<NButton type="warning" @click="resetNameModalVisiable = true"> 修改用户名 </NButton>
<NPopconfirm @positive-click="logout"> <NPopconfirm @positive-click="logout">
<template #trigger> <template #trigger>
<NButton type="error"> 登出 </NButton> <NButton type="error"> 登出 </NButton>

View File

@@ -4,8 +4,8 @@ import { DanmakuModel, ResponseLiveInfoModel } from '@/api/api-models'
import { QueryGetAPI } from '@/api/query' import { QueryGetAPI } from '@/api/query'
import DanmakuContainer from '@/components/DanmakuContainer.vue' import DanmakuContainer from '@/components/DanmakuContainer.vue'
import { LIVE_API_URL } from '@/data/constants' import { LIVE_API_URL } from '@/data/constants'
import { NButton, useMessage } from 'naive-ui' import { NButton, NEmpty, NSpin, useMessage } from 'naive-ui'
import { ref } from 'vue' import { onActivated, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
interface ResponseLiveDetail { interface ResponseLiveDetail {
@@ -18,9 +18,12 @@ const message = useMessage()
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const isLoading = ref(true)
const liveInfo = ref<ResponseLiveDetail | undefined>(await get()) const liveInfo = ref<ResponseLiveDetail | undefined>(await get())
async function get() { async function get() {
isLoading.value = true
try { try {
const data = await QueryGetAPI<ResponseLiveDetail>(LIVE_API_URL + 'get', { const data = await QueryGetAPI<ResponseLiveDetail>(LIVE_API_URL + 'get', {
id: route.params.id, id: route.params.id,
@@ -34,12 +37,22 @@ async function get() {
} }
} catch (err) { } catch (err) {
message.error('无法获取数据') message.error('无法获取数据')
} finally {
isLoading.value = false
} }
return undefined return undefined
} }
onActivated(async () => {
if (liveInfo.value?.live.liveId != route.params.id) {
liveInfo.value = await get()
}
})
</script> </script>
<template> <template>
<NSpin v-if="isLoading" show />
<template v-else>
<NButton @click="router.go(-1)" text> <NButton @click="router.go(-1)" text>
{{ '< 返回' }} {{ '< 返回' }}
</NButton> </NButton>
@@ -58,4 +71,6 @@ async function get() {
:item-range="100" :item-range="100"
:item-height="25" :item-height="25"
/> />
<NEmpty v-else description="无数据" />
</template>
</template> </template>

View File

@@ -39,6 +39,7 @@ function OnClickCover(live: ResponseLiveInfoModel) {
params: { id: live.liveId }, params: { id: live.liveId },
}) })
} }
</script> </script>
<template> <template>
@@ -54,7 +55,7 @@ function OnClickCover(live: ResponseLiveInfoModel) {
<NDivider /> <NDivider />
<NList bordered hoverable clickable> <NList bordered hoverable clickable>
<NListItem @click="OnClickCover(live)" v-for="live in lives" v-bind:key="live.liveId"> <NListItem @click="OnClickCover(live)" v-for="live in lives" v-bind:key="live.liveId">
<LiveInfoContainer :live="live" /> <LiveInfoContainer :live="live" :key="live.liveId"/>
</NListItem> </NListItem>
</NList> </NList>
</template> </template>

View File

@@ -546,7 +546,15 @@ onUnmounted(() => {
<NSlider style="min-width: 200px" v-model:value="settings.speechInfo.rate" :min="0" :max="2" :step="0.01" /> <NSlider style="min-width: 200px" v-model:value="settings.speechInfo.rate" :min="0" :max="2" :step="0.01" />
</span> </span>
</NSpace> </NSpace>
<NDivider> 自定义内容 </NDivider> <NDivider>
自定义内容
<NTooltip>
<template #trigger>
<NIcon :component="Info24Filled" />
</template>
留空则不念
</NTooltip>
</NDivider>
<NSpace vertical> <NSpace vertical>
<NSpace> <NSpace>
支持的变量: 支持的变量: