chat-customer-47net 1.5.1 → 1.5.3
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/chat-customer-47net.es.js +107 -5
- package/chat-customer-47net.umd.js +576 -514
- package/package.json +1 -1
- package/style.css +1 -1
|
@@ -1161,7 +1161,7 @@ var conversionExports = conversion.exports;
|
|
|
1161
1161
|
var imageConversion = conversionExports;
|
|
1162
1162
|
dayjs.extend(utc);
|
|
1163
1163
|
dayjs.extend(timezone);
|
|
1164
|
-
const version = "1.5.
|
|
1164
|
+
const version = "1.5.3";
|
|
1165
1165
|
const publicDateFormat = "MM/DD/YY";
|
|
1166
1166
|
const serverLocal = "America/New_York";
|
|
1167
1167
|
const getTime = dateTime => {
|
|
@@ -8747,7 +8747,7 @@ const __vue2_script$3 = {
|
|
|
8747
8747
|
}
|
|
8748
8748
|
};
|
|
8749
8749
|
const __cssModules$3 = {};
|
|
8750
|
-
var __component__$3 = /* @__PURE__ */normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "
|
|
8750
|
+
var __component__$3 = /* @__PURE__ */normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "2ec20a45", null, null);
|
|
8751
8751
|
function __vue2_injectStyles$3(context) {
|
|
8752
8752
|
for (let o in __cssModules$3) {
|
|
8753
8753
|
this[o] = __cssModules$3[o];
|
|
@@ -8928,6 +8928,7 @@ const __vue2_script$2 = {
|
|
|
8928
8928
|
back() {
|
|
8929
8929
|
this.historyRoute.pop();
|
|
8930
8930
|
this.route = this.historyRoute[this.historyRoute.length - 1];
|
|
8931
|
+
this.$emit("back");
|
|
8931
8932
|
},
|
|
8932
8933
|
handleRoute(route) {
|
|
8933
8934
|
this.route = route;
|
|
@@ -9269,7 +9270,7 @@ const __vue2_script$2 = {
|
|
|
9269
9270
|
}
|
|
9270
9271
|
};
|
|
9271
9272
|
const __cssModules$2 = {};
|
|
9272
|
-
var __component__$2 = /* @__PURE__ */normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, "
|
|
9273
|
+
var __component__$2 = /* @__PURE__ */normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, "0dded926", null, null);
|
|
9273
9274
|
function __vue2_injectStyles$2(context) {
|
|
9274
9275
|
for (let o in __cssModules$2) {
|
|
9275
9276
|
this[o] = __cssModules$2[o];
|
|
@@ -9344,6 +9345,83 @@ function __vue2_injectStyles$1(context) {
|
|
|
9344
9345
|
const ConsultButton = /* @__PURE__ */function () {
|
|
9345
9346
|
return __component__$1.exports;
|
|
9346
9347
|
}();
|
|
9348
|
+
class CrossTabSyncManager {
|
|
9349
|
+
constructor(siteName) {
|
|
9350
|
+
this.siteName = siteName;
|
|
9351
|
+
this.storageKey = "consult47_dialog_state";
|
|
9352
|
+
this.pageIdKey = "consult47_page_" + Date.now() + "_" + Math.random();
|
|
9353
|
+
this.sessionKey = "consult47_active_pages";
|
|
9354
|
+
}
|
|
9355
|
+
// 初始化:记录当前页面为活跃页面
|
|
9356
|
+
init() {
|
|
9357
|
+
this.registerActivePage();
|
|
9358
|
+
window.addEventListener("beforeunload", () => this.unregisterActivePage());
|
|
9359
|
+
}
|
|
9360
|
+
// 获取当前状态
|
|
9361
|
+
getDialogState() {
|
|
9362
|
+
try {
|
|
9363
|
+
const state = localStorage.getItem(this.storageKey);
|
|
9364
|
+
return state ? JSON.parse(state) : null;
|
|
9365
|
+
} catch (e) {
|
|
9366
|
+
return null;
|
|
9367
|
+
}
|
|
9368
|
+
}
|
|
9369
|
+
// 设置对话状态为"进入对话"
|
|
9370
|
+
setDialogActive(siteName) {
|
|
9371
|
+
const state = {
|
|
9372
|
+
isInDialog: true,
|
|
9373
|
+
siteName,
|
|
9374
|
+
timestamp: Date.now()
|
|
9375
|
+
};
|
|
9376
|
+
localStorage.setItem(this.storageKey, JSON.stringify(state));
|
|
9377
|
+
}
|
|
9378
|
+
// 设置对话状态为"退出对话"
|
|
9379
|
+
setDialogInactive(siteName) {
|
|
9380
|
+
const state = {
|
|
9381
|
+
isInDialog: false,
|
|
9382
|
+
siteName,
|
|
9383
|
+
timestamp: Date.now()
|
|
9384
|
+
};
|
|
9385
|
+
localStorage.setItem(this.storageKey, JSON.stringify(state));
|
|
9386
|
+
}
|
|
9387
|
+
// 记录当前页面为活跃
|
|
9388
|
+
registerActivePage() {
|
|
9389
|
+
try {
|
|
9390
|
+
const activePages = JSON.parse(localStorage.getItem(this.sessionKey) || "[]");
|
|
9391
|
+
activePages.push(this.pageIdKey);
|
|
9392
|
+
localStorage.setItem(this.sessionKey, JSON.stringify(activePages));
|
|
9393
|
+
} catch (e) {
|
|
9394
|
+
console.error("注册活跃页面失败", e);
|
|
9395
|
+
}
|
|
9396
|
+
}
|
|
9397
|
+
// 移除当前页面的活跃标记,如果没有其他页面则清除 localStorage 状态
|
|
9398
|
+
unregisterActivePage() {
|
|
9399
|
+
try {
|
|
9400
|
+
const activePages = JSON.parse(localStorage.getItem(this.sessionKey) || "[]");
|
|
9401
|
+
const filtered = activePages.filter(id => id !== this.pageIdKey);
|
|
9402
|
+
if (filtered.length > 0) {
|
|
9403
|
+
localStorage.setItem(this.sessionKey, JSON.stringify(filtered));
|
|
9404
|
+
} else {
|
|
9405
|
+
localStorage.removeItem(this.sessionKey);
|
|
9406
|
+
this.setDialogInactive(this.siteName);
|
|
9407
|
+
}
|
|
9408
|
+
} catch (e) {
|
|
9409
|
+
console.error("注销活跃页面失败", e);
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9412
|
+
// 清除对话状态
|
|
9413
|
+
clearDialogState() {
|
|
9414
|
+
localStorage.removeItem(this.storageKey);
|
|
9415
|
+
}
|
|
9416
|
+
// 检查是否应该直接进入对话界面
|
|
9417
|
+
shouldShowDialog() {
|
|
9418
|
+
const state = this.getDialogState();
|
|
9419
|
+
if (!state || !state.isInDialog) {
|
|
9420
|
+
return false;
|
|
9421
|
+
}
|
|
9422
|
+
return state.siteName === this.siteName;
|
|
9423
|
+
}
|
|
9424
|
+
}
|
|
9347
9425
|
var render = function () {
|
|
9348
9426
|
var _vm = this;
|
|
9349
9427
|
var _h = _vm.$createElement;
|
|
@@ -9370,7 +9448,8 @@ var render = function () {
|
|
|
9370
9448
|
"updateInitData": _vm.getInitData,
|
|
9371
9449
|
"onChangeRoute": _vm.onChangeRoute,
|
|
9372
9450
|
"updateMessage": _vm.updateMessage,
|
|
9373
|
-
"trackEvent": _vm.trackEvent
|
|
9451
|
+
"trackEvent": _vm.trackEvent,
|
|
9452
|
+
"back": _vm.backCover
|
|
9374
9453
|
}
|
|
9375
9454
|
}), _vm.showButton ? _c("ConsultButton", {
|
|
9376
9455
|
directives: [{
|
|
@@ -9414,7 +9493,9 @@ const __vue2_script = {
|
|
|
9414
9493
|
isAudioInited: false,
|
|
9415
9494
|
onWindowUrl: window.location.href,
|
|
9416
9495
|
isSetVisitedpage: true,
|
|
9417
|
-
accessToken: getToken()
|
|
9496
|
+
accessToken: getToken(),
|
|
9497
|
+
syncManager: null
|
|
9498
|
+
// 跨标签页同步管理器
|
|
9418
9499
|
};
|
|
9419
9500
|
},
|
|
9420
9501
|
computed: {
|
|
@@ -9448,6 +9529,9 @@ const __vue2_script = {
|
|
|
9448
9529
|
document.removeEventListener("touchstart", this.initAudio);
|
|
9449
9530
|
document.removeEventListener("click", this.initAudio);
|
|
9450
9531
|
if (this.unwatchRoute) this.unwatchRoute();
|
|
9532
|
+
if (this.syncManager) {
|
|
9533
|
+
this.syncManager.unregisterActivePage();
|
|
9534
|
+
}
|
|
9451
9535
|
},
|
|
9452
9536
|
watch: {
|
|
9453
9537
|
"$route"(to, from) {
|
|
@@ -9549,14 +9633,23 @@ const __vue2_script = {
|
|
|
9549
9633
|
this.isHandlingStorage = false;
|
|
9550
9634
|
}
|
|
9551
9635
|
},
|
|
9636
|
+
// 初始化跨标签页同步
|
|
9637
|
+
initCrossTabSync() {
|
|
9638
|
+
if (!this.initData.siteName) return;
|
|
9639
|
+
this.syncManager = new CrossTabSyncManager(this.initData.siteName);
|
|
9640
|
+
this.syncManager.init();
|
|
9641
|
+
},
|
|
9552
9642
|
handleClick() {
|
|
9553
9643
|
this.showView = true;
|
|
9644
|
+
const isFirstOpen = this.syncManager.shouldShowDialog();
|
|
9554
9645
|
if (this.onRoute === "dialog") {
|
|
9555
9646
|
this.updateOpenView(true);
|
|
9556
9647
|
this.clearClinetUnRead();
|
|
9557
9648
|
if (this.$refs.consultContainer) {
|
|
9558
9649
|
this.$refs.consultContainer.scrollToBottom();
|
|
9559
9650
|
}
|
|
9651
|
+
} else if (this.onRoute === "cover" && this.conversations.length > 0 && this.$refs.consultContainer && isFirstOpen) {
|
|
9652
|
+
this.$refs.consultContainer.handleToConversation(this.conversations[0]);
|
|
9560
9653
|
}
|
|
9561
9654
|
this.trackEvent("Chat opened");
|
|
9562
9655
|
},
|
|
@@ -9564,6 +9657,11 @@ const __vue2_script = {
|
|
|
9564
9657
|
this.showView = false;
|
|
9565
9658
|
this.updateOpenView(false);
|
|
9566
9659
|
},
|
|
9660
|
+
backCover() {
|
|
9661
|
+
if (this.syncManager) {
|
|
9662
|
+
this.syncManager.setDialogInactive();
|
|
9663
|
+
}
|
|
9664
|
+
},
|
|
9567
9665
|
updateOpenView(isOpenView) {
|
|
9568
9666
|
this.socket.emit("updateOpenView", {
|
|
9569
9667
|
isOpenView,
|
|
@@ -9649,6 +9747,9 @@ const __vue2_script = {
|
|
|
9649
9747
|
setTimeout(() => {
|
|
9650
9748
|
this.updateOpenView(true);
|
|
9651
9749
|
this.clearClinetUnRead();
|
|
9750
|
+
if (this.syncManager) {
|
|
9751
|
+
this.syncManager.setDialogActive(this.initData.siteName);
|
|
9752
|
+
}
|
|
9652
9753
|
}, 300);
|
|
9653
9754
|
}
|
|
9654
9755
|
},
|
|
@@ -9717,6 +9818,7 @@ const __vue2_script = {
|
|
|
9717
9818
|
if (this.userId) {
|
|
9718
9819
|
this.joinRoom("");
|
|
9719
9820
|
}
|
|
9821
|
+
this.initCrossTabSync();
|
|
9720
9822
|
callback && callback();
|
|
9721
9823
|
} catch (err) {
|
|
9722
9824
|
error && error(err);
|