dsh-gufa-code 1.3.63 → 1.3.65

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.
@@ -199,7 +199,6 @@ G.Explorer = function Explorer(props) {
199
199
  await loadDir(targetDir)
200
200
  await loadDir('')
201
201
  props.onChanged?.()
202
- showNotice(`已粘贴 ${written.length} 个文件到 ${targetDir === '' ? '项目根目录' : targetDir}`)
203
202
  } catch (error) {
204
203
  showNotice(`粘贴失败:${G.errorText(error)}`)
205
204
  }
@@ -515,18 +514,21 @@ G.SearchPanel = function SearchPanel(props) {
515
514
  const t = G.useT()
516
515
  const root = props.root
517
516
  const [query, setQuery] = useState('')
517
+ const [replacement, setReplacement] = useState('')
518
518
  const [caseSensitive, setCaseSensitive] = useState(false)
519
519
  const [regex, setRegex] = useState(false)
520
+ const [preserveCase, setPreserveCase] = useState(false)
521
+ const [includeText, setIncludeText] = useState('')
522
+ const [excludeText, setExcludeText] = useState('')
523
+ const [replaceOpen, setReplaceOpen] = useState(false)
520
524
  const [status, setStatus] = useState('idle')
521
525
  const [result, setResult] = useState(null)
522
526
  const [error, setError] = useState('')
523
527
  const [collapsed, setCollapsed] = useState({})
524
- const [replaceOpen, setReplaceOpen] = useState(false)
525
- const [replacement, setReplacement] = useState('')
526
- const [replacing, setReplacing] = useState(false)
528
+ const [ignored, setIgnored] = useState(() => new Set())
527
529
  const [confirming, setConfirming] = useState(null)
530
+ const [replacing, setReplacing] = useState(false)
528
531
  const [replaceError, setReplaceError] = useState('')
529
- const [notice, setNotice] = useState('')
530
532
  const inputRef = useRef(null)
531
533
  const requestRef = useRef(0)
532
534
 
@@ -555,13 +557,20 @@ G.SearchPanel = function SearchPanel(props) {
555
557
  setStatus('loading')
556
558
  setError('')
557
559
  try {
558
- const value = await G.api('fs.search', {
560
+ const found = await G.api('fs.search', {
559
561
  root,
560
562
  query: text,
561
- options: { caseSensitive, regex, maxFiles: 200, maxMatches: 500 },
563
+ options: {
564
+ caseSensitive,
565
+ regex,
566
+ include: includeText,
567
+ exclude: excludeText,
568
+ maxFiles: 200,
569
+ maxMatches: 500,
570
+ },
562
571
  })
563
572
  if (seq !== requestRef.current) return
564
- setResult(value)
573
+ setResult(found)
565
574
  setStatus('ready')
566
575
  } catch (err) {
567
576
  if (seq !== requestRef.current) return
@@ -569,42 +578,7 @@ G.SearchPanel = function SearchPanel(props) {
569
578
  setError(G.errorText(err))
570
579
  setStatus('error')
571
580
  }
572
- }, [root, caseSensitive, regex])
573
-
574
- const requestReplace = useCallback((paths, count, files) => {
575
- if (typeof root !== 'string' || root === '' || query.trim() === '' || replacing) return
576
- setReplaceError('')
577
- setNotice('')
578
- setConfirming({ paths: Array.isArray(paths) ? paths : null, count: Number(count) || 0, files: Number(files) || 0 })
579
- }, [root, query, replacing])
580
-
581
- const doReplace = useCallback(async () => {
582
- const pending = confirming
583
- if (pending === null || replacing) return
584
- setConfirming(null)
585
- setReplacing(true)
586
- setReplaceError('')
587
- setNotice('')
588
- try {
589
- await props.onBeforeReplace?.()
590
- const value = await G.api('fs.replace', {
591
- root,
592
- query: query.trim(),
593
- replacement,
594
- options: { caseSensitive, regex },
595
- paths: Array.isArray(pending.paths) ? pending.paths : undefined,
596
- })
597
- const count = Number(value?.replacedCount) || 0
598
- const replacedFiles = Array.isArray(value?.replacedFiles) ? value.replacedFiles : []
599
- setNotice(t('search.replaced', { count, files: replacedFiles.length }))
600
- await props.onFilesChanged?.(replacedFiles)
601
- await runSearch(query)
602
- } catch (error) {
603
- setReplaceError(G.errorText(error))
604
- } finally {
605
- setReplacing(false)
606
- }
607
- }, [confirming, replacing, props.onBeforeReplace, props.onFilesChanged, root, query, replacement, caseSensitive, regex, runSearch, t])
581
+ }, [root, caseSensitive, regex, includeText, excludeText])
608
582
 
609
583
  /* 输入防抖搜索(回车立即搜索) */
610
584
  useEffect(() => {
@@ -620,6 +594,11 @@ G.SearchPanel = function SearchPanel(props) {
620
594
  return () => window.clearTimeout(timer)
621
595
  }, [query, runSearch, root])
622
596
 
597
+ /* 搜索条件变化后,之前「忽略的匹配」不再适用 */
598
+ useEffect(() => {
599
+ setIgnored(new Set())
600
+ }, [query, caseSensitive, regex, includeText, excludeText])
601
+
623
602
  /* 快捷键/按钮打开搜索面板时聚焦输入框 */
624
603
  useEffect(() => {
625
604
  if (G.bus === null || G.bus === undefined || typeof G.bus.on !== 'function') return undefined
@@ -630,12 +609,28 @@ G.SearchPanel = function SearchPanel(props) {
630
609
  if (props.active === true) focusInput()
631
610
  }, [props.active, focusInput])
632
611
 
612
+ const matchKey = useCallback((path, match) => `${path}:${match.line}:${match.column}`, [])
613
+
614
+ /* 过滤掉用户手动「忽略」的匹配,并重新汇总数量 */
615
+ const view = useMemo(() => {
616
+ if (result === null) return null
617
+ const files = []
618
+ let total = 0
619
+ for (const file of result.files) {
620
+ const matches = file.matches.filter((match) => !ignored.has(matchKey(file.path, match)))
621
+ if (matches.length === 0) continue
622
+ files.push({ path: file.path, matches })
623
+ total += matches.length
624
+ }
625
+ return { ...result, files, total }
626
+ }, [result, ignored, matchKey])
627
+
633
628
  const summary = (() => {
634
629
  if (status === 'loading') return t('search.searching')
635
- if (status === 'error' || result === null) return ''
636
- if (result.total === 0) return result.truncated === true ? t('search.truncated') : t('search.noResult')
637
- const base = t('search.summary', { count: result.total, files: result.files.length })
638
- return result.truncated === true ? `${base} · ${t('search.truncated')}` : base
630
+ if (status === 'error' || view === null) return ''
631
+ if (view.total === 0) return view.truncated === true ? t('search.truncated') : t('search.noResult')
632
+ const base = t('search.summary', { count: view.total, files: view.files.length })
633
+ return view.truncated === true ? `${base} · ${t('search.truncated')}` : base
639
634
  })()
640
635
 
641
636
  const highlight = (match) => {
@@ -651,6 +646,81 @@ G.SearchPanel = function SearchPanel(props) {
651
646
  ]
652
647
  }
653
648
 
649
+ const applyReplace = useCallback(async (payload) => {
650
+ if (typeof root !== 'string' || root === '' || replacing) return
651
+ setReplacing(true)
652
+ setReplaceError('')
653
+ try {
654
+ await props.onBeforeReplace?.()
655
+ const value = await G.api('fs.replace', payload)
656
+ if (value?.stale === true) {
657
+ setReplaceError(t('search.stale'))
658
+ setIgnored(new Set())
659
+ await runSearch(query)
660
+ return
661
+ }
662
+ const files = Array.isArray(value?.replacedFiles) ? value.replacedFiles : []
663
+ await props.onFilesChanged?.(files)
664
+ setIgnored(new Set())
665
+ await runSearch(query)
666
+ } catch (err) {
667
+ setReplaceError(G.errorText(err))
668
+ } finally {
669
+ setReplacing(false)
670
+ }
671
+ }, [root, replacing, props.onBeforeReplace, props.onFilesChanged, t, runSearch, query])
672
+
673
+ const requestReplaceAll = () => {
674
+ if (view === null || view.total === 0 || replacing) return
675
+ setReplaceError('')
676
+ setConfirming({ count: view.total, files: view.files.length })
677
+ }
678
+ const doReplaceAll = () => {
679
+ const pending = confirming
680
+ setConfirming(null)
681
+ if (pending === null) return
682
+ void applyReplace({
683
+ root,
684
+ query: query.trim(),
685
+ replacement,
686
+ options: { caseSensitive, regex, preserveCase, include: includeText, exclude: excludeText },
687
+ })
688
+ }
689
+ const replaceFile = (file) => {
690
+ if (replacing) return
691
+ void applyReplace({
692
+ root,
693
+ query: query.trim(),
694
+ replacement,
695
+ options: { caseSensitive, regex, preserveCase },
696
+ paths: [file.path],
697
+ })
698
+ }
699
+ const replaceOne = (path, match) => {
700
+ if (replacing) return
701
+ void applyReplace({
702
+ root,
703
+ query: query.trim(),
704
+ replacement,
705
+ options: { caseSensitive, regex, preserveCase },
706
+ target: { path, line: match.line, column: match.column },
707
+ })
708
+ }
709
+ const dismiss = (path, match) => {
710
+ setIgnored((current) => {
711
+ const next = new Set(current)
712
+ next.add(matchKey(path, match))
713
+ return next
714
+ })
715
+ }
716
+ const openFirst = () => {
717
+ const file = view?.files?.[0]
718
+ const match = file?.matches?.[0]
719
+ if (file !== undefined && file !== null && match !== undefined && match !== null) {
720
+ props.onOpenFile?.(file.path, match.line, match.column)
721
+ }
722
+ }
723
+
654
724
  const body = (() => {
655
725
  if (typeof root !== 'string' || root === '') {
656
726
  return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, t('explorer.openProjectFirst'))
@@ -660,25 +730,31 @@ G.SearchPanel = function SearchPanel(props) {
660
730
  }
661
731
  if (status === 'idle') return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, t('search.idle'))
662
732
  if (status === 'loading') return h('div', { className: 'gufa-hint', style: { padding: '10px 12px', display: 'flex', gap: 8, alignItems: 'center' } }, h(G.Spinner), t('search.searching'))
663
- if (result === null || result.total === 0) {
664
- const emptyText = result !== null && result.truncated === true ? t('search.truncated') : t('search.noResult')
733
+ if (view === null || view.total === 0) {
734
+ const emptyText = view !== null && view.truncated === true ? t('search.truncated') : t('search.noResult')
665
735
  return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, emptyText)
666
736
  }
667
737
  return h(
668
738
  'div',
669
739
  { className: 'gufa-search-results' },
670
- ...result.files.map((file) => {
740
+ ...view.files.map((file) => {
671
741
  const isCollapsed = collapsed[file.path] === true
672
742
  return h(
673
743
  'div',
674
744
  { key: file.path, className: 'gufa-search-file' },
675
745
  h(
676
- 'button',
746
+ 'div',
677
747
  {
678
- type: 'button',
679
748
  className: 'gufa-search-file-head',
749
+ role: 'button',
750
+ tabIndex: 0,
680
751
  title: file.path,
681
752
  onClick: () => setCollapsed((current) => ({ ...current, [file.path]: !isCollapsed })),
753
+ onKeyDown: (event) => {
754
+ if (event.key !== 'Enter' && event.key !== ' ') return
755
+ event.preventDefault()
756
+ setCollapsed((current) => ({ ...current, [file.path]: !isCollapsed }))
757
+ },
682
758
  },
683
759
  h(G.Icon, { name: isCollapsed ? 'chevron-right' : 'chevron-down', size: 11 }),
684
760
  h('span', { className: 'gufa-search-file-name' }, G.basename(file.path)),
@@ -694,7 +770,7 @@ G.SearchPanel = function SearchPanel(props) {
694
770
  onClick: (event) => {
695
771
  event.stopPropagation()
696
772
  event.preventDefault()
697
- requestReplace([file.path], file.matches.length, 1)
773
+ replaceFile(file)
698
774
  },
699
775
  },
700
776
  h(G.Icon, { name: 'pencil', size: 11 }),
@@ -705,16 +781,56 @@ G.SearchPanel = function SearchPanel(props) {
705
781
  ? null
706
782
  : file.matches.map((match, index) =>
707
783
  h(
708
- 'button',
784
+ 'div',
709
785
  {
710
786
  key: `${file.path}:${match.line}:${match.column}:${index}`,
711
- type: 'button',
712
787
  className: 'gufa-search-match',
788
+ role: 'button',
789
+ tabIndex: 0,
713
790
  title: `${file.path}:${match.line}:${match.column}`,
714
791
  onClick: () => props.onOpenFile?.(file.path, match.line, match.column),
792
+ onKeyDown: (event) => {
793
+ if (event.key !== 'Enter') return
794
+ event.preventDefault()
795
+ props.onOpenFile?.(file.path, match.line, match.column)
796
+ },
715
797
  },
716
798
  h('span', { className: 'gufa-search-line' }, String(match.line)),
717
799
  h('span', { className: 'gufa-search-text' }, ...highlight(match)),
800
+ h(
801
+ 'span',
802
+ { className: 'gufa-search-match-actions' },
803
+ replaceOpen
804
+ ? h(
805
+ 'span',
806
+ {
807
+ className: 'gufa-search-row-action',
808
+ title: t('search.replaceOne'),
809
+ role: 'button',
810
+ onClick: (event) => {
811
+ event.stopPropagation()
812
+ event.preventDefault()
813
+ replaceOne(file.path, match)
814
+ },
815
+ },
816
+ h(G.Icon, { name: 'pencil', size: 11 }),
817
+ )
818
+ : null,
819
+ h(
820
+ 'span',
821
+ {
822
+ className: 'gufa-search-row-action',
823
+ title: t('search.dismiss'),
824
+ role: 'button',
825
+ onClick: (event) => {
826
+ event.stopPropagation()
827
+ event.preventDefault()
828
+ dismiss(file.path, match)
829
+ },
830
+ },
831
+ h(G.Icon, { name: 'close', size: 11 }),
832
+ ),
833
+ ),
718
834
  ),
719
835
  ),
720
836
  )
@@ -774,7 +890,6 @@ G.SearchPanel = function SearchPanel(props) {
774
890
  title: t('search.regex'),
775
891
  onClick: () => setRegex((value) => !value),
776
892
  }, '.*'),
777
- h('span', { className: 'gufa-search-summary', title: summary }, summary),
778
893
  ),
779
894
  replaceOpen
780
895
  ? h(
@@ -794,9 +909,16 @@ G.SearchPanel = function SearchPanel(props) {
794
909
  onKeyDown: (event) => {
795
910
  if (event.key !== 'Enter') return
796
911
  event.preventDefault()
797
- requestReplace(null, result?.total ?? 0, result?.files?.length ?? 0)
912
+ requestReplaceAll()
798
913
  },
799
914
  }),
915
+ h('button', {
916
+ type: 'button',
917
+ className: 'gufa-search-toggle',
918
+ 'data-active': preserveCase ? '' : undefined,
919
+ title: t('search.preserveCase'),
920
+ onClick: () => setPreserveCase((value) => !value),
921
+ }, 'AB'),
800
922
  ),
801
923
  h(
802
924
  'div',
@@ -807,14 +929,48 @@ G.SearchPanel = function SearchPanel(props) {
807
929
  type: 'button',
808
930
  className: 'gufa-search-action',
809
931
  'data-primary': '',
810
- disabled: replacing || result === null || result.total === 0,
811
- onClick: () => requestReplace(null, result?.total ?? 0, result?.files?.length ?? 0),
932
+ disabled: replacing || view === null || view.total === 0,
933
+ onClick: requestReplaceAll,
812
934
  },
813
935
  replacing ? t('search.replacing') : t('search.replaceAll'),
814
936
  ),
815
937
  ),
816
938
  )
817
939
  : null,
940
+ h(
941
+ 'label',
942
+ { className: 'gufa-search-filter' },
943
+ h('span', { className: 'gufa-search-filter-label' }, t('search.include')),
944
+ h('input', {
945
+ className: 'gufa-search-filter-input',
946
+ type: 'text',
947
+ value: includeText,
948
+ placeholder: t('search.includePlaceholder'),
949
+ spellCheck: false,
950
+ onChange: (event) => setIncludeText(event.target.value),
951
+ }),
952
+ ),
953
+ h(
954
+ 'label',
955
+ { className: 'gufa-search-filter' },
956
+ h('span', { className: 'gufa-search-filter-label' }, t('search.exclude')),
957
+ h('input', {
958
+ className: 'gufa-search-filter-input',
959
+ type: 'text',
960
+ value: excludeText,
961
+ placeholder: t('search.excludePlaceholder'),
962
+ spellCheck: false,
963
+ onChange: (event) => setExcludeText(event.target.value),
964
+ }),
965
+ ),
966
+ h(
967
+ 'div',
968
+ { className: 'gufa-search-summarybar' },
969
+ h('span', { className: 'gufa-search-summary', title: summary }, summary),
970
+ view !== null && view.total > 0
971
+ ? h('button', { type: 'button', className: 'gufa-search-link', onClick: openFirst }, t('search.openInEditor'))
972
+ : null,
973
+ ),
818
974
  confirming !== null
819
975
  ? h(
820
976
  'div',
@@ -824,11 +980,10 @@ G.SearchPanel = function SearchPanel(props) {
824
980
  'div',
825
981
  { className: 'gufa-search-confirm-actions' },
826
982
  h('button', { type: 'button', className: 'gufa-search-action', onClick: () => setConfirming(null) }, t('search.confirmNo')),
827
- h('button', { type: 'button', className: 'gufa-search-action', 'data-primary': '', onClick: () => void doReplace() }, t('search.confirmYes')),
983
+ h('button', { type: 'button', className: 'gufa-search-action', 'data-primary': '', onClick: doReplaceAll }, t('search.confirmYes')),
828
984
  ),
829
985
  )
830
986
  : null,
831
- notice !== '' ? h('div', { className: 'gufa-search-notice' }, notice) : null,
832
987
  replaceError !== '' ? h('div', { className: 'gufa-search-error' }, `${t('search.replaceError')}:${replaceError}`) : null,
833
988
  ),
834
989
  h('div', { className: 'gufa-panel-body gufa-scroll' }, body),
@@ -843,14 +998,6 @@ G.GitPanel = function GitPanel(props) {
843
998
  const [error, setError] = useState('')
844
999
  const [pending, setPending] = useState(false)
845
1000
  const [message, setMessage] = useState('')
846
- const [info, setInfo] = useState('')
847
-
848
- /* 操作结果提示(已推送 / 拉取完成 等)自动消失 */
849
- useEffect(() => {
850
- if (info === '') return undefined
851
- const timer = window.setTimeout(() => setInfo(''), 1500)
852
- return () => window.clearTimeout(timer)
853
- }, [info])
854
1001
  const [discardArmed, setDiscardArmed] = useState(false)
855
1002
  const [headMenu, setHeadMenu] = useState(null)
856
1003
  const [rowMenu, setRowMenu] = useState(null)
@@ -899,7 +1046,6 @@ G.GitPanel = function GitPanel(props) {
899
1046
  const act = async (fn) => {
900
1047
  setPending(true)
901
1048
  setError('')
902
- setInfo('')
903
1049
  try {
904
1050
  await fn()
905
1051
  await refresh()
@@ -914,21 +1060,17 @@ G.GitPanel = function GitPanel(props) {
914
1060
  /* 推送 / 拉取:点 ↑/↓ 直接执行 */
915
1061
  const push = () => void act(async () => {
916
1062
  await G.api('git.push', { root })
917
- setInfo(t('git.pushDone'))
918
1063
  })
919
1064
  const pull = () => void act(async () => {
920
1065
  await G.api('git.pull', { root })
921
- setInfo(t('git.pullDone'))
922
1066
  })
923
1067
 
924
1068
  /* 推送 / 拉取(新建分支还没有上游时也能直接发布:Host 会自动 -u <remote> <branch>) */
925
1069
  const pushBranch = () => void act(async () => {
926
1070
  await G.api('git.push', { root })
927
- setInfo(t('git.pushDone'))
928
1071
  })
929
1072
  const pullBranch = () => void act(async () => {
930
1073
  await G.api('git.pull', { root })
931
- setInfo(t('git.pullDone'))
932
1074
  })
933
1075
 
934
1076
  /* 一键撤销所有未暂存改动:第一次点击进入「再点确认」,3 秒后自动取消 */
@@ -941,7 +1083,6 @@ G.GitPanel = function GitPanel(props) {
941
1083
  setDiscardArmed(false)
942
1084
  void act(async () => {
943
1085
  await G.api('git.discardAll', { root })
944
- setInfo(t('git.discardDone'))
945
1086
  })
946
1087
  }
947
1088
 
@@ -950,7 +1091,7 @@ G.GitPanel = function GitPanel(props) {
950
1091
  if (root === null || pending) return
951
1092
  const text = typeof message === 'string' ? message.trim() : ''
952
1093
  if (text === '') {
953
- setInfo(t('git.commitNeedsMessage'))
1094
+ setError(t('git.commitNeedsMessage'))
954
1095
  return
955
1096
  }
956
1097
  void act(async () => {
@@ -959,7 +1100,6 @@ G.GitPanel = function GitPanel(props) {
959
1100
  if (toStage.length > 0) await G.api('git.stage', { root, paths: toStage })
960
1101
  await G.api('git.commit', { root, message: text })
961
1102
  setMessage('')
962
- setInfo(t('git.commitDone'))
963
1103
  })
964
1104
  }
965
1105
  commitRef.current = commit
@@ -1081,7 +1221,6 @@ G.GitPanel = function GitPanel(props) {
1081
1221
  'div',
1082
1222
  { className: 'gufa-panel-body gufa-scroll', style: { display: 'flex', flexDirection: 'column' } },
1083
1223
  error !== '' ? h('div', { className: 'gufa-error-banner' }, G.Icon ? h(G.Icon, { name: 'warn', size: 13 }) : null, error) : null,
1084
- info !== '' ? h('div', { className: 'gufa-info-banner' }, info) : null,
1085
1224
  !root
1086
1225
  ? h(G.Empty, { icon: 'git', title: t('explorer.openProjectFirst') })
1087
1226
  : status === null
@@ -268,7 +268,6 @@ G.GufaApp = function GufaApp(props) {
268
268
  const [modal, setModal] = useState(null)
269
269
  const [shortcutsOpen, setShortcutsOpen] = useState(false)
270
270
  const [trashUndo, setTrashUndo] = useState([])
271
- const [bannerTone, setBannerTone] = useState('error')
272
271
  const [branchMenu, setBranchMenu] = useState(null)
273
272
  const [workspaceDialog, setWorkspaceDialog] = useState(null)
274
273
  const [workspaceSessions, setWorkspaceSessions] = useState({ status: 'idle', sessions: [], groups: [], sessionIds: [], archivedSessionIds: [] })
@@ -651,28 +650,11 @@ G.GufaApp = function GufaApp(props) {
651
650
  void refreshGit()
652
651
  }, [project, patchTab, refreshGit])
653
652
 
654
- /** 顶栏提示:错误常驻红色;成功用绿色 toast,1.2 秒后自动消失。 */
655
- const successTimerRef = useRef(null)
653
+ /** 顶栏提示:只显示错误/需要用户处理的提示;成功类操作直接看界面结果,不再弹 toast。 */
656
654
  const showBanner = useCallback((text, tone) => {
657
- if (successTimerRef.current !== null) {
658
- window.clearTimeout(successTimerRef.current)
659
- successTimerRef.current = null
660
- }
661
- if (tone === 'success') {
662
- setBannerTone('success')
663
- setBanner(text)
664
- successTimerRef.current = window.setTimeout(() => {
665
- successTimerRef.current = null
666
- setBanner('')
667
- }, 1200)
668
- return
669
- }
670
- setBannerTone('error')
655
+ if (tone === 'success') return
671
656
  setBanner(text)
672
657
  }, [])
673
- useEffect(() => () => {
674
- if (successTimerRef.current !== null) window.clearTimeout(successTimerRef.current)
675
- }, [])
676
658
 
677
659
  const closeTab = useCallback((path) => {
678
660
  editorBuffersRef.current.delete(path)
@@ -800,7 +782,6 @@ G.GufaApp = function GufaApp(props) {
800
782
  try {
801
783
  await G.api('git.checkout', { root: project.root, branch: name })
802
784
  closeBranchMenu()
803
- showBanner(`已切换到分支 ${name}`, 'success')
804
785
  setGitRefreshToken((token) => token + 1)
805
786
  setRefreshToken((token) => token + 1)
806
787
  void refreshGit()
@@ -816,7 +797,6 @@ G.GufaApp = function GufaApp(props) {
816
797
  try {
817
798
  await G.api('git.createBranch', { root: project.root, name })
818
799
  closeBranchMenu()
819
- showBanner(`已创建并切换到分支 ${name}`, 'success')
820
800
  setGitRefreshToken((token) => token + 1)
821
801
  setRefreshToken((token) => token + 1)
822
802
  void refreshGit()
@@ -980,7 +960,6 @@ G.GufaApp = function GufaApp(props) {
980
960
  if (project === null) return
981
961
  try {
982
962
  await G.api('git.discard', { root: project.root, paths: [path] })
983
- showBanner('已还原该文件的改动', 'success')
984
963
  // 改动已还原:关掉该 diff 标签(内容已与暂存区一致)
985
964
  setTabs((current) => current.filter((tab) => tab.path !== path))
986
965
  setActivePath((current) => (current === path ? null : current))
@@ -996,7 +975,6 @@ G.GufaApp = function GufaApp(props) {
996
975
  if (project === null) return
997
976
  try {
998
977
  await G.api('git.stage', { root: project.root, paths: [path] })
999
- showBanner('已暂存该文件', 'success')
1000
978
  setGitRefreshToken((token) => token + 1)
1001
979
  void refreshGit()
1002
980
  } catch (error) {
@@ -1481,7 +1459,6 @@ G.GufaApp = function GufaApp(props) {
1481
1459
  const missingSet = new Set(missing)
1482
1460
  setTabs((current) => current.filter((tab) => tab !== null && !missingSet.has(tab.path)))
1483
1461
  setActivePath((current) => (current !== null && missingSet.has(current) ? null : current))
1484
- showBanner(`已关闭 ${missing.length} 个已删除文件的标签`, 'success')
1485
1462
  }, [project, tabs, showBanner])
1486
1463
  const pruneMissingTabsRef = useRef(null)
1487
1464
  pruneMissingTabsRef.current = pruneMissingTabs
@@ -1651,7 +1628,6 @@ G.GufaApp = function GufaApp(props) {
1651
1628
  await openProjectPath(workspace.path)
1652
1629
  }
1653
1630
  closeWorkspaceDialog()
1654
- showBanner(`已切换到工作区 ${workspace.title || workspace.path || ''}`, 'success')
1655
1631
  } catch (error) {
1656
1632
  setWorkspaceDialog((current) => (current === null ? current : { ...current, error: G.errorText(error) }))
1657
1633
  }
@@ -1682,7 +1658,6 @@ G.GufaApp = function GufaApp(props) {
1682
1658
  }
1683
1659
  await openProjectPath(directory)
1684
1660
  closeWorkspaceDialog()
1685
- showBanner('已创建工作区', 'success')
1686
1661
  } catch (error) {
1687
1662
  setBanner(G.errorText(error))
1688
1663
  } finally {
@@ -2459,10 +2434,7 @@ G.GufaApp = function GufaApp(props) {
2459
2434
  h(
2460
2435
  'div',
2461
2436
  { className: 'gufa-editor-area' },
2462
- banner !== '' && bannerTone === 'success'
2463
- ? h('div', { className: 'gufa-toast-success' }, h(G.Icon, { name: 'check', size: 13 }), h('span', null, banner))
2464
- : null,
2465
- banner !== '' && bannerTone !== 'success'
2437
+ banner !== ''
2466
2438
  ? h(
2467
2439
  'div',
2468
2440
  { className: 'gufa-error-banner' },