ibc-ai-web-sdk 2.1.0 → 2.1.1
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/index.cjs.js +21 -2
- package/dist/index.esm.js +21 -2
- package/dist/index.umd.js +21 -2
- package/dist/index.umd.min.js +1 -1
- package/dist-ts/AIChatDialog.d.ts +1 -0
- package/package.json +4 -7
package/dist/index.cjs.js
CHANGED
|
@@ -3634,6 +3634,8 @@ class AIChatDialog extends HTMLElement {
|
|
|
3634
3634
|
debug: false,
|
|
3635
3635
|
// P4: 自定义消息操作按钮 — 返回数组 [{label, className?, onClick}] 在 AI 消息下方渲染
|
|
3636
3636
|
onMessageActions: null,
|
|
3637
|
+
// P5: 浮窗按钮显隐控制 — false 时浮窗按钮隐藏,对话框只能通过 API 打开(登录页等场景)
|
|
3638
|
+
floatButton: true,
|
|
3637
3639
|
suggestions: [{
|
|
3638
3640
|
label: '帮我购买一台轻量应用服务器用于部署应用',
|
|
3639
3641
|
value: '帮我购买一台轻量应用服务器用于部署应用'
|
|
@@ -3647,6 +3649,7 @@ class AIChatDialog extends HTMLElement {
|
|
|
3647
3649
|
this._chatClient = new AIChatClient(this._config);
|
|
3648
3650
|
if (this._conversationId) this._chatClient.setConversationId(this._conversationId);
|
|
3649
3651
|
this.applyConfig();
|
|
3652
|
+
this.setFloatButtonVisible(this._config.floatButton !== false);
|
|
3650
3653
|
// P1-2 fix: 在 _config 就绪后初始化拖拽,以正确读取 enableDrag
|
|
3651
3654
|
if (this._config?.enableDrag !== false && this.getAttribute('mode') !== 'inline' && !this._dragInitialized) {
|
|
3652
3655
|
this.initDraggable();
|
|
@@ -3683,6 +3686,21 @@ class AIChatDialog extends HTMLElement {
|
|
|
3683
3686
|
if (this._chatClient) this._chatClient.dispose();
|
|
3684
3687
|
if (this.parentNode) this.parentNode.removeChild(this);
|
|
3685
3688
|
}
|
|
3689
|
+
// P5: 运行时动态控制浮窗按钮显隐(SPA 路由切换场景:登录页隐藏,业务页显示)
|
|
3690
|
+
setFloatButtonVisible(show) {
|
|
3691
|
+
if (!this._config) this.init({
|
|
3692
|
+
floatButton: show
|
|
3693
|
+
});else this._config.floatButton = show;
|
|
3694
|
+
const btn = this.shadowRoot?.querySelector('.float-button');
|
|
3695
|
+
if (btn) {
|
|
3696
|
+
const dialog = this.shadowRoot?.querySelector('.ai-chat-dialog');
|
|
3697
|
+
const isOpen = dialog?.classList.contains('dialog-visible');
|
|
3698
|
+
if (!isOpen) {
|
|
3699
|
+
btn.style.display = show ? 'flex' : 'none';
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
return this;
|
|
3703
|
+
}
|
|
3686
3704
|
addMessage(message) {
|
|
3687
3705
|
if (!message || !message.content) return this;
|
|
3688
3706
|
const msg = {
|
|
@@ -3725,6 +3743,7 @@ class AIChatDialog extends HTMLElement {
|
|
|
3725
3743
|
if (!this._config.appId && this._config.agentAppId) this._config.appId = this._config.agentAppId;
|
|
3726
3744
|
if (this._chatClient) this._chatClient.updateConfig(this._config);
|
|
3727
3745
|
this.loadAppDetail();
|
|
3746
|
+
if ('floatButton' in config) this.setFloatButtonVisible(this._config.floatButton !== false);
|
|
3728
3747
|
}
|
|
3729
3748
|
this.applyConfig();
|
|
3730
3749
|
return this;
|
|
@@ -3785,7 +3804,7 @@ class AIChatDialog extends HTMLElement {
|
|
|
3785
3804
|
const dialog = this.shadowRoot.querySelector('.ai-chat-dialog');
|
|
3786
3805
|
const btn = this.shadowRoot.querySelector('.float-button');
|
|
3787
3806
|
if (dialog) dialog.classList.remove('dialog-visible');
|
|
3788
|
-
if (btn) btn.style.display = 'flex';
|
|
3807
|
+
if (btn) btn.style.display = this._config?.floatButton !== false ? 'flex' : 'none';
|
|
3789
3808
|
}
|
|
3790
3809
|
// ==================== 渲染(完整CSS对齐theme.css) ====================
|
|
3791
3810
|
render() {
|
|
@@ -6660,7 +6679,7 @@ function installVuePlugin(Vue) {
|
|
|
6660
6679
|
}
|
|
6661
6680
|
function useAIChat(options = {}) {
|
|
6662
6681
|
if (typeof React === 'undefined') {
|
|
6663
|
-
console.warn('[AI Web SDK] React is not loaded
|
|
6682
|
+
console.warn('[AI Web SDK] React is not loaded globally — useAIChat requires React on window (CDN mode) or use the imperative createAIChatDialog() API directly');
|
|
6664
6683
|
return {
|
|
6665
6684
|
open: () => {},
|
|
6666
6685
|
close: () => {},
|
package/dist/index.esm.js
CHANGED
|
@@ -3630,6 +3630,8 @@ class AIChatDialog extends HTMLElement {
|
|
|
3630
3630
|
debug: false,
|
|
3631
3631
|
// P4: 自定义消息操作按钮 — 返回数组 [{label, className?, onClick}] 在 AI 消息下方渲染
|
|
3632
3632
|
onMessageActions: null,
|
|
3633
|
+
// P5: 浮窗按钮显隐控制 — false 时浮窗按钮隐藏,对话框只能通过 API 打开(登录页等场景)
|
|
3634
|
+
floatButton: true,
|
|
3633
3635
|
suggestions: [{
|
|
3634
3636
|
label: '帮我购买一台轻量应用服务器用于部署应用',
|
|
3635
3637
|
value: '帮我购买一台轻量应用服务器用于部署应用'
|
|
@@ -3643,6 +3645,7 @@ class AIChatDialog extends HTMLElement {
|
|
|
3643
3645
|
this._chatClient = new AIChatClient(this._config);
|
|
3644
3646
|
if (this._conversationId) this._chatClient.setConversationId(this._conversationId);
|
|
3645
3647
|
this.applyConfig();
|
|
3648
|
+
this.setFloatButtonVisible(this._config.floatButton !== false);
|
|
3646
3649
|
// P1-2 fix: 在 _config 就绪后初始化拖拽,以正确读取 enableDrag
|
|
3647
3650
|
if (this._config?.enableDrag !== false && this.getAttribute('mode') !== 'inline' && !this._dragInitialized) {
|
|
3648
3651
|
this.initDraggable();
|
|
@@ -3679,6 +3682,21 @@ class AIChatDialog extends HTMLElement {
|
|
|
3679
3682
|
if (this._chatClient) this._chatClient.dispose();
|
|
3680
3683
|
if (this.parentNode) this.parentNode.removeChild(this);
|
|
3681
3684
|
}
|
|
3685
|
+
// P5: 运行时动态控制浮窗按钮显隐(SPA 路由切换场景:登录页隐藏,业务页显示)
|
|
3686
|
+
setFloatButtonVisible(show) {
|
|
3687
|
+
if (!this._config) this.init({
|
|
3688
|
+
floatButton: show
|
|
3689
|
+
});else this._config.floatButton = show;
|
|
3690
|
+
const btn = this.shadowRoot?.querySelector('.float-button');
|
|
3691
|
+
if (btn) {
|
|
3692
|
+
const dialog = this.shadowRoot?.querySelector('.ai-chat-dialog');
|
|
3693
|
+
const isOpen = dialog?.classList.contains('dialog-visible');
|
|
3694
|
+
if (!isOpen) {
|
|
3695
|
+
btn.style.display = show ? 'flex' : 'none';
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
return this;
|
|
3699
|
+
}
|
|
3682
3700
|
addMessage(message) {
|
|
3683
3701
|
if (!message || !message.content) return this;
|
|
3684
3702
|
const msg = {
|
|
@@ -3721,6 +3739,7 @@ class AIChatDialog extends HTMLElement {
|
|
|
3721
3739
|
if (!this._config.appId && this._config.agentAppId) this._config.appId = this._config.agentAppId;
|
|
3722
3740
|
if (this._chatClient) this._chatClient.updateConfig(this._config);
|
|
3723
3741
|
this.loadAppDetail();
|
|
3742
|
+
if ('floatButton' in config) this.setFloatButtonVisible(this._config.floatButton !== false);
|
|
3724
3743
|
}
|
|
3725
3744
|
this.applyConfig();
|
|
3726
3745
|
return this;
|
|
@@ -3781,7 +3800,7 @@ class AIChatDialog extends HTMLElement {
|
|
|
3781
3800
|
const dialog = this.shadowRoot.querySelector('.ai-chat-dialog');
|
|
3782
3801
|
const btn = this.shadowRoot.querySelector('.float-button');
|
|
3783
3802
|
if (dialog) dialog.classList.remove('dialog-visible');
|
|
3784
|
-
if (btn) btn.style.display = 'flex';
|
|
3803
|
+
if (btn) btn.style.display = this._config?.floatButton !== false ? 'flex' : 'none';
|
|
3785
3804
|
}
|
|
3786
3805
|
// ==================== 渲染(完整CSS对齐theme.css) ====================
|
|
3787
3806
|
render() {
|
|
@@ -6656,7 +6675,7 @@ function installVuePlugin(Vue) {
|
|
|
6656
6675
|
}
|
|
6657
6676
|
function useAIChat(options = {}) {
|
|
6658
6677
|
if (typeof React === 'undefined') {
|
|
6659
|
-
console.warn('[AI Web SDK] React is not loaded
|
|
6678
|
+
console.warn('[AI Web SDK] React is not loaded globally — useAIChat requires React on window (CDN mode) or use the imperative createAIChatDialog() API directly');
|
|
6660
6679
|
return {
|
|
6661
6680
|
open: () => {},
|
|
6662
6681
|
close: () => {},
|
package/dist/index.umd.js
CHANGED
|
@@ -3636,6 +3636,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
3636
3636
|
debug: false,
|
|
3637
3637
|
// P4: 自定义消息操作按钮 — 返回数组 [{label, className?, onClick}] 在 AI 消息下方渲染
|
|
3638
3638
|
onMessageActions: null,
|
|
3639
|
+
// P5: 浮窗按钮显隐控制 — false 时浮窗按钮隐藏,对话框只能通过 API 打开(登录页等场景)
|
|
3640
|
+
floatButton: true,
|
|
3639
3641
|
suggestions: [{
|
|
3640
3642
|
label: '帮我购买一台轻量应用服务器用于部署应用',
|
|
3641
3643
|
value: '帮我购买一台轻量应用服务器用于部署应用'
|
|
@@ -3649,6 +3651,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
3649
3651
|
this._chatClient = new AIChatClient(this._config);
|
|
3650
3652
|
if (this._conversationId) this._chatClient.setConversationId(this._conversationId);
|
|
3651
3653
|
this.applyConfig();
|
|
3654
|
+
this.setFloatButtonVisible(this._config.floatButton !== false);
|
|
3652
3655
|
// P1-2 fix: 在 _config 就绪后初始化拖拽,以正确读取 enableDrag
|
|
3653
3656
|
if (this._config?.enableDrag !== false && this.getAttribute('mode') !== 'inline' && !this._dragInitialized) {
|
|
3654
3657
|
this.initDraggable();
|
|
@@ -3685,6 +3688,21 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
3685
3688
|
if (this._chatClient) this._chatClient.dispose();
|
|
3686
3689
|
if (this.parentNode) this.parentNode.removeChild(this);
|
|
3687
3690
|
}
|
|
3691
|
+
// P5: 运行时动态控制浮窗按钮显隐(SPA 路由切换场景:登录页隐藏,业务页显示)
|
|
3692
|
+
setFloatButtonVisible(show) {
|
|
3693
|
+
if (!this._config) this.init({
|
|
3694
|
+
floatButton: show
|
|
3695
|
+
});else this._config.floatButton = show;
|
|
3696
|
+
const btn = this.shadowRoot?.querySelector('.float-button');
|
|
3697
|
+
if (btn) {
|
|
3698
|
+
const dialog = this.shadowRoot?.querySelector('.ai-chat-dialog');
|
|
3699
|
+
const isOpen = dialog?.classList.contains('dialog-visible');
|
|
3700
|
+
if (!isOpen) {
|
|
3701
|
+
btn.style.display = show ? 'flex' : 'none';
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
return this;
|
|
3705
|
+
}
|
|
3688
3706
|
addMessage(message) {
|
|
3689
3707
|
if (!message || !message.content) return this;
|
|
3690
3708
|
const msg = {
|
|
@@ -3727,6 +3745,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
3727
3745
|
if (!this._config.appId && this._config.agentAppId) this._config.appId = this._config.agentAppId;
|
|
3728
3746
|
if (this._chatClient) this._chatClient.updateConfig(this._config);
|
|
3729
3747
|
this.loadAppDetail();
|
|
3748
|
+
if ('floatButton' in config) this.setFloatButtonVisible(this._config.floatButton !== false);
|
|
3730
3749
|
}
|
|
3731
3750
|
this.applyConfig();
|
|
3732
3751
|
return this;
|
|
@@ -3787,7 +3806,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
3787
3806
|
const dialog = this.shadowRoot.querySelector('.ai-chat-dialog');
|
|
3788
3807
|
const btn = this.shadowRoot.querySelector('.float-button');
|
|
3789
3808
|
if (dialog) dialog.classList.remove('dialog-visible');
|
|
3790
|
-
if (btn) btn.style.display = 'flex';
|
|
3809
|
+
if (btn) btn.style.display = this._config?.floatButton !== false ? 'flex' : 'none';
|
|
3791
3810
|
}
|
|
3792
3811
|
// ==================== 渲染(完整CSS对齐theme.css) ====================
|
|
3793
3812
|
render() {
|
|
@@ -6662,7 +6681,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
6662
6681
|
}
|
|
6663
6682
|
function useAIChat(options = {}) {
|
|
6664
6683
|
if (typeof React === 'undefined') {
|
|
6665
|
-
console.warn('[AI Web SDK] React is not loaded
|
|
6684
|
+
console.warn('[AI Web SDK] React is not loaded globally — useAIChat requires React on window (CDN mode) or use the imperative createAIChatDialog() API directly');
|
|
6666
6685
|
return {
|
|
6667
6686
|
open: () => {},
|
|
6668
6687
|
close: () => {},
|