添加了上传url的ui功能
This commit is contained in:
@@ -72,6 +72,7 @@ class ConfigPanel {
|
||||
this.moduleFolders = [];
|
||||
this.currentModuleFolderFileTree = [];
|
||||
this.projectPaths = new Map();
|
||||
this.pendingUploadFolderId = null;
|
||||
// 仓库配置
|
||||
this.repoConfigs = [];
|
||||
// 状态管理
|
||||
@@ -197,6 +198,34 @@ class ConfigPanel {
|
||||
vscode.window.showErrorMessage(`在仓库配置中未找到名为 "${repoName}" 的仓库,请检查 dcsp-repos.json。`);
|
||||
return;
|
||||
}
|
||||
// ---------------------------------------------------
|
||||
// 1️⃣ 新逻辑:Local 上传(pendingUploadFolderId 不为空)
|
||||
// ---------------------------------------------------
|
||||
if (this.pendingUploadFolderId) {
|
||||
const localFolderId = this.pendingUploadFolderId;
|
||||
this.pendingUploadFolderId = null; // 必须清空,避免影响其他操作
|
||||
console.log("🚀 Local 上传流程:repo =", repoName, "folderId =", localFolderId);
|
||||
const folder = this.moduleFolders.find(f => f.id === localFolderId);
|
||||
if (!folder) {
|
||||
vscode.window.showErrorMessage("未找到要上传的本地模块文件夹");
|
||||
return;
|
||||
}
|
||||
// 生成本地路径
|
||||
const fullPath = this.getModuleFolderFullPath(folder);
|
||||
if (!fullPath) {
|
||||
vscode.window.showErrorMessage("无法确定本地模块文件夹路径");
|
||||
return;
|
||||
}
|
||||
// 自动从本地文件夹名生成分支名
|
||||
const branchName = path.basename(fullPath);
|
||||
console.log("🌿 自动生成分支名:", branchName);
|
||||
// 正式执行上传
|
||||
await this.uploadLocalModuleFolder(localFolderId, repo.url, branchName);
|
||||
return;
|
||||
}
|
||||
// ---------------------------------------------------
|
||||
// 2️⃣ 旧逻辑:获取分支
|
||||
// ---------------------------------------------------
|
||||
this.currentRepoForBranches = repo;
|
||||
await this.fetchBranchesForRepo(repo);
|
||||
}
|
||||
@@ -264,8 +293,10 @@ class ConfigPanel {
|
||||
'deleteModuleFolder': (data) => this.deleteModuleFolder(data.folderId),
|
||||
'importGitFile': (data) => this.importGitFile(data.filePath),
|
||||
'openTheModuleFolder': (data) => this.openTheModuleFolder(data.moduleType, data.id),
|
||||
'renameModuleFolder': (data) => this.renameModuleFolder(data.folderId, data.newName),
|
||||
// 上传功能
|
||||
'uploadGitModuleFolder': (data) => this.uploadGitModuleFolder(data.folderId, data.username, data.password),
|
||||
'openRepoSelectForUpload': (data) => this.handleOpenRepoSelectForUpload(data.folderId),
|
||||
'uploadLocalModuleFolder': (data) => this.uploadLocalModuleFolder(data.folderId, data.repoUrl, data.branchName)
|
||||
};
|
||||
const handler = messageHandlers[data.type];
|
||||
@@ -476,6 +507,12 @@ class ConfigPanel {
|
||||
await this.saveCurrentProjectData();
|
||||
this.updateWebview();
|
||||
}
|
||||
async handleOpenRepoSelectForUpload(folderId) {
|
||||
console.log("📌 Local 上传:收到 openRepoSelectForUpload,folderId =", folderId);
|
||||
this.pendingUploadFolderId = folderId;
|
||||
// 复用你现有的仓库选择弹窗
|
||||
await this.openRepoSelect();
|
||||
}
|
||||
async deleteConfig(configId) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (!config)
|
||||
@@ -1629,6 +1666,31 @@ class ConfigPanel {
|
||||
vscode.window.showErrorMessage(`打开模块文件夹文件失败: ${error}`);
|
||||
}
|
||||
}
|
||||
async renameModuleFolder(folderId, newName) {
|
||||
const folder = this.moduleFolders.find(f => f.id === folderId);
|
||||
if (!folder) {
|
||||
vscode.window.showErrorMessage('未找到模块文件夹');
|
||||
return;
|
||||
}
|
||||
const oldName = folder.localPath.split('/').pop();
|
||||
if (!oldName)
|
||||
return;
|
||||
const fullPath = this.getModuleFolderFullPath(folder);
|
||||
if (!fullPath)
|
||||
return;
|
||||
const newFullPath = path.join(path.dirname(fullPath), newName);
|
||||
try {
|
||||
await fs.promises.rename(fullPath, newFullPath);
|
||||
// 更新 localPath
|
||||
folder.localPath = folder.localPath.replace(/\/[^/]+$/, '/' + newName);
|
||||
await this.saveCurrentProjectData();
|
||||
vscode.window.showInformationMessage(`已重命名文件夹: ${oldName} → ${newName}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage('重命名失败: ' + error);
|
||||
}
|
||||
}
|
||||
// =============================================
|
||||
// Webview 更新方法
|
||||
// =============================================
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -228,6 +228,12 @@ class BaseView {
|
||||
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener('click', function () {
|
||||
// 通知后端取消,清理可能的状态(例如待上传的本地文件夹)
|
||||
if (typeof vscode !== 'undefined') {
|
||||
vscode.postMessage({
|
||||
type: 'repoSelectCanceled'
|
||||
});
|
||||
}
|
||||
overlay.remove();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"BaseView.js","sourceRoot":"","sources":["../../../src/panels/views/BaseView.ts"],"names":[],"mappings":";;;AAEA,MAAsB,QAAQ;IAG1B,YAAY,YAAwB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAIS,SAAS;QACf,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAiQN,CAAC;IACN,CAAC;CACJ;AA7QD,4BA6QC"}
|
||||
{"version":3,"file":"BaseView.js","sourceRoot":"","sources":["../../../src/panels/views/BaseView.ts"],"names":[],"mappings":";;;AAEA,MAAsB,QAAQ;IAG1B,YAAY,YAAwB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAIS,SAAS;QACf,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAuQN,CAAC;IACN,CAAC;CACJ;AAnRD,4BAmRC"}
|
||||
@@ -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>
|
||||
<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 });
|
||||
|
||||
// Local 类型:不再手动输入 URL,改为复用“获取仓库”弹窗
|
||||
// 后端将根据选择的仓库 + 本地文件夹名 自动确定 repoUrl 和 分支名
|
||||
vscode.postMessage({
|
||||
type: 'uploadLocalModuleFolder',
|
||||
folderId: folderId,
|
||||
repoUrl: repoUrl,
|
||||
branchName: branchName
|
||||
type: 'openRepoSelectForUpload',
|
||||
folderId: folderId
|
||||
});
|
||||
|
||||
closeUploadDialog();
|
||||
}
|
||||
|
||||
function closeUploadDialog() {
|
||||
const modal = document.getElementById('uploadModal');
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -10,6 +10,7 @@ import { ContainerView } from './views/ContainerView';
|
||||
import { ConfigView } from './views/ConfigView';
|
||||
import { ModuleFolder } from './types/CommonTypes';
|
||||
|
||||
|
||||
// =============================================
|
||||
// 数据模型接口
|
||||
// =============================================
|
||||
@@ -92,6 +93,7 @@ export class ConfigPanel {
|
||||
private moduleFolders: ModuleFolder[] = [];
|
||||
private currentModuleFolderFileTree: GitFileTree[] = [];
|
||||
private projectPaths: Map<string, string> = new Map();
|
||||
private pendingUploadFolderId: string | null = null;
|
||||
|
||||
// 仓库配置
|
||||
private repoConfigs: RepoConfigItem[] = [];
|
||||
@@ -270,15 +272,52 @@ export class ConfigPanel {
|
||||
private async handleRepoSelectedForBranches(repoName: string): Promise<void> {
|
||||
await this.loadRepoConfigs();
|
||||
const repo = this.repoConfigs.find(r => r.name === repoName);
|
||||
|
||||
if (!repo) {
|
||||
vscode.window.showErrorMessage(`在仓库配置中未找到名为 "${repoName}" 的仓库,请检查 dcsp-repos.json。`);
|
||||
return;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
// 1️⃣ 新逻辑:Local 上传(pendingUploadFolderId 不为空)
|
||||
// ---------------------------------------------------
|
||||
if (this.pendingUploadFolderId) {
|
||||
const localFolderId = this.pendingUploadFolderId;
|
||||
this.pendingUploadFolderId = null; // 必须清空,避免影响其他操作
|
||||
|
||||
console.log("🚀 Local 上传流程:repo =", repoName, "folderId =", localFolderId);
|
||||
|
||||
const folder = this.moduleFolders.find(f => f.id === localFolderId);
|
||||
if (!folder) {
|
||||
vscode.window.showErrorMessage("未找到要上传的本地模块文件夹");
|
||||
return;
|
||||
}
|
||||
|
||||
// 生成本地路径
|
||||
const fullPath = this.getModuleFolderFullPath(folder);
|
||||
if (!fullPath) {
|
||||
vscode.window.showErrorMessage("无法确定本地模块文件夹路径");
|
||||
return;
|
||||
}
|
||||
|
||||
// 自动从本地文件夹名生成分支名
|
||||
const branchName = path.basename(fullPath);
|
||||
console.log("🌿 自动生成分支名:", branchName);
|
||||
|
||||
// 正式执行上传
|
||||
await this.uploadLocalModuleFolder(localFolderId, repo.url, branchName);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------
|
||||
// 2️⃣ 旧逻辑:获取分支
|
||||
// ---------------------------------------------------
|
||||
this.currentRepoForBranches = repo;
|
||||
await this.fetchBranchesForRepo(repo);
|
||||
}
|
||||
|
||||
|
||||
// =============================================
|
||||
// Webview 消息处理
|
||||
// =============================================
|
||||
@@ -353,9 +392,11 @@ export class ConfigPanel {
|
||||
'deleteModuleFolder': (data) => this.deleteModuleFolder(data.folderId),
|
||||
'importGitFile': (data) => this.importGitFile(data.filePath),
|
||||
'openTheModuleFolder': (data) => this.openTheModuleFolder(data.moduleType, data.id),
|
||||
'renameModuleFolder': (data) => this.renameModuleFolder(data.folderId, data.newName),
|
||||
|
||||
// 上传功能
|
||||
'uploadGitModuleFolder': (data) => this.uploadGitModuleFolder(data.folderId, data.username, data.password),
|
||||
'openRepoSelectForUpload': (data) => this.handleOpenRepoSelectForUpload(data.folderId),
|
||||
'uploadLocalModuleFolder': (data) => this.uploadLocalModuleFolder(data.folderId, data.repoUrl, data.branchName)
|
||||
};
|
||||
|
||||
@@ -607,6 +648,15 @@ export class ConfigPanel {
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
private async handleOpenRepoSelectForUpload(folderId: string): Promise<void> {
|
||||
console.log("📌 Local 上传:收到 openRepoSelectForUpload,folderId =", folderId);
|
||||
this.pendingUploadFolderId = folderId;
|
||||
|
||||
// 复用你现有的仓库选择弹窗
|
||||
await this.openRepoSelect();
|
||||
}
|
||||
|
||||
|
||||
private async deleteConfig(configId: string): Promise<void> {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (!config) return;
|
||||
@@ -1979,6 +2029,39 @@ export class ConfigPanel {
|
||||
}
|
||||
}
|
||||
|
||||
private async renameModuleFolder(folderId: string, newName: string): Promise<void> {
|
||||
const folder = this.moduleFolders.find(f => f.id === folderId);
|
||||
if (!folder) {
|
||||
vscode.window.showErrorMessage('未找到模块文件夹');
|
||||
return;
|
||||
}
|
||||
|
||||
const oldName = folder.localPath.split('/').pop();
|
||||
if (!oldName) return;
|
||||
|
||||
const fullPath = this.getModuleFolderFullPath(folder);
|
||||
if (!fullPath) return;
|
||||
|
||||
const newFullPath = path.join(path.dirname(fullPath), newName);
|
||||
|
||||
try {
|
||||
await fs.promises.rename(fullPath, newFullPath);
|
||||
|
||||
// 更新 localPath
|
||||
folder.localPath = folder.localPath.replace(/\/[^/]+$/, '/' + newName);
|
||||
|
||||
await this.saveCurrentProjectData();
|
||||
|
||||
vscode.window.showInformationMessage(`已重命名文件夹: ${oldName} → ${newName}`);
|
||||
|
||||
this.updateWebview();
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage('重命名失败: ' + error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// =============================================
|
||||
// Webview 更新方法
|
||||
// =============================================
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// src/panels/types/DataTypes.ts
|
||||
// 此文件已过时,请使用 CommonTypes.ts 中的统一类型定义
|
||||
export { ProjectData } from './CommonTypes';
|
||||
@@ -232,6 +232,12 @@ export abstract class BaseView {
|
||||
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener('click', function () {
|
||||
// 通知后端取消,清理可能的状态(例如待上传的本地文件夹)
|
||||
if (typeof vscode !== 'undefined') {
|
||||
vscode.postMessage({
|
||||
type: 'repoSelectCanceled'
|
||||
});
|
||||
}
|
||||
overlay.remove();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,12 +83,18 @@ export class ConfigView extends 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>
|
||||
<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>
|
||||
@@ -340,7 +346,7 @@ export class ConfigView extends 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;">
|
||||
@@ -363,6 +369,25 @@ export class ConfigView extends 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(
|
||||
@@ -475,90 +500,12 @@ export class ConfigView extends 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 });
|
||||
|
||||
// Local 类型:不再手动输入 URL,改为复用“获取仓库”弹窗
|
||||
// 后端将根据选择的仓库 + 本地文件夹名 自动确定 repoUrl 和 分支名
|
||||
vscode.postMessage({
|
||||
type: 'uploadLocalModuleFolder',
|
||||
folderId: folderId,
|
||||
repoUrl: repoUrl,
|
||||
branchName: branchName
|
||||
type: 'openRepoSelectForUpload',
|
||||
folderId: folderId
|
||||
});
|
||||
|
||||
closeUploadDialog();
|
||||
}
|
||||
|
||||
function closeUploadDialog() {
|
||||
const modal = document.getElementById('uploadModal');
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,16 +513,14 @@ export class ConfigView extends 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) {
|
||||
|
||||
Reference in New Issue
Block a user