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

@@ -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 上传:收到 openRepoSelectForUploadfolderId =", 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 更新方法
// =============================================