@phonghq/go-chat 1.0.4 → 1.0.6
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/IconArrowLeft.vue.d.ts +2 -0
- package/dist/assets/icons/IconPhone.vue.d.ts +2 -0
- package/dist/assets/icons/IconPlan.vue.d.ts +2 -0
- package/dist/assets/icons/IconPlus.vue.d.ts +2 -0
- package/dist/assets/icons/IconSearch.vue.d.ts +32 -0
- package/dist/assets/icons/call/IconMic.vue.d.ts +14 -0
- package/dist/assets/icons/call/IconPhone.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconPhoneCancel.vue.d.ts +2 -0
- package/dist/assets/icons/call/IconSpeaker.vue.d.ts +14 -0
- package/dist/assets/icons/customer-appointment/IconFilter.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconArrow.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconCheck.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconDate.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconGroup.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconMessage.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconNote.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconPhone.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconPin.vue.d.ts +2 -0
- package/dist/assets/icons/customer-detail/IconSearch.vue.d.ts +2 -0
- package/dist/chat/App.vue.d.ts +5 -0
- package/dist/chat/main.d.ts +6 -0
- package/dist/chat/page/customer-appointment/CustomerAppointment.vue.d.ts +2 -0
- package/dist/chat/page/customer-check-in/CollapseCheckIn.vue.d.ts +12 -0
- package/dist/chat/page/customer-check-in/CustomerCheckIn.vue.d.ts +2 -0
- package/dist/chat/page/customer-detail/CustomerDetail.vue.d.ts +7 -0
- package/dist/chat/page/customer-detail/SubInformation.vue.d.ts +16 -0
- package/dist/chat/page/error/Error.vue.d.ts +2 -0
- package/dist/chat/page/home/ChatList.vue.d.ts +20 -0
- package/dist/chat/page/home/ChatMessage.vue.d.ts +17 -0
- package/dist/chat/page/home/Home.vue.d.ts +14 -0
- package/dist/chat/page/home/HomeHeader.vue.d.ts +10 -0
- package/dist/chat/page/home/InputChat.vue.d.ts +19 -0
- package/dist/chat/page/home/NewCustomer.vue.d.ts +6 -0
- package/dist/components/ListenEvent.vue.d.ts +2 -0
- package/dist/components/chat/ScrollEvent/ScrollEvent.vue.d.ts +22 -0
- package/dist/components/chat/call/Calling.vue.d.ts +7 -0
- package/dist/components/chat/card/CardCustomerDetail.vue.d.ts +13 -0
- package/dist/components/chat/common/collapse/CollapseBase.vue.d.ts +20 -0
- package/dist/components/chat/common/input/InputSearch.vue.d.ts +16 -0
- package/dist/components/chat/common/popover/PopoverBase.vue.d.ts +35 -0
- package/dist/components/chat/common/spin/BaseSpin.vue.d.ts +2 -0
- package/dist/components/chat/customer/Avatar.vue.d.ts +12 -0
- package/dist/components/chat/layout/mobile/Footer.vue.d.ts +2 -0
- package/dist/components/common/CustomLoading.vue.d.ts +2 -0
- package/dist/components/common/Notification/NotificationDescription.vue.d.ts +7 -0
- package/dist/components/common/button/ButtonBase.vue.d.ts +22 -0
- package/dist/components/common/button/ButtonToggle.vue.d.ts +20 -0
- package/dist/components/common/checkbox/CCheckboxNumber.vue.d.ts +16 -0
- package/dist/components/common/collapse/BaseCollapse.vue.d.ts +12 -0
- package/dist/components/common/collapse/BaseCollapseItem.vue.d.ts +4 -0
- package/dist/components/common/drawer/DrawerBase.vue.d.ts +39 -0
- package/dist/components/common/dropdown/DropdownBase.vue.d.ts +21 -0
- package/dist/components/common/input/CInputSearch.vue.d.ts +14 -0
- package/dist/components/common/modal/ModalBase.vue.d.ts +35 -0
- package/dist/components/common/popover/PopoverBase.vue.d.ts +3 -0
- package/dist/components/common/slider/BaseSlider.vue.d.ts +11 -0
- package/dist/components/common/spin/CSpin.vue.d.ts +9 -0
- package/dist/components/common/tooltip/TooltipBase.vue.d.ts +2 -0
- package/dist/components/layout/Blank.vue.d.ts +9 -0
- package/dist/components/layout/Default.vue.d.ts +9 -0
- package/dist/components/modal/Confirm.vue.d.ts +2 -0
- package/dist/components/ui/button/CButton.vue.d.ts +19 -0
- package/dist/components/ui/button/c-button.d.ts +7 -0
- package/dist/components/ui/checkbox/Checkbox.vue.d.ts +18 -0
- package/dist/components/ui/checkbox/index.d.ts +1 -0
- package/dist/components/ui/collapsible/Collapsible.vue.d.ts +16 -0
- package/dist/components/ui/collapsible/CollapsibleContent.vue.d.ts +10 -0
- package/dist/components/ui/collapsible/CollapsibleTrigger.vue.d.ts +10 -0
- package/dist/components/ui/collapsible/index.d.ts +3 -0
- package/dist/components/ui/dialog/Dialog.vue.d.ts +14 -0
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +10 -0
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +29 -0
- package/dist/components/ui/dialog/DialogDescription.vue.d.ts +14 -0
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +13 -0
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +13 -0
- package/dist/components/ui/dialog/DialogScrollContent.vue.d.ts +30 -0
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +14 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +10 -0
- package/dist/components/ui/dialog/index.d.ts +9 -0
- package/dist/components/ui/drawer/Drawer.vue.d.ts +26 -0
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts +33 -0
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +14 -0
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +13 -0
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +13 -0
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +7 -0
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +14 -0
- package/dist/components/ui/drawer/index.d.ts +8 -0
- package/dist/components/ui/dropdown-menu/DropdownMenu.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts +20 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuContent.vue.d.ts +28 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts +10 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuItem.vue.d.ts +15 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts +15 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts +18 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts +7 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts +13 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSub.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts +30 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +14 -0
- package/dist/components/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts +10 -0
- package/dist/components/ui/dropdown-menu/index.d.ts +15 -0
- package/dist/components/ui/popover/Popover.vue.d.ts +14 -0
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +28 -0
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts +10 -0
- package/dist/components/ui/popover/index.d.ts +3 -0
- package/dist/components/ui/radio-group/RadioGroup.vue.d.ts +18 -0
- package/dist/components/ui/radio-group/RadioGroupItem.vue.d.ts +7 -0
- package/dist/components/ui/radio-group/index.d.ts +2 -0
- package/dist/components/ui/slider/Slider.vue.d.ts +13 -0
- package/dist/components/ui/slider/index.d.ts +1 -0
- package/dist/components/ui/switch/Switch.vue.d.ts +18 -0
- package/dist/components/ui/switch/index.d.ts +1 -0
- package/dist/composable/useCallHelper.d.ts +23 -0
- package/dist/composable/useDigibot.d.ts +7 -0
- package/dist/composable/useInitData.d.ts +11 -0
- package/dist/composable/useModalConfirm.d.ts +5 -0
- package/dist/constant/color.d.ts +22 -0
- package/dist/constant/datetime.d.ts +5 -0
- package/dist/constant/general.d.ts +8 -0
- package/dist/constant/message.d.ts +8 -0
- package/dist/constant/mqtt.d.ts +4 -0
- package/dist/constant/user.d.ts +8 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/plugins/axios-gci.d.ts +3 -0
- package/dist/plugins/axios.d.ts +3 -0
- package/dist/plugins/mqtt.d.ts +10 -0
- package/dist/plugins/sdk.d.ts +19 -0
- package/dist/plugins/websocket.d.ts +4 -0
- package/dist/style.css +1 -1
- package/dist/test/assets/icons/IconArrowLeft.vue.js +29 -0
- package/dist/test/assets/icons/IconPhone.vue.js +19 -0
- package/dist/test/assets/icons/IconPlan.vue.js +19 -0
- package/dist/test/assets/icons/IconPlus.vue.js +22 -0
- package/dist/test/assets/icons/IconSearch.vue.js +68 -0
- package/dist/test/assets/icons/call/IconMic.vue.js +123 -0
- package/dist/test/assets/icons/call/IconPhone.vue.js +35 -0
- package/dist/test/assets/icons/call/IconPhoneCancel.vue.js +35 -0
- package/dist/test/assets/icons/call/IconSpeaker.vue.js +62 -0
- package/dist/test/assets/icons/customer-appointment/IconFilter.vue.js +53 -0
- package/dist/test/assets/icons/customer-detail/IconArrow.vue.js +22 -0
- package/dist/test/assets/icons/customer-detail/IconCheck.vue.js +27 -0
- package/dist/test/assets/icons/customer-detail/IconDate.vue.js +43 -0
- package/dist/test/assets/icons/customer-detail/IconGroup.vue.js +48 -0
- package/dist/test/assets/icons/customer-detail/IconMessage.vue.js +28 -0
- package/dist/test/assets/icons/customer-detail/IconNote.vue.js +29 -0
- package/dist/test/assets/icons/customer-detail/IconPhone.vue.js +21 -0
- package/dist/test/assets/icons/customer-detail/IconPin.vue.js +29 -0
- package/dist/test/assets/icons/customer-detail/IconSearch.vue.js +29 -0
- package/dist/test/chat/App.vue.js +502 -0
- package/dist/test/chat/main.js +6 -0
- package/dist/test/chat/page/customer-appointment/CustomerAppointment.vue.js +207 -0
- package/dist/test/chat/page/customer-check-in/CollapseCheckIn.vue.js +80 -0
- package/dist/test/chat/page/customer-check-in/CustomerCheckIn.vue.js +136 -0
- package/dist/test/chat/page/customer-detail/CustomerDetail.vue.js +235 -0
- package/dist/test/chat/page/customer-detail/SubInformation.vue.js +102 -0
- package/dist/test/chat/page/error/Error.vue.js +64 -0
- package/dist/test/chat/page/home/ChatList.vue.js +387 -0
- package/dist/test/chat/page/home/ChatMessage.vue.js +295 -0
- package/dist/test/chat/page/home/Home.vue.js +332 -0
- package/dist/test/chat/page/home/HomeHeader.vue.js +127 -0
- package/dist/test/chat/page/home/InputChat.vue.js +255 -0
- package/dist/test/chat/page/home/NewCustomer.vue.js +84 -0
- package/dist/test/components/ListenEvent.vue.js +45 -0
- package/dist/test/components/chat/ScrollEvent/ScrollEvent.vue.js +197 -0
- package/dist/test/components/chat/call/Calling.vue.js +291 -0
- package/dist/test/components/chat/card/CardCustomerDetail.vue.js +28 -0
- package/dist/test/components/chat/common/collapse/CollapseBase.vue.js +59 -0
- package/dist/test/components/chat/common/input/InputSearch.vue.js +71 -0
- package/dist/test/components/chat/common/popover/PopoverBase.vue.js +148 -0
- package/dist/test/components/chat/common/spin/BaseSpin.vue.js +12 -0
- package/dist/test/components/chat/customer/Avatar.vue.js +101 -0
- package/dist/test/components/chat/layout/mobile/Footer.vue.js +109 -0
- package/dist/test/components/common/CustomLoading.vue.js +19 -0
- package/dist/test/components/common/Notification/NotificationDescription.vue.js +38 -0
- package/dist/test/components/common/button/ButtonBase.vue.js +78 -0
- package/dist/test/components/common/button/ButtonToggle.vue.js +70 -0
- package/dist/test/components/common/checkbox/CCheckboxNumber.vue.js +48 -0
- package/dist/test/components/common/collapse/BaseCollapse.vue.js +36 -0
- package/dist/test/components/common/collapse/BaseCollapseItem.vue.js +22 -0
- package/dist/test/components/common/drawer/DrawerBase.vue.js +126 -0
- package/dist/test/components/common/dropdown/DropdownBase.vue.js +91 -0
- package/dist/test/components/common/input/CInputSearch.vue.js +62 -0
- package/dist/test/components/common/modal/ModalBase.vue.js +164 -0
- package/dist/test/components/common/popover/PopoverBase.vue.js +36 -0
- package/dist/test/components/common/slider/BaseSlider.vue.js +70 -0
- package/dist/test/components/common/spin/CSpin.vue.js +41 -0
- package/dist/test/components/common/tooltip/TooltipBase.vue.js +8 -0
- package/dist/test/components/layout/Blank.vue.js +19 -0
- package/dist/test/components/layout/Default.vue.js +21 -0
- package/dist/test/components/modal/Confirm.vue.js +164 -0
- package/dist/test/components/ui/button/CButton.vue.js +49 -0
- package/dist/test/components/ui/button/c-button.js +26 -0
- package/dist/test/components/ui/checkbox/Checkbox.vue.js +79 -0
- package/dist/test/components/ui/checkbox/index.js +1 -0
- package/dist/test/components/ui/collapsible/Collapsible.vue.js +47 -0
- package/dist/test/components/ui/collapsible/CollapsibleContent.vue.js +41 -0
- package/dist/test/components/ui/collapsible/CollapsibleTrigger.vue.js +35 -0
- package/dist/test/components/ui/collapsible/index.js +3 -0
- package/dist/test/components/ui/dialog/Dialog.vue.js +42 -0
- package/dist/test/components/ui/dialog/DialogClose.vue.js +35 -0
- package/dist/test/components/ui/dialog/DialogContent.vue.js +84 -0
- package/dist/test/components/ui/dialog/DialogDescription.vue.js +43 -0
- package/dist/test/components/ui/dialog/DialogFooter.vue.js +26 -0
- package/dist/test/components/ui/dialog/DialogHeader.vue.js +26 -0
- package/dist/test/components/ui/dialog/DialogScrollContent.vue.js +99 -0
- package/dist/test/components/ui/dialog/DialogTitle.vue.js +43 -0
- package/dist/test/components/ui/dialog/DialogTrigger.vue.js +35 -0
- package/dist/test/components/ui/dialog/index.js +9 -0
- package/dist/test/components/ui/drawer/Drawer.vue.js +48 -0
- package/dist/test/components/ui/drawer/DrawerContent.vue.js +81 -0
- package/dist/test/components/ui/drawer/DrawerDescription.vue.js +42 -0
- package/dist/test/components/ui/drawer/DrawerFooter.vue.js +26 -0
- package/dist/test/components/ui/drawer/DrawerHeader.vue.js +26 -0
- package/dist/test/components/ui/drawer/DrawerOverlay.vue.js +37 -0
- package/dist/test/components/ui/drawer/DrawerTitle.vue.js +42 -0
- package/dist/test/components/ui/drawer/index.js +8 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenu.vue.js +41 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.js +79 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuContent.vue.js +61 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuGroup.vue.js +35 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuItem.vue.js +43 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuLabel.vue.js +43 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue.js +41 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuRadioItem.vue.js +80 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSeparator.vue.js +37 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuShortcut.vue.js +26 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSub.vue.js +41 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSubContent.vue.js +46 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue.js +58 -0
- package/dist/test/components/ui/dropdown-menu/DropdownMenuTrigger.vue.js +41 -0
- package/dist/test/components/ui/dropdown-menu/index.js +15 -0
- package/dist/test/components/ui/popover/Popover.vue.js +41 -0
- package/dist/test/components/ui/popover/PopoverContent.vue.js +60 -0
- package/dist/test/components/ui/popover/PopoverTrigger.vue.js +35 -0
- package/dist/test/components/ui/popover/index.js +3 -0
- package/dist/test/components/ui/radio-group/RadioGroup.vue.js +46 -0
- package/dist/test/components/ui/radio-group/RadioGroupItem.vue.js +71 -0
- package/dist/test/components/ui/radio-group/index.js +2 -0
- package/dist/test/components/ui/slider/Slider.vue.js +155 -0
- package/dist/test/components/ui/slider/index.js +1 -0
- package/dist/test/components/ui/switch/Switch.vue.js +61 -0
- package/dist/test/components/ui/switch/index.js +1 -0
- package/dist/test/composable/useCallHelper.js +170 -0
- package/dist/test/composable/useDigibot.js +22 -0
- package/dist/test/composable/useInitData.js +84 -0
- package/dist/test/composable/useModalConfirm.js +39 -0
- package/dist/test/constant/color.js +43 -0
- package/dist/test/constant/datetime.js +5 -0
- package/dist/test/constant/general.js +9 -0
- package/dist/test/constant/message.js +8 -0
- package/dist/test/constant/mqtt.js +11 -0
- package/dist/test/constant/user.js +9 -0
- package/dist/test/lib/utils.js +5 -0
- package/dist/test/plugins/axios-gci.js +25 -0
- package/dist/test/plugins/axios.js +85 -0
- package/dist/test/plugins/mqtt.js +128 -0
- package/dist/test/plugins/sdk.js +83 -0
- package/dist/test/plugins/websocket.js +65 -0
- package/dist/test/types/call.js +1 -0
- package/dist/test/types/chat/auth.js +1 -0
- package/dist/test/types/chat/global.js +1 -0
- package/dist/test/types/chat/promise.js +1 -0
- package/dist/test/types/chat/user.js +1 -0
- package/dist/test/types/conversation.js +1 -0
- package/dist/test/types/global.js +15 -0
- package/dist/test/types/message.js +1 -0
- package/dist/test/utils/chat/auth.js +51 -0
- package/dist/test/utils/chat/call.js +61 -0
- package/dist/test/utils/chat/chat-router.js +8 -0
- package/dist/test/utils/chat/conversation.js +7 -0
- package/dist/test/utils/chat/message.js +42 -0
- package/dist/test/utils/chat/user.js +33 -0
- package/dist/test/utils/debounce.js +9 -0
- package/dist/test/utils/json.js +18 -0
- package/dist/test/utils/logger.js +5 -0
- package/dist/test/utils/string-helper.js +27 -0
- package/dist/types/call.d.ts +4 -0
- package/dist/types/chat/auth.d.ts +37 -0
- package/dist/types/chat/global.d.ts +7 -0
- package/dist/types/chat/promise.d.ts +17 -0
- package/dist/types/chat/user.d.ts +88 -0
- package/dist/types/conversation.d.ts +18 -0
- package/dist/types/global.d.ts +11 -0
- package/dist/types/message.d.ts +43 -0
- package/dist/utils/chat/auth.d.ts +45 -0
- package/dist/utils/chat/call.d.ts +5 -0
- package/dist/utils/chat/chat-router.d.ts +3 -0
- package/dist/utils/chat/conversation.d.ts +3 -0
- package/dist/utils/chat/message.d.ts +17 -0
- package/dist/utils/chat/user.d.ts +193 -0
- package/dist/utils/debounce.d.ts +1 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/string-helper.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//PINIA
|
|
2
|
+
export const digibotData = {
|
|
3
|
+
id: -98,
|
|
4
|
+
receiver_id: 101,
|
|
5
|
+
username: 'digibot',
|
|
6
|
+
customer_phone: '',
|
|
7
|
+
avatar: '',
|
|
8
|
+
last_message: '',
|
|
9
|
+
last_message_time: '',
|
|
10
|
+
created_at: '',
|
|
11
|
+
updated_at: '',
|
|
12
|
+
unread_count: 0,
|
|
13
|
+
status: 1,
|
|
14
|
+
color: '#4F46E5',
|
|
15
|
+
};
|
|
16
|
+
export const digibotId = -98;
|
|
17
|
+
export function useDigibot() {
|
|
18
|
+
return {
|
|
19
|
+
digibotData,
|
|
20
|
+
digibotId,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import { sdkInit } from '../plugins/sdk';
|
|
3
|
+
import { dataProfile, getProfile, loginLink } from '../utils/chat/auth';
|
|
4
|
+
import { routerPush } from '../utils/chat/chat-router';
|
|
5
|
+
import { PAGE } from '../constant/general';
|
|
6
|
+
import { subscribeToTopic, unsubscribeFromTopic } from '../plugins/mqtt';
|
|
7
|
+
import { TOPIC_DETAIL_CALL } from '../constant/mqtt';
|
|
8
|
+
import { getWebSocket } from '../plugins/websocket';
|
|
9
|
+
//PINIA
|
|
10
|
+
export const isRouterReady = ref(false);
|
|
11
|
+
export function useInitData() {
|
|
12
|
+
const NOTIFY_ID_APPOINTMENT_NAME = 'notifyIdAppointment';
|
|
13
|
+
const initPage = async (data) => {
|
|
14
|
+
try {
|
|
15
|
+
isRouterReady.value = false;
|
|
16
|
+
const sdk_res = await sdkInit({ id: data.id, token: data.token, domain: data.domain });
|
|
17
|
+
if (sdk_res.tenant_error) {
|
|
18
|
+
const api_link_res = await loginApiLink();
|
|
19
|
+
// if (api_link_res.client_error) {
|
|
20
|
+
// routerPush(PAGE.TENANT_ERROR)
|
|
21
|
+
// return
|
|
22
|
+
// }
|
|
23
|
+
}
|
|
24
|
+
// connectMqtt()
|
|
25
|
+
await initData();
|
|
26
|
+
if (data.response == 'mobile') {
|
|
27
|
+
routerPush(PAGE.CHAT_LIST);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
routerPush(PAGE.HOME);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.log(error);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
isRouterReady.value = true;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const initData = async () => {
|
|
41
|
+
await getProfile();
|
|
42
|
+
getWebSocket();
|
|
43
|
+
unsubscribeFromTopic(TOPIC_DETAIL_CALL + dataProfile.value?.id);
|
|
44
|
+
subscribeToTopic(TOPIC_DETAIL_CALL + dataProfile.value?.id);
|
|
45
|
+
};
|
|
46
|
+
const loginApiLink = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const queryString = window.location.search;
|
|
49
|
+
const urlParams = new URLSearchParams(queryString);
|
|
50
|
+
const tenant_id = urlParams.get('tenant_id') || '';
|
|
51
|
+
const phone = urlParams.get('phone') || '';
|
|
52
|
+
const message = urlParams.get('message') || '';
|
|
53
|
+
const customer_name = urlParams.get('customer_name') || '';
|
|
54
|
+
const business_name = urlParams.get('business_name') || '';
|
|
55
|
+
if (!tenant_id || !phone || !message || !customer_name || !business_name)
|
|
56
|
+
return { client_error: true };
|
|
57
|
+
const param = {
|
|
58
|
+
tenant_id,
|
|
59
|
+
phone,
|
|
60
|
+
message,
|
|
61
|
+
customer_name,
|
|
62
|
+
business_name
|
|
63
|
+
};
|
|
64
|
+
await loginLink(param);
|
|
65
|
+
clearApiParams();
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.log(error);
|
|
70
|
+
return { client_error: true };
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const clearApiParams = () => {
|
|
76
|
+
const url = new URL(window.location.href);
|
|
77
|
+
url.search = "";
|
|
78
|
+
window.history.replaceState({}, document.title, url);
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
NOTIFY_ID_APPOINTMENT_NAME,
|
|
82
|
+
initPage
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
// export type ConfirmPayload = {
|
|
3
|
+
// headerTitle?: string
|
|
4
|
+
// bodyTitle?: string
|
|
5
|
+
// bodyImage?: string
|
|
6
|
+
// bodyMessage?: string
|
|
7
|
+
// confirmButtonText?: string
|
|
8
|
+
// cancelButtonText?: string
|
|
9
|
+
// timeOut?: number //seconds
|
|
10
|
+
// type?: 'confirm' | 'information'
|
|
11
|
+
// }
|
|
12
|
+
//
|
|
13
|
+
// export type ConfirmPayloadPromise = AddPromise<ConfirmPayload>
|
|
14
|
+
const handleConfirm = ref(null);
|
|
15
|
+
function setHandleConfirm(callback) {
|
|
16
|
+
handleConfirm.value = callback;
|
|
17
|
+
}
|
|
18
|
+
export function useModalConfirm() {
|
|
19
|
+
function setHandleConfirm(callback) {
|
|
20
|
+
handleConfirm.value = callback;
|
|
21
|
+
}
|
|
22
|
+
function modalConfirm(data) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
if (handleConfirm.value == null) {
|
|
25
|
+
reject('Modal is not already active');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
handleConfirm.value({
|
|
29
|
+
...data,
|
|
30
|
+
resolve,
|
|
31
|
+
reject
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
setHandleConfirm,
|
|
37
|
+
modalConfirm
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export var Status_Color;
|
|
2
|
+
(function (Status_Color) {
|
|
3
|
+
Status_Color["Orange"] = "#F2994A";
|
|
4
|
+
Status_Color["Blue_Teal"] = "#F2994A";
|
|
5
|
+
})(Status_Color || (Status_Color = {}));
|
|
6
|
+
var Color;
|
|
7
|
+
(function (Color) {
|
|
8
|
+
Color["Primary"] = "#0051E6";
|
|
9
|
+
Color["Primary_Hover"] = "#699FF5";
|
|
10
|
+
Color["Primary_RGB"] = "41, 121, 255";
|
|
11
|
+
Color["Error"] = "#ff3b3b";
|
|
12
|
+
Color["Error_Hover"] = "#FF8A75";
|
|
13
|
+
Color["Success"] = "#1DA91D";
|
|
14
|
+
Color["Success_Hover"] = "#5FD9A0";
|
|
15
|
+
Color["Success_Bg"] = "#E9FFE4";
|
|
16
|
+
Color["Warning"] = "#f3a22c";
|
|
17
|
+
Color["Text"] = "#333333";
|
|
18
|
+
Color["Link"] = "#1890ff";
|
|
19
|
+
Color["Default_Appointment"] = "#rgb(244, 185, 124)";
|
|
20
|
+
Color["Done_Appointment"] = "#00d652";
|
|
21
|
+
Color["Cancel_Appointment"] = "#ff0000";
|
|
22
|
+
})(Color || (Color = {}));
|
|
23
|
+
export default Color;
|
|
24
|
+
export function defineRootColor() {
|
|
25
|
+
const root = document.querySelector(':root');
|
|
26
|
+
if (root) {
|
|
27
|
+
root.style?.setProperty('--chat-color-primary', Color.Primary);
|
|
28
|
+
// root.style?.setProperty('--chat-color-primary_hover', Color.Primary_Hover)
|
|
29
|
+
// root.style?.setProperty('--chat-color-primary_rgb', Color.Primary_RGB)
|
|
30
|
+
// root.style?.setProperty('--chat-color-error', Color.Error)
|
|
31
|
+
// root.style?.setProperty('--chat-color-error_hover', Color.Error_Hover)
|
|
32
|
+
root.style?.setProperty('--chat-color-success', Color.Success);
|
|
33
|
+
// root.style?.setProperty('--chat-color-success-bg', Color.Success_Bg)
|
|
34
|
+
// root.style?.setProperty('--chat-color-success_hover', Color.Success_Hover)
|
|
35
|
+
// root.style?.setProperty('--chat-color-second-success', Color.Success)
|
|
36
|
+
// root.style?.setProperty('--chat-color-warning', Color.Warning)
|
|
37
|
+
// root.style?.setProperty('--chat-color-text', Color.Text)
|
|
38
|
+
// root.style?.setProperty('--chat-color-link', Color.Link)
|
|
39
|
+
// root.style?.setProperty('--chat-color-default_appointment', Color.Default_Appointment)
|
|
40
|
+
// root.style?.setProperty('--chat-color-done_appointment', Color.Done_Appointment)
|
|
41
|
+
// root.style?.setProperty('--chat-color-cancel_appointment', Color.Cancel_Appointment)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var PAGE;
|
|
2
|
+
(function (PAGE) {
|
|
3
|
+
PAGE["HOME"] = "home";
|
|
4
|
+
PAGE["CUSTOMER_DETAIL"] = "customer_detail";
|
|
5
|
+
PAGE["CUSTOMER_CHECK_IN"] = "customer_check_in";
|
|
6
|
+
PAGE["CUSTOMER_APPOINTMENT"] = "customer_appointment";
|
|
7
|
+
PAGE["TENANT_ERROR"] = "tenant_error";
|
|
8
|
+
PAGE["CHAT_LIST"] = "chat_list";
|
|
9
|
+
})(PAGE || (PAGE = {}));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const TOPIC_DETAIL_CHAT = 'chat/message/';
|
|
2
|
+
export const TOPIC_DETAIL_CALL = 'call/message/';
|
|
3
|
+
export const TOPIC_HOME = [
|
|
4
|
+
'chat/conversation/update/',
|
|
5
|
+
'chat/conversation/read_message/',
|
|
6
|
+
'chat/conversation/update_list/'
|
|
7
|
+
];
|
|
8
|
+
export const TOPIC_STATUS_USER = 'user/status/';
|
|
9
|
+
// export CALL_STATE = {
|
|
10
|
+
// Offer: 'offer',
|
|
11
|
+
// }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var CalendarStatus;
|
|
2
|
+
(function (CalendarStatus) {
|
|
3
|
+
CalendarStatus["Confirmed"] = "confirmed";
|
|
4
|
+
CalendarStatus["Scheduled"] = "scheduled";
|
|
5
|
+
CalendarStatus["Canceled"] = "canceled";
|
|
6
|
+
CalendarStatus["Done"] = "done";
|
|
7
|
+
CalendarStatus["Reminder"] = "reminder";
|
|
8
|
+
CalendarStatus["Waiting"] = "wait_list";
|
|
9
|
+
})(CalendarStatus || (CalendarStatus = {}));
|
|
@@ -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?.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,85 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const baseURL = 'https://go-chat.dev01.dtsmart.dev/';
|
|
3
|
+
// const baseURL = 'http://192.168.1.152:8085/'
|
|
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
|
+
console.log(newToken, 'asgfasf');
|
|
72
|
+
processQueue(null, newToken);
|
|
73
|
+
return instance(originalRequest);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
processQueue(err, null);
|
|
77
|
+
return Promise.reject(err);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
isRefreshing = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return Promise.reject(error.response?.data || error);
|
|
84
|
+
});
|
|
85
|
+
export default instance;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import mqtt from 'mqtt/dist/mqtt.min';
|
|
2
|
+
const mqttOptions = { qos: 1, retain: false };
|
|
3
|
+
// const mqttClient = ref<MqttClient | null>(null)
|
|
4
|
+
let mqttClient = null;
|
|
5
|
+
const subscribedTopics = new Set();
|
|
6
|
+
let dataCallBack = [];
|
|
7
|
+
export const connectMqtt = () => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
console.log(mqttClient);
|
|
10
|
+
if (mqttClient && mqttClient?.connected) {
|
|
11
|
+
console.log('MQTT already connected');
|
|
12
|
+
return resolve();
|
|
13
|
+
}
|
|
14
|
+
const userInfo = JSON.parse(localStorage.getItem('user') || '{}');
|
|
15
|
+
const clientId = userInfo?.id;
|
|
16
|
+
const MQTT_OPTIONS = {
|
|
17
|
+
clientId: `${clientId}_${Date.now()}_${Math.floor(Math.random() * 1000)}`,
|
|
18
|
+
host: 'mqtt-digital-signage.dev01.dtsmart.dev',
|
|
19
|
+
port: 443,
|
|
20
|
+
protocol: 'wss',
|
|
21
|
+
username: 'admin123',
|
|
22
|
+
password: 'admin123',
|
|
23
|
+
clean: true,
|
|
24
|
+
reconnectPeriod: 1000,
|
|
25
|
+
path: '/mqtt'
|
|
26
|
+
};
|
|
27
|
+
const { host, port, path, ...options } = MQTT_OPTIONS;
|
|
28
|
+
const connectUrl = `wss://${host}:${port}${path}`;
|
|
29
|
+
mqttClient = mqtt.connect(connectUrl, options);
|
|
30
|
+
mqttClient?.on('connect', () => {
|
|
31
|
+
console.log('MQTT Connected Successfully');
|
|
32
|
+
subscribedTopics.forEach((topic) => mqttClient?.subscribe(topic));
|
|
33
|
+
mqttClient?.on('message', (topic, message) => {
|
|
34
|
+
try {
|
|
35
|
+
let data = message;
|
|
36
|
+
if (message instanceof Uint8Array) {
|
|
37
|
+
const decoder = new TextDecoder('utf-8');
|
|
38
|
+
data = JSON.parse(decoder.decode(message));
|
|
39
|
+
}
|
|
40
|
+
dataCallBack
|
|
41
|
+
.filter((e) => e.topic === topic)
|
|
42
|
+
.forEach((e) => {
|
|
43
|
+
e.callBack(topic, data);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
console.error('Error parsing message:', e);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
resolve();
|
|
51
|
+
});
|
|
52
|
+
mqttClient?.on('close', () => {
|
|
53
|
+
console.log('MQTT Disconnected');
|
|
54
|
+
});
|
|
55
|
+
mqttClient?.on('error', (err) => {
|
|
56
|
+
console.error('MQTT Error:', err);
|
|
57
|
+
reject(err);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export const disconnectMqtt = () => {
|
|
62
|
+
if (mqttClient) {
|
|
63
|
+
mqttClient?.end(false, {}, () => {
|
|
64
|
+
console.log('MQTT Disconnected');
|
|
65
|
+
mqttClient = null;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export const subscribeToTopic = (topic) => {
|
|
70
|
+
if (subscribedTopics.has(topic)) {
|
|
71
|
+
console.log(`Already subscribed to ${topic}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (mqttClient?.connected || true) {
|
|
75
|
+
mqttClient?.subscribe(topic, mqttOptions, (err) => {
|
|
76
|
+
if (!err) {
|
|
77
|
+
subscribedTopics.add(topic);
|
|
78
|
+
console.log(`Subscribed to ${topic}`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.error(`Failed to subscribe ${topic}`, err);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export const unsubscribeFromTopic = (topic) => {
|
|
87
|
+
if (mqttClient?.connected || true) {
|
|
88
|
+
mqttClient?.unsubscribe(topic, (err) => {
|
|
89
|
+
if (!err) {
|
|
90
|
+
subscribedTopics.delete(topic);
|
|
91
|
+
console.log(`Unsubscribed from ${topic}`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.error(`Failed to unsubscribe ${topic}`, err);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
subscribedTopics.delete(topic);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
export const publishMessage = (topic, payload) => {
|
|
103
|
+
if (mqttClient?.connected && payload) {
|
|
104
|
+
const message = typeof payload !== 'string' ? JSON.stringify(payload) : payload;
|
|
105
|
+
mqttClient?.publish(topic, message, { qos: 1, retain: false }, (err) => {
|
|
106
|
+
if (!err) {
|
|
107
|
+
// console.log(`Published message to ${topic}`)
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.error(`Failed to publish message to ${topic}`, err);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.warn('MQTT not connected, cannot publish');
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export const addHandleMqttMessage = (key, topic, callBack) => {
|
|
119
|
+
removeHandleMqttMessage(key);
|
|
120
|
+
dataCallBack.push({ key, callBack, topic });
|
|
121
|
+
};
|
|
122
|
+
export const removeHandleMqttMessage = (key) => {
|
|
123
|
+
const index = dataCallBack.findIndex((e) => e.key === key);
|
|
124
|
+
if (index > -1) {
|
|
125
|
+
dataCallBack.splice(index, 1);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export const getMqttInstance = () => mqttClient;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import Gap, { GapApiVersion } from 'gap-nodejs-sdk';
|
|
2
|
+
import { GapMiniAppSdk } from 'gap-miniapp-sdk';
|
|
3
|
+
import logger from '../utils/logger';
|
|
4
|
+
import { loginTenant, setDataLogin } from '../utils/chat/auth';
|
|
5
|
+
import { setAxiosGciInstance } from '../plugins/axios-gci';
|
|
6
|
+
const baseSdk = new Gap.BaseApi(GapApiVersion.V1);
|
|
7
|
+
const gapMiniAppSdk = (function () {
|
|
8
|
+
let instance;
|
|
9
|
+
// let domain = '';
|
|
10
|
+
// let gClient = '';
|
|
11
|
+
// let token = '';
|
|
12
|
+
// if (process.env.NODE_ENV === "development") {
|
|
13
|
+
// domain = import.meta.env.VITE_DOMAIN;
|
|
14
|
+
// gClient = import.meta.env.VITE_GCLIENT_ID;
|
|
15
|
+
// token = import.meta.env.VITE_TOKEN;
|
|
16
|
+
// }
|
|
17
|
+
function createInstance() {
|
|
18
|
+
return new GapMiniAppSdk(logger);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
getInstance: function () {
|
|
22
|
+
if (!instance) {
|
|
23
|
+
instance = createInstance();
|
|
24
|
+
}
|
|
25
|
+
return instance;
|
|
26
|
+
},
|
|
27
|
+
getAccessToken: async function () {
|
|
28
|
+
let domain = '';
|
|
29
|
+
let gClient = '';
|
|
30
|
+
let token = '';
|
|
31
|
+
try {
|
|
32
|
+
let userAgent;
|
|
33
|
+
if (gapMiniAppSdk.getInstance().detectPlatform()) {
|
|
34
|
+
userAgent = gapMiniAppSdk.getInstance().detectPlatform();
|
|
35
|
+
}
|
|
36
|
+
if (userAgent) {
|
|
37
|
+
gapMiniAppSdk.getInstance().setPlatformExecutor(userAgent);
|
|
38
|
+
const response = await gapMiniAppSdk.getInstance().getAccessToken();
|
|
39
|
+
if (response &&
|
|
40
|
+
typeof response.token !== 'undefined' &&
|
|
41
|
+
response.token != '') {
|
|
42
|
+
domain = response.domain;
|
|
43
|
+
gClient = response.gClientId;
|
|
44
|
+
token = response.token;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(error);
|
|
50
|
+
}
|
|
51
|
+
return { domain, gClient, token };
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
55
|
+
const sdkInit = (data) => {
|
|
56
|
+
return new Promise(async (resolve, reject) => {
|
|
57
|
+
let status = false;
|
|
58
|
+
try {
|
|
59
|
+
let { domain, gClient, token } = await gapMiniAppSdk.getAccessToken();
|
|
60
|
+
domain = data.domain || domain || '';
|
|
61
|
+
gClient = data.id || gClient || '';
|
|
62
|
+
token = data.token || token || '';
|
|
63
|
+
if (!domain || !gClient || !token) {
|
|
64
|
+
resolve({ status, tenant_error: true });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setAxiosGciInstance(token, domain, gClient);
|
|
68
|
+
await loginTenant({ tenant_id: gClient });
|
|
69
|
+
status = true;
|
|
70
|
+
setDataLogin(gClient, token, domain);
|
|
71
|
+
localStorage.setItem('chat_id', gClient);
|
|
72
|
+
localStorage.setItem('chat_accessToken', token);
|
|
73
|
+
localStorage.setItem('chat_domain', domain);
|
|
74
|
+
resolve({ status });
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
resolve({ status, tenant_error: true });
|
|
78
|
+
console.error(error);
|
|
79
|
+
// reject(error)
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
export { sdkInit, gapMiniAppSdk, baseSdk };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { tryParseJson } from '../utils/json';
|
|
2
|
+
let socket = null;
|
|
3
|
+
let dataCallBack = [];
|
|
4
|
+
export function initWebSocket(server) {
|
|
5
|
+
// Create WebSocket connection.
|
|
6
|
+
socket = new WebSocket('wss://web-socket.dev01.dtsmart.dev');
|
|
7
|
+
// socket.addEventListener('open', (event: any) => {
|
|
8
|
+
// console.log('fffffff')
|
|
9
|
+
// socket.send('Hello Server!')
|
|
10
|
+
// })
|
|
11
|
+
//
|
|
12
|
+
// socket.addEventListener('message', (event: any) => {
|
|
13
|
+
// console.log('Message from server ', event.data)
|
|
14
|
+
// })
|
|
15
|
+
socket.onopen = (event) => {
|
|
16
|
+
console.log('Connected!');
|
|
17
|
+
};
|
|
18
|
+
socket.onmessage = (event) => {
|
|
19
|
+
const data = tryParseJson(event.data);
|
|
20
|
+
dataCallBack.forEach((e) => {
|
|
21
|
+
e.callBack(data);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
socket.onclose = (event) => {
|
|
25
|
+
console.log('Disconnected:', event.reason);
|
|
26
|
+
};
|
|
27
|
+
socket.onerror = (event) => {
|
|
28
|
+
console.error('Socket error:', event);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const socketSend = (data) => {
|
|
32
|
+
let request = typeof data == 'string' ? data : JSON.stringify(data);
|
|
33
|
+
socket.send(request);
|
|
34
|
+
};
|
|
35
|
+
export const getWebSocket = async () => {
|
|
36
|
+
const url = 'https://web-socket.dev01.dtsmart.dev/ws/connect';
|
|
37
|
+
try {
|
|
38
|
+
const response = await fetch(url, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
clientId: 'test1'
|
|
42
|
+
}),
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: 'Bearer -Qixt-ZztiBA5Dxl-EIWG7f2TDhK-ZCj'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
throw new Error(`Response status: ${response.status}`);
|
|
49
|
+
}
|
|
50
|
+
const result = await response.json();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error(error.message);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const addHandleWebSK = (key, callBack) => {
|
|
57
|
+
removeHandleWebSK(key);
|
|
58
|
+
dataCallBack.push({ key, callBack });
|
|
59
|
+
};
|
|
60
|
+
export const removeHandleWebSK = (key) => {
|
|
61
|
+
const index = dataCallBack.findIndex((e) => e.key === key);
|
|
62
|
+
if (index > -1) {
|
|
63
|
+
dataCallBack.splice(index, 1);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
// declare global {
|
|
3
|
+
// /**
|
|
4
|
+
// * Now declare things that go in the global namespace,
|
|
5
|
+
// * or augment existing declarations in the global namespace.
|
|
6
|
+
// */
|
|
7
|
+
// type AddPromise<T = unknown> = T & {
|
|
8
|
+
// resolve: Resolve
|
|
9
|
+
// reject?: Reject
|
|
10
|
+
// }
|
|
11
|
+
//
|
|
12
|
+
// // PROMISE
|
|
13
|
+
// declare type Resolve = typeof ReturnType<Promise.resolve>
|
|
14
|
+
// declare type Reject = typeof ReturnType<Promise.reject>
|
|
15
|
+
// }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|