添加了上传url的ui功能
This commit is contained in:
@@ -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[] = [];
|
||||
@@ -268,17 +270,54 @@ 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。`);
|
||||
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;
|
||||
}
|
||||
|
||||
this.currentRepoForBranches = repo;
|
||||
await this.fetchBranchesForRepo(repo);
|
||||
// 生成本地路径
|
||||
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 更新方法
|
||||
// =============================================
|
||||
|
||||
Reference in New Issue
Block a user