@opentiny/next-sdk 0.2.9 → 0.2.10
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/agent/AgentModelProvider.ts +10 -3
- package/agent/type.ts +3 -3
- package/dist/agent/type.d.ts +3 -0
- package/dist/index.es.dev.js +36 -22
- package/dist/index.es.js +2117 -2105
- package/dist/index.js +320 -308
- package/dist/index.umd.dev.js +36 -22
- package/dist/index.umd.js +38 -38
- package/dist/remoter/createRemoter.d.ts +3 -2
- package/dist/webagent.dev.js +15891 -15877
- package/dist/webagent.es.dev.js +15891 -15877
- package/dist/webagent.es.js +3154 -3142
- package/dist/webagent.js +35 -35
- package/package.json +1 -1
- package/remoter/createRemoter.ts +44 -23
package/package.json
CHANGED
package/remoter/createRemoter.ts
CHANGED
|
@@ -146,30 +146,33 @@ class FloatingBlock {
|
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
148
|
* 合并菜单项配置。
|
|
149
|
-
* -
|
|
150
|
-
* -
|
|
149
|
+
* - 用户明确传入 menuItems:直接使用用户配置,不受 sessionId 限制;未传 icon 时自动补充默认图标
|
|
150
|
+
* - 有 sessionId 且未传 menuItems:使用默认菜单
|
|
151
|
+
* - 无 sessionId 且未传 menuItems:不渲染任何下拉菜单,仅保留点击浮标打开对话框的能力
|
|
151
152
|
*/
|
|
152
153
|
private mergeMenuItems(userMenuItems?: MenuItemConfig[]): MenuItemConfig[] {
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
// 各 action 对应的默认图标映射
|
|
155
|
+
const defaultIcons: Partial<Record<ActionType, string>> = {
|
|
156
|
+
'qr-code': qrCode,
|
|
157
|
+
'ai-chat': chat,
|
|
158
|
+
'remote-url': link,
|
|
159
|
+
'remote-control': scan
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
// 用户明确传入了 menuItems,直接使用,并补充缺失的图标
|
|
163
|
+
if (userMenuItems) {
|
|
164
|
+
return userMenuItems.map((item) => ({
|
|
165
|
+
...item,
|
|
166
|
+
icon: item.icon ?? defaultIcons[item.action]
|
|
167
|
+
}))
|
|
160
168
|
}
|
|
161
169
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
show: userItem.show !== undefined ? userItem.show : defaultItem.show
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return defaultItem
|
|
172
|
-
})
|
|
170
|
+
// 无 sessionId 且无用户菜单:完全关闭下拉菜单,只保留点击浮标触发 onShowAIChat
|
|
171
|
+
if (!this.options.sessionId) {
|
|
172
|
+
return []
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return getDefaultMenuItems(this.options)
|
|
173
176
|
}
|
|
174
177
|
|
|
175
178
|
private init(): void {
|
|
@@ -220,7 +223,7 @@ class FloatingBlock {
|
|
|
220
223
|
<div class="tiny-remoter-dropdown-item__content">
|
|
221
224
|
<div title="${item.tip}">${item.text}</div>
|
|
222
225
|
<div class="tiny-remoter-dropdown-item__desc-wrapper">
|
|
223
|
-
<div class="tiny-remoter-dropdown-item__desc ${item.active ? 'tiny-remoter-dropdown-item__desc--active' : ''} ${item.know ? 'tiny-remoter-dropdown-item__desc--know' : ''}">${item.desc}</div>
|
|
226
|
+
<div class="tiny-remoter-dropdown-item__desc ${item.active ? 'tiny-remoter-dropdown-item__desc--active' : ''} ${item.know ? 'tiny-remoter-dropdown-item__desc--know' : ''}">${item.desc ?? ''}</div>
|
|
224
227
|
<div>
|
|
225
228
|
${
|
|
226
229
|
item.showCopyIcon
|
|
@@ -357,13 +360,31 @@ class FloatingBlock {
|
|
|
357
360
|
}
|
|
358
361
|
|
|
359
362
|
private copyRemoteControl(): void {
|
|
360
|
-
|
|
361
|
-
this.
|
|
363
|
+
// 优先使用用户菜单项中的 desc/text(支持自定义识别码),回退到 sessionId 末 6 位
|
|
364
|
+
const menuItem = this.menuItems.find((item) => item.action === 'remote-control')
|
|
365
|
+
const codeToCopy =
|
|
366
|
+
menuItem?.desc || menuItem?.text || (this.options.sessionId ? this.options.sessionId.slice(-6) : '')
|
|
367
|
+
if (codeToCopy) {
|
|
368
|
+
this.copyToClipboard(codeToCopy)
|
|
369
|
+
}
|
|
362
370
|
}
|
|
363
371
|
|
|
364
372
|
private copyRemoteURL(): void {
|
|
365
|
-
|
|
366
|
-
|
|
373
|
+
const menuItem = this.menuItems.find((item) => item.action === 'remote-url')
|
|
374
|
+
|
|
375
|
+
// 构造带 sessionId 的完整遥控链接(默认行为)
|
|
376
|
+
const sessionUrl = this.options.sessionId
|
|
377
|
+
? this.options.remoteUrl + this.sessionPrefix + this.options.sessionId
|
|
378
|
+
: ''
|
|
379
|
+
|
|
380
|
+
// 仅当 desc 是用户真正自定义的值(不同于裸 remoteUrl)时才优先使用,
|
|
381
|
+
// 否则回退到带 sessionId 的完整链接,避免默认菜单场景复制裸域名
|
|
382
|
+
const customDesc = menuItem?.desc && menuItem.desc !== this.options.remoteUrl ? menuItem.desc : undefined
|
|
383
|
+
const urlToCopy = customDesc || sessionUrl || menuItem?.text || ''
|
|
384
|
+
|
|
385
|
+
if (urlToCopy) {
|
|
386
|
+
this.copyToClipboard(urlToCopy)
|
|
387
|
+
}
|
|
367
388
|
}
|
|
368
389
|
|
|
369
390
|
// 实现复制到剪贴板功能
|