@waterplus-ai/waterbuddy 0.2.6 → 0.2.7
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/lib/client/index.js +3 -57
- package/package.json +1 -1
package/lib/client/index.js
CHANGED
|
@@ -617,41 +617,6 @@ window.__ModuleLoader__.load({
|
|
|
617
617
|
return null
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
-
/**
|
|
621
|
-
* 写剪贴板。
|
|
622
|
-
*
|
|
623
|
-
* `navigator.clipboard` 只在安全上下文可用,而且在内嵌 webview 里可能被权限策略挡掉;
|
|
624
|
-
* 这里落到 `execCommand('copy')` 兜底(已废弃,但仍是 webview 里最可靠的一条路)。
|
|
625
|
-
* @param text - 要复制的内容。
|
|
626
|
-
* @throws 两条路都不通时抛出,由调用方提示用户。
|
|
627
|
-
*/
|
|
628
|
-
async function writeClipboard(text) {
|
|
629
|
-
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
|
|
630
|
-
try {
|
|
631
|
-
await navigator.clipboard.writeText(text)
|
|
632
|
-
return
|
|
633
|
-
} catch { /* 落到下面的兜底 */ }
|
|
634
|
-
}
|
|
635
|
-
// 兜底:WebKit 对"完全不可见"的 textarea 常常拒绝复制,所以留 1px 与极小透明度,
|
|
636
|
-
// 并且必须 focus + select 之后再 execCommand。整段仍是同步的,手势不会丢。
|
|
637
|
-
const area = document.createElement('textarea')
|
|
638
|
-
area.value = text
|
|
639
|
-
area.setAttribute('readonly', '')
|
|
640
|
-
area.style.position = 'fixed'
|
|
641
|
-
area.style.top = '0'
|
|
642
|
-
area.style.left = '0'
|
|
643
|
-
area.style.width = '1px'
|
|
644
|
-
area.style.height = '1px'
|
|
645
|
-
area.style.padding = '0'
|
|
646
|
-
area.style.border = '0'
|
|
647
|
-
area.style.opacity = '0.01'
|
|
648
|
-
document.body.append(area)
|
|
649
|
-
area.focus()
|
|
650
|
-
area.select()
|
|
651
|
-
const ok = typeof document.execCommand === 'function' && document.execCommand('copy')
|
|
652
|
-
area.remove()
|
|
653
|
-
if (!ok) throw new Error('clipboard-unavailable')
|
|
654
|
-
}
|
|
655
620
|
|
|
656
621
|
/**
|
|
657
622
|
* 新会话 hero 的品牌标记:用我们左上角那个 mark,替换宿主默认的鸟形图标。
|
|
@@ -1184,20 +1149,6 @@ window.__ModuleLoader__.load({
|
|
|
1184
1149
|
const avatar = expert.avatar
|
|
1185
1150
|
? jsx('img', { src: expert.avatar, alt: '', style: { width: 48, height: 48, borderRadius: '50%', objectFit: 'cover', flexShrink: 0 } })
|
|
1186
1151
|
: jsx('span', { style: { width: 48, height: 48, borderRadius: '50%', display: 'grid', placeItems: 'center', background: '#eef4ff', fontSize: 27, flexShrink: 0 }, children: expert.emoji || '🧠' })
|
|
1187
|
-
const copySummary = () => {
|
|
1188
|
-
const lines = [
|
|
1189
|
-
expert.name,
|
|
1190
|
-
expert.profession ? `职业:${expert.profession}` : '',
|
|
1191
|
-
expert.description,
|
|
1192
|
-
expert.version ? `版本:${expert.version}` : '',
|
|
1193
|
-
expert.defaultInitPrompt ? `默认开场:${expert.defaultInitPrompt}` : '',
|
|
1194
|
-
members.length > 0 ? `团队成员:${members.map(member => `${member.name || member.slug}(${member.role === 'lead' ? '负责人' : '成员'})`).join('、')}` : '',
|
|
1195
|
-
skills.length > 0 ? `关联技能:${skills.map(skill => skill.skillName).join('、')}` : '',
|
|
1196
|
-
knowledgeBases.length > 0 ? `关联知识库:${knowledgeBases.map(item => item.name || item.id || item).join('、')}` : '',
|
|
1197
|
-
...quickPrompts.map(item => `- ${item}`),
|
|
1198
|
-
].filter(Boolean)
|
|
1199
|
-
void writeClipboard(lines.join('\n')).catch(() => {})
|
|
1200
|
-
}
|
|
1201
1152
|
return jsx('div', { style: EXPERT_STYLE.overlay, onClick: event => { if (event.target === event.currentTarget) onClose() }, children:
|
|
1202
1153
|
jsxs('div', { style: { ...EXPERT_STYLE.modal, width: 'min(860px, 100%)', maxHeight: '86vh' }, children: [
|
|
1203
1154
|
jsxs('div', { style: EXPERT_STYLE.modalHead, children: [
|
|
@@ -1273,11 +1224,7 @@ window.__ModuleLoader__.load({
|
|
|
1273
1224
|
jsx('summary', { style: { cursor: 'pointer', color: '#64748b', fontSize: 12 }, children: '查看角色定义全文' }),
|
|
1274
1225
|
jsx('pre', { style: { ...EXPERT_STYLE.pre, marginTop: 8, padding: 10, borderRadius: 9, background: '#f8fafc', maxHeight: 360, overflow: 'auto' }, children: dialog.body || '暂无角色定义' }),
|
|
1275
1226
|
] }),
|
|
1276
|
-
] }) })
|
|
1277
|
-
jsxs('div', { style: EXPERT_STYLE.modalFoot, children: [
|
|
1278
|
-
jsx('button', { type: 'button', onClick: copySummary, style: EXPERT_STYLE.ghost, children: '分享' }),
|
|
1279
|
-
jsx('button', { type: 'button', onClick: () => { void writeClipboard(dialog.body || '').catch(() => {}) }, style: EXPERT_STYLE.ghost, children: '复制提示词' }),
|
|
1280
|
-
] }),
|
|
1227
|
+
] }) })
|
|
1281
1228
|
] }) })
|
|
1282
1229
|
}
|
|
1283
1230
|
|
|
@@ -1433,9 +1380,8 @@ window.__ModuleLoader__.load({
|
|
|
1433
1380
|
}
|
|
1434
1381
|
}
|
|
1435
1382
|
|
|
1436
|
-
//
|
|
1437
|
-
//
|
|
1438
|
-
// 复制入口保留在「查看提示词」弹窗内——正文已经拿到手,点击即同步写入。
|
|
1383
|
+
// 不提供剪贴板导出能力:WebKit(Tauri 用的就是它)要求剪贴板写入发生在用户手势的同步
|
|
1384
|
+
// 调用栈里,而角色正文要先按 slug 异步取回,异步路径下写入常被拒(`NotAllowedError`)。
|
|
1439
1385
|
|
|
1440
1386
|
const experts = snapshot ? snapshot.experts || [] : []
|
|
1441
1387
|
const teams = snapshot
|