import './app.less';
import { authorize } from '@tarojs/taro';
import { createApp } from 'vue';
import { useCustomeRequest } from './hooks/http/useCustomeRequest';
import { useProviders } from 'vue-vulcan';
import { useRequestOption } from './hooks/http/useRequestOption';
import { useAuthCheck } from './hooks/user/useAuthCheck';
import { useHttpIntercept } from './hooks/http/useHttpIntercept';
import { useCustomeStorage } from './hooks/storage/useCustomeStorage';
import { useAuthData } from 'any-hooks/auth/useAuthData';
import { useCustomeSocket } from './hooks/socket/useCustomeSocket';
import { useSocketSetting } from './hooks/socket/useSocketSettings';
import { useCallCenter } from 'any-hooks/communication/useCallCenter';
import { useChannelStore } from 'any-hooks/communication/useChannelStore';
import { useNetSocketStore } from 'any-hooks/communication/useNetSocketStore';
import { useCallerListener } from './hooks/call/useCallerListener';
import { useAgoraSDK } from './hooks/meeting/useAgoraSDK';
import { useMeetingCenter } from 'any-hooks/communication/useMeetingCenter';
import { useContacts } from 'any-hooks/contacts/useContacts';
import { useAppInitInfo } from './hooks/common/useAppInitInfo';
import { useSocketHandle } from './hooks/socket/useSocketHandle';
import dataEmpty from './components/data-empty.vue';
import MeetingBar from './components/mini-meeting-bar.vue';
import { useVideoConference } from 'any-hooks/communication/useVideoConference';

const App = createApp({    
  setup() {         
    /* 提供全局配置类hook */
    useProviders(
      useRequestOption,   //提供http请求配置项  
      useSocketSetting,   //提供小程序socket通讯的全局配置 
      useAgoraSDK,        //提供声网skd配置信息
      useAppInitInfo
    )

    /* 提供用于覆盖原生api的hook(如 fetch/webSocket) */
    useProviders(
      useCustomeStorage,  //自定义基于taro的storage的接口，覆盖useState内置的sessionStorage/localStorage接口
      useCustomeRequest,  //自定义基于taro.request的请求接口，覆盖useRequet内置的fetch接口
      useCustomeSocket,   //自定义基于taro的socket通讯接口，覆盖useSocket内置的websokcet接口
    )

    /* 提供全局共享的业务逻辑hook */
    useProviders(           
      useAuthData,        //用户权限数据   
      useHttpIntercept,   //http请求拦截器
      useNetSocketStore,  //socket连接中心       
      useContacts,        //实时联系人数据
      useChannelStore,    //频道信息中心
      useCallCenter,      //多人呼叫中心       
      useVideoConference, //多人视频通讯中心    
      useMeetingCenter,   //多人会议中心
    );

    authorize({ scope: 'scope.camera' });
    useAuthCheck();    
    useCallerListener(); //全局监听呼叫消息，并执行相应的处理逻辑：提示、页面跳转等
    useSocketHandle();   //全局监听socket的主要状态       
  }
})

App.component('data-empty', dataEmpty);
App.component('meeting-bar', MeetingBar);

export default App;
