0
0

git功能已完备

This commit is contained in:
xubing
2025-11-25 16:32:06 +08:00
parent 719fb43c33
commit 23024a8461
6 changed files with 233 additions and 130 deletions

View File

@@ -26,23 +26,29 @@ class ConfigView extends BaseView_1.BaseView {
</td>
</tr>
`).join('');
// 生成 Git 仓库列表的 HTML - 以配置文件形式显示
const gitReposHtml = gitRepos.map(repo => `
// 生成 Git 仓库列表的 HTML - 修改显示方式
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 `
<tr>
<td>
<span class="editable">📁 ${repo.name}</span>
<span class="editable">📁 ${repoName}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
模型1、模型2
</div>
</td>
<td>
<span class="clickable" onclick="loadGitRepo('${repo.id}')">${repo.url.split('/').pop()}</span>
<span class="clickable" onclick="openGitRepoInVSCode('${repo.id}')">${branchName}</span>
</td>
<td>
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
</td>
</tr>
`).join('');
`;
}).join('');
// 生成分支选择的 HTML
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : '';
return `<!DOCTYPE html>
@@ -225,7 +231,7 @@ class ConfigView extends BaseView_1.BaseView {
);
}
// Git 仓库删除功能 - 修复版本
// Git 仓库删除功能
function deleteGitRepo(repoId) {
console.log('🗑️ 尝试删除 Git 仓库:', repoId);
@@ -246,6 +252,15 @@ class ConfigView extends BaseView_1.BaseView {
);
}
// 新功能:在 VSCode 中打开 Git 仓库
function openGitRepoInVSCode(repoId) {
console.log('📂 在 VSCode 中打开 Git 仓库:', repoId);
vscode.postMessage({
type: 'openGitRepoInVSCode',
repoId: repoId
});
}
function saveConfigFile() {
const content = document.getElementById('configContent').value;
vscode.postMessage({
@@ -370,7 +385,7 @@ class ConfigView extends BaseView_1.BaseView {
branchesHtml += (branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\\'' + branch.name + '\\')" style="margin-right: 10px;">';
branchesHtml += '<label for="branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-') + '" style="flex: 1; cursor: pointer;">';
branchesHtml += (branch.isCurrent ? '⭐ ' : '') + branch.name;
branchesHtml += (branch.isRemote ? '(远程)' : '(本地)') + '</label></div>';
branchesHtml += '</label></div>';
});
branchesHtml += '</div>';
@@ -477,18 +492,9 @@ class ConfigView extends BaseView_1.BaseView {
}
});
// 初始化 - 添加调试信息(修复语法错误)
// 初始化
document.addEventListener('DOMContentLoaded', function() {
console.log('📄 ConfigView 页面加载完成');
console.log('🔍 检查 Git 仓库删除按钮绑定');
// 检查所有删除按钮
const deleteButtons = document.querySelectorAll('.btn-delete');
console.log('找到删除按钮数量:', deleteButtons.length);
deleteButtons.forEach(function(btn, index) {
console.log('删除按钮 ' + index + ':', btn);
});
});
</script>
</body>