From 181bdc37b7ab65f289b6c9cae7f0b1446bcef03b Mon Sep 17 00:00:00 2001 From: ddiu8081 Date: Tue, 18 Oct 2022 00:44:34 +0800 Subject: [PATCH] feat: fetch roomInfo before create --- packages/live/src/App.vue | 16 +++++++++------- packages/live/src/index.ts | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/live/src/App.vue b/packages/live/src/App.vue index 121cf00..940238f 100644 --- a/packages/live/src/App.vue +++ b/packages/live/src/App.vue @@ -21,7 +21,15 @@ import GiftMsgCom from './components/msgCom/GiftMsgCom.vue' import GuardBuyMsgCom from './components/msgCom/GuardBuyMsgCom.vue' import UserActionMsgCom from './components/msgCom/UserActionMsgCom.vue' -const currentRoomInfo = ref(null) +interface Props { + roomId: number + roomInfo: RoomInfo + options: AppOptions +} + +const props = defineProps() + +const currentRoomInfo = ref(props.roomInfo) const liveStatus = ref({ isLive: false, startTime: '' @@ -38,12 +46,6 @@ const giftList = ref[]>([]) const guardBuyList = ref[]>([]) const userActionList = ref[]>([]) -interface Props { - roomId: number - options: AppOptions -} - -const props = defineProps() provide('options', props.options) onMounted(async () => { diff --git a/packages/live/src/index.ts b/packages/live/src/index.ts index 758d135..4d41a68 100644 --- a/packages/live/src/index.ts +++ b/packages/live/src/index.ts @@ -2,10 +2,22 @@ import { render } from '@temir/core' import { h } from 'vue' import App from './App.vue' -const startApp = (roomId: number, options: AppOptions) => { +import { getRoomInfo, type RoomInfo } from './utils/getInfo' + +const startApp = async (roomId: number, options: AppOptions) => { + const roomInfo = await getRoomInfo(roomId) + if (!roomInfo) { + console.log('房间不存在') + return process.exit(1) + } + const NewApp = { render() { - return h(App, { roomId, options }) + return h(App, { + roomId, + roomInfo, + options + }) } }