@phonghq/go-chat 1.0.72 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons/call/IconClock.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconClock.vue.js +22 -0
- package/dist/assets/icons/call/IconClose.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconClose.vue.js +26 -0
- package/dist/assets/icons/call/IconMic.vue.d.ts +14 -0
- package/dist/assets/icons/call/IconMic.vue.js +123 -0
- package/dist/assets/icons/call/IconPhone.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconPhone.vue.js +22 -0
- package/dist/assets/icons/call/IconPhoneCancel.vue.d.ts +14 -0
- package/dist/assets/icons/call/IconPhoneCancel.vue.js +46 -0
- package/dist/assets/icons/call/IconSoundDownload.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconSoundDownload.vue.js +50 -0
- package/dist/assets/icons/call/IconSpeaker.vue.d.ts +14 -0
- package/dist/assets/icons/call/IconSpeaker.vue.js +62 -0
- package/dist/assets/icons/chat/IconCalendar.vue.d.ts +14 -0
- package/dist/assets/icons/chat/IconCalendar.vue.js +42 -0
- package/dist/assets/icons/chat/IconCheck.vue.d.ts +2 -0
- package/dist/assets/icons/chat/IconCheck.vue.js +22 -0
- package/dist/assets/icons/chat/IconInfo.vue.d.ts +2 -0
- package/dist/assets/icons/chat/IconInfo.vue.js +20 -0
- package/dist/assets/icons/chat/IconLink.vue.d.ts +14 -0
- package/dist/assets/icons/chat/IconLink.vue.js +42 -0
- package/dist/assets/icons/chat/IconMenuDot.vue.d.ts +2 -0
- package/dist/assets/icons/chat/IconMenuDot.vue.js +31 -0
- package/dist/assets/icons/customer-appointment/IconChevronRight.vue.d.ts +2 -0
- package/dist/assets/icons/customer-appointment/IconChevronRight.vue.js +22 -0
- package/dist/assets/icons/customer-appointment/IconFilter.vue.d.ts +2 -0
- package/dist/assets/icons/customer-appointment/IconFilter.vue.js +53 -0
- package/dist/assets/icons/customer-detail/IconArrow.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconArrow.vue.js +22 -0
- package/dist/assets/icons/customer-detail/IconCheck.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconCheck.vue.js +27 -0
- package/dist/assets/icons/customer-detail/IconDate.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconDate.vue.js +43 -0
- package/dist/assets/icons/customer-detail/IconGroup.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconGroup.vue.js +48 -0
- package/dist/assets/icons/customer-detail/IconMessage.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconMessage.vue.js +28 -0
- package/dist/assets/icons/customer-detail/IconNote.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconNote.vue.js +29 -0
- package/dist/assets/icons/customer-detail/IconPhone.vue.d.ts +14 -0
- package/dist/assets/icons/customer-detail/IconPhone.vue.js +41 -0
- package/dist/assets/icons/customer-detail/IconPin.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconPin.vue.js +29 -0
- package/dist/assets/icons/customer-detail/IconSearch.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconSearch.vue.js +29 -0
- package/dist/assets/icons/global/IconAiCheck.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconAiCheck.vue.js +28 -0
- package/dist/assets/icons/global/IconArrowLeft.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconArrowLeft.vue.js +29 -0
- package/dist/assets/icons/global/IconBackspace.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconBackspace.vue.js +28 -0
- package/dist/assets/icons/global/IconCloseCircle.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconCloseCircle.vue.js +36 -0
- package/dist/assets/icons/global/IconMessageOutline.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconMessageOutline.vue.js +22 -0
- package/dist/assets/icons/global/IconPhone.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconPhone.vue.js +19 -0
- package/dist/assets/icons/global/IconPlan.vue.d.ts +14 -0
- package/dist/assets/icons/global/IconPlan.vue.js +39 -0
- package/dist/assets/icons/global/IconPlus.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconPlus.vue.js +22 -0
- package/dist/assets/icons/global/IconSearch.vue.d.ts +32 -0
- package/dist/assets/icons/global/IconSearch.vue.js +68 -0
- package/dist/assets/icons/global/IconSms.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconSms.vue.js +22 -0
- package/dist/assets/icons/global/IconUser.vue.d.ts +2 -0
- package/dist/assets/icons/global/IconUser.vue.js +25 -0
- package/dist/assets/icons/lib/IconZoomOut.vue.d.ts +5 -0
- package/dist/assets/icons/lib/IconZoomOut.vue.js +52 -0
- package/dist/chat/App.vue.d.ts +26 -0
- package/dist/chat/App.vue.js +928 -0
- package/dist/chat/ChatHeader.vue.d.ts +15 -0
- package/dist/chat/ChatHeader.vue.js +218 -0
- package/dist/chat/main.d.ts +7 -0
- package/dist/chat/main.js +7 -0
- package/dist/chat/page/customer-appointment/CustomerAppointment.vue.d.ts +9 -0
- package/dist/chat/page/customer-appointment/CustomerAppointment.vue.js +262 -0
- package/dist/chat/page/customer-check-in/CollapseCheckIn.vue.d.ts +12 -0
- package/dist/chat/page/customer-check-in/CollapseCheckIn.vue.js +80 -0
- package/dist/chat/page/customer-check-in/CustomerCheckIn.vue.d.ts +2 -0
- package/dist/chat/page/customer-check-in/CustomerCheckIn.vue.js +138 -0
- package/dist/chat/page/customer-detail/CustomerDetail.vue.d.ts +7 -0
- package/dist/chat/page/customer-detail/CustomerDetail.vue.js +234 -0
- package/dist/chat/page/customer-detail/SubInformation.vue.d.ts +16 -0
- package/dist/chat/page/customer-detail/SubInformation.vue.js +134 -0
- package/dist/chat/page/error/Error.vue.d.ts +2 -0
- package/dist/chat/page/error/Error.vue.js +64 -0
- package/dist/chat/page/home/ChatList.vue.d.ts +104 -0
- package/dist/chat/page/home/ChatList.vue.js +654 -0
- package/dist/chat/page/home/ChatMessage.vue.d.ts +21 -0
- package/dist/chat/page/home/ChatMessage.vue.js +210 -0
- package/dist/chat/page/home/ChatMessageItem.vue.d.ts +20 -0
- package/dist/chat/page/home/ChatMessageItem.vue.js +397 -0
- package/dist/chat/page/home/ChatMessageItem2.vue.d.ts +19 -0
- package/dist/chat/page/home/ChatMessageItem2.vue.js +351 -0
- package/dist/chat/page/home/DropZone.vue.d.ts +13 -0
- package/dist/chat/page/home/DropZone.vue.js +130 -0
- package/dist/chat/page/home/Home.vue.d.ts +29 -0
- package/dist/chat/page/home/Home.vue.js +472 -0
- package/dist/chat/page/home/HomeHeader.vue.d.ts +18 -0
- package/dist/chat/page/home/HomeHeader.vue.js +514 -0
- package/dist/chat/page/home/InputChat.vue.d.ts +27 -0
- package/dist/chat/page/home/InputChat.vue.js +412 -0
- package/dist/chat/page/home/NewCustomer.vue.d.ts +7 -0
- package/dist/chat/page/home/NewCustomer.vue.js +83 -0
- package/dist/chat/page/home/PhoneNumpad.vue.d.ts +22 -0
- package/dist/chat/page/home/PhoneNumpad.vue.js +161 -0
- package/dist/chat/page/setting/Setting.vue.d.ts +2 -0
- package/dist/chat/page/setting/Setting.vue.js +277 -0
- package/dist/chat/page/setting/SettingSuccess.vue.d.ts +2 -0
- package/dist/chat/page/setting/SettingSuccess.vue.js +33 -0
- package/dist/components/chat/ScrollEvent/ScrollEvent.vue.d.ts +24 -0
- package/dist/components/chat/ScrollEvent/ScrollEvent.vue.js +207 -0
- package/dist/components/chat/call/Calling.vue.d.ts +17 -0
- package/dist/components/chat/call/Calling.vue.js +594 -0
- package/dist/components/chat/call/TimeLeft.vue.d.ts +5 -0
- package/dist/components/chat/call/TimeLeft.vue.js +59 -0
- package/dist/components/chat/card/CardCustomerDetail.vue.d.ts +13 -0
- package/dist/components/chat/card/CardCustomerDetail.vue.js +28 -0
- package/dist/components/chat/common/collapse/CollapseBase.vue.d.ts +20 -0
- package/dist/components/chat/common/collapse/CollapseBase.vue.js +59 -0
- package/dist/components/chat/common/input/InputSearch.vue.d.ts +16 -0
- package/dist/components/chat/common/input/InputSearch.vue.js +71 -0
- package/dist/components/chat/common/modal/Modal.vue.d.ts +94 -0
- package/dist/components/chat/common/modal/Modal.vue.js +260 -0
- package/dist/components/chat/common/popover/PopoverBase.vue.d.ts +35 -0
- package/dist/components/chat/common/popover/PopoverBase.vue.js +148 -0
- package/dist/components/chat/common/spin/BaseSpin.vue.d.ts +10 -0
- package/dist/components/chat/common/spin/BaseSpin.vue.js +43 -0
- package/dist/components/chat/common/switch/SwitchBase.vue.d.ts +17 -0
- package/dist/components/chat/common/switch/SwitchBase.vue.js +76 -0
- package/dist/components/chat/common/tab/TabBase.vue.d.ts +30 -0
- package/dist/components/chat/common/tab/TabBase.vue.js +86 -0
- package/dist/components/chat/common/tabs/TabBase.vue.d.ts +18 -0
- package/dist/components/chat/common/tabs/TabBase.vue.js +93 -0
- package/dist/components/chat/customer/Avatar.vue.d.ts +12 -0
- package/dist/components/chat/customer/Avatar.vue.js +127 -0
- package/dist/components/chat/layout/mobile/Footer.vue.d.ts +2 -0
- package/dist/components/chat/layout/mobile/Footer.vue.js +114 -0
- package/dist/components/chat/select/SelectBase.vue.d.ts +24 -0
- package/dist/components/chat/select/SelectBase.vue.js +105 -0
- package/dist/components/common/CustomLoading.vue.d.ts +2 -0
- package/dist/components/common/CustomLoading.vue.js +19 -0
- package/dist/components/common/Notification/NotificationDescription.vue.d.ts +7 -0
- package/dist/components/common/Notification/NotificationDescription.vue.js +38 -0
- package/dist/components/common/button/ButtonBase.vue.d.ts +22 -0
- package/dist/components/common/button/ButtonBase.vue.js +78 -0
- package/dist/components/common/button/ButtonToggle.vue.d.ts +20 -0
- package/dist/components/common/button/ButtonToggle.vue.js +70 -0
- package/dist/components/common/checkbox/CCheckboxNumber.vue.d.ts +16 -0
- package/dist/components/common/checkbox/CCheckboxNumber.vue.js +48 -0
- package/dist/components/common/collapse/BaseCollapse.vue.d.ts +12 -0
- package/dist/components/common/collapse/BaseCollapse.vue.js +36 -0
- package/dist/components/common/collapse/BaseCollapseItem.vue.d.ts +4 -0
- package/dist/components/common/collapse/BaseCollapseItem.vue.js +22 -0
- package/dist/components/common/drawer/DrawerBase.vue.d.ts +39 -0
- package/dist/components/common/drawer/DrawerBase.vue.js +126 -0
- package/dist/components/common/drawer/DrawerBaseCustom.vue.d.ts +33 -0
- package/dist/components/common/drawer/DrawerBaseCustom.vue.js +135 -0
- package/dist/components/common/dropdown/DropdownBase.vue.d.ts +21 -0
- package/dist/components/common/dropdown/DropdownBase.vue.js +93 -0
- package/dist/components/common/input/CInputSearch.vue.d.ts +14 -0
- package/dist/components/common/input/CInputSearch.vue.js +62 -0
- package/dist/components/common/modal/ModalBase.vue.d.ts +35 -0
- package/dist/components/common/modal/ModalBase.vue.js +187 -0
- package/dist/components/common/popover/PopoverBase.vue.d.ts +3 -0
- package/dist/components/common/popover/PopoverBase.vue.js +36 -0
- package/dist/components/common/select/SelectBase.vue.d.ts +33 -0
- package/dist/components/common/select/SelectBase.vue.js +120 -0
- package/dist/components/common/slider/BaseSlider.vue.d.ts +11 -0
- package/dist/components/common/slider/BaseSlider.vue.js +70 -0
- package/dist/components/common/spin/CSpin.vue.d.ts +9 -0
- package/dist/components/common/spin/CSpin.vue.js +41 -0
- package/dist/components/common/tooltip/TooltipBase.vue.d.ts +2 -0
- package/dist/components/common/tooltip/TooltipBase.vue.js +8 -0
- package/dist/components/layout/PageError.vue.d.ts +2 -0
- package/dist/components/layout/PageError.vue.js +91 -0
- package/dist/components/ui/button/CButton.vue.d.ts +19 -0
- package/dist/components/ui/button/CButton.vue.js +49 -0
- package/dist/components/ui/button/c-button.d.ts +7 -0
- package/dist/components/ui/button/c-button.js +26 -0
- package/dist/components/ui/checkbox/Checkbox.vue.d.ts +18 -0
- package/dist/components/ui/checkbox/Checkbox.vue.js +79 -0
- package/dist/components/ui/checkbox/index.d.ts +1 -0
- package/dist/components/ui/checkbox/index.js +1 -0
- package/dist/components/ui/collapsible/Collapsible.vue.d.ts +16 -0
- package/dist/components/ui/collapsible/Collapsible.vue.js +47 -0
- package/dist/components/ui/collapsible/CollapsibleContent.vue.d.ts +10 -0
- package/dist/components/ui/collapsible/CollapsibleContent.vue.js +41 -0
- package/dist/components/ui/collapsible/CollapsibleTrigger.vue.d.ts +10 -0
- package/dist/components/ui/collapsible/CollapsibleTrigger.vue.js +35 -0
- package/dist/components/ui/collapsible/index.d.ts +3 -0
- package/dist/components/ui/collapsible/index.js +3 -0
- package/dist/components/ui/dialog/Dialog.vue.d.ts +14 -0
- package/dist/components/ui/dialog/Dialog.vue.js +42 -0
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +10 -0
- package/dist/components/ui/dialog/DialogClose.vue.js +35 -0
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +29 -0
- package/dist/components/ui/dialog/DialogContent.vue.js +84 -0
- package/dist/components/ui/dialog/DialogDescription.vue.d.ts +14 -0
- package/dist/components/ui/dialog/DialogDescription.vue.js +43 -0
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +13 -0
- package/dist/components/ui/dialog/DialogFooter.vue.js +26 -0
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +13 -0
- package/dist/components/ui/dialog/DialogHeader.vue.js +26 -0
- package/dist/components/ui/dialog/DialogScrollContent.vue.d.ts +30 -0
- package/dist/components/ui/dialog/DialogScrollContent.vue.js +99 -0
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +14 -0
- package/dist/components/ui/dialog/DialogTitle.vue.js +43 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +10 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.js +35 -0
- package/dist/components/ui/dialog/index.d.ts +9 -0
- package/dist/components/ui/dialog/index.js +9 -0
- package/dist/components/ui/drawer/Drawer.vue.d.ts +26 -0
- package/dist/components/ui/drawer/Drawer.vue.js +48 -0
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts +33 -0
- package/dist/components/ui/drawer/DrawerContent.vue.js +81 -0
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +14 -0
- package/dist/components/ui/drawer/DrawerDescription.vue.js +42 -0
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +13 -0
- package/dist/components/ui/drawer/DrawerFooter.vue.js +26 -0
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +13 -0
- package/dist/components/ui/drawer/DrawerHeader.vue.js +26 -0
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +7 -0
- package/dist/components/ui/drawer/DrawerOverlay.vue.js +37 -0
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +14 -0
- package/dist/components/ui/drawer/DrawerTitle.vue.js +42 -0
- package/dist/components/ui/drawer/index.d.ts +8 -0
- package/dist/components/ui/drawer/index.js +8 -0
- package/dist/components/ui/dropdown-menu/DropdownMenu.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenu.vue.js +41 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts +20 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.js +79 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuContent.vue.d.ts +28 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuContent.vue.js +66 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts +10 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuGroup.vue.js +35 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuItem.vue.d.ts +15 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuItem.vue.js +43 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts +15 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuLabel.vue.js +43 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue.js +41 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts +18 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioItem.vue.js +80 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts +7 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSeparator.vue.js +37 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts +13 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuShortcut.vue.js +26 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSub.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSub.vue.js +41 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts +30 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSubContent.vue.js +46 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue.js +58 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts +10 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuTrigger.vue.js +41 -0
- package/dist/components/ui/dropdown-menu/index.d.ts +15 -0
- package/dist/components/ui/dropdown-menu/index.js +15 -0
- package/dist/components/ui/popover/Popover.vue.d.ts +14 -0
- package/dist/components/ui/popover/Popover.vue.js +41 -0
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +28 -0
- package/dist/components/ui/popover/PopoverContent.vue.js +60 -0
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts +10 -0
- package/dist/components/ui/popover/PopoverTrigger.vue.js +35 -0
- package/dist/components/ui/popover/index.d.ts +3 -0
- package/dist/components/ui/popover/index.js +3 -0
- package/dist/components/ui/radio-group/RadioGroup.vue.d.ts +18 -0
- package/dist/components/ui/radio-group/RadioGroup.vue.js +46 -0
- package/dist/components/ui/radio-group/RadioGroupItem.vue.d.ts +7 -0
- package/dist/components/ui/radio-group/RadioGroupItem.vue.js +71 -0
- package/dist/components/ui/radio-group/index.d.ts +2 -0
- package/dist/components/ui/radio-group/index.js +2 -0
- package/dist/components/ui/select/Select.vue.d.ts +20 -0
- package/dist/components/ui/select/Select.vue.js +49 -0
- package/dist/components/ui/select/SelectContent.vue.d.ts +24 -0
- package/dist/components/ui/select/SelectContent.vue.js +103 -0
- package/dist/components/ui/select/SelectGroup.vue.d.ts +10 -0
- package/dist/components/ui/select/SelectGroup.vue.js +37 -0
- package/dist/components/ui/select/SelectItem.vue.d.ts +18 -0
- package/dist/components/ui/select/SelectItem.vue.js +73 -0
- package/dist/components/ui/select/SelectItemText.vue.d.ts +10 -0
- package/dist/components/ui/select/SelectItemText.vue.js +37 -0
- package/dist/components/ui/select/SelectLabel.vue.d.ts +14 -0
- package/dist/components/ui/select/SelectLabel.vue.js +40 -0
- package/dist/components/ui/select/SelectScrollDownButton.vue.d.ts +14 -0
- package/dist/components/ui/select/SelectScrollDownButton.vue.js +58 -0
- package/dist/components/ui/select/SelectScrollUpButton.vue.d.ts +14 -0
- package/dist/components/ui/select/SelectScrollUpButton.vue.js +58 -0
- package/dist/components/ui/select/SelectSeparator.vue.d.ts +7 -0
- package/dist/components/ui/select/SelectSeparator.vue.js +39 -0
- package/dist/components/ui/select/SelectTrigger.vue.d.ts +17 -0
- package/dist/components/ui/select/SelectTrigger.vue.js +49 -0
- package/dist/components/ui/select/SelectValue.vue.d.ts +10 -0
- package/dist/components/ui/select/SelectValue.vue.js +37 -0
- package/dist/components/ui/select/index.d.ts +11 -0
- package/dist/components/ui/select/index.js +11 -0
- package/dist/components/ui/slider/Slider.vue.d.ts +13 -0
- package/dist/components/ui/slider/Slider.vue.js +155 -0
- package/dist/components/ui/slider/index.d.ts +1 -0
- package/dist/components/ui/slider/index.js +1 -0
- package/dist/components/ui/switch/Switch.vue.d.ts +18 -0
- package/dist/components/ui/switch/Switch.vue.js +61 -0
- package/dist/components/ui/switch/index.d.ts +1 -0
- package/dist/components/ui/switch/index.js +1 -0
- package/dist/components/ui/tabs/Tabs.vue.d.ts +20 -0
- package/dist/components/ui/tabs/Tabs.vue.js +54 -0
- package/dist/components/ui/tabs/TabsContent.vue.d.ts +14 -0
- package/dist/components/ui/tabs/TabsContent.vue.js +44 -0
- package/dist/components/ui/tabs/TabsList.vue.d.ts +14 -0
- package/dist/components/ui/tabs/TabsList.vue.js +44 -0
- package/dist/components/ui/tabs/TabsTrigger.vue.d.ts +14 -0
- package/dist/components/ui/tabs/TabsTrigger.vue.js +45 -0
- package/dist/components/ui/tabs/index.d.ts +4 -0
- package/dist/components/ui/tabs/index.js +4 -0
- package/dist/composable/useDigibot.d.ts +7 -0
- package/dist/composable/useDigibot.js +23 -0
- package/dist/composable/useInitData.d.ts +12 -0
- package/dist/composable/useInitData.js +101 -0
- package/dist/composable/useListConversations.d.ts +59 -0
- package/dist/composable/useListConversations.js +220 -0
- package/dist/composable/useListentEvent.d.ts +5 -0
- package/dist/composable/useListentEvent.js +69 -0
- package/dist/composable/usePlivo.d.ts +15 -0
- package/dist/composable/usePlivo.js +201 -0
- package/dist/constant/color.d.ts +22 -0
- package/dist/constant/color.js +47 -0
- package/dist/constant/datetime.d.ts +7 -0
- package/dist/constant/datetime.js +7 -0
- package/dist/constant/general.d.ts +11 -0
- package/dist/constant/general.js +12 -0
- package/dist/constant/message.d.ts +8 -0
- package/dist/constant/message.js +8 -0
- package/dist/constant/mqtt.d.ts +7 -0
- package/dist/constant/mqtt.js +18 -0
- package/dist/constant/user.d.ts +8 -0
- package/dist/constant/user.js +9 -0
- package/dist/go-chat.es.js +18766 -17073
- package/dist/go-chat.umd.js +23 -23
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/plugins/axios-gci.d.ts +3 -0
- package/dist/plugins/axios-gci.js +25 -0
- package/dist/plugins/axios.d.ts +3 -0
- package/dist/plugins/axios.js +84 -0
- package/dist/plugins/mqtt.d.ts +8 -0
- package/dist/plugins/mqtt.js +189 -0
- package/dist/plugins/pocketbase.d.ts +5 -0
- package/dist/plugins/pocketbase.js +15 -0
- package/dist/plugins/sdk.d.ts +18 -0
- package/dist/plugins/sdk.js +73 -0
- package/dist/plugins/websocket.d.ts +15 -0
- package/dist/plugins/websocket.js +151 -0
- package/dist/style.css +1 -1
- package/dist/types/chat/auth.d.ts +41 -0
- package/dist/types/chat/auth.js +1 -0
- package/dist/types/chat/call.d.ts +19 -0
- package/dist/types/chat/call.js +23 -0
- package/dist/types/chat/global.d.ts +58 -0
- package/dist/types/chat/global.js +1 -0
- package/dist/types/chat/promise.d.ts +17 -0
- package/dist/types/chat/promise.js +1 -0
- package/dist/types/chat/user.d.ts +88 -0
- package/dist/types/chat/user.js +1 -0
- package/dist/types/conversation.d.ts +23 -0
- package/dist/types/conversation.js +1 -0
- package/dist/types/global.d.ts +11 -0
- package/dist/types/global.js +15 -0
- package/dist/types/message.d.ts +52 -0
- package/dist/types/message.js +1 -0
- package/dist/utils/chat/cache.d.ts +7 -0
- package/dist/utils/chat/cache.js +63 -0
- package/dist/utils/chat/chat-router.d.ts +5 -0
- package/dist/utils/chat/chat-router.js +14 -0
- package/dist/utils/chat/page-error.d.ts +4 -0
- package/dist/utils/chat/page-error.js +25 -0
- package/dist/utils/chat/phone-string.d.ts +1 -0
- package/dist/utils/chat/phone-string.js +4 -0
- package/dist/utils/chat/queue.d.ts +7 -0
- package/dist/utils/chat/queue.js +30 -0
- package/dist/utils/chat/store/auth.d.ts +62 -0
- package/dist/utils/chat/store/auth.js +93 -0
- package/dist/utils/chat/store/call.d.ts +15 -0
- package/dist/utils/chat/store/call.js +160 -0
- package/dist/utils/chat/store/conversation.d.ts +14 -0
- package/dist/utils/chat/store/conversation.js +73 -0
- package/dist/utils/chat/store/message.d.ts +27 -0
- package/dist/utils/chat/store/message.js +70 -0
- package/dist/utils/chat/store/time-limit.d.ts +5 -0
- package/dist/utils/chat/store/time-limit.js +8 -0
- package/dist/utils/chat/store/user.d.ts +200 -0
- package/dist/utils/chat/store/user.js +44 -0
- package/dist/utils/dayjs-helper.d.ts +3 -0
- package/dist/utils/dayjs-helper.js +8 -0
- package/dist/utils/debounce.d.ts +1 -0
- package/dist/utils/debounce.js +9 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +18 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.js +5 -0
- package/dist/utils/string-helper.d.ts +3 -0
- package/dist/utils/string-helper.js +43 -0
- package/dist/views/NotTenantPhone.vue.d.ts +9 -0
- package/dist/views/NotTenantPhone.vue.js +99 -0
- package/dist/views/home/phone-numpad/ConvercationList.vue.d.ts +19 -0
- package/dist/views/home/phone-numpad/ConvercationList.vue.js +177 -0
- package/dist/views/home/phone-numpad/PhoneNumpad.vue.d.ts +32 -0
- package/dist/views/home/phone-numpad/PhoneNumpad.vue.js +403 -0
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const instance = axios.create({
|
|
3
|
+
timeout: 20000,
|
|
4
|
+
headers: {
|
|
5
|
+
'Content-Type': 'application/json'
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
export const setAxiosGciInstance = (token, domain, id) => {
|
|
9
|
+
instance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
10
|
+
instance.defaults.baseURL = domain;
|
|
11
|
+
instance.defaults.headers.common['G-ClientID'] = id || '';
|
|
12
|
+
};
|
|
13
|
+
instance.interceptors.response.use((response) => {
|
|
14
|
+
console.log(response);
|
|
15
|
+
const data = response?.data;
|
|
16
|
+
if (data?.status == 'OK' && (data?.result?.status == 'OK' || data?.result?.status == 200) && data?.result?.data) {
|
|
17
|
+
return Promise.resolve(data?.result?.data);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return Promise.reject(data?.message ?? 'Error');
|
|
21
|
+
}
|
|
22
|
+
}, async (error) => {
|
|
23
|
+
return Promise.reject(error.response?.data || error);
|
|
24
|
+
});
|
|
25
|
+
export default instance;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
// const baseURL = 'https://go-chat.dev01.dtsmart.dev/'
|
|
3
|
+
const baseURL = 'https://go-chat-backend.gci-app2.dtsmart.dev';
|
|
4
|
+
const instance = axios.create({
|
|
5
|
+
baseURL,
|
|
6
|
+
timeout: 20000,
|
|
7
|
+
headers: {
|
|
8
|
+
'Content-Type': 'application/json'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export const setAxiosInstance = (token, domain) => {
|
|
12
|
+
instance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
13
|
+
instance.defaults.baseURL = domain || baseURL;
|
|
14
|
+
};
|
|
15
|
+
instance.interceptors.request.use((config) => {
|
|
16
|
+
const token = config?.token || localStorage.getItem('chat_token');
|
|
17
|
+
if (token) {
|
|
18
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
}, (error) => Promise.reject(error));
|
|
22
|
+
let isRefreshing = false;
|
|
23
|
+
let failedQueue = [];
|
|
24
|
+
const processQueue = (error, token = null) => {
|
|
25
|
+
failedQueue.forEach((prom) => {
|
|
26
|
+
if (token) {
|
|
27
|
+
prom.resolve(token);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
prom.reject(error);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
failedQueue = [];
|
|
34
|
+
};
|
|
35
|
+
instance.interceptors.response.use((response) => {
|
|
36
|
+
const data = response?.data;
|
|
37
|
+
if (data.files) {
|
|
38
|
+
return Promise.resolve(data.files);
|
|
39
|
+
}
|
|
40
|
+
if (data?.status && data?.data) {
|
|
41
|
+
return Promise.resolve(data.data);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return Promise.reject(data?.messages ?? 'Error');
|
|
45
|
+
}
|
|
46
|
+
}, async (error) => {
|
|
47
|
+
const originalRequest = error.config;
|
|
48
|
+
if (error.response?.status === 403 && !originalRequest._retry) {
|
|
49
|
+
originalRequest._retry = true;
|
|
50
|
+
if (isRefreshing) {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
failedQueue.push({
|
|
53
|
+
resolve: (token) => {
|
|
54
|
+
originalRequest.headers['Authorization'] = 'Bearer ' + token;
|
|
55
|
+
resolve(instance(originalRequest));
|
|
56
|
+
},
|
|
57
|
+
reject: (err) => reject(err)
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
isRefreshing = true;
|
|
62
|
+
const authStore = null;
|
|
63
|
+
try {
|
|
64
|
+
const body = {
|
|
65
|
+
refresh_token: localStorage.getItem('refresh_token') || ''
|
|
66
|
+
};
|
|
67
|
+
const res = await authStore.refreshToken(body);
|
|
68
|
+
const newToken = res.data.token;
|
|
69
|
+
localStorage.setItem('chat_token', newToken);
|
|
70
|
+
instance.defaults.headers.common['Authorization'] = 'Bearer ' + newToken;
|
|
71
|
+
processQueue(null, newToken);
|
|
72
|
+
return instance(originalRequest);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
processQueue(err, null);
|
|
76
|
+
return Promise.reject(err);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
isRefreshing = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Promise.reject(error.response?.data || error);
|
|
83
|
+
});
|
|
84
|
+
export default instance;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import mqtt from 'mqtt';
|
|
2
|
+
export declare const connectMqtt: () => Promise<void>;
|
|
3
|
+
export declare const subscribeToTopic: (topic: string) => void;
|
|
4
|
+
export declare const unsubscribeFromTopic: (topic: string) => Promise<void>;
|
|
5
|
+
export declare const publishMessage: (topic: string, payload: any) => Promise<void>;
|
|
6
|
+
export declare const addHandleMqttMessage: (key: string, topic: string, callBack: any) => void;
|
|
7
|
+
export declare const removeHandleMqttMessage: (key: string) => void;
|
|
8
|
+
export declare const getMqttInstance: () => mqtt.MqttClient | null;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// import mqtt from 'mqtt/dist/mqtt.min'
|
|
2
|
+
import mqtt from 'mqtt';
|
|
3
|
+
import { tryParseJson } from '../utils/json';
|
|
4
|
+
const mqttOptions = { qos: 1, retain: false };
|
|
5
|
+
// const mqttClient = ref<MqttClient | null>(null)
|
|
6
|
+
let mqttClient = null;
|
|
7
|
+
let _clientTime = `_${Date.now()}_${Math.floor(Math.random() * 1000)}`;
|
|
8
|
+
let _isConnected = false;
|
|
9
|
+
const subscribedTopics = new Set();
|
|
10
|
+
let dataCallBack = [];
|
|
11
|
+
let reconnectCount = 0;
|
|
12
|
+
const MAX_RECONNECT = 5;
|
|
13
|
+
export const connectMqtt = async () => {
|
|
14
|
+
const res = await _setupMqtt();
|
|
15
|
+
if (res?.is_new_connect) {
|
|
16
|
+
subscribedTopics.forEach((topic) => {
|
|
17
|
+
mqttClient?.subscribe(topic, mqttOptions, (err) => {
|
|
18
|
+
if (!err) {
|
|
19
|
+
console.log(`Subscribed to ${topic}`);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.error(`Failed to subscribe ${topic}`, err);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
mqttClient?.on('message', (topic, message) => {
|
|
27
|
+
try {
|
|
28
|
+
let data = message;
|
|
29
|
+
if (message instanceof Uint8Array) {
|
|
30
|
+
const decoder = new TextDecoder('utf-8');
|
|
31
|
+
data = tryParseJson(decoder.decode(message));
|
|
32
|
+
}
|
|
33
|
+
console.log(data, topic);
|
|
34
|
+
dataCallBack
|
|
35
|
+
.filter((e) => {
|
|
36
|
+
return _getSameTopic(topic, e.topic);
|
|
37
|
+
})
|
|
38
|
+
.forEach((e) => {
|
|
39
|
+
e.callBack(topic, data);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.error('Error parsing message:', e);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const _getSameTopic = (topic_response, topic) => {
|
|
49
|
+
if (topic_response == topic)
|
|
50
|
+
return true;
|
|
51
|
+
if (!topic.indexOf('+'))
|
|
52
|
+
return false;
|
|
53
|
+
const topic_parts = topic.split('/');
|
|
54
|
+
const topic_response_parts = topic_response.split('/');
|
|
55
|
+
if (topic_parts.length !== topic_response_parts.length)
|
|
56
|
+
return false;
|
|
57
|
+
return topic_parts.every((part, i) => {
|
|
58
|
+
return part === '+' || part === topic_response_parts[i];
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const _setupMqtt = () => {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
reconnectCount = 0;
|
|
64
|
+
if (mqttClient && _isConnected) {
|
|
65
|
+
return resolve({});
|
|
66
|
+
}
|
|
67
|
+
mqttClient?.removeAllListeners();
|
|
68
|
+
const userInfo = JSON.parse(localStorage.getItem('user') || '{}');
|
|
69
|
+
const clientId = userInfo?.id;
|
|
70
|
+
const MQTT_OPTIONS = {
|
|
71
|
+
protocolVersion: 5,
|
|
72
|
+
clientId: `${clientId}_${_clientTime}`,
|
|
73
|
+
// host: 'mqtt-digital-signage.dev01.dtsmart.dev',
|
|
74
|
+
host: 'gap-broker.fast-boy.net',
|
|
75
|
+
port: 443,
|
|
76
|
+
protocol: 'wss',
|
|
77
|
+
// username: 'admin123',
|
|
78
|
+
// password: 'admin123',
|
|
79
|
+
clean: false,
|
|
80
|
+
reconnectPeriod: 1000,
|
|
81
|
+
path: '/mqtt'
|
|
82
|
+
};
|
|
83
|
+
const { host, port, path, ...options } = MQTT_OPTIONS;
|
|
84
|
+
const connectUrl = `wss://${host}:${port}${path}`;
|
|
85
|
+
mqttClient = mqtt.connect(connectUrl, options);
|
|
86
|
+
mqttClient?.on('reconnect', () => {
|
|
87
|
+
console.log('Reconnecting...');
|
|
88
|
+
reconnectCount++;
|
|
89
|
+
if (reconnectCount >= MAX_RECONNECT) {
|
|
90
|
+
reject();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
mqttClient?.on('offline', () => {
|
|
94
|
+
_isConnected = false;
|
|
95
|
+
});
|
|
96
|
+
mqttClient?.on('close', () => {
|
|
97
|
+
_isConnected = false;
|
|
98
|
+
});
|
|
99
|
+
mqttClient?.on('error', (err) => {
|
|
100
|
+
_isConnected = false;
|
|
101
|
+
reject(err);
|
|
102
|
+
});
|
|
103
|
+
mqttClient?.on('connect', () => {
|
|
104
|
+
_isConnected = true;
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
resolve({ is_new_connect: true });
|
|
107
|
+
}, 200);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const _disconnectMqtt = () => {
|
|
112
|
+
if (mqttClient) {
|
|
113
|
+
mqttClient?.removeAllListeners();
|
|
114
|
+
mqttClient?.end(false, {}, () => {
|
|
115
|
+
mqttClient = null;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
export const subscribeToTopic = (topic) => {
|
|
120
|
+
if (subscribedTopics.has(topic) || !topic) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (_isConnected) {
|
|
124
|
+
mqttClient?.subscribe(topic, mqttOptions, (err) => {
|
|
125
|
+
if (!err) {
|
|
126
|
+
subscribedTopics.add(topic);
|
|
127
|
+
console.log(`Subscribed to ${topic}`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.error(`Failed to subscribe ${topic}`, err);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
export const unsubscribeFromTopic = async (topic) => {
|
|
136
|
+
if (!topic)
|
|
137
|
+
return;
|
|
138
|
+
if (!_isConnected || !mqttClient) {
|
|
139
|
+
subscribedTopics.delete(topic);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
await new Promise((resolve, reject) => {
|
|
144
|
+
mqttClient?.unsubscribe(topic, (err) => {
|
|
145
|
+
if (err)
|
|
146
|
+
reject(err);
|
|
147
|
+
else
|
|
148
|
+
resolve();
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
subscribedTopics.delete(topic);
|
|
152
|
+
console.log(`Unsubscribed from ${topic}`);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
console.error(`Failed to unsubscribe ${topic}`, err);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
export const publishMessage = async (topic, payload) => {
|
|
159
|
+
if (!_isConnected) {
|
|
160
|
+
await connectMqtt();
|
|
161
|
+
}
|
|
162
|
+
if (_isConnected && payload) {
|
|
163
|
+
const message = typeof payload !== 'string' ? JSON.stringify(payload) : payload;
|
|
164
|
+
mqttClient?.publish(topic, message, {
|
|
165
|
+
qos: 1,
|
|
166
|
+
retain: false,
|
|
167
|
+
properties: {
|
|
168
|
+
messageExpiryInterval: 60
|
|
169
|
+
}
|
|
170
|
+
}, (err) => {
|
|
171
|
+
if (!err) {
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.error(`Failed to publish message to ${topic}`, err);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
export const addHandleMqttMessage = (key, topic, callBack) => {
|
|
180
|
+
removeHandleMqttMessage(key);
|
|
181
|
+
dataCallBack.push({ key, callBack, topic });
|
|
182
|
+
};
|
|
183
|
+
export const removeHandleMqttMessage = (key) => {
|
|
184
|
+
const index = dataCallBack.findIndex((e) => e.key === key);
|
|
185
|
+
if (index > -1) {
|
|
186
|
+
dataCallBack.splice(index, 1);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
export const getMqttInstance = () => mqttClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import PocketBase from 'pocketbase';
|
|
2
|
+
const instance = new PocketBase("https://gap-calendar-log.gci-app.dtsmart.dev/");
|
|
3
|
+
export const createBusinessTenantPhone = async (data) => {
|
|
4
|
+
await instance.collection('go_chat_service').create(data);
|
|
5
|
+
};
|
|
6
|
+
export const checkHasBusinessTenantPhone = async (id) => {
|
|
7
|
+
try {
|
|
8
|
+
await instance.collection('go_chat_service').getFirstListItem(`tenant_id="${id}"`);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export default instance;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GapMiniAppSdk } from 'gap-miniapp-sdk';
|
|
2
|
+
declare const gapMiniAppSdk: {
|
|
3
|
+
getInstance: () => GapMiniAppSdk;
|
|
4
|
+
getAccessToken: () => Promise<{
|
|
5
|
+
domain: string;
|
|
6
|
+
gClient: string;
|
|
7
|
+
token: string;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
declare const sdkInit: (data: {
|
|
11
|
+
id?: string;
|
|
12
|
+
token?: string;
|
|
13
|
+
domain?: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
status: boolean;
|
|
16
|
+
tenant_error?: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
export { sdkInit, gapMiniAppSdk };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GapMiniAppSdk } from 'gap-miniapp-sdk';
|
|
2
|
+
import logger from '../utils/logger';
|
|
3
|
+
import { loginTenant, setDataLogin } from '../utils/chat/store/auth';
|
|
4
|
+
import { setAxiosGciInstance } from '../plugins/axios-gci';
|
|
5
|
+
const gapMiniAppSdk = (function () {
|
|
6
|
+
let instance;
|
|
7
|
+
function createInstance() {
|
|
8
|
+
return new GapMiniAppSdk(logger);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
getInstance: function () {
|
|
12
|
+
if (!instance) {
|
|
13
|
+
instance = createInstance();
|
|
14
|
+
}
|
|
15
|
+
return instance;
|
|
16
|
+
},
|
|
17
|
+
getAccessToken: async function () {
|
|
18
|
+
let domain = '';
|
|
19
|
+
let gClient = '';
|
|
20
|
+
let token = '';
|
|
21
|
+
try {
|
|
22
|
+
let userAgent;
|
|
23
|
+
if (gapMiniAppSdk.getInstance().detectPlatform()) {
|
|
24
|
+
userAgent = gapMiniAppSdk.getInstance().detectPlatform();
|
|
25
|
+
}
|
|
26
|
+
if (userAgent) {
|
|
27
|
+
gapMiniAppSdk.getInstance().setPlatformExecutor(userAgent);
|
|
28
|
+
const response = await gapMiniAppSdk.getInstance().getAccessToken();
|
|
29
|
+
if (response &&
|
|
30
|
+
typeof response.token !== 'undefined' &&
|
|
31
|
+
response.token != '') {
|
|
32
|
+
domain = response.domain;
|
|
33
|
+
gClient = response.gClientId;
|
|
34
|
+
token = response.token;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error(error);
|
|
40
|
+
}
|
|
41
|
+
return { domain, gClient, token };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
const sdkInit = (data) => {
|
|
46
|
+
return new Promise(async (resolve, reject) => {
|
|
47
|
+
let status = false;
|
|
48
|
+
try {
|
|
49
|
+
let { domain, gClient, token } = await gapMiniAppSdk.getAccessToken();
|
|
50
|
+
domain = data.domain || domain || '';
|
|
51
|
+
gClient = data.id || gClient || '';
|
|
52
|
+
token = data.token || token || '';
|
|
53
|
+
if (!domain || !gClient || !token) {
|
|
54
|
+
resolve({ status, tenant_error: true });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setAxiosGciInstance(token, domain, gClient);
|
|
58
|
+
await loginTenant({ tenant_id: gClient });
|
|
59
|
+
status = true;
|
|
60
|
+
setDataLogin(gClient, token, domain);
|
|
61
|
+
localStorage.setItem('chat_id', gClient);
|
|
62
|
+
localStorage.setItem('chat_accessToken', token);
|
|
63
|
+
localStorage.setItem('chat_domain', domain);
|
|
64
|
+
resolve({ status });
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
resolve({ status, tenant_error: true });
|
|
68
|
+
console.error(error);
|
|
69
|
+
// reject(error)
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
export { sdkInit, gapMiniAppSdk };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function initWebSocket(): Promise<any>;
|
|
2
|
+
export declare const socketSend: (data: any) => void;
|
|
3
|
+
export declare const getWebSocket: () => Promise<any>;
|
|
4
|
+
export declare const addHandleWebSK: (key: string, callBack: any) => void;
|
|
5
|
+
export declare const removeHandleWebSK: (key: string) => void;
|
|
6
|
+
export declare class WebSocketClient {
|
|
7
|
+
private socket;
|
|
8
|
+
private dataCallbacks;
|
|
9
|
+
private server;
|
|
10
|
+
constructor(server: string, callBack: ((message: any) => any));
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
send(data: any): void;
|
|
13
|
+
sendDefault(data: any): void;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { tryParseJson } from '../utils/json';
|
|
2
|
+
import { dataProfile } from '../utils/chat/store/auth';
|
|
3
|
+
let socket = null;
|
|
4
|
+
let dataCallBack = [];
|
|
5
|
+
let callId = '';
|
|
6
|
+
// const BASE_URL = 'wss://web-socket.dev01.dtsmart.dev/web-stream'
|
|
7
|
+
const BASE_URL = 'wss://web-socket-test.dev01.dtsmart.dev/web-stream';
|
|
8
|
+
const BARE_URL_INBOUND = 'https://web-socket.dev01.dtsmart.dev';
|
|
9
|
+
export function initWebSocket() {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
if (socket && socket.readyState === 1) {
|
|
12
|
+
console.log("WebSocket đã kết nối, bỏ qua connect.");
|
|
13
|
+
resolve('Connected');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const timer = setTimeout(() => {
|
|
17
|
+
socket?.close?.();
|
|
18
|
+
reject(new Error("WebSocket connection timeout"));
|
|
19
|
+
}, 5000);
|
|
20
|
+
// socket = new WebSocket('wss://' + callId)
|
|
21
|
+
socket = new WebSocket(BASE_URL);
|
|
22
|
+
socket.binaryType = 'arraybuffer';
|
|
23
|
+
socket.onopen = (event) => {
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
resolve('Connected');
|
|
26
|
+
};
|
|
27
|
+
socket.onmessage = (event) => {
|
|
28
|
+
const data = tryParseJson(event.data);
|
|
29
|
+
dataCallBack.forEach((e) => {
|
|
30
|
+
e.callBack(data);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
socket.onclose = (event) => {
|
|
34
|
+
console.log('Disconnected:', event.reason);
|
|
35
|
+
};
|
|
36
|
+
socket.onerror = (event) => {
|
|
37
|
+
console.error('Socket error:', event);
|
|
38
|
+
reject(event);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export const socketSend = (data) => {
|
|
43
|
+
try {
|
|
44
|
+
let request = typeof data == 'string' ? data : JSON.stringify(data);
|
|
45
|
+
socket?.send(data);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
console.log(e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export const getWebSocket = async () => {
|
|
52
|
+
const url = 'https://web-socket.dev01.dtsmart.dev/ws/connect';
|
|
53
|
+
try {
|
|
54
|
+
const response = await fetch(url, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
clientId: dataProfile.value?.tenant_id
|
|
58
|
+
}),
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
Authorization: 'Bearer -Qixt-ZztiBA5Dxl-EIWG7f2TDhK-ZCj'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw new Error(`Response status: ${response.status}`);
|
|
66
|
+
}
|
|
67
|
+
const result = await response.json();
|
|
68
|
+
callId = result?.wsUrl;
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error(error.message);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
export const addHandleWebSK = (key, callBack) => {
|
|
76
|
+
removeHandleWebSK(key);
|
|
77
|
+
dataCallBack.push({ key, callBack });
|
|
78
|
+
};
|
|
79
|
+
export const removeHandleWebSK = (key) => {
|
|
80
|
+
const index = dataCallBack.findIndex((e) => e.key === key);
|
|
81
|
+
if (index > -1) {
|
|
82
|
+
dataCallBack.splice(index, 1);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export class WebSocketClient {
|
|
86
|
+
socket = null;
|
|
87
|
+
dataCallbacks = null;
|
|
88
|
+
server;
|
|
89
|
+
constructor(server, callBack) {
|
|
90
|
+
this.server = server;
|
|
91
|
+
this.dataCallbacks = callBack;
|
|
92
|
+
}
|
|
93
|
+
async init() {
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
if (!this.server)
|
|
96
|
+
reject(new Error("Missing uuid!"));
|
|
97
|
+
this.socket = new WebSocket(BASE_URL + '?call_uuid=' + this.server);
|
|
98
|
+
console.log(BASE_URL + '?call_uuid=' + this.server);
|
|
99
|
+
this.socket.binaryType = "arraybuffer";
|
|
100
|
+
const timeout = setTimeout(() => {
|
|
101
|
+
reject(new Error("⏰ WebSocket connection timeout"));
|
|
102
|
+
}, 5000); // 5s timeout
|
|
103
|
+
this.socket.onopen = () => {
|
|
104
|
+
clearTimeout(timeout);
|
|
105
|
+
resolve(); // Kết nối thành công
|
|
106
|
+
};
|
|
107
|
+
this.socket.onmessage = (event) => {
|
|
108
|
+
const data = tryParseJson(event.data);
|
|
109
|
+
console.log(data);
|
|
110
|
+
this.dataCallbacks?.(data);
|
|
111
|
+
};
|
|
112
|
+
this.socket.onclose = (event) => {
|
|
113
|
+
};
|
|
114
|
+
this.socket.onerror = (event) => {
|
|
115
|
+
clearTimeout(timeout);
|
|
116
|
+
reject(new Error("WebSocket connection error"));
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
send(data) {
|
|
121
|
+
try {
|
|
122
|
+
const message = typeof data === 'string' ? data : JSON.stringify(data);
|
|
123
|
+
this.socket?.send(message);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
console.error('Send error:', e);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
sendDefault(data) {
|
|
130
|
+
try {
|
|
131
|
+
this.socket?.send(data);
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
console.error('Send error:', e);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
disconnect() {
|
|
138
|
+
if (this.socket) {
|
|
139
|
+
this.socket.onopen = null;
|
|
140
|
+
this.socket.onmessage = null;
|
|
141
|
+
this.socket.onclose = null;
|
|
142
|
+
this.socket.onerror = null;
|
|
143
|
+
if (this.socket.readyState === WebSocket.OPEN) {
|
|
144
|
+
this.socket.close(1000, "Manual disconnect");
|
|
145
|
+
console.log("🔌 WebSocket closed manually");
|
|
146
|
+
}
|
|
147
|
+
this.socket = null;
|
|
148
|
+
}
|
|
149
|
+
this.dataCallbacks = null;
|
|
150
|
+
}
|
|
151
|
+
}
|