"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigView = void 0; const BaseView_1 = require("./BaseView"); class ConfigView extends BaseView_1.BaseView { render(data) { const container = data?.container; const configs = data?.configs || []; const gitRepos = data?.gitRepos || []; const currentGitRepo = data?.currentGitRepo; const gitFileTree = data?.gitFileTree || []; const gitLoading = data?.gitLoading || false; const gitBranches = data?.gitBranches || []; const gitRepoUrl = data?.gitRepoUrl || ''; const mergedFolders = data?.mergedFolders || []; // 生成配置列表的 HTML - 包含配置文件和 Git 仓库 const configsHtml = configs.map((config) => ` 🔧 ${config.name} 📄 ${config.fileName} `).join(''); // 生成合并文件夹的 HTML - 显示在配置列表中 const mergedFoldersHtml = mergedFolders.map((folder) => ` 📁 ${folder.displayName} ${folder.folderName} `).join(''); // 生成 Git 仓库列表的 HTML - 修改显示方式,Git 仓库不可勾选 const gitReposHtml = gitRepos.map(repo => { // 提取仓库名称(从URL中获取或使用name) const repoName = repo.name.split(' (')[0]; // 移除分支名部分 // 提取分支名 const branchMatch = repo.name.match(/\(([^)]+)\)/); const branchName = branchMatch ? branchMatch[1] : repo.branch; return ` 📁 ${repoName}
${branchName} `; }).join(''); // 生成分支选择的 HTML - 使用树状结构 const branchesHtml = gitBranches.length > 0 ? this.generateBranchesTreeHtml(gitBranches) : ''; return ` 配置管理 ${this.getStyles()}

⚙️ 配置管理 - ${container?.name || '未知容器'}

📋 配置文件管理

${configsHtml} ${mergedFoldersHtml} ${gitReposHtml}
配置 文件 操作

📚 Git 仓库管理

🔗 添加 Git 仓库

${branchesHtml}
`; } generateBranchesTreeHtml(branches) { if (branches.length === 0) return ''; // 构建分支树 const branchTree = this.buildBranchTree(branches); let html = '
'; html += '

🌳 分支树

'; html += '
'; html += ''; html += ''; html += '
'; html += '
'; html += this.renderBranchTreeNodes(branchTree, 0); html += '
'; html += '
'; html += ''; html += ''; html += '
'; return html; } /** * 构建分支树状结构 */ buildBranchTree(branches) { const root = []; branches.forEach(branch => { const parts = branch.name.split('/'); let currentLevel = root; for (let i = 0; i < parts.length; i++) { const part = parts[i]; const isLeaf = i === parts.length - 1; const fullName = parts.slice(0, i + 1).join('/'); let node = currentLevel.find(n => n.name === part); if (!node) { node = { name: part, fullName: fullName, isLeaf: isLeaf, children: [], level: i }; currentLevel.push(node); } if (isLeaf) { node.branch = branch; } else { node.expanded = node.expanded || true; // 默认展开 } currentLevel = node.children; } }); return root; } /** * 渲染分支树节点 */ renderBranchTreeNodes(nodes, level) { let html = ''; nodes.forEach(node => { const indent = level * 20; const nodeId = node.fullName.replace(/[^a-zA-Z0-9-]/g, '-'); if (node.isLeaf) { // 叶子节点(实际分支) html += '
'; html += ''; html += '🌿'; html += ''; html += node.name; html += (node.branch && node.branch.isCurrent ? ' ⭐' : ''); html += ''; html += '
'; } else { // 文件夹节点 html += '
'; html += ''; html += (node.expanded ? '🪵' : '🪵'); html += ''; html += '🪵'; html += '' + node.name + ''; html += '
'; if (node.expanded && node.children && node.children.length > 0) { html += '
'; html += this.renderBranchTreeNodes(node.children, level + 1); html += '
'; } } }); return html; } /** * 计算叶子节点数量 */ countLeafNodes(nodes) { let count = 0; nodes.forEach(node => { if (node.isLeaf) { count++; } else { count += this.countLeafNodes(node.children); } }); return count; } } exports.ConfigView = ConfigView; //# sourceMappingURL=ConfigView.js.map