import { reactive, ref } from 'vue'

const runtime = reactive({
  messageList: [] as Array<any>,
  joinList: {} as { [key: string]: any },
  lookList: [] as Array<any>,
})

export default runtime

// 添加消息
type Message = {
  name: string,
  id: number,
  isSelf?: boolean,
  content?: string,
  sendTime?: string
  type?: string | number,
  audienceName?: string,
  audienceId?: string | number,
  teacherId?: string | number,
  teacherName?: string,
}
/**
 * 添加消息
 * @param message 消息对象
 */
export const addMessage = (message: Message) => {
  runtime.messageList.push(message)
}
/**
 * 添加上麦消息
 */
export const addJoin = (key: string, message: Message) => {
  runtime.joinList[key] = message
}

export const removeJoin = (key: string) => {
  delete runtime.joinList[key]
}

export const addLook = (message: Message) => {
  runtime.lookList.push(message)
}