dsh-gallery 0.7.2 → 0.8.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/CHANGELOG.md +104 -0
- package/client.js +482 -15
- package/cordis.patch.yml +5 -1
- package/index.js +1531 -1187
- package/package.json +3 -2
- package/session-index.js +187 -0
package/client.js
CHANGED
|
@@ -50,12 +50,39 @@ window.__ModuleLoader__.load({
|
|
|
50
50
|
kindFile: '文件',
|
|
51
51
|
scopeGlobal: '全局资产',
|
|
52
52
|
scopeSession: '当前对话',
|
|
53
|
-
scopeGlobalHint: '
|
|
53
|
+
scopeGlobalHint: '按对话分组的全部产出',
|
|
54
54
|
scopeSessionHint: '仅本对话产出过的文件',
|
|
55
55
|
scopeUnknown: '未记录本对话产出',
|
|
56
56
|
scopeNotFound: '找不到本对话的会话记录',
|
|
57
57
|
scopeLogEmpty: '本对话的会话记录为空',
|
|
58
58
|
subCount: '{shown} / {total} 条',
|
|
59
|
+
// ===== 资产分类(三色边框)=====
|
|
60
|
+
catFinal: '最终',
|
|
61
|
+
catInput: '输入',
|
|
62
|
+
catIntermediate: '中间',
|
|
63
|
+
catUnknown: '未归类',
|
|
64
|
+
catLegendFinal: '最终交付物',
|
|
65
|
+
catLegendInput: '输入素材',
|
|
66
|
+
catLegendIntermediate: '中间产物',
|
|
67
|
+
catLegendUnknown: '未归类',
|
|
68
|
+
catLegendHint: '边框颜色代表资产类型;「未归类」是会话记录里查不到归属的历史文件',
|
|
69
|
+
// ===== 全局按对话分组 =====
|
|
70
|
+
groupCount: '{count} 个',
|
|
71
|
+
groupFinal: '最终 {n}',
|
|
72
|
+
groupInput: '输入 {n}',
|
|
73
|
+
groupIntermediate: '中间 {n}',
|
|
74
|
+
groupUnknown: '未归类 {n}',
|
|
75
|
+
groupTruncated: '仅显示最近 {shown} 个,共 {total} 个',
|
|
76
|
+
groupHistoryTitle: '历史资产',
|
|
77
|
+
groupCurrentBadge: '当前对话',
|
|
78
|
+
groupHistoryHint: '这些文件在会话记录里查不到归属对话',
|
|
79
|
+
groupUnassigned: '未归属对话',
|
|
80
|
+
groupFiles: '{n} 个文件',
|
|
81
|
+
groupExpand: '展开',
|
|
82
|
+
groupCollapse: '收起',
|
|
83
|
+
groupEmpty: '没有资产',
|
|
84
|
+
groupShowIntermediate: '显示中间产物 {n}',
|
|
85
|
+
groupHideIntermediate: '隐藏中间产物 {n}',
|
|
59
86
|
// 设置面板
|
|
60
87
|
settingsTitle: '设置产出根目录',
|
|
61
88
|
rootLabel: '产出根目录',
|
|
@@ -148,12 +175,39 @@ window.__ModuleLoader__.load({
|
|
|
148
175
|
kindFile: 'Files',
|
|
149
176
|
scopeGlobal: 'All assets',
|
|
150
177
|
scopeSession: 'This chat',
|
|
151
|
-
scopeGlobalHint: '
|
|
178
|
+
scopeGlobalHint: 'All outputs, grouped by conversation',
|
|
152
179
|
scopeSessionHint: 'Only files produced in this chat',
|
|
153
180
|
scopeUnknown: 'No outputs recorded for this chat',
|
|
154
181
|
scopeNotFound: 'Cannot find this chat’s session log',
|
|
155
182
|
scopeLogEmpty: 'This chat’s session log is empty',
|
|
156
183
|
subCount: '{shown} of {total}',
|
|
184
|
+
// Asset categories (colored borders)
|
|
185
|
+
catFinal: 'Final',
|
|
186
|
+
catInput: 'Input',
|
|
187
|
+
catIntermediate: 'Interim',
|
|
188
|
+
catUnknown: 'Unclassified',
|
|
189
|
+
catLegendFinal: 'Final deliverable',
|
|
190
|
+
catLegendInput: 'Input material',
|
|
191
|
+
catLegendIntermediate: 'Interim product',
|
|
192
|
+
catLegendUnknown: 'Unclassified',
|
|
193
|
+
catLegendHint: 'Border color shows the asset type; “Unclassified” means the session logs have no record of it',
|
|
194
|
+
// Grouped by conversation (global view)
|
|
195
|
+
groupCount: '{count} files',
|
|
196
|
+
groupFinal: 'Final {n}',
|
|
197
|
+
groupInput: 'Input {n}',
|
|
198
|
+
groupIntermediate: 'Interim {n}',
|
|
199
|
+
groupUnknown: 'Unclassified {n}',
|
|
200
|
+
groupTruncated: 'Showing latest {shown} of {total}',
|
|
201
|
+
groupHistoryTitle: 'Older assets',
|
|
202
|
+
groupCurrentBadge: 'This chat',
|
|
203
|
+
groupHistoryHint: 'These files have no conversation recorded in the session logs',
|
|
204
|
+
groupUnassigned: 'No conversation',
|
|
205
|
+
groupFiles: '{n} files',
|
|
206
|
+
groupExpand: 'Expand',
|
|
207
|
+
groupCollapse: 'Collapse',
|
|
208
|
+
groupEmpty: 'No assets',
|
|
209
|
+
groupShowIntermediate: 'Show interim files ({n})',
|
|
210
|
+
groupHideIntermediate: 'Hide interim files ({n})',
|
|
157
211
|
// Settings panel
|
|
158
212
|
settingsTitle: 'Output root folder',
|
|
159
213
|
rootLabel: 'Output root',
|
|
@@ -639,6 +693,167 @@ window.__ModuleLoader__.load({
|
|
|
639
693
|
}
|
|
640
694
|
.dg-card:hover { border-color: var(--dsw-alias-border-l2); }
|
|
641
695
|
.dg-card:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
|
|
696
|
+
|
|
697
|
+
/* ===== 资产分类:三色边框 + 角标 =====
|
|
698
|
+
输入 = 灰蓝、中间 = 橙色、最终 = 绿色。
|
|
699
|
+
边框加粗到 2px 以便一眼分辨。 */
|
|
700
|
+
.dg-card { position: relative; }
|
|
701
|
+
.dg-cat-final { border: 2px solid #1A936F; }
|
|
702
|
+
.dg-cat-input { border: 2px solid #8A8F99; }
|
|
703
|
+
.dg-cat-intermediate { border: 2px solid #D48806; }
|
|
704
|
+
.dg-cat-unknown { border: 2px solid #C8CDD6; }
|
|
705
|
+
.dg-cat-final:hover { border-color: #157A5C; }
|
|
706
|
+
.dg-cat-input:hover { border-color: #6B7079; }
|
|
707
|
+
.dg-cat-intermediate:hover { border-color: #B36F05; }
|
|
708
|
+
.dg-cat-unknown:hover { border-color: #A8AEB8; }
|
|
709
|
+
|
|
710
|
+
/* 角标:贴在缩略图右上角 */
|
|
711
|
+
.dg-catBadge {
|
|
712
|
+
position: absolute;
|
|
713
|
+
top: 6px;
|
|
714
|
+
right: 6px;
|
|
715
|
+
z-index: 2;
|
|
716
|
+
padding: 2px 7px;
|
|
717
|
+
border-radius: 9px;
|
|
718
|
+
font-size: 10px;
|
|
719
|
+
font-weight: 600;
|
|
720
|
+
line-height: 1.5;
|
|
721
|
+
color: #FFFFFF;
|
|
722
|
+
pointer-events: none;
|
|
723
|
+
}
|
|
724
|
+
.dg-catBadge-final { background: #1A936F; }
|
|
725
|
+
.dg-catBadge-input { background: #8A8F99; }
|
|
726
|
+
.dg-catBadge-intermediate { background: #D48806; }
|
|
727
|
+
.dg-catBadge-unknown { background: #8C93A0; }
|
|
728
|
+
|
|
729
|
+
/* ===== 图例(分类颜色说明)===== */
|
|
730
|
+
.dg-legend {
|
|
731
|
+
display: flex;
|
|
732
|
+
gap: 12px;
|
|
733
|
+
flex-wrap: wrap;
|
|
734
|
+
align-items: center;
|
|
735
|
+
padding: 7px 10px;
|
|
736
|
+
font-size: 11px;
|
|
737
|
+
color: var(--dsw-alias-label-secondary);
|
|
738
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
739
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
740
|
+
border-radius: 6px;
|
|
741
|
+
}
|
|
742
|
+
.dg-legendItem { display: inline-flex; align-items: center; gap: 5px; }
|
|
743
|
+
.dg-legendSwatch {
|
|
744
|
+
width: 10px;
|
|
745
|
+
height: 10px;
|
|
746
|
+
border-radius: 2px;
|
|
747
|
+
flex: 0 0 auto;
|
|
748
|
+
}
|
|
749
|
+
.dg-legendSwatch-final { background: #1A936F; }
|
|
750
|
+
.dg-legendSwatch-input { background: #8A8F99; }
|
|
751
|
+
.dg-legendSwatch-intermediate { background: #D48806; }
|
|
752
|
+
.dg-legendSwatch-unknown { background: #8C93A0; }
|
|
753
|
+
|
|
754
|
+
/* ===== 分组(全局按对话)===== */
|
|
755
|
+
.dg-groups { display: flex; flex-direction: column; gap: 8px; }
|
|
756
|
+
.dg-group {
|
|
757
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
758
|
+
border-radius: 8px;
|
|
759
|
+
overflow: hidden;
|
|
760
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
761
|
+
}
|
|
762
|
+
.dg-groupHead {
|
|
763
|
+
display: flex;
|
|
764
|
+
align-items: center;
|
|
765
|
+
gap: 8px;
|
|
766
|
+
width: 100%;
|
|
767
|
+
padding: 9px 11px;
|
|
768
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
769
|
+
border: none;
|
|
770
|
+
border-bottom: 1px solid transparent;
|
|
771
|
+
cursor: pointer;
|
|
772
|
+
font: inherit;
|
|
773
|
+
color: inherit;
|
|
774
|
+
text-align: left;
|
|
775
|
+
appearance: none;
|
|
776
|
+
}
|
|
777
|
+
.dg-groupHead:hover { background: var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-layer-2)); }
|
|
778
|
+
.dg-groupHeadOpen { border-bottom-color: var(--dsw-alias-border-l1); }
|
|
779
|
+
.dg-groupArrow {
|
|
780
|
+
flex: 0 0 auto;
|
|
781
|
+
font-size: 10px;
|
|
782
|
+
color: var(--dsw-alias-label-secondary);
|
|
783
|
+
transition: transform .15s ease;
|
|
784
|
+
width: 10px;
|
|
785
|
+
}
|
|
786
|
+
.dg-groupArrowOpen { transform: rotate(90deg); }
|
|
787
|
+
.dg-groupTitle {
|
|
788
|
+
flex: 1 1 auto;
|
|
789
|
+
min-width: 0;
|
|
790
|
+
font-size: 13px;
|
|
791
|
+
font-weight: 600;
|
|
792
|
+
color: var(--dsw-alias-label-primary);
|
|
793
|
+
overflow: hidden;
|
|
794
|
+
text-overflow: ellipsis;
|
|
795
|
+
white-space: nowrap;
|
|
796
|
+
}
|
|
797
|
+
.dg-groupHistory .dg-groupTitle { color: var(--dsw-alias-label-secondary); font-weight: 500; }
|
|
798
|
+
|
|
799
|
+
/* 当前对话组:置顶 + 左侧强调条 + 徽标,让用户一眼认出「这就是我刚才那次」 */
|
|
800
|
+
.dg-groupCurrent {
|
|
801
|
+
border-color: var(--dsw-alias-brand-primary);
|
|
802
|
+
box-shadow: 0 0 0 1px color-mix(in srgb, var(--dsw-alias-brand-primary) 22%, transparent);
|
|
803
|
+
}
|
|
804
|
+
.dg-groupCurrent .dg-groupHead {
|
|
805
|
+
background: color-mix(in srgb, var(--dsw-alias-brand-primary) 7%, var(--dsw-alias-bg-layer-2));
|
|
806
|
+
}
|
|
807
|
+
.dg-groupCurrentBadge {
|
|
808
|
+
flex: 0 0 auto;
|
|
809
|
+
padding: 1px 7px;
|
|
810
|
+
border-radius: 9px;
|
|
811
|
+
font-size: 10px;
|
|
812
|
+
font-weight: 600;
|
|
813
|
+
line-height: 1.6;
|
|
814
|
+
color: #FFFFFF;
|
|
815
|
+
background: var(--dsw-alias-brand-primary);
|
|
816
|
+
}
|
|
817
|
+
.dg-groupCurrent .dg-groupTitle { font-weight: 700; }
|
|
818
|
+
.dg-groupDate {
|
|
819
|
+
flex: 0 0 auto;
|
|
820
|
+
font-size: 11px;
|
|
821
|
+
color: var(--dsw-alias-label-secondary);
|
|
822
|
+
white-space: nowrap;
|
|
823
|
+
}
|
|
824
|
+
.dg-groupChips { display: inline-flex; gap: 5px; flex: 0 0 auto; }
|
|
825
|
+
.dg-chip {
|
|
826
|
+
padding: 1px 7px;
|
|
827
|
+
border-radius: 9px;
|
|
828
|
+
font-size: 10px;
|
|
829
|
+
font-weight: 600;
|
|
830
|
+
line-height: 1.6;
|
|
831
|
+
color: #FFFFFF;
|
|
832
|
+
}
|
|
833
|
+
.dg-chip-final { background: #1A936F; }
|
|
834
|
+
.dg-chip-input { background: #8A8F99; }
|
|
835
|
+
.dg-chip-intermediate { background: #D48806; }
|
|
836
|
+
.dg-chip-unknown { background: #8C93A0; }
|
|
837
|
+
.dg-chipMuted {
|
|
838
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
839
|
+
color: var(--dsw-alias-label-secondary);
|
|
840
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
841
|
+
font-weight: 500;
|
|
842
|
+
}
|
|
843
|
+
.dg-groupBody { padding: 10px; }
|
|
844
|
+
.dg-groupEmpty {
|
|
845
|
+
padding: 14px 10px;
|
|
846
|
+
font-size: 12px;
|
|
847
|
+
color: var(--dsw-alias-label-secondary);
|
|
848
|
+
text-align: center;
|
|
849
|
+
}
|
|
850
|
+
.dg-groupHint {
|
|
851
|
+
padding: 7px 11px;
|
|
852
|
+
font-size: 11px;
|
|
853
|
+
color: var(--dsw-alias-label-secondary);
|
|
854
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
855
|
+
border-bottom: 1px solid var(--dsw-alias-border-l1);
|
|
856
|
+
}
|
|
642
857
|
.dg-thumb {
|
|
643
858
|
display: flex;
|
|
644
859
|
align-items: center;
|
|
@@ -1341,9 +1556,10 @@ ${absPath}
|
|
|
1341
1556
|
return h('button', {
|
|
1342
1557
|
type: 'button',
|
|
1343
1558
|
ref: setNode,
|
|
1344
|
-
className:
|
|
1345
|
-
title: item.relPath
|
|
1559
|
+
className: `dg-card dg-cat-${item.category || 'none'}`,
|
|
1560
|
+
title: `${item.relPath}${item.category ? `\n[${t('cat' + item.category[0].toUpperCase() + item.category.slice(1))}]` : ''}`,
|
|
1346
1561
|
'data-gallery-card': item.relPath,
|
|
1562
|
+
'data-gallery-category': item.category || '',
|
|
1347
1563
|
onClick: (event) => onOpen(item, event.currentTarget),
|
|
1348
1564
|
onContextMenu: (event) => {
|
|
1349
1565
|
event.preventDefault()
|
|
@@ -1351,6 +1567,14 @@ ${absPath}
|
|
|
1351
1567
|
if (typeof onContextMenu === 'function') onContextMenu(item, null, event)
|
|
1352
1568
|
},
|
|
1353
1569
|
}, [
|
|
1570
|
+
// 分类角标
|
|
1571
|
+
item.category
|
|
1572
|
+
? h('span', {
|
|
1573
|
+
className: `dg-catBadge dg-catBadge-${item.category}`,
|
|
1574
|
+
key: 'badge',
|
|
1575
|
+
'data-gallery-badge': item.category,
|
|
1576
|
+
}, t('cat' + item.category[0].toUpperCase() + item.category.slice(1)))
|
|
1577
|
+
: null,
|
|
1354
1578
|
h('div', { className: 'dg-thumb', key: 'thumb' },
|
|
1355
1579
|
state.status === 'ready'
|
|
1356
1580
|
? h('img', {
|
|
@@ -2102,6 +2326,24 @@ ${absPath}
|
|
|
2102
2326
|
const [page, setPage] = React.useState(1)
|
|
2103
2327
|
// 设置面板开关(改产出根目录)
|
|
2104
2328
|
const [settingsOpen, setSettingsOpen] = React.useState(false)
|
|
2329
|
+
// 全局分组:哪些组是展开的(键是 sessionId 或 '__history__')
|
|
2330
|
+
const [openGroups, setOpenGroups] = React.useState(new Set())
|
|
2331
|
+
// 分组默认展开只做一次:当前对话组优先,没有则展开第一个。
|
|
2332
|
+
// 用 ref 记住「已初始化」,否则用户手动收起后每次渲染又被强制展开。
|
|
2333
|
+
const groupsInitRef = React.useRef(false)
|
|
2334
|
+
// 全局分组:哪些组显示了中间产物
|
|
2335
|
+
const [showInterim, setShowInterim] = React.useState({})
|
|
2336
|
+
const toggleGroup = React.useCallback((key) => {
|
|
2337
|
+
setOpenGroups((prev) => {
|
|
2338
|
+
const next = new Set(prev)
|
|
2339
|
+
if (next.has(key)) next.delete(key)
|
|
2340
|
+
else next.add(key)
|
|
2341
|
+
return next
|
|
2342
|
+
})
|
|
2343
|
+
}, [])
|
|
2344
|
+
const toggleInterim = React.useCallback((key) => {
|
|
2345
|
+
setShowInterim((prev) => ({ ...prev, [key]: !prev[key] }))
|
|
2346
|
+
}, [])
|
|
2105
2347
|
// 右键菜单:{ item, absPath, x, y }
|
|
2106
2348
|
const [ctxMenu, setCtxMenu] = React.useState(null)
|
|
2107
2349
|
// 删除确认:{ item, busy }
|
|
@@ -2122,8 +2364,16 @@ ${absPath}
|
|
|
2122
2364
|
|
|
2123
2365
|
const closeContextMenu = React.useCallback(() => setCtxMenu(null), [])
|
|
2124
2366
|
|
|
2125
|
-
/**
|
|
2126
|
-
|
|
2367
|
+
/**
|
|
2368
|
+
* 打开某张图:先记住当前滚动位置。
|
|
2369
|
+
*
|
|
2370
|
+
* @param index - 在 list 里的下标。
|
|
2371
|
+
* @param anchorEl - 被点击的卡片元素(用于退出时精确回位)。
|
|
2372
|
+
* @param list - 该图片所属的列表快照。**必须传**:
|
|
2373
|
+
* 分组视图下卡片来自 `data.groups[i].files`,与当前页的扁平 `items` 是两个不同的集合,
|
|
2374
|
+
* 直接用全局 `items` 的索引会「点哪张都跳出同一张图」。
|
|
2375
|
+
*/
|
|
2376
|
+
const openViewer = React.useCallback((index, anchorEl, list) => {
|
|
2127
2377
|
const scroller = bodyScrollRef.current
|
|
2128
2378
|
if (scroller !== null) {
|
|
2129
2379
|
savedScrollRef.current = {
|
|
@@ -2134,7 +2384,15 @@ ${absPath}
|
|
|
2134
2384
|
: null,
|
|
2135
2385
|
}
|
|
2136
2386
|
}
|
|
2137
|
-
|
|
2387
|
+
// 只保留查看器需要的字段,避免把整个分组对象塞进 state
|
|
2388
|
+
const snapshot = list.map((it) => ({
|
|
2389
|
+
relPath: it.relPath,
|
|
2390
|
+
name: it.name ?? it.relPath.split('/').pop(),
|
|
2391
|
+
extension: it.extension ?? ('.' + (it.relPath.split('.').pop() || '')),
|
|
2392
|
+
width: it.width ?? null,
|
|
2393
|
+
height: it.height ?? null,
|
|
2394
|
+
}))
|
|
2395
|
+
setViewer({ index, list: snapshot })
|
|
2138
2396
|
}, [])
|
|
2139
2397
|
|
|
2140
2398
|
/** 关闭查看器:恢复到原来那张缩略图的位置。 */
|
|
@@ -2247,11 +2505,27 @@ ${absPath}
|
|
|
2247
2505
|
|
|
2248
2506
|
const data = view.status === 'ready' ? view.data : null
|
|
2249
2507
|
const items = data?.items ?? []
|
|
2508
|
+
|
|
2509
|
+
// 分组首次渲染时,默认展开「当前对话」那一组(没有则展开第一组)。
|
|
2510
|
+
// 只做一次:之后用户手动收起/展开都保留。
|
|
2511
|
+
React.useEffect(() => {
|
|
2512
|
+
if (groupsInitRef.current) return
|
|
2513
|
+
if (data === null || !Array.isArray(data.groups) || data.groups.length === 0) return
|
|
2514
|
+
groupsInitRef.current = true
|
|
2515
|
+
const target = data.groups.find((g) => g.isCurrent === true) ?? data.groups[0]
|
|
2516
|
+
if (target === undefined) return
|
|
2517
|
+
setOpenGroups(new Set([target.sessionId ?? '__history__']))
|
|
2518
|
+
}, [data])
|
|
2519
|
+
|
|
2250
2520
|
const step = React.useCallback((delta) => {
|
|
2251
|
-
setViewer((current) =>
|
|
2252
|
-
|
|
2521
|
+
setViewer((current) => {
|
|
2522
|
+
if (current === null) return null
|
|
2523
|
+
// 用查看器自己的列表长度(不是全局 items),分组视图下两者不同
|
|
2524
|
+
const len = current.list.length
|
|
2525
|
+
if (len === 0) return current
|
|
2526
|
+
return { ...current, index: (current.index + delta + len) % len }
|
|
2253
2527
|
})
|
|
2254
|
-
}, [
|
|
2528
|
+
}, [])
|
|
2255
2529
|
|
|
2256
2530
|
// 分类开关:全局资产 / 当前对话
|
|
2257
2531
|
const scopeSwitch = h('div', { className: 'dg-scopeSwitch', key: 'scope' }, [
|
|
@@ -2321,6 +2595,33 @@ ${absPath}
|
|
|
2321
2595
|
}, refreshing ? t('refreshing') : t('refresh')),
|
|
2322
2596
|
])
|
|
2323
2597
|
|
|
2598
|
+
// 分类图例:告诉用户三种边框颜色代表什么(只在有数据时显示)
|
|
2599
|
+
// 「未归类」只有在确实存在这类文件时才显示,避免图例噪音
|
|
2600
|
+
const hasUnknown = data !== null && Array.isArray(data.groups) &&
|
|
2601
|
+
data.groups.some((gr) => (gr.counts?.unknown ?? 0) > 0)
|
|
2602
|
+
const legend = data !== null && items.length > 0
|
|
2603
|
+
? h('div', { className: 'dg-legend', key: 'legend', title: t('catLegendHint') }, [
|
|
2604
|
+
h('span', { className: 'dg-legendItem', key: 'f' }, [
|
|
2605
|
+
h('span', { className: 'dg-legendSwatch dg-legendSwatch-final', key: 's' }),
|
|
2606
|
+
h('span', { key: 'l' }, t('catLegendFinal')),
|
|
2607
|
+
]),
|
|
2608
|
+
h('span', { className: 'dg-legendItem', key: 'i' }, [
|
|
2609
|
+
h('span', { className: 'dg-legendSwatch dg-legendSwatch-input', key: 's' }),
|
|
2610
|
+
h('span', { key: 'l' }, t('catLegendInput')),
|
|
2611
|
+
]),
|
|
2612
|
+
h('span', { className: 'dg-legendItem', key: 'm' }, [
|
|
2613
|
+
h('span', { className: 'dg-legendSwatch dg-legendSwatch-intermediate', key: 's' }),
|
|
2614
|
+
h('span', { key: 'l' }, t('catLegendIntermediate')),
|
|
2615
|
+
]),
|
|
2616
|
+
hasUnknown
|
|
2617
|
+
? h('span', { className: 'dg-legendItem', key: 'u' }, [
|
|
2618
|
+
h('span', { className: 'dg-legendSwatch dg-legendSwatch-unknown', key: 's' }),
|
|
2619
|
+
h('span', { key: 'l' }, t('catLegendUnknown')),
|
|
2620
|
+
])
|
|
2621
|
+
: null,
|
|
2622
|
+
])
|
|
2623
|
+
: null
|
|
2624
|
+
|
|
2324
2625
|
let body
|
|
2325
2626
|
if (view.status === 'loading') {
|
|
2326
2627
|
body = h('div', { className: 'dg-body', key: 'body' }, h('p', { className: 'dg-status' }, t('loading')))
|
|
@@ -2360,6 +2661,166 @@ ${absPath}
|
|
|
2360
2661
|
body = h('div', { className: 'dg-body', key: 'body' },
|
|
2361
2662
|
h('p', { className: 'dg-status' }, emptyText))
|
|
2362
2663
|
} else {
|
|
2664
|
+
// 全局模式 + 有分组数据 → 按对话分组渲染(可折叠)
|
|
2665
|
+
const useGroups = scope === 'global' && Array.isArray(data.groups) && data.groups.length > 0
|
|
2666
|
+
|
|
2667
|
+
if (useGroups) {
|
|
2668
|
+
const cardFor = (item, groupKey, listForViewer) => {
|
|
2669
|
+
// 分组里的文件也走同一套卡片组件
|
|
2670
|
+
const enriched = {
|
|
2671
|
+
...item,
|
|
2672
|
+
name: item.name ?? item.relPath.split('/').pop(),
|
|
2673
|
+
extension: item.extension ?? ('.' + (item.relPath.split('.').pop() || '')),
|
|
2674
|
+
}
|
|
2675
|
+
if (kind === 'file') {
|
|
2676
|
+
return h(FileCard, {
|
|
2677
|
+
key: `${groupKey}:${item.relPath}`,
|
|
2678
|
+
item: enriched,
|
|
2679
|
+
t,
|
|
2680
|
+
absPath: buildAbsPath(data.root, item.relPath),
|
|
2681
|
+
onOpenFolder: () => { void callHost('reveal', { path: item.relPath }).catch((e) => console.error('dsh-gallery: reveal 失败', e)) },
|
|
2682
|
+
onContextMenu: openContextMenu,
|
|
2683
|
+
onPreview: (abs) => {
|
|
2684
|
+
const address = sessionFileAddressOf(sessionId, abs)
|
|
2685
|
+
try {
|
|
2686
|
+
ctxRef.current.sidebarRight.openResource(address, { kind: 'text' })
|
|
2687
|
+
} catch (error) {
|
|
2688
|
+
console.error('dsh-gallery: 侧栏预览失败', error, address)
|
|
2689
|
+
void copyText(abs)
|
|
2690
|
+
}
|
|
2691
|
+
},
|
|
2692
|
+
onCopy: (abs) => { void copyText(abs) },
|
|
2693
|
+
})
|
|
2694
|
+
}
|
|
2695
|
+
return h(Card, {
|
|
2696
|
+
key: `${groupKey}:${item.relPath}`,
|
|
2697
|
+
item: enriched,
|
|
2698
|
+
t,
|
|
2699
|
+
limiter: limiter.current,
|
|
2700
|
+
onContextMenu: openContextMenu,
|
|
2701
|
+
onOpen: (opened, anchorEl) => {
|
|
2702
|
+
// 用**该组当前可见的文件**作为查看器列表:
|
|
2703
|
+
// 左右切图应在本组内循环,而不是跳到别的对话的图。
|
|
2704
|
+
const list = Array.isArray(listForViewer) ? listForViewer : group.files
|
|
2705
|
+
let pos = list.indexOf(opened)
|
|
2706
|
+
if (pos < 0) {
|
|
2707
|
+
// 对象引用对不上时按 relPath 找(enriched 是浅拷贝,引用可能不同)
|
|
2708
|
+
pos = list.findIndex((f) => f.relPath === opened.relPath)
|
|
2709
|
+
}
|
|
2710
|
+
if (pos < 0) return
|
|
2711
|
+
openViewer(pos, anchorEl ?? null, list)
|
|
2712
|
+
},
|
|
2713
|
+
})
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
const groupNodes = data.groups.map((group, gi) => {
|
|
2717
|
+
const groupKey = group.sessionId ?? '__history__'
|
|
2718
|
+
const isOpen = openGroups.has(groupKey)
|
|
2719
|
+
// 组内中间产物的显隐:
|
|
2720
|
+
// - 当前对话:**默认显示**(用户刚做完的就是要看过程,可选收起)
|
|
2721
|
+
// - 其他对话 / 历史资产:**默认隐藏**(避免别人调试图淹没列表)
|
|
2722
|
+
// 用户手动切换后,以 showInterim 里记录的为准(true=显示 / false=隐藏)。
|
|
2723
|
+
const interimDefault = group.isCurrent === true
|
|
2724
|
+
const stored = showInterim[groupKey]
|
|
2725
|
+
const showIntermediate = stored === undefined ? interimDefault : stored
|
|
2726
|
+
const visibleFiles = showIntermediate
|
|
2727
|
+
? group.files
|
|
2728
|
+
: group.files.filter((f) => f.category !== 'intermediate')
|
|
2729
|
+
const hiddenCount = group.files.length - visibleFiles.length
|
|
2730
|
+
|
|
2731
|
+
const chips = []
|
|
2732
|
+
if (group.counts.final > 0) {
|
|
2733
|
+
chips.push(h('span', { className: 'dg-chip dg-chip-final', key: 'f' }, format(t('groupFinal'), { n: group.counts.final })))
|
|
2734
|
+
}
|
|
2735
|
+
if (group.counts.input > 0) {
|
|
2736
|
+
chips.push(h('span', { className: 'dg-chip dg-chip-input', key: 'i' }, format(t('groupInput'), { n: group.counts.input })))
|
|
2737
|
+
}
|
|
2738
|
+
if (group.counts.intermediate > 0) {
|
|
2739
|
+
chips.push(h('span', { className: 'dg-chip dg-chip-intermediate', key: 'm' }, format(t('groupIntermediate'), { n: group.counts.intermediate })))
|
|
2740
|
+
}
|
|
2741
|
+
if ((group.counts.unknown ?? 0) > 0) {
|
|
2742
|
+
chips.push(h('span', { className: 'dg-chip dg-chip-unknown', key: 'u' }, format(t('groupUnknown'), { n: group.counts.unknown })))
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
const headKey = group.sessionId ?? '__history__'
|
|
2746
|
+
return h('div', {
|
|
2747
|
+
className: `dg-group${group.isHistory ? ' dg-groupHistory' : ''}${group.isCurrent ? ' dg-groupCurrent' : ''}`,
|
|
2748
|
+
key: `g:${headKey}`,
|
|
2749
|
+
'data-gallery-group': headKey,
|
|
2750
|
+
'data-gallery-group-current': group.isCurrent === true ? '1' : '0',
|
|
2751
|
+
}, [
|
|
2752
|
+
h('button', {
|
|
2753
|
+
type: 'button',
|
|
2754
|
+
className: `dg-groupHead${isOpen ? ' dg-groupHeadOpen' : ''}`,
|
|
2755
|
+
key: 'head',
|
|
2756
|
+
onClick: () => toggleGroup(headKey),
|
|
2757
|
+
title: group.title || t('groupHistoryTitle'),
|
|
2758
|
+
}, [
|
|
2759
|
+
h('span', { className: `dg-groupArrow${isOpen ? ' dg-groupArrowOpen' : ''}`, key: 'a' }, '▶'),
|
|
2760
|
+
group.isCurrent === true
|
|
2761
|
+
? h('span', { className: 'dg-groupCurrentBadge', key: 'cur', 'data-gallery-current-badge': true }, t('groupCurrentBadge'))
|
|
2762
|
+
: null,
|
|
2763
|
+
h('span', { className: 'dg-groupTitle', key: 't' },
|
|
2764
|
+
group.isHistory ? t('groupHistoryTitle') : (group.title || t('groupUnassigned'))),
|
|
2765
|
+
h('span', { className: 'dg-groupDate', key: 'd' },
|
|
2766
|
+
group.isHistory ? format(t('groupFiles'), { n: group.fileCount }) : formatTime(group.createdAt)),
|
|
2767
|
+
h('span', { className: 'dg-groupChips', key: 'c' }, chips),
|
|
2768
|
+
]),
|
|
2769
|
+
isOpen
|
|
2770
|
+
? [
|
|
2771
|
+
group.isHistory
|
|
2772
|
+
? h('div', { className: 'dg-groupHint', key: 'hint' }, t('groupHistoryHint'))
|
|
2773
|
+
: null,
|
|
2774
|
+
// 只有该组确实存在中间产物时才给切换按钮:
|
|
2775
|
+
// 否则「显示中间产物」点了也没东西可显示,按钮是死的。
|
|
2776
|
+
(group.counts.intermediate ?? 0) > 0
|
|
2777
|
+
? h('div', { className: 'dg-groupHint', key: 'toggle' }, [
|
|
2778
|
+
h('button', {
|
|
2779
|
+
type: 'button',
|
|
2780
|
+
className: 'dg-btn dg-btnSmall',
|
|
2781
|
+
'data-gallery-toggle-interim': headKey,
|
|
2782
|
+
'data-gallery-interim-shown': showIntermediate ? '1' : '0',
|
|
2783
|
+
onClick: () => toggleInterim(headKey),
|
|
2784
|
+
}, showIntermediate
|
|
2785
|
+
? format(t('groupHideIntermediate'), { n: group.counts.intermediate })
|
|
2786
|
+
: format(t('groupShowIntermediate'), { n: hiddenCount })),
|
|
2787
|
+
])
|
|
2788
|
+
: null,
|
|
2789
|
+
h('div', { className: 'dg-groupBody', key: 'body' }, [
|
|
2790
|
+
visibleFiles.length > 0
|
|
2791
|
+
? h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}`, key: 'grid' },
|
|
2792
|
+
visibleFiles.map((f) => cardFor(f, headKey, visibleFiles)))
|
|
2793
|
+
: h('div', { className: 'dg-groupEmpty', key: 'empty' }, t('groupEmpty')),
|
|
2794
|
+
group.truncated
|
|
2795
|
+
? h('div', { className: 'dg-groupEmpty', key: 'trunc', style: { marginTop: '8px' } },
|
|
2796
|
+
format(t('groupTruncated'), { shown: group.returnedCount, total: group.fileCount }))
|
|
2797
|
+
: null,
|
|
2798
|
+
]),
|
|
2799
|
+
]
|
|
2800
|
+
: null,
|
|
2801
|
+
])
|
|
2802
|
+
})
|
|
2803
|
+
|
|
2804
|
+
body = h('div', { className: 'dg-bodyWrap', key: 'bodyWrap' }, [
|
|
2805
|
+
h('div', {
|
|
2806
|
+
className: `dg-body${kind === 'file' ? ' dg-fileBody' : ''}`,
|
|
2807
|
+
key: 'body',
|
|
2808
|
+
'data-gallery-body': true,
|
|
2809
|
+
ref: bodyScrollRef,
|
|
2810
|
+
}, [
|
|
2811
|
+
h('div', { className: 'dg-groups', key: 'groups' }, groupNodes),
|
|
2812
|
+
data.scan.capped
|
|
2813
|
+
? h('div', { className: 'dg-more', key: 'capped' }, t('capped'))
|
|
2814
|
+
: null,
|
|
2815
|
+
]),
|
|
2816
|
+
h(ScrollRail, {
|
|
2817
|
+
key: 'rail',
|
|
2818
|
+
scrollerRef: bodyScrollRef,
|
|
2819
|
+
t,
|
|
2820
|
+
railClassName: kind === 'file' ? 'dg-panRailFiles' : '',
|
|
2821
|
+
}),
|
|
2822
|
+
])
|
|
2823
|
+
} else {
|
|
2363
2824
|
const gridChildren = items.map((item) => kind === 'file'
|
|
2364
2825
|
? h(FileCard, {
|
|
2365
2826
|
key: item.relPath,
|
|
@@ -2385,7 +2846,7 @@ ${absPath}
|
|
|
2385
2846
|
t,
|
|
2386
2847
|
limiter: limiter.current,
|
|
2387
2848
|
onContextMenu: openContextMenu,
|
|
2388
|
-
onOpen: (opened, anchorEl) => openViewer(items.indexOf(opened), anchorEl),
|
|
2849
|
+
onOpen: (opened, anchorEl) => openViewer(items.indexOf(opened), anchorEl, items),
|
|
2389
2850
|
}))
|
|
2390
2851
|
// 网格区外面包一层定位容器,右侧放滚动辅助列(无滚轮场景用)
|
|
2391
2852
|
body = h('div', { className: 'dg-bodyWrap', key: 'bodyWrap' }, [
|
|
@@ -2407,10 +2868,13 @@ ${absPath}
|
|
|
2407
2868
|
railClassName: kind === 'file' ? 'dg-panRailFiles' : '',
|
|
2408
2869
|
}),
|
|
2409
2870
|
])
|
|
2871
|
+
}
|
|
2410
2872
|
}
|
|
2411
2873
|
|
|
2412
2874
|
// 分页条:常驻显示「还有 X 张」+ 页码。单页时只显示总数,不渲染页码按钮。
|
|
2413
|
-
|
|
2875
|
+
// 全局分组模式下不分页(分组自己带折叠),所以只在「当前对话」与非分组时显示。
|
|
2876
|
+
const usePager = scope !== 'global' || (data !== null && !Array.isArray(data.groups))
|
|
2877
|
+
const pager = usePager && data !== null && items.length > 0
|
|
2414
2878
|
? h(Pager, {
|
|
2415
2879
|
key: 'pager',
|
|
2416
2880
|
t,
|
|
@@ -2432,11 +2896,13 @@ ${absPath}
|
|
|
2432
2896
|
: null
|
|
2433
2897
|
|
|
2434
2898
|
// 查看器作为覆盖层叠在网格上:网格保持挂载,滚动位置不丢
|
|
2435
|
-
|
|
2899
|
+
// 用 viewer.list(打开时记录的快照),不用全局 items:
|
|
2900
|
+
// 分组视图下卡片来自组内文件,与当前页的扁平 items 不是同一个集合。
|
|
2901
|
+
const viewerLayer = viewer !== null && Array.isArray(viewer.list) && viewer.list.length > 0
|
|
2436
2902
|
? h('div', { className: 'dg-viewerLayer', key: 'viewerLayer' },
|
|
2437
2903
|
h(Viewer, {
|
|
2438
|
-
items,
|
|
2439
|
-
index: viewer.index,
|
|
2904
|
+
items: viewer.list,
|
|
2905
|
+
index: Math.min(viewer.index, viewer.list.length - 1),
|
|
2440
2906
|
t,
|
|
2441
2907
|
onClose: closeViewer,
|
|
2442
2908
|
onStep: step,
|
|
@@ -2485,6 +2951,7 @@ ${absPath}
|
|
|
2485
2951
|
|
|
2486
2952
|
return h('div', { className: 'dg-root', 'data-gallery-root': true }, [
|
|
2487
2953
|
header,
|
|
2954
|
+
legend,
|
|
2488
2955
|
body,
|
|
2489
2956
|
pager,
|
|
2490
2957
|
viewerLayer,
|
package/cordis.patch.yml
CHANGED
|
@@ -16,7 +16,11 @@
|
|
|
16
16
|
name: 'dsh-gallery'
|
|
17
17
|
config:
|
|
18
18
|
# root 留空 → 走自动探测 / 运行时设置
|
|
19
|
-
|
|
19
|
+
#
|
|
20
|
+
# ⚠️ windowHours 不要在这里写死!
|
|
21
|
+
# 它是「扫描多久以内的文件」。写死 24 会让「全局按对话分组」只剩当天产出,
|
|
22
|
+
# 历史对话全部看不到(这正是 v0.8.0 分组只显示 2 组的原因)。
|
|
23
|
+
# 代码里的默认值是一整年;想覆盖请改 <DSH_HOME>/dsh-gallery.json 里的 windowHours。
|
|
20
24
|
maxItems: 60
|
|
21
25
|
maxDepth: 3
|
|
22
26
|
extensions:
|