优化: 项目文件树/依赖图组件 + 灵感对抗校验 + 小程序脚本 + 模块管理
This commit is contained in:
@@ -129,6 +129,7 @@
|
||||
:file-path="selectedFilePath"
|
||||
:module-root-path="currentModule?.path ?? ''"
|
||||
:git-status="selectedFileGitStatus"
|
||||
:external-diff="selectedCommitDiff"
|
||||
/>
|
||||
<div v-else class="preview-placeholder-inline">{{ $t('fileExplorer.selectFileHint') }}</div>
|
||||
</div>
|
||||
@@ -252,6 +253,8 @@ const expandedPaths = reactive(new Set<string>())
|
||||
const loadedChildren = reactive(new Map<string, FileTreeEntry[]>())
|
||||
const selectedFilePath = ref<string | null>(null)
|
||||
const selectedFileGitStatus = ref<string | undefined>(undefined)
|
||||
/** GitChanges(变更/提交历史)点文件注入的 diff:传给右侧 FilePreview 在宽区渲染(历史提交的 diff 优先)。 */
|
||||
const selectedCommitDiff = ref('')
|
||||
|
||||
const currentModule = computed(
|
||||
() => modules.value.find((m) => m.id === currentModuleId.value) ?? null,
|
||||
@@ -302,6 +305,7 @@ function resetTreeState() {
|
||||
loadedChildren.clear()
|
||||
selectedFilePath.value = null
|
||||
selectedFileGitStatus.value = undefined
|
||||
selectedCommitDiff.value = ''
|
||||
}
|
||||
|
||||
/** 自定义下拉选择工程。 */
|
||||
@@ -317,6 +321,8 @@ function onFileSelect(path: string) {
|
||||
selectedFilePath.value = path
|
||||
// 从 loadedChildren 反查 git_status(任意层目录的条目都可能含此文件)。
|
||||
selectedFileGitStatus.value = findEntryGitStatus(path)
|
||||
// 树视图选中 → 回到内容预览,不残留 GitChanges 注入的 diff
|
||||
selectedCommitDiff.value = ''
|
||||
}
|
||||
|
||||
/** 递归在 loadedChildren 缓存中查指定路径条目的 git_status。 */
|
||||
@@ -351,6 +357,7 @@ async function refresh() {
|
||||
loadedChildren.clear()
|
||||
selectedFilePath.value = null
|
||||
selectedFileGitStatus.value = undefined
|
||||
selectedCommitDiff.value = ''
|
||||
// 等一个 tick 让 FileTree watch 触发重拉;实际拉取在子组件,这里只做状态清空。
|
||||
await new Promise((r) => setTimeout(r, 50))
|
||||
refreshing.value = false
|
||||
@@ -402,10 +409,11 @@ async function switchToChanges() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Git 变更视图中选择文件 → 在右侧预览显示 diff。 */
|
||||
function onChangeFileSelect(path: string) {
|
||||
/** Git 变更视图中选择文件 → 在右侧预览显示 diff(变化/提交历史点文件都走此路,宽区渲染)。 */
|
||||
function onChangeFileSelect(path: string, diff?: string) {
|
||||
selectedFilePath.value = path
|
||||
selectedFileGitStatus.value = gitStatusData.value?.changed_files.find(f => f.path === path)?.status
|
||||
selectedCommitDiff.value = diff ?? ''
|
||||
}
|
||||
|
||||
watch(() => props.projectId, loadModules, { immediate: true })
|
||||
@@ -761,6 +769,7 @@ async function onRemoveModule() {
|
||||
|
||||
.explorer-tree {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 8px 4px 8px 0;
|
||||
|
||||
Reference in New Issue
Block a user