0
0

将git和配置文件合并,增加了配置文件永久删除的功能

This commit is contained in:
xubing
2025-11-25 14:30:54 +08:00
parent d3ef13de42
commit 056f98fd25
6 changed files with 1117 additions and 1258 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,6 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigView = void 0; exports.ConfigView = void 0;
// src/panels/views/ConfigView.ts
const BaseView_1 = require("./BaseView"); const BaseView_1 = require("./BaseView");
class ConfigView extends BaseView_1.BaseView { class ConfigView extends BaseView_1.BaseView {
render(data) { render(data) {
@@ -13,7 +12,7 @@ class ConfigView extends BaseView_1.BaseView {
const gitLoading = data?.gitLoading || false; const gitLoading = data?.gitLoading || false;
const gitBranches = data?.gitBranches || []; const gitBranches = data?.gitBranches || [];
const gitRepoUrl = data?.gitRepoUrl || ''; const gitRepoUrl = data?.gitRepoUrl || '';
// 生成配置列表的 HTML // 生成配置列表的 HTML - 包含配置文件和 Git 仓库
const configsHtml = configs.map((config) => ` const configsHtml = configs.map((config) => `
<tr> <tr>
<td> <td>
@@ -27,21 +26,17 @@ class ConfigView extends BaseView_1.BaseView {
</td> </td>
</tr> </tr>
`).join(''); `).join('');
// 生成 Git 仓库列表的 HTML // 生成 Git 仓库列表的 HTML - 以配置文件形式显示
const gitReposHtml = gitRepos.map(repo => ` const gitReposHtml = gitRepos.map(repo => `
<tr> <tr>
<td> <td>
<span class="repo-name" data-repo-id="${repo.id}">📁 ${repo.name}</span> <span class="editable">📁 ${repo.name}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;"> <div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
${repo.url} 模型1、模型2
</div>
<div style="font-size: 11px; color: var(--vscode-descriptionForeground);">
分支: ${repo.branch} | 最后同步: ${repo.lastSync}
</div> </div>
</td> </td>
<td> <td>
<span class="clickable" onclick="loadGitRepo('${repo.id}')">打开</span> <span class="clickable" onclick="loadGitRepo('${repo.id}')">${repo.url.split('/').pop()}</span>
<span class="clickable" onclick="syncGitRepo('${repo.id}')" style="margin-left: 10px;">同步</span>
</td> </td>
<td> <td>
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button> <button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
@@ -50,8 +45,6 @@ class ConfigView extends BaseView_1.BaseView {
`).join(''); `).join('');
// 生成分支选择的 HTML // 生成分支选择的 HTML
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : ''; const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : '';
// 生成文件树的 HTML
const fileTreeHtml = gitFileTree.length > 0 ? this.renderFileTree(gitFileTree) : '<div style="text-align: center; padding: 20px; color: var(--vscode-descriptionForeground);">选择仓库以浏览文件</div>';
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
@@ -60,77 +53,6 @@ class ConfigView extends BaseView_1.BaseView {
<title>配置管理</title> <title>配置管理</title>
${this.getStyles()} ${this.getStyles()}
<style> <style>
.git-container {
display: flex;
gap: 20px;
margin-top: 20px;
}
.repo-list {
flex: 1;
min-width: 300px;
}
.file-tree {
flex: 2;
min-width: 400px;
border: 1px solid var(--vscode-panel-border);
border-radius: 4px;
padding: 15px;
background: var(--vscode-panel-background);
max-height: 400px;
overflow-y: auto;
}
.tree-item {
margin: 2px 0;
}
.tree-folder {
cursor: pointer;
padding: 2px 4px;
border-radius: 2px;
display: inline-block;
}
.tree-folder:hover {
background: var(--vscode-list-hoverBackground);
}
.tree-file {
padding: 2px 4px;
border-radius: 2px;
display: inline-block;
}
.tree-file:hover {
background: var(--vscode-list-hoverBackground);
}
.tree-children {
margin-left: 10px;
}
.current-repo {
background: var(--vscode-badge-background);
padding: 10px;
border-radius: 4px;
margin-bottom: 15px;
}
.loading {
text-align: center;
padding: 20px;
color: var(--vscode-descriptionForeground);
}
.btn-sync {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
border: none;
padding: 6px 12px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.btn-sync:hover {
background: var(--vscode-button-hoverBackground);
}
.branch-selection {
border: 1px solid var(--vscode-input-border);
}
.branch-item:hover {
background: var(--vscode-list-hoverBackground);
}
.url-input-section { .url-input-section {
background: var(--vscode-panel-background); background: var(--vscode-panel-background);
padding: 15px; padding: 15px;
@@ -138,24 +60,21 @@ class ConfigView extends BaseView_1.BaseView {
margin-bottom: 15px; margin-bottom: 15px;
border: 1px solid var(--vscode-input-border); border: 1px solid var(--vscode-input-border);
} }
.debug-panel {
background: var(--vscode-inputValidation-infoBackground);
padding: 10px;
margin-bottom: 15px;
border-radius: 4px;
border: 1px solid var(--vscode-inputValidation-infoBorder);
}
.debug-info {
font-size: 12px;
color: var(--vscode-input-foreground);
font-family: 'Courier New', monospace;
}
.section-title { .section-title {
margin: 30px 0 15px 0; margin: 30px 0 15px 0;
padding-bottom: 10px; padding-bottom: 10px;
border-bottom: 2px solid var(--vscode-panel-border); border-bottom: 2px solid var(--vscode-panel-border);
color: var(--vscode-titleBar-activeForeground); color: var(--vscode-titleBar-activeForeground);
} }
.config-section {
margin-bottom: 30px;
}
.branch-selection {
border: 1px solid var(--vscode-input-border);
}
.branch-item:hover {
background: var(--vscode-list-hoverBackground);
}
</style> </style>
</head> </head>
<body> <body>
@@ -164,72 +83,55 @@ class ConfigView extends BaseView_1.BaseView {
<button class="back-btn" onclick="goBackToContainers()">← 返回容器管理</button> <button class="back-btn" onclick="goBackToContainers()">← 返回容器管理</button>
</div> </div>
<!-- 配置管理部分 --> <!-- 配置文件管理部分 -->
<h3 class="section-title">📋 配置文件管理</h3> <div class="config-section">
<table class="table"> <h3 class="section-title">📋 配置文件管理</h3>
<thead> <table class="table">
<tr> <thead>
<th width="30%">配置</th> <tr>
<th width="40%">文件</th> <th width="30%">配置</th>
<th width="30%">操作</th> <th width="40%">文件</th>
</tr> <th width="30%">操作</th>
</thead> </tr>
<tbody> </thead>
${configsHtml} <tbody>
<tr> ${configsHtml}
<td colspan="3" style="text-align: center; padding: 20px;"> ${gitReposHtml}
<button class="btn-new" onclick="createNewConfig()">+ 新建配置</button> <tr>
</td> <td colspan="3" style="text-align: center; padding: 20px;">
</tr> <button class="btn-new" onclick="createNewConfig()">+ 新建配置</button>
</tbody> </td>
</table> </tr>
</tbody>
</table>
</div>
<!-- Git 仓库管理部分 --> <!-- Git 仓库管理部分 -->
<h3 class="section-title">📚 Git 仓库管理</h3> <div class="config-section">
<h3 class="section-title">📚 Git 仓库管理</h3>
<!-- URL 输入区域 -->
<div class="url-input-section"> <!-- URL 输入区域 -->
<h4>🔗 添加 Git 仓库</h4> <div class="url-input-section">
<div style="display: flex; gap: 10px; margin-top: 10px;"> <h4>🔗 添加 Git 仓库</h4>
<input type="text" id="repoUrlInput" <div style="display: flex; gap: 10px; margin-top: 10px;">
placeholder="请输入 Git 仓库 URL例如: https://github.com/username/repo.git" <input type="text" id="repoUrlInput"
value="${gitRepoUrl}" placeholder="请输入 Git 仓库 URL例如: https://github.com/username/repo.git"
style="flex: 1; padding: 8px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border); border-radius: 4px;"> value="${gitRepoUrl}"
<button class="btn-new" onclick="fetchBranches()">获取分支</button> style="flex: 1; padding: 8px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border); border-radius: 4px;">
</div> <button class="btn-new" onclick="fetchBranches()">获取分支</button>
<div id="branchSelectionContainer"> </div>
${branchesHtml} <div id="branchSelectionContainer">
</div> ${branchesHtml}
</div>
<div style="margin-bottom: 20px;">
${currentGitRepo ? `
<div class="current-repo">
<strong>当前仓库:</strong> ${currentGitRepo.name} (${currentGitRepo.url})
<button class="btn-sync" onclick="syncGitRepo('${currentGitRepo.id}')">同步</button>
</div> </div>
` : ''}
</div>
<div class="git-container">
<div class="repo-list">
<table class="table">
<thead>
<tr>
<th width="60%">仓库</th>
<th width="20%">操作</th>
<th width="20%">管理</th>
</tr>
</thead>
<tbody>
${gitReposHtml}
</tbody>
</table>
</div> </div>
<div class="file-tree"> <div style="margin-bottom: 20px;">
<h4>📂 文件浏览器</h4> ${currentGitRepo ? `
${gitLoading ? '<div class="loading">🔄 加载中...</div>' : fileTreeHtml} <div style="background: var(--vscode-badge-background); padding: 10px; border-radius: 4px; margin-bottom: 15px;">
<strong>当前仓库:</strong> ${currentGitRepo.name} (${currentGitRepo.url})
<button class="btn-sync" onclick="syncGitRepo('${currentGitRepo.id}')" style="background: var(--vscode-button-background); color: var(--vscode-button-foreground); border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; margin-left: 10px;">同步</button>
</div>
` : ''}
</div> </div>
</div> </div>
@@ -329,14 +231,6 @@ class ConfigView extends BaseView_1.BaseView {
} }
// Git 仓库管理功能 // Git 仓库管理功能
function updateDebugInfo(message) {
const debugElement = document.getElementById('debugInfo');
if (debugElement) {
debugElement.innerHTML = message;
console.log('🔍 调试信息:', message);
}
}
function fetchBranches() { function fetchBranches() {
const urlInput = document.getElementById('repoUrlInput'); const urlInput = document.getElementById('repoUrlInput');
const repoUrl = urlInput.value.trim(); const repoUrl = urlInput.value.trim();
@@ -353,7 +247,6 @@ class ConfigView extends BaseView_1.BaseView {
currentRepoUrl = repoUrl; currentRepoUrl = repoUrl;
console.log('🌿 获取分支列表:', repoUrl); console.log('🌿 获取分支列表:', repoUrl);
updateDebugInfo('🌿 正在获取分支列表...');
vscode.postMessage({ vscode.postMessage({
type: 'fetchBranches', type: 'fetchBranches',
@@ -369,7 +262,6 @@ class ConfigView extends BaseView_1.BaseView {
selectedBranches.delete(branchName); selectedBranches.delete(branchName);
} }
console.log('选中的分支:', Array.from(selectedBranches)); console.log('选中的分支:', Array.from(selectedBranches));
updateDebugInfo('选中的分支: ' + Array.from(selectedBranches).join(', '));
} }
function cloneSelectedBranches() { function cloneSelectedBranches() {
@@ -379,7 +271,6 @@ class ConfigView extends BaseView_1.BaseView {
} }
console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches)); console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches));
updateDebugInfo('🚀 开始克隆分支: ' + Array.from(selectedBranches).join(', '));
vscode.postMessage({ vscode.postMessage({
type: 'cloneBranches', type: 'cloneBranches',
@@ -394,7 +285,6 @@ class ConfigView extends BaseView_1.BaseView {
// 隐藏分支选择区域 // 隐藏分支选择区域
document.getElementById('branchSelectionContainer').innerHTML = ''; document.getElementById('branchSelectionContainer').innerHTML = '';
updateDebugInfo('✅ 分支克隆请求已发送');
} }
function cancelBranchSelection() { function cancelBranchSelection() {
@@ -405,8 +295,6 @@ class ConfigView extends BaseView_1.BaseView {
// 隐藏分支选择区域 // 隐藏分支选择区域
document.getElementById('branchSelectionContainer').innerHTML = ''; document.getElementById('branchSelectionContainer').innerHTML = '';
updateDebugInfo('❌ 已取消分支选择');
vscode.postMessage({ vscode.postMessage({
type: 'cancelBranchSelection' type: 'cancelBranchSelection'
}); });
@@ -414,7 +302,6 @@ class ConfigView extends BaseView_1.BaseView {
function loadGitRepo(repoId) { function loadGitRepo(repoId) {
console.log('📂 加载仓库:', repoId); console.log('📂 加载仓库:', repoId);
updateDebugInfo('📂 正在加载仓库...');
vscode.postMessage({ vscode.postMessage({
type: 'loadGitRepo', type: 'loadGitRepo',
repoId: repoId repoId: repoId
@@ -423,7 +310,6 @@ class ConfigView extends BaseView_1.BaseView {
function syncGitRepo(repoId) { function syncGitRepo(repoId) {
console.log('🔄 同步仓库:', repoId); console.log('🔄 同步仓库:', repoId);
updateDebugInfo('🔄 正在同步仓库...');
vscode.postMessage({ vscode.postMessage({
type: 'syncGitRepo', type: 'syncGitRepo',
repoId: repoId repoId: repoId
@@ -433,7 +319,6 @@ class ConfigView extends BaseView_1.BaseView {
function deleteGitRepo(repoId) { function deleteGitRepo(repoId) {
if (confirm('确定删除这个 Git 仓库吗?')) { if (confirm('确定删除这个 Git 仓库吗?')) {
console.log('🗑️ 删除仓库:', repoId); console.log('🗑️ 删除仓库:', repoId);
updateDebugInfo('🗑️ 正在删除仓库...');
vscode.postMessage({ vscode.postMessage({
type: 'deleteGitRepo', type: 'deleteGitRepo',
repoId: repoId repoId: repoId
@@ -441,24 +326,6 @@ class ConfigView extends BaseView_1.BaseView {
} }
} }
function importFile(filePath) {
if (confirm('确定要将此文件导入到当前容器吗?')) {
console.log('📥 导入文件:', filePath);
updateDebugInfo('📥 正在导入文件...');
vscode.postMessage({
type: 'importGitFile',
filePath: filePath
});
}
}
function toggleFolder(folderPath) {
const folderElement = document.getElementById('folder-' + folderPath.replace(/[^a-zA-Z0-9]/g, '-'));
if (folderElement) {
folderElement.style.display = folderElement.style.display === 'none' ? 'block' : 'none';
}
}
// 动态渲染分支选择区域 // 动态渲染分支选择区域
function renderBranchSelection(branches, repoUrl) { function renderBranchSelection(branches, repoUrl) {
const container = document.getElementById('branchSelectionContainer'); const container = document.getElementById('branchSelectionContainer');
@@ -577,29 +444,17 @@ class ConfigView extends BaseView_1.BaseView {
if (message.type === 'branchesFetched') { if (message.type === 'branchesFetched') {
console.log('🌿 收到分支数据:', message.branches); console.log('🌿 收到分支数据:', message.branches);
updateDebugInfo('✅ 获取到 ' + message.branches.length + ' 个分支');
renderBranchSelection(message.branches, message.repoUrl); renderBranchSelection(message.branches, message.repoUrl);
} }
if (message.type === 'configFileLoaded') { if (message.type === 'configFileLoaded') {
document.getElementById('configContent').value = message.content; document.getElementById('configContent').value = message.content;
} }
if (message.type === 'gitRepoLoading') {
updateDebugInfo(message.loading ? '🔄 后端正在加载仓库文件树...' : '✅ 后端文件树加载完成');
}
}); });
// 初始化 // 初始化
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
console.log('📄 ConfigView 页面加载完成'); console.log('📄 ConfigView 页面加载完成');
updateDebugInfo('📄 页面加载完成 - 等待用户操作');
setTimeout(() => {
document.querySelectorAll('.tree-children').forEach(el => {
el.style.display = 'block';
});
}, 100);
}); });
</script> </script>
</body> </body>
@@ -627,32 +482,6 @@ class ConfigView extends BaseView_1.BaseView {
html += '</div></div>'; html += '</div></div>';
return html; return html;
} }
renderFileTree(nodes, level = 0) {
return nodes.map(node => {
const paddingLeft = level * 20;
if (node.type === 'folder') {
return `
<div class="tree-item" style="padding-left: ${paddingLeft}px;">
<span class="tree-folder" onclick="toggleFolder('${node.path}')">
📁 ${node.name}
</span>
<div id="folder-${node.path.replace(/[^a-zA-Z0-9]/g, '-')}" class="tree-children">
${this.renderFileTree(node.children || [], level + 1)}
</div>
</div>
`;
}
else {
return `
<div class="tree-item" style="padding-left: ${paddingLeft}px;">
<span class="tree-file clickable" onclick="importFile('${node.path}')">
📄 ${node.name}
</span>
</div>
`;
}
}).join('');
}
} }
exports.ConfigView = ConfigView; exports.ConfigView = ConfigView;
//# sourceMappingURL=ConfigView.js.map //# sourceMappingURL=ConfigView.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"ConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/ConfigView.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yCAAsC;AAmBtC,MAAa,UAAW,SAAQ,mBAAQ;IACpC,MAAM,CAAC,IAON;QACG,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC;QACtC,MAAM,cAAc,GAAG,IAAI,EAAE,cAAc,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC;QAC5C,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,KAAK,CAAC;QAC7C,MAAM,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,EAAE,CAAC;QAC5C,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,I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M,GAAG,UAAU,CAAC;QAC7D,IAAI,IAAI,oEAAoE,CAAC;QAE7E,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACtB,MAAM,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;YACvE,IAAI,IAAI,0IAA0I,CAAC;YACnJ,IAAI,IAAI,6BAA6B,GAAG,QAAQ,GAAG,IAAI,CAAC;YACxD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,4BAA4B,GAAG,MAAM,CAAC,IAAI,GAAG,mCAAmC,CAAC;YAC9H,IAAI,IAAI,cAAc,GAAG,QAAQ,GAAG,sCAAsC,CAAC;YAC3E,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;YACrD,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC;QACnE,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,QAAQ,CAAC;QACjB,IAAI,IAAI,iCAAiC,CAAC;QAC1C,IAAI,IAAI,yGAAyG,CAAC;QAClH,IAAI,IAAI,wEAAwE,CAAC;QACjF,IAAI,IAAI,cAAc,CAAC;QAEvB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA/eD,gCA+eC"}

File diff suppressed because it is too large Load Diff

303
src/panels/views/ConfigView.ts Normal file → Executable file
View File

@@ -1,4 +1,3 @@
// src/panels/views/ConfigView.ts
import { BaseView } from './BaseView'; import { BaseView } from './BaseView';
import { ContainerConfigData, ConfigViewData } from '../types/ViewTypes'; import { ContainerConfigData, ConfigViewData } from '../types/ViewTypes';
@@ -18,10 +17,21 @@ interface GitFileTree {
children?: GitFileTree[]; children?: GitFileTree[];
} }
// Git 仓库接口
interface GitRepo {
id: string;
name: string;
url: string;
localPath: string;
branch: string;
lastSync: string;
containerId: string;
}
export class ConfigView extends BaseView { export class ConfigView extends BaseView {
render(data?: ContainerConfigData & { render(data?: ContainerConfigData & {
gitRepos?: any[]; gitRepos?: GitRepo[];
currentGitRepo?: any; currentGitRepo?: GitRepo;
gitFileTree?: GitFileTree[]; gitFileTree?: GitFileTree[];
gitLoading?: boolean; gitLoading?: boolean;
gitBranches?: GitBranch[]; gitBranches?: GitBranch[];
@@ -36,7 +46,7 @@ export class ConfigView extends BaseView {
const gitBranches = data?.gitBranches || []; const gitBranches = data?.gitBranches || [];
const gitRepoUrl = data?.gitRepoUrl || ''; const gitRepoUrl = data?.gitRepoUrl || '';
// 生成配置列表的 HTML // 生成配置列表的 HTML - 包含配置文件和 Git 仓库
const configsHtml = configs.map((config: ConfigViewData) => ` const configsHtml = configs.map((config: ConfigViewData) => `
<tr> <tr>
<td> <td>
@@ -51,21 +61,17 @@ export class ConfigView extends BaseView {
</tr> </tr>
`).join(''); `).join('');
// 生成 Git 仓库列表的 HTML // 生成 Git 仓库列表的 HTML - 以配置文件形式显示
const gitReposHtml = gitRepos.map(repo => ` const gitReposHtml = gitRepos.map(repo => `
<tr> <tr>
<td> <td>
<span class="repo-name" data-repo-id="${repo.id}">📁 ${repo.name}</span> <span class="editable">📁 ${repo.name}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;"> <div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
${repo.url} 模型1、模型2
</div>
<div style="font-size: 11px; color: var(--vscode-descriptionForeground);">
分支: ${repo.branch} | 最后同步: ${repo.lastSync}
</div> </div>
</td> </td>
<td> <td>
<span class="clickable" onclick="loadGitRepo('${repo.id}')">打开</span> <span class="clickable" onclick="loadGitRepo('${repo.id}')">${repo.url.split('/').pop()}</span>
<span class="clickable" onclick="syncGitRepo('${repo.id}')" style="margin-left: 10px;">同步</span>
</td> </td>
<td> <td>
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button> <button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
@@ -76,9 +82,6 @@ export class ConfigView extends BaseView {
// 生成分支选择的 HTML // 生成分支选择的 HTML
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : ''; const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : '';
// 生成文件树的 HTML
const fileTreeHtml = gitFileTree.length > 0 ? this.renderFileTree(gitFileTree) : '<div style="text-align: center; padding: 20px; color: var(--vscode-descriptionForeground);">选择仓库以浏览文件</div>';
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
@@ -87,77 +90,6 @@ export class ConfigView extends BaseView {
<title>配置管理</title> <title>配置管理</title>
${this.getStyles()} ${this.getStyles()}
<style> <style>
.git-container {
display: flex;
gap: 20px;
margin-top: 20px;
}
.repo-list {
flex: 1;
min-width: 300px;
}
.file-tree {
flex: 2;
min-width: 400px;
border: 1px solid var(--vscode-panel-border);
border-radius: 4px;
padding: 15px;
background: var(--vscode-panel-background);
max-height: 400px;
overflow-y: auto;
}
.tree-item {
margin: 2px 0;
}
.tree-folder {
cursor: pointer;
padding: 2px 4px;
border-radius: 2px;
display: inline-block;
}
.tree-folder:hover {
background: var(--vscode-list-hoverBackground);
}
.tree-file {
padding: 2px 4px;
border-radius: 2px;
display: inline-block;
}
.tree-file:hover {
background: var(--vscode-list-hoverBackground);
}
.tree-children {
margin-left: 10px;
}
.current-repo {
background: var(--vscode-badge-background);
padding: 10px;
border-radius: 4px;
margin-bottom: 15px;
}
.loading {
text-align: center;
padding: 20px;
color: var(--vscode-descriptionForeground);
}
.btn-sync {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
border: none;
padding: 6px 12px;
border-radius: 4px;
cursor: pointer;
margin-left: 10px;
}
.btn-sync:hover {
background: var(--vscode-button-hoverBackground);
}
.branch-selection {
border: 1px solid var(--vscode-input-border);
}
.branch-item:hover {
background: var(--vscode-list-hoverBackground);
}
.url-input-section { .url-input-section {
background: var(--vscode-panel-background); background: var(--vscode-panel-background);
padding: 15px; padding: 15px;
@@ -165,24 +97,21 @@ export class ConfigView extends BaseView {
margin-bottom: 15px; margin-bottom: 15px;
border: 1px solid var(--vscode-input-border); border: 1px solid var(--vscode-input-border);
} }
.debug-panel {
background: var(--vscode-inputValidation-infoBackground);
padding: 10px;
margin-bottom: 15px;
border-radius: 4px;
border: 1px solid var(--vscode-inputValidation-infoBorder);
}
.debug-info {
font-size: 12px;
color: var(--vscode-input-foreground);
font-family: 'Courier New', monospace;
}
.section-title { .section-title {
margin: 30px 0 15px 0; margin: 30px 0 15px 0;
padding-bottom: 10px; padding-bottom: 10px;
border-bottom: 2px solid var(--vscode-panel-border); border-bottom: 2px solid var(--vscode-panel-border);
color: var(--vscode-titleBar-activeForeground); color: var(--vscode-titleBar-activeForeground);
} }
.config-section {
margin-bottom: 30px;
}
.branch-selection {
border: 1px solid var(--vscode-input-border);
}
.branch-item:hover {
background: var(--vscode-list-hoverBackground);
}
</style> </style>
</head> </head>
<body> <body>
@@ -191,72 +120,55 @@ export class ConfigView extends BaseView {
<button class="back-btn" onclick="goBackToContainers()">← 返回容器管理</button> <button class="back-btn" onclick="goBackToContainers()">← 返回容器管理</button>
</div> </div>
<!-- 配置管理部分 --> <!-- 配置文件管理部分 -->
<h3 class="section-title">📋 配置文件管理</h3> <div class="config-section">
<table class="table"> <h3 class="section-title">📋 配置文件管理</h3>
<thead> <table class="table">
<tr> <thead>
<th width="30%">配置</th> <tr>
<th width="40%">文件</th> <th width="30%">配置</th>
<th width="30%">操作</th> <th width="40%">文件</th>
</tr> <th width="30%">操作</th>
</thead> </tr>
<tbody> </thead>
${configsHtml} <tbody>
<tr> ${configsHtml}
<td colspan="3" style="text-align: center; padding: 20px;"> ${gitReposHtml}
<button class="btn-new" onclick="createNewConfig()">+ 新建配置</button> <tr>
</td> <td colspan="3" style="text-align: center; padding: 20px;">
</tr> <button class="btn-new" onclick="createNewConfig()">+ 新建配置</button>
</tbody> </td>
</table> </tr>
</tbody>
</table>
</div>
<!-- Git 仓库管理部分 --> <!-- Git 仓库管理部分 -->
<h3 class="section-title">📚 Git 仓库管理</h3> <div class="config-section">
<h3 class="section-title">📚 Git 仓库管理</h3>
<!-- URL 输入区域 -->
<div class="url-input-section"> <!-- URL 输入区域 -->
<h4>🔗 添加 Git 仓库</h4> <div class="url-input-section">
<div style="display: flex; gap: 10px; margin-top: 10px;"> <h4>🔗 添加 Git 仓库</h4>
<input type="text" id="repoUrlInput" <div style="display: flex; gap: 10px; margin-top: 10px;">
placeholder="请输入 Git 仓库 URL例如: https://github.com/username/repo.git" <input type="text" id="repoUrlInput"
value="${gitRepoUrl}" placeholder="请输入 Git 仓库 URL例如: https://github.com/username/repo.git"
style="flex: 1; padding: 8px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border); border-radius: 4px;"> value="${gitRepoUrl}"
<button class="btn-new" onclick="fetchBranches()">获取分支</button> style="flex: 1; padding: 8px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border); border-radius: 4px;">
</div> <button class="btn-new" onclick="fetchBranches()">获取分支</button>
<div id="branchSelectionContainer"> </div>
${branchesHtml} <div id="branchSelectionContainer">
</div> ${branchesHtml}
</div>
<div style="margin-bottom: 20px;">
${currentGitRepo ? `
<div class="current-repo">
<strong>当前仓库:</strong> ${currentGitRepo.name} (${currentGitRepo.url})
<button class="btn-sync" onclick="syncGitRepo('${currentGitRepo.id}')">同步</button>
</div> </div>
` : ''}
</div>
<div class="git-container">
<div class="repo-list">
<table class="table">
<thead>
<tr>
<th width="60%">仓库</th>
<th width="20%">操作</th>
<th width="20%">管理</th>
</tr>
</thead>
<tbody>
${gitReposHtml}
</tbody>
</table>
</div> </div>
<div class="file-tree"> <div style="margin-bottom: 20px;">
<h4>📂 文件浏览器</h4> ${currentGitRepo ? `
${gitLoading ? '<div class="loading">🔄 加载中...</div>' : fileTreeHtml} <div style="background: var(--vscode-badge-background); padding: 10px; border-radius: 4px; margin-bottom: 15px;">
<strong>当前仓库:</strong> ${currentGitRepo.name} (${currentGitRepo.url})
<button class="btn-sync" onclick="syncGitRepo('${currentGitRepo.id}')" style="background: var(--vscode-button-background); color: var(--vscode-button-foreground); border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; margin-left: 10px;">同步</button>
</div>
` : ''}
</div> </div>
</div> </div>
@@ -356,14 +268,6 @@ export class ConfigView extends BaseView {
} }
// Git 仓库管理功能 // Git 仓库管理功能
function updateDebugInfo(message) {
const debugElement = document.getElementById('debugInfo');
if (debugElement) {
debugElement.innerHTML = message;
console.log('🔍 调试信息:', message);
}
}
function fetchBranches() { function fetchBranches() {
const urlInput = document.getElementById('repoUrlInput'); const urlInput = document.getElementById('repoUrlInput');
const repoUrl = urlInput.value.trim(); const repoUrl = urlInput.value.trim();
@@ -380,7 +284,6 @@ export class ConfigView extends BaseView {
currentRepoUrl = repoUrl; currentRepoUrl = repoUrl;
console.log('🌿 获取分支列表:', repoUrl); console.log('🌿 获取分支列表:', repoUrl);
updateDebugInfo('🌿 正在获取分支列表...');
vscode.postMessage({ vscode.postMessage({
type: 'fetchBranches', type: 'fetchBranches',
@@ -396,7 +299,6 @@ export class ConfigView extends BaseView {
selectedBranches.delete(branchName); selectedBranches.delete(branchName);
} }
console.log('选中的分支:', Array.from(selectedBranches)); console.log('选中的分支:', Array.from(selectedBranches));
updateDebugInfo('选中的分支: ' + Array.from(selectedBranches).join(', '));
} }
function cloneSelectedBranches() { function cloneSelectedBranches() {
@@ -406,7 +308,6 @@ export class ConfigView extends BaseView {
} }
console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches)); console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches));
updateDebugInfo('🚀 开始克隆分支: ' + Array.from(selectedBranches).join(', '));
vscode.postMessage({ vscode.postMessage({
type: 'cloneBranches', type: 'cloneBranches',
@@ -421,7 +322,6 @@ export class ConfigView extends BaseView {
// 隐藏分支选择区域 // 隐藏分支选择区域
document.getElementById('branchSelectionContainer').innerHTML = ''; document.getElementById('branchSelectionContainer').innerHTML = '';
updateDebugInfo('✅ 分支克隆请求已发送');
} }
function cancelBranchSelection() { function cancelBranchSelection() {
@@ -432,8 +332,6 @@ export class ConfigView extends BaseView {
// 隐藏分支选择区域 // 隐藏分支选择区域
document.getElementById('branchSelectionContainer').innerHTML = ''; document.getElementById('branchSelectionContainer').innerHTML = '';
updateDebugInfo('❌ 已取消分支选择');
vscode.postMessage({ vscode.postMessage({
type: 'cancelBranchSelection' type: 'cancelBranchSelection'
}); });
@@ -441,7 +339,6 @@ export class ConfigView extends BaseView {
function loadGitRepo(repoId) { function loadGitRepo(repoId) {
console.log('📂 加载仓库:', repoId); console.log('📂 加载仓库:', repoId);
updateDebugInfo('📂 正在加载仓库...');
vscode.postMessage({ vscode.postMessage({
type: 'loadGitRepo', type: 'loadGitRepo',
repoId: repoId repoId: repoId
@@ -450,7 +347,6 @@ export class ConfigView extends BaseView {
function syncGitRepo(repoId) { function syncGitRepo(repoId) {
console.log('🔄 同步仓库:', repoId); console.log('🔄 同步仓库:', repoId);
updateDebugInfo('🔄 正在同步仓库...');
vscode.postMessage({ vscode.postMessage({
type: 'syncGitRepo', type: 'syncGitRepo',
repoId: repoId repoId: repoId
@@ -460,7 +356,6 @@ export class ConfigView extends BaseView {
function deleteGitRepo(repoId) { function deleteGitRepo(repoId) {
if (confirm('确定删除这个 Git 仓库吗?')) { if (confirm('确定删除这个 Git 仓库吗?')) {
console.log('🗑️ 删除仓库:', repoId); console.log('🗑️ 删除仓库:', repoId);
updateDebugInfo('🗑️ 正在删除仓库...');
vscode.postMessage({ vscode.postMessage({
type: 'deleteGitRepo', type: 'deleteGitRepo',
repoId: repoId repoId: repoId
@@ -468,24 +363,6 @@ export class ConfigView extends BaseView {
} }
} }
function importFile(filePath) {
if (confirm('确定要将此文件导入到当前容器吗?')) {
console.log('📥 导入文件:', filePath);
updateDebugInfo('📥 正在导入文件...');
vscode.postMessage({
type: 'importGitFile',
filePath: filePath
});
}
}
function toggleFolder(folderPath) {
const folderElement = document.getElementById('folder-' + folderPath.replace(/[^a-zA-Z0-9]/g, '-'));
if (folderElement) {
folderElement.style.display = folderElement.style.display === 'none' ? 'block' : 'none';
}
}
// 动态渲染分支选择区域 // 动态渲染分支选择区域
function renderBranchSelection(branches, repoUrl) { function renderBranchSelection(branches, repoUrl) {
const container = document.getElementById('branchSelectionContainer'); const container = document.getElementById('branchSelectionContainer');
@@ -604,29 +481,17 @@ export class ConfigView extends BaseView {
if (message.type === 'branchesFetched') { if (message.type === 'branchesFetched') {
console.log('🌿 收到分支数据:', message.branches); console.log('🌿 收到分支数据:', message.branches);
updateDebugInfo('✅ 获取到 ' + message.branches.length + ' 个分支');
renderBranchSelection(message.branches, message.repoUrl); renderBranchSelection(message.branches, message.repoUrl);
} }
if (message.type === 'configFileLoaded') { if (message.type === 'configFileLoaded') {
document.getElementById('configContent').value = message.content; document.getElementById('configContent').value = message.content;
} }
if (message.type === 'gitRepoLoading') {
updateDebugInfo(message.loading ? '🔄 后端正在加载仓库文件树...' : '✅ 后端文件树加载完成');
}
}); });
// 初始化 // 初始化
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
console.log('📄 ConfigView 页面加载完成'); console.log('📄 ConfigView 页面加载完成');
updateDebugInfo('📄 页面加载完成 - 等待用户操作');
setTimeout(() => {
document.querySelectorAll('.tree-children').forEach(el => {
el.style.display = 'block';
});
}, 100);
}); });
</script> </script>
</body> </body>
@@ -658,30 +523,4 @@ export class ConfigView extends BaseView {
return html; return html;
} }
private renderFileTree(nodes: GitFileTree[], level = 0): string {
return nodes.map(node => {
const paddingLeft = level * 20;
if (node.type === 'folder') {
return `
<div class="tree-item" style="padding-left: ${paddingLeft}px;">
<span class="tree-folder" onclick="toggleFolder('${node.path}')">
📁 ${node.name}
</span>
<div id="folder-${node.path.replace(/[^a-zA-Z0-9]/g, '-')}" class="tree-children">
${this.renderFileTree(node.children || [], level + 1)}
</div>
</div>
`;
} else {
return `
<div class="tree-item" style="padding-left: ${paddingLeft}px;">
<span class="tree-file clickable" onclick="importFile('${node.path}')">
📄 ${node.name}
</span>
</div>
`;
}
}).join('');
}
} }