添加了代码上传功能,但是存在bug待修复
This commit is contained in:
@@ -89,9 +89,7 @@ export class ConfigView extends 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>
|
||||
@@ -144,7 +142,7 @@ export class ConfigView extends BaseView {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.btn-sync {
|
||||
.btn-upload {
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
padding: 4px 8px;
|
||||
@@ -153,9 +151,15 @@ export class ConfigView extends 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 {
|
||||
@@ -442,13 +446,111 @@ export class ConfigView extends 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() {
|
||||
@@ -992,4 +1094,4 @@ export class ConfigView extends BaseView {
|
||||
});
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user