@@ -13,6 +13,13 @@ import {
1313} from ' ./rename-engine'
1414import { executeBatchRename , isDirPath , listDirEntries , statPaths , type RenameResultItem } from ' ./tauri'
1515import RuleCard from ' ./RuleCard.vue'
16+ import SButton from ' @qingfeng346/ui-kit/components/button/SButton.vue'
17+ import SCheckbox from ' @qingfeng346/ui-kit/components/checkbox/SCheckbox.vue'
18+ import SSplit from ' @qingfeng346/ui-kit/components/SSplit.vue'
19+ import SEllipsis from ' @qingfeng346/ui-kit/components/SEllipsis.vue'
20+ import SEmpty from ' @qingfeng346/ui-kit/components/SEmpty.vue'
21+ import SSortableList from ' @qingfeng346/ui-kit/components/sortable/SSortableList.vue'
22+ import SSortableItem from ' @qingfeng346/ui-kit/components/sortable/SSortableItem.vue'
1623
1724interface FileEntry {
1825 path: string
@@ -72,27 +79,19 @@ const canExecute = computed(() =>
7279)
7380
7481// ---- 列表拖拽排序(pointer 实现):Windows 上 Tauri 接管了 WebView2 的原生 drop 处理,
75- // HTML5 DnD 的 drop 事件不会触发,因此规则与文件行都用 pointermove 手动换位 ----
82+ // HTML5 DnD 的 drop 事件不会触发;规则使用 ui-kit 排序,文件行保留整行拖动 ----
7683
77- type DragList = ' rule' | ' file'
78-
79- const draggingList = ref <DragList | null >(null )
80-
81- const ROW_SELECTOR: Record <DragList , string > = {
82- rule: ' .rule-slot' ,
83- file: ' .preview-row:not(.head-row)' ,
84- }
84+ const draggingFiles = ref (false )
8585
8686/** 行内表单控件与按钮上的按下不启动拖拽 */
87- function beginListDrag (event : PointerEvent , kind : DragList ) {
87+ function beginFileDrag (event : PointerEvent ) {
8888 if (event .button !== 0 ) return
89- if (kind === ' rule' && ! (event .target as Element ).closest (' .grip' )) return
9089 if ((event .target as HTMLElement ).closest (' input, textarea, select, button, a, label' )) return
9190 const rowEl = event .currentTarget as HTMLElement
9291 const container = rowEl .parentElement
9392 if (! container ) return
9493
95- draggingList .value = kind
94+ draggingFiles .value = true
9695 rowEl .style .opacity = ' 0.5'
9796 document .body .style .userSelect = ' none'
9897
@@ -107,25 +106,25 @@ function beginListDrag(event: PointerEvent, kind: DragList) {
107106 if (lastY < rect .top + 32 ) container .scrollTop -= 14
108107 else if (lastY > rect .bottom - 32 ) container .scrollTop += 14
109108
110- const rows = [... container .querySelectorAll <HTMLElement >(ROW_SELECTOR [ kind ] )]
109+ const rows = [... container .querySelectorAll <HTMLElement >(' .preview-row:not(.head-row) ' )]
111110 const at = rows .findIndex (row => {
112111 const r = row .getBoundingClientRect ()
113112 return lastY >= r .top && lastY < r .bottom
114113 })
115114 const from = rows .indexOf (rowEl )
116115 if (at < 0 || from < 0 || from === at ) return
117- const list = kind === ' rule ' ? rules . value : files .value
116+ const list = files .value
118117 const [item] = list .splice (from , 1 )
119118 list .splice (at , 0 , item )
120- if ( kind === ' file ' ) sortKey .value = null
119+ sortKey .value = null
121120 }
122121
123122 const onMove = (e : PointerEvent ) => {
124123 lastY = e .clientY
125124 if (! raf ) raf = requestAnimationFrame (applyMove )
126125 }
127126 const onUp = () => {
128- draggingList .value = null
127+ draggingFiles .value = false
129128 rowEl .style .opacity = ' '
130129 document .body .style .userSelect = ' '
131130 window .removeEventListener (' pointermove' , onMove )
@@ -341,38 +340,38 @@ onUnmounted(() => {
341340
342341 <section class =" card" >
343342 <div class =" toolbar" >
344- <button type = " button " class = " btn btn-outline " :disabled =" adding" @click =" chooseFiles" >
343+ <SButton size="small " :disabled =" adding " @click =" chooseFiles " >
345344 <Plus :size =" 15 " /> 添加文件
346- </button >
347- <button type = " button " class = " btn btn-outline " :disabled =" adding" @click =" chooseFolder" >
345+ </SButton >
346+ <SButton size="small " :disabled =" adding " @click =" chooseFolder " >
348347 <FolderOpen :size =" 15 " /> 添加文件夹
349- </button >
350- <label class =" check-inline" title =" 勾选后添加文件夹时会递归收集所有子文件夹中的文件" >
351- <input v-model =" recursive" type =" checkbox" /> 包含子文件夹
352- </label >
353- <button type =" button" class =" btn btn-outline danger" :disabled =" !files.length" @click =" clearFiles" >
348+ </SButton >
349+ <SCheckbox v-model :checked =" recursive " title="勾选后添加文件夹时会递归收集所有子文件夹中的文件">包含子文件夹</SCheckbox >
350+ <SButton size="small" type="error" tertiary :disabled =" ! files .length " @click =" clearFiles " >
354351 <X :size =" 15 " /> 清空列表
355- </button >
352+ </SButton >
356353 <span class =" toolbar-note" >{{ adding ? '正在读取…' : files.length ? `已添加 ${files.length} 个文件` : '尚未添加文件' }}</span >
357354 </div >
358355 </section >
359356
360357 <section class =" card workbench" >
361- <div class =" panes" >
358+ <SSplit class="panes" direction="vertical" :default-size =" 0.4 " :min =" 0.2 " :max =" 0.7 " >
359+ <template #1 >
362360 <div class =" rules-pane" >
363361 <div class =" pane-head" >
364362 <h3 >规则(按顺序执行)</h3 >
365- <button type = " button " class = " btn btn-outline " @click =" addRule" >
363+ <SButton size="small " @click =" addRule " >
366364 <Plus :size =" 15 " /> 添加规则
367- </button >
365+ </SButton >
368366 </div >
369- <p v-if =" !rules.length" class =" empty" >还没有规则。点击「添加规则」,规则会从上到下依次作用于每个文件名。</p >
370- <div
367+ <SEmpty v-if =" ! rules .length " description="还没有规则。点击「添加规则」,规则会从上到下依次作用于每个文件名。" />
368+ <SSortableList :items =" rules " label="规则" @reorder =" rules = $event " >
369+ <SSortableItem
371370 v-for =" (rule , index ) in rules "
372371 :key =" rule .id "
373372 class="rule-slot"
374- :class = " { dragging: draggingList === 'rule' } "
375- @pointerdown = " beginListDrag($event, 'rule') "
373+ :index = " index "
374+ : label = " ` 规则 ${ index + 1 } ` "
376375 >
377376 <RuleCard
378377 :rule =" rule "
@@ -382,32 +381,32 @@ onUnmounted(() => {
382381 @remove =" removeRule (index )"
383382 @read-clipboard =" refreshClipboard "
384383 />
385- </div >
384+ </SSortableItem >
385+ </SSortableList >
386386 </div >
387-
387+ </template >
388+ <template #2 >
388389 <div class =" preview-pane" >
389390 <div class =" pane-head stacked" >
390391 <div class =" head-line" >
391392 <h3 >预览</h3 >
392- <button v-if = " usesClipboard " type = " button " class = " link-btn " :disabled =" readingClipboard" @click =" refreshClipboard" >{{ readingClipboard ? '正在读取…' : '重新读取剪贴板' }}</button >
393+ <SButton size="small" text v-if = " usesClipboard " :disabled =" readingClipboard " @click =" refreshClipboard " >{{ readingClipboard ? '正在读取…' : '重新读取剪贴板' }}</SButton >
393394 <span class =" summary" >
394395 {{ files.length }} 个文件 · {{ counts.willRename }} 将重命名 · {{ counts.unchanged }} 无变化 · {{ counts.conflict }} 冲突
395396 </span >
396397 </div >
397398 <div v-if =" files.length > 1" class =" sort-row" >
398399 <span class =" sort-label" >排序</span >
399- <button
400- v-for =" opt in sortOptions"
400+ <SButton size="small" text v-for =" opt in sortOptions "
401401 :key =" opt .key "
402- type = " button "
403- class =" link-btn sort-btn"
402+
403+ class="sort-btn"
404404 :class =" { active: sortKey === opt .key } "
405- @click =" sortBy(opt.key)"
406- >{{ opt.label }}{{ sortKey === opt.key ? (sortAsc ? ' ↑' : ' ↓') : '' }}</button >
405+ @click =" sortBy (opt .key )" >{{ opt.label }}{{ sortKey === opt.key ? (sortAsc ? ' ↑' : ' ↓') : '' }}</SButton >
407406 <span class =" sort-hint" >拖动行可手动调整顺序</span >
408407 </div >
409408 </div >
410- <p v-if =" !files.length" class = " empty " > 还没有文件。点击上方「添加文件」或直接把文件拖进窗口。</ p >
409+ <SEmpty v-if =" ! files .length " description=" 还没有文件。点击上方「添加文件」或直接把文件拖进窗口。" / >
411410 <div v-else class =" preview-list" >
412411 <div class =" preview-row head-row" >
413412 <span >原始文件名</span >
@@ -420,24 +419,22 @@ onUnmounted(() => {
420419 v-for =" (item, i) in preview"
421420 :key =" files[i].path"
422421 class =" preview-row"
423- :class =" [`status-${item.status}`, { dragging: draggingList === 'file' }]"
424- @pointerdown =" beginListDrag ($event, 'file' )"
422+ :class =" [`status-${item.status}`, { dragging: draggingFiles }]"
423+ @pointerdown =" beginFileDrag ($event)"
425424 >
426425 <span class =" name" :title =" files[i].path" >{{ item.originalName }}</span >
427426 <span class =" name final" >
428427 <ChevronRight class="arrow" :size =" 14 " />
429428 {{ item.finalName }}
430429 </span >
431- <span class =" folder-path" :title = " parentDir(files[i].path) " >{{ parentDir(files[i].path) }}</span >
430+ <SEllipsis class="folder-path">{{ parentDir(files[i].path) }}</SEllipsis >
432431 <span class =" file-status" :title =" item.statusDetail" >{{ item.status === 'ok' ? '将重命名' : statusText(item) }}</span >
433432 <span class =" row-actions" >
434- <button
435- v-if =" item.steps.length"
436- type =" button"
437- class =" link-btn"
438- @click =" toggleExpand(files[i].path)"
439- >{{ expanded.has(files[i].path) ? '收起' : '步骤' }}</button >
440- <button type =" button" class =" link-btn" @click =" removeFile(i)" >移除</button >
433+ <SButton size="small" text v-if =" item .steps .length "
434+
435+
436+ @click =" toggleExpand (files [i ].path )" >{{ expanded.has(files[i].path) ? '收起' : '步骤' }}</SButton >
437+ <SButton size="small" text @click =" removeFile (i )" >移除</SButton >
441438 </span >
442439 <div v-if =" expanded.has(files[i].path) && item.steps.length" class =" steps" >
443440 <div v-for =" (step, s) in item.steps" :key =" step.ruleId + s" class =" step" >
@@ -453,7 +450,8 @@ onUnmounted(() => {
453450 </div >
454451 </div >
455452 </div >
456- </div >
453+ </template >
454+ </SSplit >
457455 </section >
458456
459457 <section class =" card footer-bar" >
@@ -463,9 +461,9 @@ onUnmounted(() => {
463461 <template v-else-if =" ! counts .willRename " >所有文件名均无变化</template >
464462 <template v-else >将重命名 {{ counts.willRename }} 个文件</template >
465463 </span >
466- <button type = " button " class = " btn " :disabled =" !canExecute" @click =" execute" >
464+ <SButton size="small" type="primary " :disabled =" ! canExecute " @click =" execute " >
467465 {{ executing ? '正在执行…' : '执行重命名' }}
468- </button >
466+ </SButton >
469467 </section >
470468 </div >
471469</template >
@@ -477,14 +475,12 @@ onUnmounted(() => {
477475.card { padding : 12px 16px ; margin-bottom : 12px ; border : 1px solid var (--border ); border-radius : var (--radius ); background : var (--card ); }
478476h3 { margin : 0 ; font-size : 14px ; }
479477.toolbar { display : flex ; gap : 8px ; align-items : center ; flex-wrap : wrap ; flex : 0 0 auto ; }
480- .btn { display : inline-flex ; gap : 6px ; align-items : center ; }
481478.toolbar-note { color : var (--fg-muted ); font-size : 13px ; }
482- .check-inline { display : inline-flex ; gap : 5px ; align-items : center ; font-size : 13px ; color : var (--fg-muted ); cursor : pointer ; user-select : none ; }
483- .btn-outline.danger :hover { border-color : var (--danger ); color : var (--danger ); }
484479.workbench { flex : 1 1 auto ; min-height : 0 ; overflow : hidden ; display : flex ; flex-direction : column ; padding : 0 ; }
485- .panes { display : grid ; grid-template-rows : minmax (100px , 2fr ) minmax (0 , 3fr ); flex : 1 1 auto ; min-height : 0 ; }
486- .rules-pane { min-width : 0 ; min-height : 0 ; overflow-y : auto ; padding : 12px 16px ; }
487- .preview-pane { min-width : 0 ; min-height : 0 ; display : flex ; flex-direction : column ; border-top : 1px solid var (--border ); padding : 12px 16px ; }
480+ .panes { flex : 1 1 auto ; min-height : 0 ; }
481+ .panes :deep(.s-split-pane ) { overflow : hidden ; }
482+ .rules-pane { height : 100% ; box-sizing : border-box ; min-width : 0 ; min-height : 0 ; overflow-y : auto ; padding : 12px 16px ; }
483+ .preview-pane { height : 100% ; box-sizing : border-box ; min-width : 0 ; min-height : 0 ; display : flex ; flex-direction : column ; border-top : 1px solid var (--border ); padding : 12px 16px ; }
488484.preview-pane > .pane-head { flex : 0 0 auto ; }
489485.pane-head { position : sticky ; top : 0 ; z-index : 1 ; display : flex ; gap : 12px ; align-items : center ; justify-content : space-between ; flex-wrap : wrap ; padding-bottom : 10px ; background : var (--card ); }
490486.pane-head.stacked { flex-direction : column ; align-items : stretch ; gap : 8px ; }
@@ -494,14 +490,14 @@ h3 { margin: 0; font-size: 14px; }
494490.sort-hint { margin-left : auto ; }
495491.sort-btn.active { font-weight : 600 ; }
496492.summary { color : var (--fg-muted ); font-size : 12px ; }
497- .empty { margin : 8px 0 ; font-size : 13px ; color : var (--fg-muted ); }
498493.rule-slot { margin-bottom : 6px ; }
494+ .rule-slot :deep(> .sort-handle ) { position : absolute ; top : 10px ; left : 8px ; z-index : 1 ; }
499495.preview-list { border : 1px solid var (--border ); border-radius : 6px ; overflow-y : auto ; min-height : 0 ; flex : 1 1 auto ; }
500496.preview-row { display : grid ; grid-template-columns : minmax (0 , 1fr ) minmax (0 , 1.2fr ) minmax (0 , 1fr ) minmax (80px , 0.4fr ) 76px ; gap : 10px ; align-items : start ; padding : 6px 12px ; border-top : 1px solid var (--border ); font-size : 13px ; cursor : grab ; }
501497.preview-row :active { cursor : grabbing ; }
502498.preview-row.head-row { position : sticky ; top : 0 ; z-index : 1 ; border-top : none ; background : var (--bg ); color : var (--fg-muted ); font-size : 12px ; cursor : default ; }
503499.name { overflow-wrap : anywhere; font : 12px ui-monospace , SFMono-Regular, Consolas, monospace ; }
504- .folder-path { min-width : 0 ; overflow : hidden ; text-overflow : ellipsis ; white-space : nowrap ; color : var (--fg-muted ); font : 12px ui-monospace , SFMono-Regular, Consolas, monospace ; }
500+ .folder-path { color : var (--fg-muted ); font : 12px ui-monospace , SFMono-Regular, Consolas, monospace ; }
505501.final { display : flex ; gap : 4px ; align-items : baseline ; flex-wrap : wrap ; }
506502.arrow { flex : 0 0 auto ; align-self : center ; color : var (--fg-muted ); }
507503.status-unchanged .final { color : var (--fg-muted ); }
@@ -510,8 +506,6 @@ h3 { margin: 0; font-size: 14px; }
510506.status-ok .file-status { color : var (--success ); }
511507.status-conflict-duplicate .file-status , .status-conflict-exists .file-status , .status-invalid .file-status { color : var (--danger ); }
512508.row-actions { display : flex ; gap : 8px ; }
513- .link-btn { padding : 0 ; border : none ; background : none ; color : var (--primary ); font-size : 12px ; cursor : pointer ; }
514- .link-btn :hover { text-decoration : underline ; }
515509.steps { grid-column : 1 / -1 ; display : grid ; gap : 4px ; padding : 8px 0 2px ; }
516510.step { display : flex ; gap : 10px ; align-items : baseline ; font-size : 12px ; }
517511.step-name { flex : 0 0 auto ; color : var (--fg-muted ); }
0 commit comments