<template>
  <div id="app">
    <NuxtLayout>
      <NuxtPage />
    </NuxtLayout>
    <PageLoading />
  </div>
</template>

<script setup lang="ts">

const appStore = useAppStore()
const userStore = useUserStore();
const { on, emit } = useEventBus()

//连接signlar
const ConnectSignlar = (clientId: string) => {
  console.log(`客户端:${clientId}`);
}


// 初始化应用配置
onMounted(() => {
  // 初始化屏幕尺寸
  if (typeof window !== 'undefined') {
    appStore.updateScreenSize(window.innerWidth, window.innerHeight)

    // 监听屏幕尺寸变化
    window.addEventListener('resize', () => {
      appStore.updateScreenSize(window.innerWidth, window.innerHeight)
    })

    // 监听网络状态变化
    window.addEventListener('online', () => {
      appStore.setOnlineStatus(true)
    })
    window.addEventListener('offline', () => {
      appStore.setOnlineStatus(false)
    })
  }
  if (userStore.getUserId != '') {
    ConnectSignlar(userStore.getUserId);
  }


  //监听启动连接signlaR   
  on<any>('connect', (payload) => {
    ConnectSignlar(payload);
  })
})


</script>

<style>
/* 页面级样式可以在这里定义 */
/* 全局样式已移至 src/assets/css/style.css */

:root {
  --van-base-font: initial !important;
}
</style>
