@fzbykj/ai-chat-sdk-mp 1.0.3 → 1.0.5
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/package.json +1 -1
- package/sdk/components/ai-float/ai-float.vue +15 -6
- package/sdk/utils/sdk.js +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- components/ai-float/ai-float.vue -->
|
|
2
2
|
<template>
|
|
3
|
-
<view class="ai-float-wrapper">
|
|
3
|
+
<view class="ai-float-wrapper" v-if="isVisible">
|
|
4
4
|
<!-- 折叠状态 -->
|
|
5
5
|
<view v-if="isCollapsed" class="float-collapsed" :style="collapsedStyleStr" @click="expand">
|
|
6
6
|
<text class="collapse-text">AI</text>
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
<!-- 正常状态 -->
|
|
12
12
|
<view v-else class="float-btn" :style="btnStyleStr" @touchstart="onTouchStart" @touchmove="onTouchMove"
|
|
13
13
|
@touchend="onTouchEnd" @click="openChat">
|
|
14
|
-
<image class="btn-icon"
|
|
14
|
+
<image class="btn-icon" src="https://agent.fzbykj.com/logo.png" mode="aspectFit" />
|
|
15
15
|
</view>
|
|
16
16
|
</view>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script>
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
aichat
|
|
22
|
+
} from '../../utils/sdk.js'
|
|
21
23
|
|
|
22
24
|
export default {
|
|
23
25
|
name: 'AiFloat',
|
|
@@ -60,7 +62,7 @@
|
|
|
60
62
|
_apiKey: '',
|
|
61
63
|
_userId: '',
|
|
62
64
|
_baseUrl: '',
|
|
63
|
-
|
|
65
|
+
isVisible: true // ✅ 默认显示
|
|
64
66
|
}
|
|
65
67
|
},
|
|
66
68
|
|
|
@@ -86,7 +88,8 @@
|
|
|
86
88
|
this._apiKey = this.apiKey || aichat.getApiKey()
|
|
87
89
|
this._userId = this.userId || aichat.getUserId()
|
|
88
90
|
this._baseUrl = this.baseUrl || aichat.getBaseUrl()
|
|
89
|
-
|
|
91
|
+
// ✅ 监听 SDK 的显示状态变化
|
|
92
|
+
this.isVisible = aichat.isFloatingVisible()
|
|
90
93
|
const systemInfo = uni.getSystemInfoSync()
|
|
91
94
|
this.screenWidth = systemInfo.windowWidth
|
|
92
95
|
this.screenHeight = systemInfo.windowHeight
|
|
@@ -103,6 +106,12 @@
|
|
|
103
106
|
},
|
|
104
107
|
|
|
105
108
|
methods: {
|
|
109
|
+
/**
|
|
110
|
+
* ✅ 外部调用,更新显示状态
|
|
111
|
+
*/
|
|
112
|
+
updateVisibility() {
|
|
113
|
+
this.isVisible = aichat.isFloatingVisible()
|
|
114
|
+
},
|
|
106
115
|
onTouchStart(e) {
|
|
107
116
|
const touch = e.touches[0]
|
|
108
117
|
this.startX = touch.clientX
|
|
@@ -207,7 +216,7 @@
|
|
|
207
216
|
const baseUrl = encodeURIComponent(this._baseUrl || aichat.getBaseUrl())
|
|
208
217
|
const apiKey = encodeURIComponent(this._apiKey || aichat.getApiKey())
|
|
209
218
|
const userId = encodeURIComponent(this._userId || aichat.getUserId())
|
|
210
|
-
console.log(baseUrl,apiKey,userId)
|
|
219
|
+
console.log(baseUrl, apiKey, userId)
|
|
211
220
|
uni.navigateTo({
|
|
212
221
|
url: `/pages/chat/chat?baseUrl=${baseUrl}&apiKey=${apiKey}&userId=${userId}`
|
|
213
222
|
})
|
package/sdk/utils/sdk.js
CHANGED
|
@@ -10,7 +10,9 @@ class AIChatSDK {
|
|
|
10
10
|
apiKey: '',
|
|
11
11
|
userId: '',
|
|
12
12
|
baseUrl: 'https://agent.fzbykj.com/app_chat.html',
|
|
13
|
-
enableLog: false
|
|
13
|
+
enableLog: false,
|
|
14
|
+
// ✅ 新增:是否显示悬浮图标,默认显示
|
|
15
|
+
showFloating: true
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -62,6 +64,23 @@ class AIChatSDK {
|
|
|
62
64
|
console.log('[AIChatSDK] ' + message)
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* 设置悬浮图标是否显示
|
|
69
|
+
* @param {boolean} show - true 显示,false 隐藏
|
|
70
|
+
*/
|
|
71
|
+
setFloatingVisible(show) {
|
|
72
|
+
this.config.showFloating = show
|
|
73
|
+
this.log('悬浮图标显示状态: ' + (show ? '显示' : '隐藏'))
|
|
74
|
+
return this
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 获取悬浮图标显示状态
|
|
79
|
+
* @returns {boolean}
|
|
80
|
+
*/
|
|
81
|
+
isFloatingVisible() {
|
|
82
|
+
return this.config.showFloating
|
|
83
|
+
}
|
|
65
84
|
}
|
|
66
85
|
|
|
67
86
|
// 导出单例
|