"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitView = void 0;
// src/panels/views/GitView.ts
const BaseView_1 = require("./BaseView");
class GitView extends BaseView_1.BaseView {
render(data) {
const repos = data?.repos || [];
const currentRepo = data?.currentRepo;
const fileTree = data?.fileTree || [];
const loading = data?.loading || false;
const branches = data?.branches || [];
const repoUrl = data?.repoUrl || '';
// 生成仓库列表的 HTML
const reposHtml = repos.map(repo => `
|
📁 ${repo.name}
${repo.url}
分支: ${repo.branch} | 最后同步: ${repo.lastSync}
|
打开
同步
|
|
`).join('');
// 生成分支选择的 HTML - 使用转义符处理嵌套
const branchesHtml = branches.length > 0 ? this.generateBranchesHtml(branches) : '';
// 生成文件树的 HTML
const fileTreeHtml = fileTree.length > 0 ? this.renderFileTree(fileTree) : '选择仓库以浏览文件
';
return `
Git 仓库管理
${this.getStyles()}
${currentRepo ? `
当前仓库: ${currentRepo.name} (${currentRepo.url})
` : ''}
📂 文件浏览器
${loading ? '
🔄 加载中...
' : fileTreeHtml}
`;
}
generateBranchesHtml(branches) {
if (branches.length === 0)
return '';
let html = '';
html += '
🌿 选择要克隆的分支 (共 ' + branches.length + ' 个)
';
html += '
';
branches.forEach(branch => {
const branchId = 'branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-');
html += '
';
html += '';
html += '
';
});
html += '
';
html += '
';
html += '';
html += '';
html += '
';
return html;
}
renderFileTree(nodes, level = 0) {
return nodes.map(node => {
const paddingLeft = level * 20;
if (node.type === 'folder') {
return `
📁 ${node.name}
${this.renderFileTree(node.children || [], level + 1)}
`;
}
else {
return `
📄 ${node.name}
`;
}
}).join('');
}
}
exports.GitView = GitView;
//# sourceMappingURL=GitView.js.map