0
0

添加了代码上传功能,但是存在bug待修复

This commit is contained in:
xubing
2025-11-28 16:21:12 +08:00
parent 5075a5f5cc
commit e2a4b7a80d
6 changed files with 970 additions and 23 deletions

View File

@@ -43,9 +43,7 @@ class ConfigView extends BaseView_1.BaseView {
<span class="clickable" onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">${folder.localPath.split('/').pop()}</span>
</td>
<td>
${folder.type === 'git' ? `
<button class="btn-sync" onclick="syncModuleFolder('${folder.id}')" style="margin-right: 5px;">同步</button>
` : ''}
<button class="btn-upload" onclick="uploadModuleFolder('${folder.id}', '${folder.type}')" style="margin-right: 5px;">上传</button>
<button class="btn-delete" onclick="deleteModuleFolder('${folder.id}')">删除</button>
</td>
</tr>
@@ -96,7 +94,7 @@ class ConfigView extends BaseView_1.BaseView {
opacity: 0.8;
}
.btn-sync {
.btn-upload {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
padding: 4px 8px;
@@ -105,9 +103,15 @@ class ConfigView extends BaseView_1.BaseView {
cursor: pointer;
}
.btn-sync:hover {
.btn-upload:hover {
background: var(--vscode-button-hoverBackground);
}
.btn-upload:disabled {
background: var(--vscode-button-secondaryBackground);
color: var(--vscode-button-secondaryForeground);
cursor: not-allowed;
}
/* 树状分支样式 */
.branch-tree {
@@ -394,13 +398,111 @@ class ConfigView extends BaseView_1.BaseView {
);
}
// 同步 Git 模块文件夹
function syncModuleFolder(folderId) {
console.log('🔄 同步模块文件夹:', folderId);
// 上传模块文件夹功能
function uploadModuleFolder(folderId, folderType) {
console.log('📤 上传模块文件夹:', { folderId, folderType });
if (folderType === 'git') {
// Git 类型:直接上传(相当于 push
showConfirmDialog(
'确认上传',
'确定要将 Git 文件夹的内容上传到远程仓库吗?这将执行 git push 操作。',
function() {
vscode.postMessage({
type: 'uploadGitModuleFolder',
folderId: folderId
});
},
function() {
console.log('❌ 用户取消上传 Git 文件夹');
}
);
} else if (folderType === 'local') {
// Local 类型:弹出 URL 输入对话框
showUploadDialog(folderId);
}
}
// 添加上传对话框函数
function showUploadDialog(folderId) {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.id = 'uploadModal';
overlay.innerHTML = \`
<div class="modal-dialog" style="width: 500px;">
<div class="modal-title">上传本地文件夹到 Git 仓库</div>
<div class="merge-dialog-content">
<div class="merge-input-section">
<label class="merge-input-label">Git 仓库 URL</label>
<input type="text" id="gitRepoUrlInput" class="merge-input-field"
placeholder="请输入 Git 仓库 URL例如: https://github.com/username/repo.git">
<div class="merge-input-help">将把当前文件夹的内容上传到此仓库</div>
</div>
<div class="merge-input-section">
<label class="merge-input-label">分支名称</label>
<input type="text" id="branchNameInput" class="merge-input-field"
placeholder="请输入分支名称" value="">
<div class="merge-input-help">将以当前文件夹名称作为分支名创建新分支</div>
</div>
</div>
<div class="modal-buttons">
<button class="modal-btn modal-btn-secondary" onclick="closeUploadDialog()">取消</button>
<button class="modal-btn modal-btn-primary" onclick="confirmUpload('\${folderId}')">确定上传</button>
</div>
</div>
\`;
document.body.appendChild(overlay);
// 自动聚焦到 URL 输入框
setTimeout(() => {
const urlInput = document.getElementById('gitRepoUrlInput');
if (urlInput) {
urlInput.focus();
}
}, 100);
}
function confirmUpload(folderId) {
const urlInput = document.getElementById('gitRepoUrlInput');
const branchInput = document.getElementById('branchNameInput');
const repoUrl = urlInput.value.trim();
const branchName = branchInput.value.trim();
if (!repoUrl) {
alert('请输入 Git 仓库 URL');
return;
}
if (!repoUrl.startsWith('http')) {
alert('请输入有效的 Git 仓库 URL');
return;
}
if (!branchName) {
alert('请输入分支名称');
return;
}
console.log('📤 确认上传本地文件夹:', { folderId, repoUrl, branchName });
vscode.postMessage({
type: 'syncGitModuleFolder',
folderId: folderId
type: 'uploadLocalModuleFolder',
folderId: folderId,
repoUrl: repoUrl,
branchName: branchName
});
closeUploadDialog();
}
function closeUploadDialog() {
const modal = document.getElementById('uploadModal');
if (modal) {
modal.remove();
}
}
function goBackToContainers() {

File diff suppressed because one or more lines are too long