diff --git a/frontend/src/components/git/FileViewer.vue b/frontend/src/components/git/FileViewer.vue new file mode 100644 index 0000000..c97f80a --- /dev/null +++ b/frontend/src/components/git/FileViewer.vue @@ -0,0 +1,308 @@ + + + + + + + Cargando archivo... + + + + + + {{ fileName }} + {{ file.path }} + {{ formatSize(file.size) }} + + + + + + + + + + + + + + + Archivo binario - no se puede mostrar el contenido + {{ formatSize(file.size) }} + + + + + {{ i + 1 }} + + {{ file.content }} + + + + + + + + + Selecciona un archivo para ver su contenido + + + + + diff --git a/frontend/src/components/git/ProjectTree.vue b/frontend/src/components/git/ProjectTree.vue new file mode 100644 index 0000000..93fb578 --- /dev/null +++ b/frontend/src/components/git/ProjectTree.vue @@ -0,0 +1,290 @@ + + + + + + + Cargando archivos... + + + Sin archivos + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ node.name }} + + + + + + + + + + + diff --git a/frontend/src/components/git/index.ts b/frontend/src/components/git/index.ts index 5475a23..6cbc7f8 100644 --- a/frontend/src/components/git/index.ts +++ b/frontend/src/components/git/index.ts @@ -2,3 +2,5 @@ export { default as DiffViewer } from './DiffViewer.vue' export { default as FileTree } from './FileTree.vue' export { default as CommitList } from './CommitList.vue' export { default as BranchSelector } from './BranchSelector.vue' +export { default as ProjectTree } from './ProjectTree.vue' +export { default as FileViewer } from './FileViewer.vue' diff --git a/frontend/src/composables/git/useGitApi.ts b/frontend/src/composables/git/useGitApi.ts index 18fd818..0dcb601 100644 --- a/frontend/src/composables/git/useGitApi.ts +++ b/frontend/src/composables/git/useGitApi.ts @@ -1,5 +1,5 @@ import { ref } from 'vue' -import type { GitStatus, CommitInfo, FileDiff, BranchInfo, CompareResult, DiffResult } from '@/types/git' +import type { GitStatus, CommitInfo, FileDiff, BranchInfo, CompareResult, DiffResult, TreeNode, FileContent } from '@/types/git' const API_BASE = '/api/git' @@ -11,6 +11,8 @@ export function useGitApi() { const diff = ref(null) const compareResult = ref(null) const selectedCommit = ref(null) + const fileTree = ref([]) + const fileContent = ref(null) const loading = ref(false) const error = ref(null) @@ -116,6 +118,42 @@ export function useGitApi() { compareResult.value = null } + async function fetchFileTree(path?: string) { + loading.value = true + error.value = null + try { + const params = new URLSearchParams() + if (path) params.set('path', path) + + const res = await fetch(`${API_BASE}/tree?${params}`) + if (!res.ok) throw new Error('Failed to fetch file tree') + fileTree.value = await res.json() + } catch (e: any) { + error.value = e.message + } finally { + loading.value = false + } + } + + async function fetchFileContent(path: string) { + loading.value = true + error.value = null + try { + const params = new URLSearchParams({ path }) + const res = await fetch(`${API_BASE}/file?${params}`) + if (!res.ok) throw new Error('Failed to fetch file content') + fileContent.value = await res.json() + } catch (e: any) { + error.value = e.message + } finally { + loading.value = false + } + } + + function clearFileContent() { + fileContent.value = null + } + return { status, commits, @@ -124,6 +162,8 @@ export function useGitApi() { diff, compareResult, selectedCommit, + fileTree, + fileContent, loading, error, fetchStatus, @@ -133,6 +173,9 @@ export function useGitApi() { fetchBranches, compare, clearDiff, - clearCompare + clearCompare, + fetchFileTree, + fetchFileContent, + clearFileContent } } diff --git a/frontend/src/pages/GitPage.vue b/frontend/src/pages/GitPage.vue index dbead08..bea6bea 100644 --- a/frontend/src/pages/GitPage.vue +++ b/frontend/src/pages/GitPage.vue @@ -1,9 +1,9 @@
Archivo binario - no se puede mostrar el contenido
{{ file.content }}
Selecciona un archivo para ver su contenido