Skip to content

Commit

Permalink
feat: fetch roomInfo before create
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed Oct 17, 2022
1 parent cd33542 commit 181bdc3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
16 changes: 9 additions & 7 deletions packages/live/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<RoomInfo | null>(null)
interface Props {
roomId: number
roomInfo: RoomInfo
options: AppOptions
}
const props = defineProps<Props>()
const currentRoomInfo = ref<RoomInfo>(props.roomInfo)
const liveStatus = ref({
isLive: false,
startTime: ''
Expand All @@ -38,12 +46,6 @@ const giftList = ref<Message<GiftMsg>[]>([])
const guardBuyList = ref<Message<GuardBuyMsg>[]>([])
const userActionList = ref<Message<UserActionMsg>[]>([])
interface Props {
roomId: number
options: AppOptions
}
const props = defineProps<Props>()
provide('options', props.options)
onMounted(async () => {
Expand Down
16 changes: 14 additions & 2 deletions packages/live/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}

Expand Down

0 comments on commit 181bdc3

Please sign in to comment.