@fabianactor/dsh-lil-whale-group-ui 1.9.0 → 1.11.0
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/icon.png +0 -0
- package/lib/client.js +129 -4
- package/lib/index.js +99 -25
- package/lib/messages-core.js +43 -0
- package/locale/en.json +1 -0
- package/locale/zh.json +1 -0
- package/package.json +9 -4
package/icon.png
ADDED
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -120,6 +120,41 @@ window.__ModuleLoader__.load({
|
|
|
120
120
|
return cachedConfig
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* 版本:读两个包当前版本;「检查更新」才去问 npm。
|
|
125
|
+
* 两个包必须一起用,所以两条一起显示、一起说"有没有新的"。
|
|
126
|
+
*/
|
|
127
|
+
async function loadVersions() {
|
|
128
|
+
const response = await fetch('/group/api/version', { headers: { accept: 'application/json' } })
|
|
129
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
|
130
|
+
return await response.json()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function checkUpdates() {
|
|
134
|
+
const response = await fetch('/group/api/check-update', {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
headers: { 'x-llw-panel': '1' },
|
|
137
|
+
})
|
|
138
|
+
const data = await response.json().catch(() => null)
|
|
139
|
+
if (!response.ok) throw new Error(data?.error ?? `HTTP ${response.status}`)
|
|
140
|
+
return data
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 版本状态 → 一句人话。检查失败要说出原因,不能显示成"已是最新"。 */
|
|
144
|
+
function versionLineOf(state) {
|
|
145
|
+
if (!state) return '还没读到版本'
|
|
146
|
+
if (state.error) return `检查失败:${state.error}`
|
|
147
|
+
const part = (label, side) => {
|
|
148
|
+
if (!side) return `${label} 未知`
|
|
149
|
+
if (side.error) return `${label} ${side.current ?? '未知'}(检查失败:${side.error})`
|
|
150
|
+
if (side.latest == null) return `${label} ${side.current ?? '未知'}`
|
|
151
|
+
if (side.updateAvailable === true) return `${label} ${side.current} → 最新 ${side.latest}`
|
|
152
|
+
if (side.updateAvailable === false) return `${label} ${side.current}(已是最新)`
|
|
153
|
+
return `${label} ${side.current}(最新 ${side.latest},无法比较)`
|
|
154
|
+
}
|
|
155
|
+
return `${part('宿主', state.host)};${part('面板', state.ui)}`
|
|
156
|
+
}
|
|
157
|
+
|
|
123
158
|
/**
|
|
124
159
|
* 名字:默认按成员 id 取。
|
|
125
160
|
* 但同一个人的多段会话会共用一个 id(`lee`),所以如果能拿到这条消息的 `s`,
|
|
@@ -640,11 +675,42 @@ function insertNewline(el, value, setValue) {
|
|
|
640
675
|
growTextarea(el)
|
|
641
676
|
})
|
|
642
677
|
}
|
|
643
|
-
|
|
678
|
+
// 点消息头上的行号复制引用:`群 #1763` / `私聊 fabian__lee2 #3`。
|
|
679
|
+
// 优先用 Clipboard API;不安全的上下文(非 https/非 localhost)会没有这个对象,
|
|
680
|
+
// 落到老办法(临时 textarea + execCommand),失败就返回 false,让调用方不显示「已复制」。
|
|
681
|
+
async function copyToClipboard(text) {
|
|
682
|
+
try {
|
|
683
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
684
|
+
await navigator.clipboard.writeText(text)
|
|
685
|
+
return true
|
|
686
|
+
}
|
|
687
|
+
} catch {
|
|
688
|
+
// 继续走兜底
|
|
689
|
+
}
|
|
690
|
+
try {
|
|
691
|
+
const area = document.createElement('textarea')
|
|
692
|
+
area.value = text
|
|
693
|
+
area.setAttribute('readonly', '')
|
|
694
|
+
area.style.position = 'fixed'
|
|
695
|
+
area.style.top = '-1000px'
|
|
696
|
+
area.style.opacity = '0'
|
|
697
|
+
document.body.appendChild(area)
|
|
698
|
+
area.select()
|
|
699
|
+
const ok = document.execCommand('copy')
|
|
700
|
+
area.remove()
|
|
701
|
+
return ok
|
|
702
|
+
} catch {
|
|
703
|
+
return false
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const Bubble = React.memo(function Bubble({ config, message, onMention, animate = false, citePrefix = '' }) {
|
|
644
708
|
// 只在挂载时决定「要不要动画」:否则后续每次重渲染都会让老消息重新弹一遍。
|
|
645
709
|
const animateOnMount = useRef(animate).current
|
|
646
710
|
// 点图片打开官方看图器(大图、点外面关)。
|
|
647
711
|
const [previewIndex, setPreviewIndex] = useState(-1)
|
|
712
|
+
// 行号点一下复制引用;1.2 秒内显示「已复制」当回执。
|
|
713
|
+
const [lineCopied, setLineCopied] = useState(false)
|
|
648
714
|
const images = Array.isArray(message.images) ? message.images : (message.image ? [message.image] : [])
|
|
649
715
|
const imageSrcs = images.map((image) => imageUrlOf(image))
|
|
650
716
|
const humanId = config?.humanId ?? 'fabian'
|
|
@@ -654,6 +720,18 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
654
720
|
const targetTo = message.toSeat ? `${message.to}@${message.toSeat}` : message.to
|
|
655
721
|
const target = message.to && message.to !== 'all' ? ` → ${targetName(config, targetTo)}` : ''
|
|
656
722
|
const time = formatStamp(message.ts)
|
|
723
|
+
// 行号:引用地址。群是 messages.jsonl 的行,私聊是 pool\dm\<pair>.jsonl 的行。
|
|
724
|
+
// 文件是 append-only,行号不会变;点一下复制成别人能直接引用的形状。
|
|
725
|
+
const lineNo = typeof message.line === 'number' && message.line > 0 ? message.line : 0
|
|
726
|
+
const cite = lineNo > 0 ? `${citePrefix} #${lineNo}`.trim() : ''
|
|
727
|
+
const copyCite = () => {
|
|
728
|
+
if (!cite) return
|
|
729
|
+
copyToClipboard(cite).then((ok) => {
|
|
730
|
+
if (!ok) return
|
|
731
|
+
setLineCopied(true)
|
|
732
|
+
window.setTimeout(() => setLineCopied(false), 1200)
|
|
733
|
+
})
|
|
734
|
+
}
|
|
657
735
|
return h(React.Fragment, null,
|
|
658
736
|
h('div', {
|
|
659
737
|
style: {
|
|
@@ -684,7 +762,15 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
684
762
|
display: 'flex', alignItems: 'baseline', gap: 6,
|
|
685
763
|
fontSize: 12, color: 'var(--dsw-alias-label-tertiary)',
|
|
686
764
|
},
|
|
687
|
-
},
|
|
765
|
+
},
|
|
766
|
+
h('span', null, who + target),
|
|
767
|
+
h('span', null, time),
|
|
768
|
+
lineNo > 0 ? h('span', {
|
|
769
|
+
key: 'line',
|
|
770
|
+
title: lineCopied ? '已复制' : `点击复制引用:${cite}`,
|
|
771
|
+
onClick: copyCite,
|
|
772
|
+
style: { cursor: 'pointer', fontSize: 11, color: 'var(--dsw-alias-label-caption)', userSelect: 'none' },
|
|
773
|
+
}, lineCopied ? '已复制' : `#${lineNo}`) : null),
|
|
688
774
|
h('div', {
|
|
689
775
|
style: {
|
|
690
776
|
padding: '8px 12px', borderRadius: 'var(--dsw-radius-lg, 12px)',
|
|
@@ -1519,7 +1605,12 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
1519
1605
|
// 同群聊:打字不重排私聊历史。
|
|
1520
1606
|
const dmListNode = useMemo(
|
|
1521
1607
|
() => withDivider(messages, String(seenDm[activePeer] ?? ''), (message, index) => h(Bubble, {
|
|
1522
|
-
key: `${message.ts}-${index}`,
|
|
1608
|
+
key: `${message.ts}-${index}`,
|
|
1609
|
+
config,
|
|
1610
|
+
message,
|
|
1611
|
+
animate: animateRef.current,
|
|
1612
|
+
// 私聊引用要写清是哪一本:pool\dm\<a>__<b>.jsonl,键按字典序排(与文件命名同规则)。
|
|
1613
|
+
citePrefix: `私聊 ${[(config?.humanId ?? 'fabian'), activePeer].sort().join('__')}`,
|
|
1523
1614
|
})),
|
|
1524
1615
|
[messages, seenDm, activePeer, config],
|
|
1525
1616
|
)
|
|
@@ -2217,6 +2308,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
2217
2308
|
message,
|
|
2218
2309
|
animate: animateRef.current,
|
|
2219
2310
|
onMention: mentionTo,
|
|
2311
|
+
citePrefix: '群',
|
|
2220
2312
|
}), dividerRef)
|
|
2221
2313
|
if (visibleStart === 0) return nodes
|
|
2222
2314
|
const earlier = h(
|
|
@@ -2762,6 +2854,23 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
2762
2854
|
const fileInputs = useRef({})
|
|
2763
2855
|
const [avatarBusy, setAvatarBusy] = useState('')
|
|
2764
2856
|
|
|
2857
|
+
// 版本:进设置页先读当前版本;「检查更新」是显式动作(要联网,不自动跑)。
|
|
2858
|
+
const [versions, setVersions] = useState(null)
|
|
2859
|
+
const [updateState, setUpdateState] = useState(null)
|
|
2860
|
+
const [updateBusy, setUpdateBusy] = useState(false)
|
|
2861
|
+
useEffect(() => {
|
|
2862
|
+
void loadVersions()
|
|
2863
|
+
.then((data) => setVersions(data))
|
|
2864
|
+
.catch(() => setVersions({ error: '连不上宿主,读不到版本' }))
|
|
2865
|
+
}, [])
|
|
2866
|
+
const runCheckUpdate = () => {
|
|
2867
|
+
setUpdateBusy(true)
|
|
2868
|
+
void checkUpdates()
|
|
2869
|
+
.then((data) => setUpdateState(data))
|
|
2870
|
+
.catch((error) => setUpdateState({ error: String(error?.message ?? error) }))
|
|
2871
|
+
.finally(() => setUpdateBusy(false))
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2765
2874
|
const uploadAvatar = (member, file) => {
|
|
2766
2875
|
if (!file) return
|
|
2767
2876
|
if (!/^image\/(png|jpeg|webp)$/.test(file.type)) {
|
|
@@ -2931,6 +3040,22 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
2931
3040
|
: '群里任何人说的话都算未读(除了你自己发的)。'),
|
|
2932
3041
|
),
|
|
2933
3042
|
|
|
3043
|
+
h(SettingsSection, { title: '版本', hint: '两个包必须一起装:宿主 + 面板。版本也一起看。' },
|
|
3044
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, marginTop: 8, flexWrap: 'wrap' } },
|
|
3045
|
+
h('div', { style: { flex: 1, minWidth: 220, fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)' } },
|
|
3046
|
+
versionLineOf(updateState ?? versions)),
|
|
3047
|
+
h('button', {
|
|
3048
|
+
onClick: runCheckUpdate,
|
|
3049
|
+
disabled: updateBusy,
|
|
3050
|
+
style: { ...smallBtnStyle, opacity: updateBusy ? 0.6 : 1 },
|
|
3051
|
+
}, updateBusy ? '检查中…' : '检查更新'),
|
|
3052
|
+
),
|
|
3053
|
+
updateState?.checkedAt
|
|
3054
|
+
? h('div', { style: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)', marginTop: 6 } },
|
|
3055
|
+
`检查时间:${String(updateState.checkedAt).replace('T', ' ').slice(0, 19)}`)
|
|
3056
|
+
: null,
|
|
3057
|
+
),
|
|
3058
|
+
|
|
2934
3059
|
h('div', {
|
|
2935
3060
|
style: { marginTop: 16, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },
|
|
2936
3061
|
}, status || '改动会自动保存。侧边栏名称要刷新页面才变。'),
|
|
@@ -3650,7 +3775,7 @@ const Bubble = React.memo(function Bubble({ config, message, onMention, animate
|
|
|
3650
3775
|
inject: ['slots'],
|
|
3651
3776
|
apply(ctx) {
|
|
3652
3777
|
// 一行"我跑的是哪一版"的自报,方便判断浏览器是不是还在用旧 bundle
|
|
3653
|
-
console.info('[dsh-lil-whale-group-ui] client build
|
|
3778
|
+
console.info('[dsh-lil-whale-group-ui] client build v52 · line-cite:', Object.keys(MARKDOWN_LABELS).join(','))
|
|
3654
3779
|
// 「正在回复…」那三个点的呼吸动画 + 过场转圈。只在浏览器里注入一次。
|
|
3655
3780
|
if (typeof document !== 'undefined' && !document.getElementById('dsh-lil-whale-group-keyframes')) {
|
|
3656
3781
|
const style = document.createElement('style')
|
package/lib/index.js
CHANGED
|
@@ -10,7 +10,10 @@ import { join } from 'node:path'
|
|
|
10
10
|
import { createHash } from 'node:crypto'
|
|
11
11
|
import { spawn } from 'node:child_process'
|
|
12
12
|
import { Socket } from 'node:net'
|
|
13
|
+
import { fileURLToPath } from 'node:url'
|
|
14
|
+
import { createRequire } from 'node:module'
|
|
13
15
|
import { config } from './config.js'
|
|
16
|
+
import { parseMessageLines } from './messages-core.js'
|
|
14
17
|
|
|
15
18
|
export const name = '@fabianactor/dsh-lil-whale-group-ui'
|
|
16
19
|
export const inject = ['webServer', 'agents']
|
|
@@ -56,6 +59,61 @@ const IMAGE_EXT = { png: 'image/png', jpg: 'image/jpeg', webp: 'image/webp', gif
|
|
|
56
59
|
const IMAGE_FMT = 2
|
|
57
60
|
const IMAGE_ALGO = 'sha256'
|
|
58
61
|
|
|
62
|
+
// 版本:设置页要显示「当前版本」并检查 npm 上的最新版。
|
|
63
|
+
// 当前版本从两个包自己的 package.json 读(ui 就是自己;host 走模块解析,
|
|
64
|
+
// 解析不到再按同 scope 的兄弟目录找)——不写死数字,免得代码和 package.json 各说各话。
|
|
65
|
+
const UI_PACKAGE = JSON.parse(readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'))
|
|
66
|
+
const HOST_PACKAGE_NAME = '@fabianactor/dsh-lil-whale-group'
|
|
67
|
+
|
|
68
|
+
function hostPackageVersion() {
|
|
69
|
+
try {
|
|
70
|
+
const req = createRequire(import.meta.url)
|
|
71
|
+
const file = req.resolve(HOST_PACKAGE_NAME + '/package.json')
|
|
72
|
+
return JSON.parse(readFileSync(file, 'utf8')).version ?? null
|
|
73
|
+
} catch {
|
|
74
|
+
try {
|
|
75
|
+
return JSON.parse(readFileSync(fileURLToPath(new URL('../../dsh-lil-whale-group/package.json', import.meta.url)), 'utf8')).version ?? null
|
|
76
|
+
} catch {
|
|
77
|
+
return null
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function versionState() {
|
|
83
|
+
return {
|
|
84
|
+
host: { name: HOST_PACKAGE_NAME, current: hostPackageVersion() },
|
|
85
|
+
ui: { name: UI_PACKAGE.name, current: UI_PACKAGE.version ?? null },
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 只比 x.y.z 的数字段;预发布标签(-rc.1)忽略——给人看的是版本,不是 semver 全集。 */
|
|
90
|
+
function newerThan(latest, current) {
|
|
91
|
+
if (!latest || !current) return null
|
|
92
|
+
const a = String(latest).split('-')[0].split('.').map((n) => Number(n) || 0)
|
|
93
|
+
const b = String(current).split('-')[0].split('.').map((n) => Number(n) || 0)
|
|
94
|
+
for (let i = 0; i < 3; i += 1) {
|
|
95
|
+
if ((a[i] ?? 0) > (b[i] ?? 0)) return true
|
|
96
|
+
if ((a[i] ?? 0) < (b[i] ?? 0)) return false
|
|
97
|
+
}
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function latestOnNpm(packageName) {
|
|
102
|
+
const controller = new AbortController()
|
|
103
|
+
const timer = setTimeout(() => controller.abort(), 8000)
|
|
104
|
+
try {
|
|
105
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName.replace('/', '%2F')}/latest`, {
|
|
106
|
+
signal: controller.signal,
|
|
107
|
+
headers: { accept: 'application/json' },
|
|
108
|
+
})
|
|
109
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
|
110
|
+
const data = await response.json()
|
|
111
|
+
return typeof data?.version === 'string' ? data.version : null
|
|
112
|
+
} finally {
|
|
113
|
+
clearTimeout(timer)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
59
117
|
/**
|
|
60
118
|
* 读不到的图片必须留痕,否则"没有图"和"图丢了"看起来一样(小肥鱼的原话:
|
|
61
119
|
* 校验的价值不在拦住坏路径,在让坏路径有痕迹)。
|
|
@@ -417,31 +475,9 @@ function lastTsOf(file) {
|
|
|
417
475
|
|
|
418
476
|
function readMessages(file = MESSAGES) {
|
|
419
477
|
if (!existsSync(file)) return []
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (!text) continue
|
|
424
|
-
try {
|
|
425
|
-
const record = JSON.parse(text)
|
|
426
|
-
// 投影要带全:面板靠这些字段画图、画「→ 某人的哪一段」、判断私聊/群。早先只留了
|
|
427
|
-
// ts/from/to/text/kind,结果她发的图在面板里根本不显示 —— 记录里有、列表里没有。
|
|
428
|
-
out.push({
|
|
429
|
-
ts: record.ts,
|
|
430
|
-
from: record.from,
|
|
431
|
-
to: record.to,
|
|
432
|
-
text: record.text,
|
|
433
|
-
kind: record.kind ?? 'say',
|
|
434
|
-
...(record.s ? { s: record.s } : {}),
|
|
435
|
-
...(record.channel ? { channel: record.channel } : {}),
|
|
436
|
-
...(record.toSeat ? { toSeat: record.toSeat } : {}),
|
|
437
|
-
...(record.image ? { image: record.image } : {}),
|
|
438
|
-
...(Array.isArray(record.images) && record.images.length > 0 ? { images: record.images } : {}),
|
|
439
|
-
})
|
|
440
|
-
} catch {
|
|
441
|
-
// 半截行(另一个进程正在写)——跳过,下一次轮询就整了
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
return out
|
|
478
|
+
// 投影与行号在 lib/messages-core.js:行号是物理行号(空行/半截行也算),
|
|
479
|
+
// 它是面板上 #1763 这个引用地址的来源(r328)。
|
|
480
|
+
return parseMessageLines(readFileSync(file, 'utf8'))
|
|
445
481
|
}
|
|
446
482
|
|
|
447
483
|
function readBody(req, limit = 256 * 1024) {
|
|
@@ -877,6 +913,44 @@ export function apply(ctx) {
|
|
|
877
913
|
},
|
|
878
914
|
}))
|
|
879
915
|
|
|
916
|
+
// 版本:当前版本随时能看;「检查更新」才去问 npm。
|
|
917
|
+
// 网络不通要说清楚,不能装成"已是最新"——那和真的检查过长得一样(§60)。
|
|
918
|
+
disposers.push(ctx.webServer.register({
|
|
919
|
+
kind: 'exact',
|
|
920
|
+
path: '/group/api/version',
|
|
921
|
+
handler(req, res) {
|
|
922
|
+
if (req.method !== 'GET') {
|
|
923
|
+
sendJson(res, 405, { error: 'method-not-allowed' })
|
|
924
|
+
return
|
|
925
|
+
}
|
|
926
|
+
sendJson(res, 200, versionState())
|
|
927
|
+
},
|
|
928
|
+
}))
|
|
929
|
+
|
|
930
|
+
disposers.push(ctx.webServer.register({
|
|
931
|
+
kind: 'exact',
|
|
932
|
+
path: '/group/api/check-update',
|
|
933
|
+
async handler(req, res) {
|
|
934
|
+
if (!guardWrite(req, res, '/group/api/check-update')) return
|
|
935
|
+
if (req.method !== 'POST') {
|
|
936
|
+
sendJson(res, 405, { error: 'method-not-allowed' })
|
|
937
|
+
return
|
|
938
|
+
}
|
|
939
|
+
const base = versionState()
|
|
940
|
+
const result = { checkedAt: new Date().toISOString(), host: { ...base.host }, ui: { ...base.ui } }
|
|
941
|
+
for (const side of ['host', 'ui']) {
|
|
942
|
+
try {
|
|
943
|
+
const latest = await latestOnNpm(result[side].name)
|
|
944
|
+
result[side].latest = latest
|
|
945
|
+
result[side].updateAvailable = newerThan(latest, result[side].current)
|
|
946
|
+
} catch (error) {
|
|
947
|
+
result[side].error = String(error?.message ?? error)
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
sendJson(res, 200, result)
|
|
951
|
+
},
|
|
952
|
+
}))
|
|
953
|
+
|
|
880
954
|
/**
|
|
881
955
|
* 头像照片:读一张、换一张、去掉。
|
|
882
956
|
*
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// 消息文件的投影:把 JSONL 变成面板能画的对象,同时带上**物理行号**。
|
|
2
|
+
//
|
|
3
|
+
// 为什么行号要在这里定:面板上的 `#1763` 是引用地址,指的是 messages.jsonl /
|
|
4
|
+
// pool\dm\<a>__<b>.jsonl 的第 1763 行(两个文件都是 append-only,行号不会变)。
|
|
5
|
+
// 行号必须按"读到的第几行"算,包含空行与半截行 —— 否则引用会随文件里的空行错位。
|
|
6
|
+
//
|
|
7
|
+
// 抽出成纯函数(2026-11-18,r328)是为了能直接测:以前这段埋在 web 路由的文件里,
|
|
8
|
+
// 只靠静态断言证明"代码里写了这件事",测不到"空行/坏行时行号对不对"。
|
|
9
|
+
|
|
10
|
+
export function projectMessage(record) {
|
|
11
|
+
// 投影要带全:面板靠这些字段画图、画「→ 某人的哪一段」、判断私聊/群。早先只留了
|
|
12
|
+
// ts/from/to/text/kind,结果她发的图在面板里根本不显示 —— 记录里有、列表里没有。
|
|
13
|
+
const out = {
|
|
14
|
+
ts: record.ts,
|
|
15
|
+
from: record.from,
|
|
16
|
+
to: record.to,
|
|
17
|
+
text: record.text,
|
|
18
|
+
kind: record.kind ?? 'say',
|
|
19
|
+
}
|
|
20
|
+
if (record.s) out.s = record.s
|
|
21
|
+
if (record.channel) out.channel = record.channel
|
|
22
|
+
if (record.toSeat) out.toSeat = record.toSeat
|
|
23
|
+
if (record.image) out.image = record.image
|
|
24
|
+
if (Array.isArray(record.images) && record.images.length > 0) out.images = record.images
|
|
25
|
+
return out
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function parseMessageLines(text) {
|
|
29
|
+
const out = []
|
|
30
|
+
let lineNo = 0
|
|
31
|
+
for (const line of String(text).split(/\r?\n/)) {
|
|
32
|
+
lineNo += 1
|
|
33
|
+
const raw = line.trim()
|
|
34
|
+
if (!raw) continue
|
|
35
|
+
try {
|
|
36
|
+
const record = JSON.parse(raw)
|
|
37
|
+
out.push({ line: lineNo, ...projectMessage(record) })
|
|
38
|
+
} catch {
|
|
39
|
+
// 半截行(另一个进程正在写)——跳过,下一次轮询就整了;行号照旧往前数。
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return out
|
|
43
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"meta":{"title":"lil-whale panel","description":"Sidebar panel for the lil-whale group: group chat, DMs, unread badges, images and a pond page that starts and stops each agent. Requires the host package @fabianactor/dsh-lil-whale-group."}}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"meta":{"title":"小小肥鱼 · 面板","description":"侧边栏面板:群聊、私聊、未读红点、图片,以及开关每条鱼的鱼塘页。需同时安装宿主包 @fabianactor/dsh-lil-whale-group。"}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabianactor/dsh-lil-whale-group-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "群聊页面:侧边栏一个图标,点开是三条鱼的群(读写 lil-whale\\group\\messages.jsonl)",
|
|
6
6
|
"author": "Fabian",
|
|
@@ -25,11 +25,15 @@
|
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": "./lib/index.js",
|
|
28
|
-
"./client": "./lib/client.js"
|
|
28
|
+
"./client": "./lib/client.js",
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./locale/*": "./locale/*"
|
|
29
31
|
},
|
|
30
32
|
"files": [
|
|
31
33
|
"lib/*.js",
|
|
32
|
-
"cordis.patch.yml"
|
|
34
|
+
"cordis.patch.yml",
|
|
35
|
+
"icon.png",
|
|
36
|
+
"locale"
|
|
33
37
|
],
|
|
34
38
|
"dsh": {
|
|
35
39
|
"bundle": {
|
|
@@ -42,5 +46,6 @@
|
|
|
42
46
|
"@deepseek-ai/dsh-client-ui-primitives"
|
|
43
47
|
]
|
|
44
48
|
}
|
|
45
|
-
}
|
|
49
|
+
},
|
|
50
|
+
"icon": "icon.png"
|
|
46
51
|
}
|