Browse Source

支持图标拖拽固定-优化

dev-mcp
wanghanlin 3 weeks ago
parent
commit
9e9d9aad94
  1. 26
      client/dist/chatbot-sdk.js
  2. 2
      client/dist/chatbot-sdk.js.map
  3. 2
      client/dist/chatbot-sdk.min.js
  4. 2
      client/dist/chatbot-sdk.min.js.map
  5. 7
      client/src/dom.ts
  6. 21
      client/src/index.ts
  7. 26
      src/main/resources/static/sdk/chatbot-sdk.js
  8. 2
      src/main/resources/static/sdk/chatbot-sdk.js.map
  9. 2
      src/main/resources/static/sdk/chatbot-sdk.min.js
  10. 2
      src/main/resources/static/sdk/chatbot-sdk.min.js.map

26
client/dist/chatbot-sdk.js

@ -2871,6 +2871,12 @@ var ChatbotSDK = (function () {
if (isSnapping)
onTransitionEnd();
}, 350);
// 阻止本次拖拽触发 click 事件(mousedown → mousemove → mouseup → click 的浏览器默认链路)
const preventClick = (ev) => {
ev.stopPropagation();
launcherEl.removeEventListener('click', preventClick, true);
};
launcherEl.addEventListener('click', preventClick, true);
// 恢复未读徽章
const badge = launcherEl.querySelector('.csk-launcher__badge');
if (badge)
@ -4400,9 +4406,18 @@ var ChatbotSDK = (function () {
launcherDragCleanup = enableLauncherDrag(launcherEl, config, (pos) => {
launcherPos = pos;
saveLauncherPosition(config.integrateId, pos);
// Launcher 位置变更后,同步聊天弹窗对齐侧
// 同步聊天弹窗对齐侧(若弹窗已被用户拖拽过,清除内联定位让 CSS 类接管)
resetWindowPosition();
syncWindowAlignment(pos.side);
// 重新定位 teaser 气泡(若正在显示)
if (teaserEl && !teaserEl.classList.contains('csk-teaser--hidden')) {
positionTeaser();
}
});
// 6.3 恢复弹窗对齐侧(与 Launcher 同侧)
if (launcherPos) {
syncWindowAlignment(launcherPos.side);
}
// 7. 创建聊天弹窗
const dom = createChatWindow(config);
windowEl = dom.window;
@ -4765,6 +4780,15 @@ var ChatbotSDK = (function () {
}
catch ( /* 忽略 */_a) { /* 忽略 */ }
}
/** 清除弹窗的内联定位样式,使其回到 CSS 类控制的默认位置 */
function resetWindowPosition() {
if (!windowEl)
return;
windowEl.style.left = '';
windowEl.style.top = '';
windowEl.style.right = '';
windowEl.style.bottom = '';
}
/** 同步聊天弹窗对齐侧(Launcher 拖拽到左/右侧时跟随) */
function syncWindowAlignment(side) {
if (!windowEl)

2
client/dist/chatbot-sdk.js.map
File diff suppressed because it is too large
View File

2
client/dist/chatbot-sdk.min.js
File diff suppressed because it is too large
View File

2
client/dist/chatbot-sdk.min.js.map
File diff suppressed because it is too large
View File

7
client/src/dom.ts

@ -539,6 +539,13 @@ export function enableLauncherDrag(
if (isSnapping) onTransitionEnd();
}, 350);
// 阻止本次拖拽触发 click 事件(mousedown → mousemove → mouseup → click 的浏览器默认链路)
const preventClick = (ev: Event): void => {
ev.stopPropagation();
launcherEl.removeEventListener('click', preventClick, true);
};
launcherEl.addEventListener('click', preventClick, true);
// 恢复未读徽章
const badge = launcherEl.querySelector('.csk-launcher__badge');
if (badge) (badge as HTMLElement).style.display = '';

21
client/src/index.ts

@ -103,10 +103,20 @@ function init(rawConfig: SDKConfig): void {
launcherDragCleanup = enableLauncherDrag(launcherEl, config, (pos) => {
launcherPos = pos;
saveLauncherPosition(config!.integrateId, pos);
// Launcher 位置变更后,同步聊天弹窗对齐侧
// 同步聊天弹窗对齐侧(若弹窗已被用户拖拽过,清除内联定位让 CSS 类接管)
resetWindowPosition();
syncWindowAlignment(pos.side);
// 重新定位 teaser 气泡(若正在显示)
if (teaserEl && !teaserEl.classList.contains('csk-teaser--hidden')) {
positionTeaser();
}
});
// 6.3 恢复弹窗对齐侧(与 Launcher 同侧)
if (launcherPos) {
syncWindowAlignment(launcherPos.side);
}
// 7. 创建聊天弹窗
const dom = createChatWindow(config);
windowEl = dom.window;
@ -465,6 +475,15 @@ function restoreLauncherPosition(integrateId: string, el: HTMLElement): void {
} catch { /* 忽略 */ }
}
/** 清除弹窗的内联定位样式,使其回到 CSS 类控制的默认位置 */
function resetWindowPosition(): void {
if (!windowEl) return;
windowEl.style.left = '';
windowEl.style.top = '';
windowEl.style.right = '';
windowEl.style.bottom = '';
}
/** 同步聊天弹窗对齐侧(Launcher 拖拽到左/右侧时跟随) */
function syncWindowAlignment(side: 'left' | 'right'): void {
if (!windowEl) return;

26
src/main/resources/static/sdk/chatbot-sdk.js

@ -2871,6 +2871,12 @@ var ChatbotSDK = (function () {
if (isSnapping)
onTransitionEnd();
}, 350);
// 阻止本次拖拽触发 click 事件(mousedown → mousemove → mouseup → click 的浏览器默认链路)
const preventClick = (ev) => {
ev.stopPropagation();
launcherEl.removeEventListener('click', preventClick, true);
};
launcherEl.addEventListener('click', preventClick, true);
// 恢复未读徽章
const badge = launcherEl.querySelector('.csk-launcher__badge');
if (badge)
@ -4400,9 +4406,18 @@ var ChatbotSDK = (function () {
launcherDragCleanup = enableLauncherDrag(launcherEl, config, (pos) => {
launcherPos = pos;
saveLauncherPosition(config.integrateId, pos);
// Launcher 位置变更后,同步聊天弹窗对齐侧
// 同步聊天弹窗对齐侧(若弹窗已被用户拖拽过,清除内联定位让 CSS 类接管)
resetWindowPosition();
syncWindowAlignment(pos.side);
// 重新定位 teaser 气泡(若正在显示)
if (teaserEl && !teaserEl.classList.contains('csk-teaser--hidden')) {
positionTeaser();
}
});
// 6.3 恢复弹窗对齐侧(与 Launcher 同侧)
if (launcherPos) {
syncWindowAlignment(launcherPos.side);
}
// 7. 创建聊天弹窗
const dom = createChatWindow(config);
windowEl = dom.window;
@ -4765,6 +4780,15 @@ var ChatbotSDK = (function () {
}
catch ( /* 忽略 */_a) { /* 忽略 */ }
}
/** 清除弹窗的内联定位样式,使其回到 CSS 类控制的默认位置 */
function resetWindowPosition() {
if (!windowEl)
return;
windowEl.style.left = '';
windowEl.style.top = '';
windowEl.style.right = '';
windowEl.style.bottom = '';
}
/** 同步聊天弹窗对齐侧(Launcher 拖拽到左/右侧时跟随) */
function syncWindowAlignment(side) {
if (!windowEl)

2
src/main/resources/static/sdk/chatbot-sdk.js.map
File diff suppressed because it is too large
View File

2
src/main/resources/static/sdk/chatbot-sdk.min.js
File diff suppressed because it is too large
View File

2
src/main/resources/static/sdk/chatbot-sdk.min.js.map
File diff suppressed because it is too large
View File

Loading…
Cancel
Save