index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <script setup>
  2. import HeaderGroup from './components/HeaderGroup';
  3. import Sidebar from './components/Sidebar'
  4. import TelNoticeBar from './components/TelNoticeBar'
  5. import TelNoticeBox from './components/TelNoticeBox'
  6. import { AppMain } from './components'
  7. import useVoiceStore from "@/store/modules/voice";
  8. import useUserStore from "@/store/modules/user";
  9. import { workbenchApi } from '@/api/voice/workbench';
  10. const useVoice = useVoiceStore();
  11. const useUser = useUserStore();
  12. // window.addEventListener('onunload', function (e) {
  13. // // 取消事件的默认行为(某些浏览器需要)
  14. // e.preventDefault();
  15. // e.returnValue = 'Are you sure you want to leave?';
  16. // alert('请先关闭工作台')
  17. // return 'Are you sure you want to leave?'; // 某些旧版本的浏览器需要这种写法
  18. // });
  19. onMounted(() => {
  20. if ( useVoice.isAuthPane ) {
  21. workbenchApi.getSeatsByUser({ userId: useUser.id }).then(({ data }) => {
  22. if (!data) return;
  23. useVoice.HS_CTI_INSTANCE(data.outId);
  24. const voiceStatus = localStorage.getItem('VOICE_STATUS');
  25. if ( voiceStatus ) {
  26. if ( voiceStatus === 'busy' ) {
  27. setTimeout(() => useVoice.setBusy(), 1000);
  28. } else {
  29. setTimeout(() => useVoice.setIdle(), 1000);
  30. }
  31. // useVoice.systemState = voiceStatus !== 'busy'
  32. } else {
  33. setTimeout(() => {
  34. try {
  35. useVoice.setIdle();
  36. } catch(error) {
  37. console.log(error);
  38. }
  39. }, 3000);
  40. }
  41. })
  42. }
  43. })
  44. </script>
  45. <template>
  46. <div class="app-wrapper">
  47. <HeaderGroup></HeaderGroup>
  48. <div class="main-wrapper">
  49. <Sidebar class="sidebar-container" />
  50. <AppMain class="main-container"/>
  51. </div>
  52. <TelNoticeBar></TelNoticeBar>
  53. <TelNoticeBox></TelNoticeBox>
  54. </div>
  55. </template>
  56. <style lang="scss" scoped>
  57. @import "@/assets/styles/mixin.scss";
  58. @import "@/assets/styles/variables.module.scss";
  59. .app-wrapper {
  60. @include clearfix;
  61. position: relative;
  62. height: 100vh;
  63. width: 100vw;
  64. background: #EFF1F8;
  65. overflow: hidden;
  66. .main-wrapper {
  67. display: flex;
  68. height: calc(100% - 92px);
  69. padding: 0 20px 20px 0;
  70. .sidebar-container {
  71. height: 100%;
  72. flex-shrink: 0;
  73. }
  74. }
  75. }
  76. </style>