新增: Git 能力闭环(Diff 行号解析/分支只读展示/提交详情/写入后自动刷新变更视图)
- Diff 行号修复:解析 @@ -a,b +c,d @@ 头,计算旧/新行号(原恒空字符串) - 提交详情增强:显示父提交哈希/作者/日期/完整消息(git show -s --format=%P\t%an) - 分支只读展示:list_branches IPC + 变更面板顶部下拉查看分支(切换走 AI 工具) - AI 工具写入后自动跳转变更视图:监听 df-data-changed entity=file 切 Tab + 刷新
This commit is contained in:
@@ -181,6 +181,7 @@
|
||||
*/
|
||||
import { ref, computed, watch, reactive, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { listen, type UnlistenFn } from '@tauri-apps/api/event'
|
||||
import { moduleApi, type ProjectModuleRecord, type FileTreeEntry, type GitStatusResult } from '@/api/module'
|
||||
import FileTree from './FileTree.vue'
|
||||
import FilePreview from './FilePreview.vue'
|
||||
@@ -364,6 +365,25 @@ function closeDropdown() { moduleDropdownOpen.value = false }
|
||||
onMounted(() => document.addEventListener('click', closeDropdown))
|
||||
onUnmounted(() => document.removeEventListener('click', closeDropdown))
|
||||
|
||||
// AI 工具写入文件后(df-data-changed entity=file)自动跳转变更视图 + 刷新
|
||||
let _unlistenDataChanged: UnlistenFn | null = null
|
||||
onMounted(async () => {
|
||||
_unlistenDataChanged = await listen<{ entity: string; action: string }>('df-data-changed', (e) => {
|
||||
if (e.payload.entity !== 'file') return
|
||||
// 刷新 git 状态缓存,使变更计数角标即时更新
|
||||
gitStatusData.value = null
|
||||
if (viewMode.value === 'changes') {
|
||||
// 已在变更视图,触发 GitChanges 重新拉取(切一次 viewMode 触发 watch)
|
||||
viewMode.value = 'tree'
|
||||
viewMode.value = 'changes'
|
||||
} else {
|
||||
// 不在变更视图,自动切换到变更视图,让用户看到 AI 写入的内容
|
||||
viewMode.value = 'changes'
|
||||
}
|
||||
})
|
||||
})
|
||||
onUnmounted(() => { _unlistenDataChanged?.() })
|
||||
|
||||
// 自动扫描子仓库
|
||||
async function onScanSubmodules() {
|
||||
moduleDropdownOpen.value = false
|
||||
|
||||
Reference in New Issue
Block a user