cnhis-design-vue 3.4.0-beta.9 → 3.4.0-release.7
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/es/_virtual/_virtual_i18n-methods.js +5 -1
- package/es/components/audio-sdk/index.d.ts +4 -4
- package/es/components/audio-sdk/src/Index.vue.d.ts +4 -4
- package/es/components/audio-sdk/src/components/recording-modal.vue.d.ts +4 -4
- package/es/components/audio-sdk/src/components/recording.vue.d.ts +4 -4
- package/es/components/base-search/index.d.ts +34 -0
- package/es/components/base-search/src/index.vue.d.ts +34 -0
- package/es/components/base-search/src/index.vue2.js +9 -1
- package/es/components/button-print/index.d.ts +32 -0
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +32 -0
- package/es/components/button-print/src/ButtonPrint.vue2.js +4 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +4 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue2.js +77 -50
- package/es/components/button-print/src/components/OldPrintComponent.vue.d.ts +11 -0
- package/es/components/button-print/src/components/OldPrintComponent.vue2.js +35 -0
- package/es/components/button-print/src/utils/print.d.ts +2 -1
- package/es/components/button-print/src/utils/print.js +13 -8
- package/es/components/callback/src/components/render/popupMaps.d.ts +110 -222
- package/es/components/classification/index.d.ts +123 -0
- package/es/components/classification/src/components/search-filter/index.vue.d.ts +123 -0
- package/es/components/classification/src/components/set-classification/index.vue.d.ts +123 -0
- package/es/components/classification/src/index.vue.d.ts +123 -0
- package/es/components/classification/src/index.vue2.js +7 -0
- package/es/components/date-picker/index.d.ts +41 -0
- package/es/components/date-picker/src/DatePicker.vue.d.ts +41 -0
- package/es/components/date-picker/src/DatePicker.vue2.js +34 -4
- package/es/components/expand-field/index.d.ts +31 -0
- package/es/components/expand-field/src/components/FormItemPerson.vue.d.ts +31 -0
- package/es/components/expand-field/src/components/PersonModal.vue.d.ts +31 -0
- package/es/components/expand-field/src/components/form.vue.d.ts +31 -0
- package/es/components/expand-field/src/index.vue.d.ts +31 -0
- package/es/components/fabric-chart/index.d.ts +3 -3
- package/es/components/fabric-chart/src/FabricChart.vue.d.ts +3 -3
- package/es/components/fabric-chart/src/FabricChart.vue2.js +1 -0
- package/es/components/fabric-chart/src/components/PopupMenu.d.ts +4 -4
- package/es/components/fabric-chart/src/components/PopupMenu.js +57 -39
- package/es/components/fabric-chart/src/constants/index.d.ts +19 -5
- package/es/components/fabric-chart/src/constants/index.js +26 -11
- package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcess.d.ts +4 -3
- package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcess.js +119 -193
- package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcessChart.js +69 -117
- package/es/components/fabric-chart/src/hooks/electrocardiogram/hooks/useDetailEvent.js +18 -12
- package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogram.d.ts +1 -1
- package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogram.js +61 -33
- package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogramChart.d.ts +2 -2
- package/es/components/fabric-chart/src/hooks/electrocardiogram/useElectrocardiogramChart.js +86 -120
- package/es/components/fabric-chart/src/hooks/electrocardiogram/useMeasureInstrument.js +1 -0
- package/es/components/fabric-chart/src/hooks/newBirthProcess/useNewBirthProcessChart.js +65 -113
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useCenter.d.ts +4 -3
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useCenter.js +63 -37
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useLeft.js +31 -14
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useOther.d.ts +4 -3
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useOther.js +21 -14
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useSurgicalAnesthesiaChart.js +152 -208
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useTop.d.ts +4 -3
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useTop.js +8 -9
- package/es/components/fabric-chart/src/hooks/temperature/useBottom.js +1 -0
- package/es/components/fabric-chart/src/hooks/temperature/useCenter.d.ts +4 -3
- package/es/components/fabric-chart/src/hooks/temperature/useCenter.js +138 -229
- package/es/components/fabric-chart/src/hooks/temperature/useOther.js +16 -14
- package/es/components/fabric-chart/src/hooks/temperature/useTemperatureChart.js +195 -273
- package/es/components/fabric-chart/src/hooks/temperature/useTop.js +1 -0
- package/es/components/fabric-chart/src/interface.d.ts +15 -1
- package/es/components/fabric-chart/src/utils/eventBus.d.ts +2 -0
- package/es/components/fabric-chart/src/utils/eventBus.js +5 -0
- package/es/components/fabric-chart/src/utils/index.d.ts +1 -1
- package/es/components/fabric-chart/src/utils/index.js +2 -10
- package/es/components/fabric-chart/style/index.css +1 -1
- package/es/components/field-editor/index.d.ts +1 -0
- package/es/components/field-editor/src/FieldEditor.vue.d.ts +1 -0
- package/es/components/field-set/src/FieldColor.vue.d.ts +83 -1
- package/es/components/field-set/src/FieldColor.vue2.js +2 -1
- package/es/components/field-set/src/FieldFilter.vue.d.ts +1 -1
- package/es/components/field-set/src/FieldFilter.vue2.js +2 -1
- package/es/components/field-set/src/FieldSet.vue.d.ts +2 -2
- package/es/components/field-set/src/FieldSet.vue2.js +4 -1
- package/es/components/field-set/src/components/condition.vue.d.ts +41 -0
- package/es/components/field-set/src/components/edit-dialog.vue.d.ts +82 -0
- package/es/components/field-set/src/components/edit-filter.vue.d.ts +41 -0
- package/es/components/field-set/src/components/table-row.vue.d.ts +1 -1
- package/es/components/field-set/src/components/table-row.vue2.js +1 -0
- package/es/components/form-config/index.d.ts +24 -0
- package/es/components/form-config/src/FormConfig.vue.d.ts +24 -0
- package/es/components/form-config/src/components/FormConfigCreator.vue.d.ts +1 -0
- package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +19 -0
- package/es/components/form-config/src/components/FormConfigEdit.vue2.js +48 -24
- package/es/components/form-config/src/components/FormConfigEventSetting.vue.d.ts +1 -0
- package/es/components/form-config/src/constants/index.d.ts +2 -0
- package/es/components/form-config/src/constants/index.js +2 -0
- package/es/components/form-config/src/hooks/useConfigurationField.js +20 -3
- package/es/components/form-render/index.d.ts +1 -0
- package/es/components/form-render/src/FormRender.vue.d.ts +1 -0
- package/es/components/form-render/src/FormRenderWrapper.vue.d.ts +1 -0
- package/es/components/form-render/src/components/renderer/combination/hooks/useCombination.js +1 -1
- package/es/components/form-render/src/components/renderer/combination/jsonCombination.js +1 -0
- package/es/components/form-render/src/components/renderer/lineBar/FormCollapse.vue.d.ts +1 -0
- package/es/components/form-render/src/components/renderer/lineBar/index.d.ts +1 -0
- package/es/components/form-render/src/components/renderer/radio_checkbox.js +3 -2
- package/es/components/form-render/src/components/renderer/textarea.d.ts +2 -2
- package/es/components/form-render/src/components/renderer/textarea.js +1 -1
- package/es/components/form-render/src/hooks/useFieldNormalize.d.ts +2 -0
- package/es/components/form-render/src/hooks/useFormEvent.js +1 -1
- package/es/components/form-render/src/hooks/useNewLowCodeReactions.js +8 -0
- package/es/components/form-render/src/types/index.d.ts +1 -0
- package/es/components/form-render/src/utils/index.d.ts +1 -1
- package/es/components/form-render/src/utils/index.js +5 -2
- package/es/components/iho-chat/index.d.ts +2785 -302
- package/es/components/iho-chat/src/Index.vue.d.ts +2785 -302
- package/es/components/iho-chat/src/Index.vue2.js +5 -3
- package/es/components/iho-chat/src/api/index.d.ts +89 -16
- package/es/components/iho-chat/src/api/index.js +8 -1
- package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +104 -22
- package/es/components/iho-chat/src/components/ChatFile.vue.d.ts +191 -29
- package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +191 -29
- package/es/components/iho-chat/src/components/ChatFooter.vue2.js +3 -0
- package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +796 -101
- package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +611 -51
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +27 -28
- package/es/components/iho-chat/src/components/ChatRecord.vue.d.ts +217 -14
- package/es/components/iho-chat/src/components/ChatSearch.vue.d.ts +175 -10
- package/es/components/iho-chat/src/components/ChatSearch.vue2.js +2 -1
- package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +197 -29
- package/es/components/iho-chat/src/components/ChatSet.vue2.js +48 -11
- package/es/components/iho-chat/src/components/ContextMenu.js +7 -10
- package/es/components/iho-chat/src/components/MessageEvent.vue.d.ts +88 -7
- package/es/components/iho-chat/src/components/MessageMarkdown.vue.d.ts +158 -0
- package/es/components/iho-chat/src/components/MessageMarkdown.vue.js +6 -0
- package/es/components/iho-chat/src/components/MessageMarkdown.vue2.js +51 -0
- package/es/components/iho-chat/src/components/MessageMergeForward.vue.d.ts +176 -14
- package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +192 -29
- package/es/components/iho-chat/src/components/MultipleVideo.vue2.js +2 -1
- package/es/components/iho-chat/src/components/PersonProfile.vue.d.ts +91 -8
- package/es/components/iho-chat/src/components/SiderList.vue.d.ts +134 -11
- package/es/components/iho-chat/src/components/Video.vue.d.ts +89 -8
- package/es/components/iho-chat/src/components/userItemRender.js +2 -1
- package/es/components/iho-chat/src/constants/index.d.ts +2 -1
- package/es/components/iho-chat/src/constants/index.js +1 -0
- package/es/components/iho-chat/src/hooks/useData.d.ts +374 -27
- package/es/components/iho-chat/src/hooks/useData.js +31 -10
- package/es/components/iho-chat/src/hooks/useStreamOutput.d.ts +6 -0
- package/es/components/iho-chat/src/hooks/useStreamOutput.js +100 -0
- package/es/components/iho-chat/src/hooks/useVideo.d.ts +89 -7
- package/es/components/iho-chat/src/hooks/useWebSocket.js +14 -4
- package/es/components/iho-chat/src/types/index.d.ts +39 -7
- package/es/components/iho-chat/src/utils/index.d.ts +2 -1
- package/es/components/iho-chat/src/utils/sseClient.d.ts +22 -0
- package/es/components/iho-chat/src/utils/sseClient.js +97 -0
- package/es/components/iho-chat/style/index.css +1 -1
- package/es/components/iho-table/index.d.ts +109 -222
- package/es/components/iho-table/src/IhoTable.vue.d.ts +109 -222
- package/es/components/iho-table/src/IhoTable.vue2.js +23 -14
- package/es/components/iho-table/src/constants/index.d.ts +3 -3
- package/es/components/iho-table/src/constants/index.js +0 -21
- package/es/components/iho-table/src/hooks/tapHooks/index.d.ts +39 -60
- package/es/components/iho-table/src/hooks/tapHooks/useEventHooks.d.ts +1 -1
- package/es/components/iho-table/src/hooks/useColumnConfigAdaptor.js +1 -1
- package/es/components/iho-table/src/plugins/filterDaterangeRenderPlugin/filter.vue.d.ts +43 -4
- package/es/components/iho-table/src/plugins/filterDaterangeRenderPlugin/filter.vue2.js +22 -8
- package/es/components/iho-table/src/plugins/highLightSetPlugin.js +7 -2
- package/es/components/iho-table/src/plugins/lowCodeFieldAdaptorPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/editDate.vue.d.ts +41 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/dateRendererPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/hooks/useAutoFocus.js +25 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/inputRendererPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/levelSearchCascadePlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/levelSearchCascadePlugin/levelSearchCascade.vue.d.ts +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/numberRendererPlugin.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/selectRendererPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/editSeparate.vue.d.ts +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/index.js +1 -1
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/utils.d.ts +1 -1
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/utils.js +8 -2
- package/es/components/iho-table/src/types/index.d.ts +3 -1
- package/es/components/index.css +1 -1
- package/es/components/info-header/index.d.ts +46 -2
- package/es/components/info-header/src/InfoHeader.vue.d.ts +46 -2
- package/es/components/info-header/src/components/infoDescription/DescriptionItem.vue.d.ts +41 -2
- package/es/components/info-header/src/components/infoDescription/DescriptionItem.vue2.js +2 -1
- package/es/components/info-header/src/components/infoDescription/DescriptionList.vue.d.ts +41 -2
- package/es/components/info-header/src/components/infoDescription/HiddenContent.vue.d.ts +20 -1
- package/es/components/info-header/src/components/infoDescription/InfoEllipsis.vue.d.ts +20 -1
- package/es/components/info-header/src/components/infoDescription/InfoEllipsis.vue2.js +9 -6
- package/es/components/info-header/src/components/infoDescription/index.vue.d.ts +42 -2
- package/es/components/info-header/src/components/infoDescription/index.vue2.js +1 -1
- package/es/components/info-header/src/components/patientInfo/index.vue.d.ts +1 -0
- package/es/components/scale-view/index.d.ts +1 -1
- package/es/components/scale-view/src/ScaleView.vue.d.ts +1 -1
- package/es/components/scale-view/src/ScaleView.vue2.js +9 -3
- package/es/components/scale-view/src/hooks/use-event.js +56 -22
- package/es/components/select-person/index.d.ts +31 -0
- package/es/components/select-person/src/SelectPerson.vue.d.ts +14 -0
- package/es/components/select-person/src/SelectPerson.vue2.js +38 -9
- package/es/components/select-person/src/index.vue.d.ts +31 -0
- package/es/components/select-person/src/index.vue2.js +4 -0
- package/es/components/select-person/src/utils/index.js +11 -9
- package/es/components/shortcut-provider/src/hooks/useShortcuts.d.ts +3 -0
- package/es/components/shortcut-provider/src/hooks/useShortcuts.js +9 -3
- package/es/components/shortcut-setter/index.d.ts +2 -0
- package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +2 -0
- package/es/components/table-export-field/index.d.ts +6 -0
- package/es/components/table-export-field/src/components/ExportModal.vue2.js +1 -0
- package/es/components/table-export-field/src/components/SaveProjectModal.vue.d.ts +2 -0
- package/es/components/table-export-field/src/components/SaveProjectModal.vue2.js +49 -18
- package/es/components/table-export-field/src/index.vue.d.ts +6 -0
- package/es/components/table-export-field/src/types/index.d.ts +1 -0
- package/es/components/table-filter/src/components/bi-filter/ValueCfg.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/bi-filter/components/Date.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/bi-filter/components/index.d.ts +41 -0
- package/es/components/table-filter/src/components/bi-filter/index.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/classify-filter/ValueCfg.vue.d.ts +82 -0
- package/es/components/table-filter/src/components/classify-filter/components/Date.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/classify-filter/components/DateRange.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/classify-filter/components/index.d.ts +82 -0
- package/es/components/table-filter/src/components/classify-filter/index.vue.d.ts +82 -0
- package/es/components/table-filter/src/components/render-widget/components/DateInner.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/render-widget/components/DateOut.vue.d.ts +43 -0
- package/es/components/table-filter/src/components/render-widget/components/DateOut.vue2.js +10 -2
- package/es/components/table-filter/src/components/render-widget/components/DateRangeInner.vue.d.ts +41 -0
- package/es/components/table-filter/src/components/render-widget/components/DateRangeOut.vue.d.ts +43 -0
- package/es/components/table-filter/src/components/render-widget/components/DateRangeOut.vue2.js +10 -2
- package/es/components/table-filter/src/components/render-widget/components/index.d.ts +168 -0
- package/es/components/table-filter/src/components/render-widget/helpers/presetValToTimestamp.js +9 -9
- package/es/components/table-filter/src/components/render-widget/widgetCfgMaps.d.ts +168 -0
- package/es/components/table-filter/src/constants/index.d.ts +1 -0
- package/es/components/table-filter/src/constants/index.js +4 -1
- package/es/shared/components/CancelRadio/CancelRadio.js +3 -1
- package/es/shared/components/Ellipsis/Ellipsis.d.ts +12 -0
- package/es/shared/components/Ellipsis/Ellipsis.js +86 -0
- package/es/shared/components/Ellipsis/index.d.ts +2 -0
- package/es/shared/components/Ellipsis/index.js +2 -0
- package/es/shared/components/InputNumberSlash/InputNumberSlash.d.ts +15 -0
- package/es/shared/components/InputNumberSlash/InputNumberSlash.js +24 -10
- package/es/shared/package.json.js +1 -1
- package/es/shared/types/business.d.ts +3 -2
- package/es/shared/utils/business.js +16 -0
- package/es/shared/utils/ho-edge.d.ts +12 -0
- package/es/shared/utils/ho-edge.js +58 -0
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reactive, ref, computed, watch, toRef, inject, toRaw } from 'vue';
|
|
2
2
|
import { openSessionApi, updateStatusApi, groupUserApi } from '../api/index.js';
|
|
3
3
|
import { promiseTimeout, useIntervalFn } from '@vueuse/core';
|
|
4
4
|
import { isGroup, listSort, formatTime, transformMessage, $message, simplifyMessage } from '../utils/index.js';
|
|
@@ -23,7 +23,13 @@ function getLastMessageContent(session) {
|
|
|
23
23
|
return content;
|
|
24
24
|
}
|
|
25
25
|
function initData(props, emit) {
|
|
26
|
-
const stompClient =
|
|
26
|
+
const stompClient = {
|
|
27
|
+
value: null
|
|
28
|
+
};
|
|
29
|
+
const tempState = {
|
|
30
|
+
currentMsg: {},
|
|
31
|
+
updateSessionItem: {}
|
|
32
|
+
};
|
|
27
33
|
const state = reactive({
|
|
28
34
|
orgId: props.orgId,
|
|
29
35
|
currentSessionItem: {},
|
|
@@ -32,11 +38,8 @@ function initData(props, emit) {
|
|
|
32
38
|
id: props.userId
|
|
33
39
|
},
|
|
34
40
|
msgList: [],
|
|
35
|
-
currentMsg: {},
|
|
36
|
-
isAppendMsg: false,
|
|
37
41
|
sessionList: [],
|
|
38
42
|
isChangeSession: false,
|
|
39
|
-
updateSessionItem: {},
|
|
40
43
|
isUpdateSession: false,
|
|
41
44
|
currentReferenceMsg: null,
|
|
42
45
|
currentReEditMsg: null,
|
|
@@ -50,8 +53,10 @@ function initData(props, emit) {
|
|
|
50
53
|
userId: "",
|
|
51
54
|
info: null
|
|
52
55
|
},
|
|
53
|
-
isForward: false
|
|
56
|
+
isForward: false,
|
|
57
|
+
loading: false
|
|
54
58
|
});
|
|
59
|
+
const chatMainRef = ref();
|
|
55
60
|
const cssVars = useTheme();
|
|
56
61
|
const unreadTotal = computed(() => {
|
|
57
62
|
return state.sessionList.reduce((num, item) => num + +item.unreadNum, 0);
|
|
@@ -96,7 +101,7 @@ function initData(props, emit) {
|
|
|
96
101
|
state.isChangeSession = false;
|
|
97
102
|
}
|
|
98
103
|
if (isUpdateSession) {
|
|
99
|
-
updateSessionList(
|
|
104
|
+
updateSessionList(tempState.updateSessionItem);
|
|
100
105
|
state.isUpdateSession = false;
|
|
101
106
|
}
|
|
102
107
|
},
|
|
@@ -145,6 +150,17 @@ function initData(props, emit) {
|
|
|
145
150
|
resume();
|
|
146
151
|
}
|
|
147
152
|
}
|
|
153
|
+
function appendMsg() {
|
|
154
|
+
setMsgList([tempState.currentMsg, ...state.msgList]);
|
|
155
|
+
scrollToBottom();
|
|
156
|
+
}
|
|
157
|
+
function scrollToBottom() {
|
|
158
|
+
var _a;
|
|
159
|
+
(_a = chatMainRef.value) == null ? void 0 : _a.scrollTo({
|
|
160
|
+
top: 0,
|
|
161
|
+
behavior: "auto"
|
|
162
|
+
});
|
|
163
|
+
}
|
|
148
164
|
async function sendMessage(message) {
|
|
149
165
|
var _a;
|
|
150
166
|
try {
|
|
@@ -239,7 +255,7 @@ function initData(props, emit) {
|
|
|
239
255
|
...item,
|
|
240
256
|
lastMessageContent: getLastMessageContent({ ...item, chatType: item.chatType || (matchSessionItem == null ? void 0 : matchSessionItem.chatType) })
|
|
241
257
|
};
|
|
242
|
-
|
|
258
|
+
tempState.updateSessionItem = matchSessionItem ? {
|
|
243
259
|
...cloneDeep(matchSessionItem),
|
|
244
260
|
...commonItem
|
|
245
261
|
} : commonItem;
|
|
@@ -247,7 +263,7 @@ function initData(props, emit) {
|
|
|
247
263
|
}
|
|
248
264
|
async function openSession(session) {
|
|
249
265
|
try {
|
|
250
|
-
const item = typeof session === "string" ? state.sessionList.find((_session) => _session.id
|
|
266
|
+
const item = typeof session === "string" ? state.sessionList.find((_session) => session && (_session.id, _session.sessionKey).includes(session)) : session;
|
|
251
267
|
if (!item)
|
|
252
268
|
return;
|
|
253
269
|
if (item.status === STATUS.REMOVED) {
|
|
@@ -332,9 +348,12 @@ function initData(props, emit) {
|
|
|
332
348
|
return {
|
|
333
349
|
filterable: toRef(props, "filterable"),
|
|
334
350
|
trtcProxy: toRef(props, "trtcProxy"),
|
|
351
|
+
token: toRef(props, "token"),
|
|
335
352
|
cssVars,
|
|
336
353
|
stompClient,
|
|
337
354
|
state,
|
|
355
|
+
chatMainRef,
|
|
356
|
+
tempState,
|
|
338
357
|
unreadTotal,
|
|
339
358
|
isGroupChat,
|
|
340
359
|
isGroupLeader,
|
|
@@ -350,7 +369,9 @@ function initData(props, emit) {
|
|
|
350
369
|
setUpdateSessionItem,
|
|
351
370
|
setSessionList,
|
|
352
371
|
emit,
|
|
353
|
-
setUserDetail
|
|
372
|
+
setUserDetail,
|
|
373
|
+
appendMsg,
|
|
374
|
+
scrollToBottom
|
|
354
375
|
};
|
|
355
376
|
}
|
|
356
377
|
const useData = () => inject(InjectionIChatData);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useData } from './useData.js';
|
|
2
|
+
import 'vue';
|
|
3
|
+
import 'stompjs';
|
|
4
|
+
import 'sockjs-client/dist/sockjs.min.js';
|
|
5
|
+
import { MESSAGE_TYPE } from '../constants/index.js';
|
|
6
|
+
import '../api/index.js';
|
|
7
|
+
import '../utils/index.js';
|
|
8
|
+
import 'lodash-es';
|
|
9
|
+
import 'trtc-sdk-v5';
|
|
10
|
+
import { SseClient } from '../utils/sseClient.js';
|
|
11
|
+
import { uuidGenerator } from '../../../../shared/utils/index.js';
|
|
12
|
+
import { format } from 'date-fns';
|
|
13
|
+
import { useThrottleFn } from '@vueuse/core';
|
|
14
|
+
|
|
15
|
+
function useStreamOutput() {
|
|
16
|
+
const { state, token, appendMsg, tempState, scrollToBottom } = useData();
|
|
17
|
+
function handleRender(id, content) {
|
|
18
|
+
const msgItem = state.msgList.find((item) => item.id === id);
|
|
19
|
+
if (msgItem) {
|
|
20
|
+
const oldContent = msgItem.content.msg;
|
|
21
|
+
if (content && oldContent !== content) {
|
|
22
|
+
msgItem.content.msg = content;
|
|
23
|
+
scrollToBottom();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const _handleRender = useThrottleFn(handleRender, 250, true, true);
|
|
28
|
+
let sseClient = null;
|
|
29
|
+
async function handleStreamOutput() {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
if (sseClient == null ? void 0 : sseClient.active)
|
|
32
|
+
return;
|
|
33
|
+
const flagObj = {
|
|
34
|
+
id: uuidGenerator(),
|
|
35
|
+
status: "START",
|
|
36
|
+
content: ""
|
|
37
|
+
};
|
|
38
|
+
state.loading = true;
|
|
39
|
+
sseClient == null ? void 0 : sseClient.disconnect();
|
|
40
|
+
sseClient = new SseClient();
|
|
41
|
+
await sseClient.connect(
|
|
42
|
+
"/flow/ai/mcpApi/conversation",
|
|
43
|
+
{
|
|
44
|
+
agentCode: ((_b = (_a = state.currentSessionItem.businessInfo) == null ? void 0 : _a.topicInfo) == null ? void 0 : _b.agentCode) || "A17696-012",
|
|
45
|
+
sessionId: state.currentSessionItem.receiver,
|
|
46
|
+
conversationId: flagObj.id,
|
|
47
|
+
content: "\u804A\u5929\u603B\u7ED3",
|
|
48
|
+
configs: {
|
|
49
|
+
...(_d = (_c = state.currentSessionItem.businessInfo) == null ? void 0 : _c.topicInfo) == null ? void 0 : _d.param,
|
|
50
|
+
groupId: state.currentSessionItem.receiver
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
(data, msg) => {
|
|
54
|
+
const content = data != null ? data : "";
|
|
55
|
+
if (flagObj.status === "START") {
|
|
56
|
+
tempState.currentMsg = {
|
|
57
|
+
id: flagObj.id,
|
|
58
|
+
chatType: state.currentSessionItem.chatType,
|
|
59
|
+
receiver: state.currentSessionItem.receiver,
|
|
60
|
+
content: { chatMessageType: MESSAGE_TYPE.AI_SUMMARY, msg: "" },
|
|
61
|
+
sender: state.userInfo.id,
|
|
62
|
+
senderName: state.userInfo.name,
|
|
63
|
+
senderAvatar: state.userInfo.avatar,
|
|
64
|
+
sendTime: format(new Date(Date.now() + 30 * 1e3), "yyyy-MM-dd HH:mm:ss")
|
|
65
|
+
};
|
|
66
|
+
appendMsg();
|
|
67
|
+
flagObj.status = "STOP";
|
|
68
|
+
} else {
|
|
69
|
+
flagObj.content += content;
|
|
70
|
+
const { id, content: snapshotContent } = flagObj;
|
|
71
|
+
_handleRender(id, snapshotContent);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: "bearer " + token.value
|
|
77
|
+
},
|
|
78
|
+
method: "POST",
|
|
79
|
+
onClose: () => {
|
|
80
|
+
state.loading = false;
|
|
81
|
+
sseClient = null;
|
|
82
|
+
},
|
|
83
|
+
onError: () => {
|
|
84
|
+
state.loading = false;
|
|
85
|
+
sseClient == null ? void 0 : sseClient.disconnect();
|
|
86
|
+
sseClient = null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
return {
|
|
91
|
+
msgId: flagObj.id,
|
|
92
|
+
content: flagObj.content
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
handleStreamOutput
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { useStreamOutput };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
+
import { MESSAGE_TYPE } from '../constants';
|
|
2
3
|
import TRTC from 'trtc-sdk-v5';
|
|
3
4
|
import { AnyFn } from '../../../../shared/types';
|
|
4
5
|
export interface RemoteUser {
|
|
@@ -28,8 +29,50 @@ export interface VideoConfig {
|
|
|
28
29
|
}
|
|
29
30
|
export declare function useVideo(config?: VideoConfig): {
|
|
30
31
|
state: {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
orgId: string;
|
|
34
|
+
currentSessionItem: {
|
|
35
|
+
id: string;
|
|
36
|
+
sessionKey: string;
|
|
37
|
+
receiver: string;
|
|
38
|
+
createdTime: string;
|
|
39
|
+
avatar: string;
|
|
40
|
+
name: string;
|
|
41
|
+
defaultName: string;
|
|
42
|
+
chatType: import("../constants").CHAT_TYPE;
|
|
43
|
+
roleInfo: import("../constants").ROLE_TYPE;
|
|
44
|
+
status: import("../constants").STATUS;
|
|
45
|
+
sortTime: string;
|
|
46
|
+
topping: boolean;
|
|
47
|
+
unreadNum: number;
|
|
48
|
+
updatedTime: string;
|
|
49
|
+
lastMessageContent: string;
|
|
50
|
+
sender?: string | undefined;
|
|
51
|
+
lastMessageId?: string | undefined;
|
|
52
|
+
lastMessage?: {
|
|
53
|
+
[x: string]: any;
|
|
54
|
+
chatMessageType: MESSAGE_TYPE;
|
|
55
|
+
msg: string;
|
|
56
|
+
referenceContent?: any;
|
|
57
|
+
forwardMessageList?: import("../../../../shared/types").AnyObject[] | undefined;
|
|
58
|
+
messageTemplate?: any;
|
|
59
|
+
messageTemplateData?: any;
|
|
60
|
+
fileUrl?: string | undefined;
|
|
61
|
+
avStatus?: string | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
lastMessageSendTime?: string | undefined;
|
|
64
|
+
lastMessageStatus?: string | undefined;
|
|
65
|
+
lastSenderName?: string | undefined;
|
|
66
|
+
businessInfo?: {
|
|
67
|
+
uiSetting?: import("../../../../shared/types").AnyObject | undefined;
|
|
68
|
+
topicInfo?: {
|
|
69
|
+
[x: string]: any;
|
|
70
|
+
param?: import("../../../../shared/types").AnyObject | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
} | undefined;
|
|
73
|
+
labelList?: import("../../../../shared/types").AnyObject[] | undefined;
|
|
74
|
+
notDisturb: boolean;
|
|
75
|
+
};
|
|
33
76
|
id: string;
|
|
34
77
|
userInfo: import("../../../../shared/types").AnyObject;
|
|
35
78
|
msgList: {
|
|
@@ -38,7 +81,7 @@ export declare function useVideo(config?: VideoConfig): {
|
|
|
38
81
|
sessionKey: string;
|
|
39
82
|
content: {
|
|
40
83
|
[x: string]: any;
|
|
41
|
-
chatMessageType:
|
|
84
|
+
chatMessageType: MESSAGE_TYPE;
|
|
42
85
|
msg: string;
|
|
43
86
|
referenceContent?: any;
|
|
44
87
|
forwardMessageList?: import("../../../../shared/types").AnyObject[] | undefined;
|
|
@@ -56,11 +99,49 @@ export declare function useVideo(config?: VideoConfig): {
|
|
|
56
99
|
__time?: string | undefined;
|
|
57
100
|
__sendTime?: string | undefined;
|
|
58
101
|
}[];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
102
|
+
sessionList: {
|
|
103
|
+
id: string;
|
|
104
|
+
sessionKey: string;
|
|
105
|
+
receiver: string;
|
|
106
|
+
createdTime: string;
|
|
107
|
+
avatar: string;
|
|
108
|
+
name: string;
|
|
109
|
+
defaultName: string;
|
|
110
|
+
chatType: import("../constants").CHAT_TYPE;
|
|
111
|
+
roleInfo: import("../constants").ROLE_TYPE;
|
|
112
|
+
status: import("../constants").STATUS;
|
|
113
|
+
sortTime: string;
|
|
114
|
+
topping: boolean;
|
|
115
|
+
unreadNum: number;
|
|
116
|
+
updatedTime: string;
|
|
117
|
+
lastMessageContent: string;
|
|
118
|
+
sender?: string | undefined;
|
|
119
|
+
lastMessageId?: string | undefined;
|
|
120
|
+
lastMessage?: {
|
|
121
|
+
[x: string]: any;
|
|
122
|
+
chatMessageType: MESSAGE_TYPE;
|
|
123
|
+
msg: string;
|
|
124
|
+
referenceContent?: any;
|
|
125
|
+
forwardMessageList?: import("../../../../shared/types").AnyObject[] | undefined;
|
|
126
|
+
messageTemplate?: any;
|
|
127
|
+
messageTemplateData?: any;
|
|
128
|
+
fileUrl?: string | undefined;
|
|
129
|
+
avStatus?: string | undefined;
|
|
130
|
+
} | undefined;
|
|
131
|
+
lastMessageSendTime?: string | undefined;
|
|
132
|
+
lastMessageStatus?: string | undefined;
|
|
133
|
+
lastSenderName?: string | undefined;
|
|
134
|
+
businessInfo?: {
|
|
135
|
+
uiSetting?: import("../../../../shared/types").AnyObject | undefined;
|
|
136
|
+
topicInfo?: {
|
|
137
|
+
[x: string]: any;
|
|
138
|
+
param?: import("../../../../shared/types").AnyObject | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
} | undefined;
|
|
141
|
+
labelList?: import("../../../../shared/types").AnyObject[] | undefined;
|
|
142
|
+
notDisturb: boolean;
|
|
143
|
+
}[];
|
|
62
144
|
isChangeSession: boolean;
|
|
63
|
-
updateSessionItem: import("../../../../shared/types").AnyObject;
|
|
64
145
|
isUpdateSession: boolean;
|
|
65
146
|
currentReferenceMsg: import("../../../../shared/types").AnyObject | null;
|
|
66
147
|
currentReEditMsg: import("../../../../shared/types").AnyObject | null;
|
|
@@ -78,6 +159,7 @@ export declare function useVideo(config?: VideoConfig): {
|
|
|
78
159
|
info: import("../../../../shared/types").AnyObject | null;
|
|
79
160
|
};
|
|
80
161
|
isForward: boolean;
|
|
162
|
+
loading: boolean;
|
|
81
163
|
};
|
|
82
164
|
trtcProxy: Ref<any, any>;
|
|
83
165
|
sendMessage: (message: {
|
|
@@ -6,7 +6,17 @@ import { isAudioOrVideoMessage } from '../utils/index.js';
|
|
|
6
6
|
import { remove } from 'lodash-es';
|
|
7
7
|
|
|
8
8
|
function useWebSocket(props, data) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
stompClient,
|
|
11
|
+
state,
|
|
12
|
+
tempState,
|
|
13
|
+
openSession,
|
|
14
|
+
closeSession,
|
|
15
|
+
setSessionList,
|
|
16
|
+
setUpdateSessionItem,
|
|
17
|
+
setCurrentSessionItem,
|
|
18
|
+
appendMsg
|
|
19
|
+
} = data;
|
|
10
20
|
const groupSessionList = [];
|
|
11
21
|
initWebSocket();
|
|
12
22
|
function initWebSocket() {
|
|
@@ -77,9 +87,9 @@ function useWebSocket(props, data) {
|
|
|
77
87
|
);
|
|
78
88
|
}
|
|
79
89
|
async function handleMessage(messageVo, chatType) {
|
|
80
|
-
|
|
90
|
+
tempState.currentMsg = messageVo;
|
|
81
91
|
if (messageVo.sessionKey === state.currentSessionItem.sessionKey) {
|
|
82
|
-
|
|
92
|
+
appendMsg();
|
|
83
93
|
if (messageVo.sender !== state.userInfo.id) {
|
|
84
94
|
await readMessageApi({
|
|
85
95
|
chatType,
|
|
@@ -115,7 +125,7 @@ function useWebSocket(props, data) {
|
|
|
115
125
|
case SUBSCRIBE_MESSAGE_TYPE.MESSAGE: {
|
|
116
126
|
if (isAudioOrVideoMessage(messageVo.content)) {
|
|
117
127
|
if (!state.showVideo && !state.showMultipleVideo || messageVo.content.avStatus !== AV_STATUS.IN_CALL) {
|
|
118
|
-
|
|
128
|
+
tempState.currentMsg = messageVo;
|
|
119
129
|
Object.assign(state.currentAVMsg, {
|
|
120
130
|
strRoomId: messageVo.sessionKey,
|
|
121
131
|
chatMessageType: messageVo.content.chatMessageType,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AnyObject } from '../../../../shared/types';
|
|
2
2
|
import { UploadFileInfo } from 'naive-ui';
|
|
3
|
+
import { CHAT_TYPE, MESSAGE_TYPE, ROLE_TYPE, STATUS } from '../constants';
|
|
3
4
|
type ItemContent = {
|
|
4
|
-
chatMessageType:
|
|
5
|
+
chatMessageType: MESSAGE_TYPE;
|
|
5
6
|
msg: string;
|
|
6
7
|
referenceContent?: any;
|
|
7
8
|
forwardMessageList?: AnyObject[];
|
|
@@ -25,17 +26,46 @@ export type MsgListItem = {
|
|
|
25
26
|
__sendTime?: string;
|
|
26
27
|
[key: string]: any;
|
|
27
28
|
};
|
|
29
|
+
export type SessionItem = {
|
|
30
|
+
id: string;
|
|
31
|
+
sessionKey: string;
|
|
32
|
+
receiver: string;
|
|
33
|
+
createdTime: string;
|
|
34
|
+
avatar: string;
|
|
35
|
+
name: string;
|
|
36
|
+
defaultName: string;
|
|
37
|
+
chatType: CHAT_TYPE;
|
|
38
|
+
roleInfo: ROLE_TYPE;
|
|
39
|
+
status: STATUS;
|
|
40
|
+
sortTime: string;
|
|
41
|
+
topping: boolean;
|
|
42
|
+
unreadNum: number;
|
|
43
|
+
updatedTime: string;
|
|
44
|
+
lastMessageContent: string;
|
|
45
|
+
sender?: string;
|
|
46
|
+
lastMessageId?: string;
|
|
47
|
+
lastMessage?: ItemContent;
|
|
48
|
+
lastMessageSendTime?: string;
|
|
49
|
+
lastMessageStatus?: string;
|
|
50
|
+
lastSenderName?: string;
|
|
51
|
+
businessInfo?: {
|
|
52
|
+
uiSetting?: AnyObject;
|
|
53
|
+
topicInfo?: {
|
|
54
|
+
param?: AnyObject;
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
labelList?: AnyObject[];
|
|
59
|
+
notDisturb: boolean;
|
|
60
|
+
};
|
|
28
61
|
export type IState = {
|
|
29
|
-
orgId:
|
|
30
|
-
currentSessionItem:
|
|
62
|
+
orgId: string;
|
|
63
|
+
currentSessionItem: SessionItem;
|
|
31
64
|
id: string;
|
|
32
65
|
userInfo: AnyObject;
|
|
33
66
|
msgList: MsgListItem[];
|
|
34
|
-
|
|
35
|
-
isAppendMsg: boolean;
|
|
36
|
-
sessionList: AnyObject[];
|
|
67
|
+
sessionList: SessionItem[];
|
|
37
68
|
isChangeSession: boolean;
|
|
38
|
-
updateSessionItem: AnyObject;
|
|
39
69
|
isUpdateSession: boolean;
|
|
40
70
|
currentReferenceMsg: null | AnyObject;
|
|
41
71
|
currentReEditMsg: null | AnyObject;
|
|
@@ -53,6 +83,8 @@ export type IState = {
|
|
|
53
83
|
info: AnyObject | null;
|
|
54
84
|
};
|
|
55
85
|
isForward: boolean;
|
|
86
|
+
loading: boolean;
|
|
87
|
+
[key: string]: any;
|
|
56
88
|
};
|
|
57
89
|
export type FileOptions = {
|
|
58
90
|
file: UploadFileInfo;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AnyObject } from '../../../../shared/types';
|
|
2
|
+
import { SessionItem } from '../types';
|
|
2
3
|
export declare const $message: import("naive-ui/es/message").MessageApi;
|
|
3
4
|
export declare function formatTime(dateStr: string): {
|
|
4
5
|
siderMsgTime: any;
|
|
5
6
|
msgTime: any;
|
|
6
7
|
recordTime: string;
|
|
7
8
|
};
|
|
8
|
-
export declare function listSort(list:
|
|
9
|
+
export declare function listSort(list: SessionItem[]): SessionItem[];
|
|
9
10
|
export declare function transformMessage(content: AnyObject): any;
|
|
10
11
|
export declare function getAVTime(msg: string): string;
|
|
11
12
|
export declare function simplifyMessage(lastMessage: AnyObject): any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type EventSourceMessage } from '@microsoft/fetch-event-source';
|
|
2
|
+
import { AnyObject, AnyFn } from '../../../../shared/types';
|
|
3
|
+
type SSEClientOptions = {
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
method?: 'GET' | 'POST';
|
|
6
|
+
withCredentials?: boolean;
|
|
7
|
+
parseJSON?: boolean;
|
|
8
|
+
abortOn?: (msg: EventSourceMessage) => boolean;
|
|
9
|
+
onOpen?: (response: Response) => void;
|
|
10
|
+
onError?: (error: unknown) => void;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
};
|
|
13
|
+
export declare class SseClient {
|
|
14
|
+
private controller?;
|
|
15
|
+
private connecting;
|
|
16
|
+
private baseOptions;
|
|
17
|
+
constructor(options?: SSEClientOptions);
|
|
18
|
+
get active(): boolean;
|
|
19
|
+
disconnect(): void;
|
|
20
|
+
connect(url: string, params: AnyObject | undefined, onMessage: AnyFn<[unknown, EventSourceMessage], void>, options?: SSEClientOptions): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export default SseClient;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
2
|
+
|
|
3
|
+
function toQuery(url, params) {
|
|
4
|
+
if (!params || Object.keys(params).length === 0)
|
|
5
|
+
return url;
|
|
6
|
+
const usp = new URLSearchParams();
|
|
7
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
8
|
+
if (v === void 0 || v === null)
|
|
9
|
+
return;
|
|
10
|
+
usp.append(k, typeof v === "string" ? v : JSON.stringify(v));
|
|
11
|
+
});
|
|
12
|
+
return url + (url.includes("?") ? "&" : "?") + usp.toString();
|
|
13
|
+
}
|
|
14
|
+
function safeParse(data, enable) {
|
|
15
|
+
if (!enable)
|
|
16
|
+
return data;
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(data);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class SseClient {
|
|
24
|
+
constructor(options = { method: "POST", parseJSON: true }) {
|
|
25
|
+
this.connecting = false;
|
|
26
|
+
this.baseOptions = options;
|
|
27
|
+
}
|
|
28
|
+
get active() {
|
|
29
|
+
return this.connecting && !!this.controller && !this.controller.signal.aborted;
|
|
30
|
+
}
|
|
31
|
+
disconnect() {
|
|
32
|
+
if (this.controller && !this.controller.signal.aborted) {
|
|
33
|
+
this.controller.abort();
|
|
34
|
+
}
|
|
35
|
+
this.connecting = false;
|
|
36
|
+
}
|
|
37
|
+
async connect(url, params = {}, onMessage, options = {}) {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
const opts = {
|
|
40
|
+
parseJSON: true,
|
|
41
|
+
abortOn: (msg) => msg.data === "[DONE]",
|
|
42
|
+
...this.baseOptions,
|
|
43
|
+
...options
|
|
44
|
+
};
|
|
45
|
+
if (this.controller)
|
|
46
|
+
this.controller.abort();
|
|
47
|
+
this.controller = new AbortController();
|
|
48
|
+
this.connecting = true;
|
|
49
|
+
const method = (_a = opts.method) != null ? _a : "POST";
|
|
50
|
+
const headers = { "Content-Type": "application/json", ...(_b = opts.headers) != null ? _b : {} };
|
|
51
|
+
const credentials = opts.withCredentials ? "include" : "same-origin";
|
|
52
|
+
const finalUrl = method === "GET" ? toQuery(url, params) : url;
|
|
53
|
+
const body = method === "POST" ? JSON.stringify(params != null ? params : {}) : void 0;
|
|
54
|
+
try {
|
|
55
|
+
await fetchEventSource(finalUrl, {
|
|
56
|
+
method,
|
|
57
|
+
headers,
|
|
58
|
+
body,
|
|
59
|
+
signal: this.controller.signal,
|
|
60
|
+
credentials,
|
|
61
|
+
openWhenHidden: true,
|
|
62
|
+
onopen: async (r) => {
|
|
63
|
+
var _a2;
|
|
64
|
+
return (_a2 = opts.onOpen) == null ? void 0 : _a2.call(opts, r);
|
|
65
|
+
},
|
|
66
|
+
onmessage: (msg) => {
|
|
67
|
+
var _a2;
|
|
68
|
+
try {
|
|
69
|
+
const data = safeParse(msg.data, opts.parseJSON !== false);
|
|
70
|
+
onMessage(data, msg);
|
|
71
|
+
if (opts.abortOn && opts.abortOn(msg))
|
|
72
|
+
this.disconnect();
|
|
73
|
+
} catch (e) {
|
|
74
|
+
(_a2 = opts.onError) == null ? void 0 : _a2.call(opts, e);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
onclose: () => {
|
|
78
|
+
this.disconnect();
|
|
79
|
+
},
|
|
80
|
+
onerror: (err) => {
|
|
81
|
+
var _a2;
|
|
82
|
+
(_a2 = opts.onError) == null ? void 0 : _a2.call(opts, err);
|
|
83
|
+
this.disconnect();
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} catch (e) {
|
|
88
|
+
(_c = opts.onError) == null ? void 0 : _c.call(opts, e);
|
|
89
|
+
this.disconnect();
|
|
90
|
+
} finally {
|
|
91
|
+
this.connecting = false;
|
|
92
|
+
(_d = opts.onClose) == null ? void 0 : _d.call(opts);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { SseClient, SseClient as default };
|