0
0

添加了上传url的ui功能

This commit is contained in:
xubing
2025-12-02 14:48:30 +08:00
parent fb8e31babb
commit 07acf9f617
10 changed files with 240 additions and 196 deletions

View File

@@ -38,12 +38,18 @@ class ConfigView extends BaseView_1.BaseView {
return `
<tr>
<td>
<span class="editable">${icon} ${folder.name}</span>
<span class="editable clickable" onclick="renameModuleFolder('${folder.id}')">
${icon} ${folder.name}
</span>
</td>
<td class="category-${folder.type}">${category}</td>
<td>
<span class="clickable" onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">${folder.localPath.split('/').pop()}</span>
</td>
<span class="clickable"
onclick="renameModuleFolder('${folder.id}', '${folder.localPath.split('/').pop()}')">
📄 ${folder.localPath.split('/').pop()}
</span>
</td>
<td>
<button class="btn-upload" onclick="uploadModuleFolder('${folder.id}', '${folder.type}')" style="margin-right: 5px;">上传</button>
<button class="btn-delete" onclick="deleteModuleFolder('${folder.id}')">删除</button>
@@ -293,7 +299,7 @@ class ConfigView extends BaseView_1.BaseView {
<div class="config-section">
<h3 class="section-title">📚 模块云仓库</h3>
<!-- 仓库选择区域:不再手动输入 URL通过弹窗获取仓库 -->
<!-- 仓库选择区域 -->
<div class="url-input-section">
<h4>🔗 获取仓库</h4>
<div style="display: flex; gap: 10px; margin-top: 10px; align-items: center;">
@@ -316,6 +322,25 @@ class ConfigView extends BaseView_1.BaseView {
let branchTreeData = [];
let selectedConfigs = new Set();
function renameModuleFolder(folderId, oldName) {
showPromptDialog(
'重命名模块文件夹',
'请输入新的名称:',
oldName,
function(newName) {
if (newName && newName.trim() && newName !== oldName) {
vscode.postMessage({
type: 'renameModuleFolder',
folderId: folderId,
newName: newName.trim()
});
}
}
);
}
// 配置管理功能
function editConfigName(configId, currentName) {
showPromptDialog(
@@ -428,90 +453,12 @@ class ConfigView extends BaseView_1.BaseView {
}
);
} else if (folderType === 'local') {
// Local 类型:弹出 URL 输入对话框
showUploadDialog(folderId);
}
}
// 上传对话框函数(本地->Git
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: 'uploadLocalModuleFolder',
folderId: folderId,
repoUrl: repoUrl,
branchName: branchName
});
closeUploadDialog();
}
function closeUploadDialog() {
const modal = document.getElementById('uploadModal');
if (modal) {
modal.remove();
// Local 类型:不再手动输入 URL改为复用“获取仓库”弹窗
// 后端将根据选择的仓库 + 本地文件夹名 自动确定 repoUrl 和 分支名
vscode.postMessage({
type: 'openRepoSelectForUpload',
folderId: folderId
});
}
}
@@ -519,16 +466,14 @@ class ConfigView extends BaseView_1.BaseView {
vscode.postMessage({ type: 'goBackToContainers' });
}
// 🔁 新逻辑:通过弹窗获取仓库(不再手动输入 URL
// 🔁 通过弹窗获取仓库(用于克隆
function openRepoSelect() {
console.log('📦 请求仓库列表以选择 Git 仓库');
console.log('📦 请求仓库列表以选择 Git 仓库(用于克隆分支)');
vscode.postMessage({
type: 'openRepoSelect'
});
}
// 不再在前端手动输入/校验 URL分支拉取由 repo 选择 + 后端完成
function toggleBranch(branchName) {
const checkbox = document.getElementById('branch-' + branchName.replace(/[^a-zA-Z0-9-]/g, '-'));
if (checkbox.checked) {