修改上传逻辑,增加了分支名输入的功能
This commit is contained in:
@@ -5,6 +5,12 @@
|
|||||||
"url": "http://117.72.162.127:3000/xb/test.git",
|
"url": "http://117.72.162.127:3000/xb/test.git",
|
||||||
"username": "xb",
|
"username": "xb",
|
||||||
"token": "582e19830c58bdbfa8962f881ec873cce208ead0"
|
"token": "582e19830c58bdbfa8962f881ec873cce208ead0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "动力学模型",
|
||||||
|
"url": "http://117.72.162.127:3000/xb/build.git",
|
||||||
|
"username": "xb",
|
||||||
|
"token": "582e19830c58bdbfa8962f881ec873cce208ead0"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.ConfigPanel = void 0;
|
exports.ConfigPanel = void 0;
|
||||||
// src/panels/ConfigPanel.ts
|
|
||||||
const vscode = __importStar(require("vscode"));
|
const vscode = __importStar(require("vscode"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ProjectView_1 = require("./views/ProjectView");
|
const ProjectView_1 = require("./views/ProjectView");
|
||||||
@@ -58,9 +57,6 @@ class ConfigPanel {
|
|||||||
this.currentAircraftId = '';
|
this.currentAircraftId = '';
|
||||||
this.currentContainerId = '';
|
this.currentContainerId = '';
|
||||||
this.currentModuleFolderId = '';
|
this.currentModuleFolderId = '';
|
||||||
// 上传相关
|
|
||||||
this.pendingUploadFolderId = null;
|
|
||||||
this.pendingGitUploadFolderId = null;
|
|
||||||
// 仓库配置
|
// 仓库配置
|
||||||
this.repoConfigs = [];
|
this.repoConfigs = [];
|
||||||
// 状态管理
|
// 状态管理
|
||||||
@@ -96,7 +92,7 @@ class ConfigPanel {
|
|||||||
await this.loadRepoConfigs();
|
await this.loadRepoConfigs();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 弹出仓库选择弹窗
|
* 弹出仓库选择弹窗(仅用于“获取仓库 -> 获取分支”)
|
||||||
*/
|
*/
|
||||||
async openRepoSelect() {
|
async openRepoSelect() {
|
||||||
await this.loadRepoConfigs();
|
await this.loadRepoConfigs();
|
||||||
@@ -112,7 +108,25 @@ class ConfigPanel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 仓库选择确认后的统一入口
|
* 弹出“上传代码”时的仓库 + 分支选择弹窗
|
||||||
|
*/
|
||||||
|
async openUploadRepoSelect(folderId, folderType) {
|
||||||
|
await this.loadRepoConfigs();
|
||||||
|
if (this.repoConfigs.length === 0) {
|
||||||
|
vscode.window.showWarningMessage('尚未配置任何仓库,请先点击右上角 "仓库配置" 按钮编辑 dcsp-repos.json。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.isWebviewDisposed)
|
||||||
|
return;
|
||||||
|
this.panel.webview.postMessage({
|
||||||
|
type: 'showUploadRepoSelect',
|
||||||
|
repos: this.repoConfigs.map(r => ({ name: r.name })),
|
||||||
|
folderId,
|
||||||
|
folderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* “获取仓库”弹窗确认后:用于拉取分支
|
||||||
*/
|
*/
|
||||||
async handleRepoSelectedForBranches(repoName) {
|
async handleRepoSelectedForBranches(repoName) {
|
||||||
await this.loadRepoConfigs();
|
await this.loadRepoConfigs();
|
||||||
@@ -121,39 +135,37 @@ class ConfigPanel {
|
|||||||
vscode.window.showErrorMessage(`在仓库配置中未找到名为 "${repoName}" 的仓库`);
|
vscode.window.showErrorMessage(`在仓库配置中未找到名为 "${repoName}" 的仓库`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 1️⃣ Local 模块上传(local -> git)
|
|
||||||
if (this.pendingUploadFolderId) {
|
|
||||||
const localFolderId = this.pendingUploadFolderId;
|
|
||||||
this.pendingUploadFolderId = null;
|
|
||||||
await this.processLocalUpload(localFolderId, repo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 2️⃣ Git 模块上传(git -> repo)
|
|
||||||
if (this.pendingGitUploadFolderId) {
|
|
||||||
const gitFolderId = this.pendingGitUploadFolderId;
|
|
||||||
this.pendingGitUploadFolderId = null;
|
|
||||||
await this.processGitUpload(gitFolderId, repo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 3️⃣ 默认:获取分支(用于"获取仓库"-> 克隆)
|
|
||||||
this.currentRepoForBranches = repo;
|
this.currentRepoForBranches = repo;
|
||||||
await this.fetchBranchesForRepo(repo);
|
await this.fetchBranchesForRepo(repo);
|
||||||
}
|
}
|
||||||
async processLocalUpload(folderId, repo) {
|
/**
|
||||||
const folder = this.projectService.getModuleFolder(folderId);
|
* “上传代码”弹窗确认后:根据 folderType 决定上传逻辑,并使用用户输入的 branchName
|
||||||
if (!folder || folder.type !== 'local') {
|
*/
|
||||||
vscode.window.showErrorMessage("未找到要上传的本地模块文件夹");
|
async handleUploadRepoSelected(folderId, folderType, repoName, branchName) {
|
||||||
|
const trimmedBranch = (branchName || '').trim();
|
||||||
|
if (!trimmedBranch) {
|
||||||
|
vscode.window.showErrorMessage('分支名称不能为空');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fullPath = this.projectService.getModuleFolderFullPath(folder);
|
await this.loadRepoConfigs();
|
||||||
if (!fullPath) {
|
const repo = this.repoConfigs.find(r => r.name === repoName);
|
||||||
vscode.window.showErrorMessage("无法确定本地模块文件夹路径");
|
if (!repo) {
|
||||||
|
vscode.window.showErrorMessage(`在仓库配置中未找到名为 "${repoName}" 的仓库`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const branchName = path.basename(fullPath);
|
if (folderType === 'local') {
|
||||||
await this.uploadLocalModuleFolder(folderId, repo.url, branchName, repo.username, repo.token);
|
// 本地模块 -> 选中仓库 + 指定分支
|
||||||
|
await this.uploadLocalModuleFolder(folderId, repo.url, trimmedBranch, repo.username, repo.token);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Git 模块 -> 选中仓库 + 指定分支
|
||||||
|
await this.processGitUploadWithBranch(folderId, repo, trimmedBranch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async processGitUpload(folderId, repo) {
|
/**
|
||||||
|
* Git 模块上传(可能换仓库 / 改名),使用用户指定的分支
|
||||||
|
*/
|
||||||
|
async processGitUploadWithBranch(folderId, repo, branchName) {
|
||||||
const folder = this.projectService.getModuleFolder(folderId);
|
const folder = this.projectService.getModuleFolder(folderId);
|
||||||
if (!folder || folder.type !== 'git') {
|
if (!folder || folder.type !== 'git') {
|
||||||
vscode.window.showErrorMessage("未找到要上传的 Git 模块文件夹");
|
vscode.window.showErrorMessage("未找到要上传的 Git 模块文件夹");
|
||||||
@@ -168,12 +180,12 @@ class ConfigPanel {
|
|||||||
vscode.window.showErrorMessage("无法确定 Git 模块文件夹路径");
|
vscode.window.showErrorMessage("无法确定 Git 模块文件夹路径");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 2.1 未改名 + 还是原来的仓库 → 直接在原分支上 push(更新代码)
|
// 未改名 + 还是原来的仓库 → 直接在原分支上 push(更新代码)
|
||||||
if (!isRenamed && isSameRepo) {
|
if (!isRenamed && isSameRepo) {
|
||||||
await this.uploadGitModuleFolder(folderId);
|
await this.uploadGitModuleFolder(folderId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 2.2 改了名字 或 换了仓库 → 使用"当前文件夹名"作为分支,推送到选中仓库
|
// 改了名字 或 换了仓库 → 使用“用户输入的分支名”进行推送
|
||||||
await vscode.window.withProgress({
|
await vscode.window.withProgress({
|
||||||
location: vscode.ProgressLocation.Notification,
|
location: vscode.ProgressLocation.Notification,
|
||||||
title: `正在上传 Git 仓库: ${folder.name}`,
|
title: `正在上传 Git 仓库: ${folder.name}`,
|
||||||
@@ -181,7 +193,7 @@ class ConfigPanel {
|
|||||||
}, async (progress) => {
|
}, async (progress) => {
|
||||||
try {
|
try {
|
||||||
progress.report({ increment: 0, message: '准备上传...' });
|
progress.report({ increment: 0, message: '准备上传...' });
|
||||||
await GitService_1.GitService.pushToRepoUrl(fullPath, repo.url, newFolderName, repo.username, repo.token);
|
await GitService_1.GitService.pushToRepoUrl(fullPath, repo.url, branchName, repo.username, repo.token);
|
||||||
this.projectService.updateModuleFolder(folderId, {
|
this.projectService.updateModuleFolder(folderId, {
|
||||||
uploaded: true,
|
uploaded: true,
|
||||||
originalFolderName: newFolderName,
|
originalFolderName: newFolderName,
|
||||||
@@ -189,7 +201,7 @@ class ConfigPanel {
|
|||||||
});
|
});
|
||||||
await this.saveCurrentProjectData();
|
await this.saveCurrentProjectData();
|
||||||
progress.report({ increment: 100, message: '完成' });
|
progress.report({ increment: 100, message: '完成' });
|
||||||
vscode.window.showInformationMessage(`✅ Git 仓库已上传到 ${repo.name} 的分支 ${newFolderName}`);
|
vscode.window.showInformationMessage(`✅ Git 仓库已上传到 ${repo.name} 的分支 ${branchName}`);
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -264,10 +276,12 @@ class ConfigPanel {
|
|||||||
'renameModuleFolder': (data) => this.renameModuleFolder(data.folderId, data.newName),
|
'renameModuleFolder': (data) => this.renameModuleFolder(data.folderId, data.newName),
|
||||||
// 上传功能
|
// 上传功能
|
||||||
'uploadGitModuleFolder': (data) => this.uploadGitModuleFolder(data.folderId, data.username, data.password),
|
'uploadGitModuleFolder': (data) => this.uploadGitModuleFolder(data.folderId, data.username, data.password),
|
||||||
'openRepoSelectForUpload': (data) => this.handleOpenRepoSelectForUpload(data.folderId),
|
'openRepoSelectForUpload': (data) => this.openUploadRepoSelect(data.folderId, 'local'),
|
||||||
'uploadLocalModuleFolder': (data) => this.uploadLocalModuleFolder(data.folderId, data.repoUrl, data.branchName),
|
'uploadLocalModuleFolder': (data) => this.uploadLocalModuleFolder(data.folderId, data.repoUrl, data.branchName),
|
||||||
'openRepoSelectForGitUpload': (data) => this.openRepoSelectForGitUpload(data.folderId),
|
'openRepoSelectForGitUpload': (data) => this.openUploadRepoSelect(data.folderId, 'git'),
|
||||||
'repoSelectedForGitUpload': (data) => this.handleRepoSelectedForGitUpload(data.folderId, data.repoName)
|
// 旧的 repoSelectedForGitUpload 保留兼容的话可以转发到 handleRepoSelectedForBranches,但现在不再使用
|
||||||
|
// 新增:上传时仓库 + 分支选择确认
|
||||||
|
'uploadRepoSelected': (data) => this.handleUploadRepoSelected(data.folderId, data.folderType, data.repoName, data.branchName)
|
||||||
};
|
};
|
||||||
const handler = messageHandlers[data.type];
|
const handler = messageHandlers[data.type];
|
||||||
if (handler) {
|
if (handler) {
|
||||||
@@ -327,21 +341,6 @@ class ConfigPanel {
|
|||||||
console.log('❌ 取消分支选择');
|
console.log('❌ 取消分支选择');
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
async handleOpenRepoSelectForUpload(folderId) {
|
|
||||||
console.log("📌 Local 上传:收到 openRepoSelectForUpload,folderId =", folderId);
|
|
||||||
this.pendingUploadFolderId = folderId;
|
|
||||||
await this.openRepoSelect();
|
|
||||||
}
|
|
||||||
async openRepoSelectForGitUpload(folderId) {
|
|
||||||
console.log('📌 Git 上传:收到 openRepoSelectForGitUpload,folderId =', folderId);
|
|
||||||
this.pendingGitUploadFolderId = folderId;
|
|
||||||
await this.openRepoSelect();
|
|
||||||
}
|
|
||||||
async handleRepoSelectedForGitUpload(folderId, repoName) {
|
|
||||||
// 兼容:如果前端用的是 repoSelectedForGitUpload 事件,则这里转成统一逻辑
|
|
||||||
this.pendingGitUploadFolderId = folderId;
|
|
||||||
await this.handleRepoSelectedForBranches(repoName);
|
|
||||||
}
|
|
||||||
// =============================================
|
// =============================================
|
||||||
// 项目管理方法
|
// 项目管理方法
|
||||||
// =============================================
|
// =============================================
|
||||||
@@ -879,7 +878,7 @@ class ConfigPanel {
|
|||||||
progress.report({ increment: 10, message: '初始化 Git 仓库...' });
|
progress.report({ increment: 10, message: '初始化 Git 仓库...' });
|
||||||
await GitService_1.GitService.initRepository(fullPath, branchName);
|
await GitService_1.GitService.initRepository(fullPath, branchName);
|
||||||
progress.report({ increment: 20, message: '添加远程仓库...' });
|
progress.report({ increment: 20, message: '添加远程仓库...' });
|
||||||
await GitService_1.GitService.addRemote(fullPath, repoUrl);
|
await GitService_1.GitService.addRemote(fullPath, repoUrl, username, token);
|
||||||
progress.report({ increment: 40, message: '提交初始文件...' });
|
progress.report({ increment: 40, message: '提交初始文件...' });
|
||||||
await GitService_1.GitService.commitInitialFiles(fullPath);
|
await GitService_1.GitService.commitInitialFiles(fullPath);
|
||||||
progress.report({ increment: 60, message: '推送到远程仓库...' });
|
progress.report({ increment: 60, message: '推送到远程仓库...' });
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -255,7 +255,7 @@ class BaseView {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取仓库选择对话框的脚本(仅ConfigView需要)
|
* 获取仓库选择对话框的脚本(ConfigView 使用)
|
||||||
*/
|
*/
|
||||||
getRepoSelectScript() {
|
getRepoSelectScript() {
|
||||||
return `
|
return `
|
||||||
@@ -267,6 +267,7 @@ class BaseView {
|
|||||||
}
|
}
|
||||||
window.__dcspRepoDialogInitialized = true;
|
window.__dcspRepoDialogInitialized = true;
|
||||||
|
|
||||||
|
// ① 仅用于“获取仓库 -> 拉取分支”的弹窗
|
||||||
function showRepoSelectDialog(repos) {
|
function showRepoSelectDialog(repos) {
|
||||||
// 移除已有弹窗
|
// 移除已有弹窗
|
||||||
var existing = document.getElementById('repoSelectModal');
|
var existing = document.getElementById('repoSelectModal');
|
||||||
@@ -350,11 +351,120 @@ class BaseView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ② 专门用于“上传代码”的仓库+分支弹窗
|
||||||
|
function showUploadRepoSelectDialog(repos, folderId, folderType) {
|
||||||
|
var existing = document.getElementById('uploadRepoSelectModal');
|
||||||
|
if (existing) {
|
||||||
|
existing.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
var overlay = document.createElement('div');
|
||||||
|
overlay.className = 'modal-overlay';
|
||||||
|
overlay.id = 'uploadRepoSelectModal';
|
||||||
|
|
||||||
|
var hasRepos = Array.isArray(repos) && repos.length > 0;
|
||||||
|
var optionsHtml = '';
|
||||||
|
if (hasRepos) {
|
||||||
|
for (var i = 0; i < repos.length; i++) {
|
||||||
|
var r = repos[i];
|
||||||
|
if (!r || !r.name) continue;
|
||||||
|
optionsHtml += '<option value="' + r.name + '">' + r.name + '</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var disabledAttr = hasRepos ? '' : 'disabled';
|
||||||
|
|
||||||
|
var noRepoTip = '';
|
||||||
|
if (!hasRepos) {
|
||||||
|
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在"仓库配置"中添加。</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
overlay.innerHTML =
|
||||||
|
'<div class="modal-dialog">' +
|
||||||
|
'<div class="modal-title">上传到仓库</div>' +
|
||||||
|
'<div style="margin-bottom: 10px;">' +
|
||||||
|
'<label style="display:block; margin-bottom:6px;">请选择仓库:</label>' +
|
||||||
|
'<select id="uploadRepoSelect" style="width:100%; padding:6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border:1px solid var(--vscode-input-border); border-radius:4px;">' +
|
||||||
|
optionsHtml +
|
||||||
|
'</select>' +
|
||||||
|
noRepoTip +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="margin-bottom: 10px;">' +
|
||||||
|
'<label style="display:block; margin-bottom:6px;">请输入分支名称:</label>' +
|
||||||
|
'<input type="text" id="uploadBranchInput" style="width:100%; padding:6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border:1px solid var(--vscode-input-border); border-radius:4px;" placeholder="如:main、develop、feature/xxx">' +
|
||||||
|
'<div style="font-size:12px; color: var(--vscode-descriptionForeground); margin-top:4px;">将把代码推送到该分支,如不存在则自动创建</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="modal-buttons">' +
|
||||||
|
'<button class="modal-btn modal-btn-secondary" id="uploadRepoSelectCancelBtn">取消</button>' +
|
||||||
|
'<button class="modal-btn modal-btn-primary" id="uploadRepoSelectOkBtn" ' + disabledAttr + '>确定</button>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
var cancelBtn = document.getElementById('uploadRepoSelectCancelBtn');
|
||||||
|
var okBtn = document.getElementById('uploadRepoSelectOkBtn');
|
||||||
|
var repoSelect = document.getElementById('uploadRepoSelect');
|
||||||
|
var branchInput = document.getElementById('uploadBranchInput');
|
||||||
|
|
||||||
|
if (cancelBtn) {
|
||||||
|
cancelBtn.addEventListener('click', function () {
|
||||||
|
if (typeof vscode !== 'undefined') {
|
||||||
|
vscode.postMessage({
|
||||||
|
type: 'uploadRepoSelectCanceled',
|
||||||
|
folderId: folderId,
|
||||||
|
folderType: folderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
overlay.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (okBtn) {
|
||||||
|
okBtn.addEventListener('click', function () {
|
||||||
|
if (!hasRepos || !repoSelect) {
|
||||||
|
overlay.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var repoName = repoSelect.value;
|
||||||
|
var branchName = branchInput ? branchInput.value.trim() : '';
|
||||||
|
if (!repoName) {
|
||||||
|
alert('请选择一个仓库');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!branchName) {
|
||||||
|
alert('请输入分支名称');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof vscode !== 'undefined') {
|
||||||
|
vscode.postMessage({
|
||||||
|
type: 'uploadRepoSelected',
|
||||||
|
repoName: repoName,
|
||||||
|
branchName: branchName,
|
||||||
|
folderId: folderId,
|
||||||
|
folderType: folderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
overlay.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
if (branchInput) {
|
||||||
|
branchInput.focus();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('message', function (event) {
|
window.addEventListener('message', function (event) {
|
||||||
var message = event.data;
|
var message = event.data;
|
||||||
if (!message || !message.type) return;
|
if (!message || !message.type) return;
|
||||||
if (message.type === 'showRepoSelect') {
|
if (message.type === 'showRepoSelect') {
|
||||||
|
// 旧逻辑:仅用于获取分支
|
||||||
showRepoSelectDialog(message.repos || []);
|
showRepoSelectDialog(message.repos || []);
|
||||||
|
} else if (message.type === 'showUploadRepoSelect') {
|
||||||
|
// 新逻辑:上传代码用(仓库 + 分支)
|
||||||
|
showUploadRepoSelectDialog(message.repos || [], message.folderId, message.folderType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"BaseView.js","sourceRoot":"","sources":["../../../src/panels/views/BaseView.ts"],"names":[],"mappings":";;;AAGA,MAAsB,QAAQ;IAG1B,YAAY,YAAwB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAID;;OAEG;IACO,uBAAuB;QAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAmPN,CAAC;IACN,CAAC;IAED;;OAEG;IACO,mBAAmB;QACzB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAqGN,CAAC;IACN,CAAC;IAED;;OAEG;IACO,SAAS;QACf,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAC1C,CAAC;CACJ;AArXD,4BAqXC"}
|
{"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;IAID;;OAEG;IACO,uBAAuB;QAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAmPN,CAAC;IACN,CAAC;IAED;;OAEG;IACO,mBAAmB;QACzB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAmNN,CAAC;IACN,CAAC;IAED;;OAEG;IACO,SAAS;QACf,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAC1C,CAAC;CACJ;AAneD,4BAmeC"}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
// src/panels/ConfigPanel.ts
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { ProjectView } from './views/ProjectView';
|
import { ProjectView } from './views/ProjectView';
|
||||||
@@ -41,10 +40,6 @@ export class ConfigPanel {
|
|||||||
private currentContainerId: string = '';
|
private currentContainerId: string = '';
|
||||||
private currentModuleFolderId: string = '';
|
private currentModuleFolderId: string = '';
|
||||||
|
|
||||||
// 上传相关
|
|
||||||
private pendingUploadFolderId: string | null = null;
|
|
||||||
private pendingGitUploadFolderId: string | null = null;
|
|
||||||
|
|
||||||
// 仓库配置
|
// 仓库配置
|
||||||
private repoConfigs: RepoConfigItem[] = [];
|
private repoConfigs: RepoConfigItem[] = [];
|
||||||
private currentRepoForBranches: RepoConfigItem | undefined;
|
private currentRepoForBranches: RepoConfigItem | undefined;
|
||||||
@@ -125,7 +120,7 @@ export class ConfigPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 弹出仓库选择弹窗
|
* 弹出仓库选择弹窗(仅用于“获取仓库 -> 获取分支”)
|
||||||
*/
|
*/
|
||||||
private async openRepoSelect(): Promise<void> {
|
private async openRepoSelect(): Promise<void> {
|
||||||
await this.loadRepoConfigs();
|
await this.loadRepoConfigs();
|
||||||
@@ -144,7 +139,28 @@ export class ConfigPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仓库选择确认后的统一入口
|
* 弹出“上传代码”时的仓库 + 分支选择弹窗
|
||||||
|
*/
|
||||||
|
private async openUploadRepoSelect(folderId: string, folderType: 'git' | 'local'): Promise<void> {
|
||||||
|
await this.loadRepoConfigs();
|
||||||
|
|
||||||
|
if (this.repoConfigs.length === 0) {
|
||||||
|
vscode.window.showWarningMessage('尚未配置任何仓库,请先点击右上角 "仓库配置" 按钮编辑 dcsp-repos.json。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isWebviewDisposed) return;
|
||||||
|
|
||||||
|
this.panel.webview.postMessage({
|
||||||
|
type: 'showUploadRepoSelect',
|
||||||
|
repos: this.repoConfigs.map(r => ({ name: r.name })),
|
||||||
|
folderId,
|
||||||
|
folderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* “获取仓库”弹窗确认后:用于拉取分支
|
||||||
*/
|
*/
|
||||||
private async handleRepoSelectedForBranches(repoName: string): Promise<void> {
|
private async handleRepoSelectedForBranches(repoName: string): Promise<void> {
|
||||||
await this.loadRepoConfigs();
|
await this.loadRepoConfigs();
|
||||||
@@ -155,51 +171,55 @@ export class ConfigPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1️⃣ Local 模块上传(local -> git)
|
|
||||||
if (this.pendingUploadFolderId) {
|
|
||||||
const localFolderId = this.pendingUploadFolderId;
|
|
||||||
this.pendingUploadFolderId = null;
|
|
||||||
await this.processLocalUpload(localFolderId, repo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2️⃣ Git 模块上传(git -> repo)
|
|
||||||
if (this.pendingGitUploadFolderId) {
|
|
||||||
const gitFolderId = this.pendingGitUploadFolderId;
|
|
||||||
this.pendingGitUploadFolderId = null;
|
|
||||||
await this.processGitUpload(gitFolderId, repo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3️⃣ 默认:获取分支(用于"获取仓库"-> 克隆)
|
|
||||||
this.currentRepoForBranches = repo;
|
this.currentRepoForBranches = repo;
|
||||||
await this.fetchBranchesForRepo(repo);
|
await this.fetchBranchesForRepo(repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async processLocalUpload(folderId: string, repo: RepoConfigItem): Promise<void> {
|
/**
|
||||||
const folder = this.projectService.getModuleFolder(folderId);
|
* “上传代码”弹窗确认后:根据 folderType 决定上传逻辑,并使用用户输入的 branchName
|
||||||
if (!folder || folder.type !== 'local') {
|
*/
|
||||||
vscode.window.showErrorMessage("未找到要上传的本地模块文件夹");
|
private async handleUploadRepoSelected(
|
||||||
|
folderId: string,
|
||||||
|
folderType: 'git' | 'local',
|
||||||
|
repoName: string,
|
||||||
|
branchName: string
|
||||||
|
): Promise<void> {
|
||||||
|
const trimmedBranch = (branchName || '').trim();
|
||||||
|
if (!trimmedBranch) {
|
||||||
|
vscode.window.showErrorMessage('分支名称不能为空');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullPath = this.projectService.getModuleFolderFullPath(folder);
|
await this.loadRepoConfigs();
|
||||||
if (!fullPath) {
|
const repo = this.repoConfigs.find(r => r.name === repoName);
|
||||||
vscode.window.showErrorMessage("无法确定本地模块文件夹路径");
|
if (!repo) {
|
||||||
|
vscode.window.showErrorMessage(`在仓库配置中未找到名为 "${repoName}" 的仓库`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const branchName = path.basename(fullPath);
|
if (folderType === 'local') {
|
||||||
await this.uploadLocalModuleFolder(
|
// 本地模块 -> 选中仓库 + 指定分支
|
||||||
folderId,
|
await this.uploadLocalModuleFolder(
|
||||||
repo.url,
|
folderId,
|
||||||
branchName,
|
repo.url,
|
||||||
repo.username,
|
trimmedBranch,
|
||||||
repo.token
|
repo.username,
|
||||||
);
|
repo.token
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Git 模块 -> 选中仓库 + 指定分支
|
||||||
|
await this.processGitUploadWithBranch(folderId, repo, trimmedBranch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async processGitUpload(folderId: string, repo: RepoConfigItem): Promise<void> {
|
/**
|
||||||
|
* Git 模块上传(可能换仓库 / 改名),使用用户指定的分支
|
||||||
|
*/
|
||||||
|
private async processGitUploadWithBranch(
|
||||||
|
folderId: string,
|
||||||
|
repo: RepoConfigItem,
|
||||||
|
branchName: string
|
||||||
|
): Promise<void> {
|
||||||
const folder = this.projectService.getModuleFolder(folderId);
|
const folder = this.projectService.getModuleFolder(folderId);
|
||||||
if (!folder || folder.type !== 'git') {
|
if (!folder || folder.type !== 'git') {
|
||||||
vscode.window.showErrorMessage("未找到要上传的 Git 模块文件夹");
|
vscode.window.showErrorMessage("未找到要上传的 Git 模块文件夹");
|
||||||
@@ -218,13 +238,13 @@ export class ConfigPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.1 未改名 + 还是原来的仓库 → 直接在原分支上 push(更新代码)
|
// 未改名 + 还是原来的仓库 → 直接在原分支上 push(更新代码)
|
||||||
if (!isRenamed && isSameRepo) {
|
if (!isRenamed && isSameRepo) {
|
||||||
await this.uploadGitModuleFolder(folderId);
|
await this.uploadGitModuleFolder(folderId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.2 改了名字 或 换了仓库 → 使用"当前文件夹名"作为分支,推送到选中仓库
|
// 改了名字 或 换了仓库 → 使用“用户输入的分支名”进行推送
|
||||||
await vscode.window.withProgress({
|
await vscode.window.withProgress({
|
||||||
location: vscode.ProgressLocation.Notification,
|
location: vscode.ProgressLocation.Notification,
|
||||||
title: `正在上传 Git 仓库: ${folder.name}`,
|
title: `正在上传 Git 仓库: ${folder.name}`,
|
||||||
@@ -236,12 +256,11 @@ export class ConfigPanel {
|
|||||||
await GitService.pushToRepoUrl(
|
await GitService.pushToRepoUrl(
|
||||||
fullPath,
|
fullPath,
|
||||||
repo.url,
|
repo.url,
|
||||||
newFolderName,
|
branchName,
|
||||||
repo.username,
|
repo.username,
|
||||||
repo.token
|
repo.token
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
this.projectService.updateModuleFolder(folderId, {
|
this.projectService.updateModuleFolder(folderId, {
|
||||||
uploaded: true,
|
uploaded: true,
|
||||||
originalFolderName: newFolderName,
|
originalFolderName: newFolderName,
|
||||||
@@ -251,7 +270,7 @@ export class ConfigPanel {
|
|||||||
await this.saveCurrentProjectData();
|
await this.saveCurrentProjectData();
|
||||||
|
|
||||||
progress.report({ increment: 100, message: '完成' });
|
progress.report({ increment: 100, message: '完成' });
|
||||||
vscode.window.showInformationMessage(`✅ Git 仓库已上传到 ${repo.name} 的分支 ${newFolderName}`);
|
vscode.window.showInformationMessage(`✅ Git 仓库已上传到 ${repo.name} 的分支 ${branchName}`);
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('❌ Git 上传到新仓库/分支失败:', error);
|
console.error('❌ Git 上传到新仓库/分支失败:', error);
|
||||||
@@ -336,10 +355,17 @@ export class ConfigPanel {
|
|||||||
|
|
||||||
// 上传功能
|
// 上传功能
|
||||||
'uploadGitModuleFolder': (data) => this.uploadGitModuleFolder(data.folderId, data.username, data.password),
|
'uploadGitModuleFolder': (data) => this.uploadGitModuleFolder(data.folderId, data.username, data.password),
|
||||||
'openRepoSelectForUpload': (data) => this.handleOpenRepoSelectForUpload(data.folderId),
|
'openRepoSelectForUpload': (data) => this.openUploadRepoSelect(data.folderId, 'local'),
|
||||||
'uploadLocalModuleFolder': (data) => this.uploadLocalModuleFolder(data.folderId, data.repoUrl, data.branchName),
|
'uploadLocalModuleFolder': (data) => this.uploadLocalModuleFolder(data.folderId, data.repoUrl, data.branchName),
|
||||||
'openRepoSelectForGitUpload': (data) => this.openRepoSelectForGitUpload(data.folderId),
|
'openRepoSelectForGitUpload': (data) => this.openUploadRepoSelect(data.folderId, 'git'),
|
||||||
'repoSelectedForGitUpload': (data) => this.handleRepoSelectedForGitUpload(data.folderId, data.repoName)
|
// 旧的 repoSelectedForGitUpload 保留兼容的话可以转发到 handleRepoSelectedForBranches,但现在不再使用
|
||||||
|
// 新增:上传时仓库 + 分支选择确认
|
||||||
|
'uploadRepoSelected': (data) => this.handleUploadRepoSelected(
|
||||||
|
data.folderId,
|
||||||
|
data.folderType,
|
||||||
|
data.repoName,
|
||||||
|
data.branchName
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handler = messageHandlers[data.type];
|
const handler = messageHandlers[data.type];
|
||||||
@@ -409,24 +435,6 @@ export class ConfigPanel {
|
|||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleOpenRepoSelectForUpload(folderId: string): Promise<void> {
|
|
||||||
console.log("📌 Local 上传:收到 openRepoSelectForUpload,folderId =", folderId);
|
|
||||||
this.pendingUploadFolderId = folderId;
|
|
||||||
await this.openRepoSelect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async openRepoSelectForGitUpload(folderId: string): Promise<void> {
|
|
||||||
console.log('📌 Git 上传:收到 openRepoSelectForGitUpload,folderId =', folderId);
|
|
||||||
this.pendingGitUploadFolderId = folderId;
|
|
||||||
await this.openRepoSelect();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async handleRepoSelectedForGitUpload(folderId: string, repoName: string): Promise<void> {
|
|
||||||
// 兼容:如果前端用的是 repoSelectedForGitUpload 事件,则这里转成统一逻辑
|
|
||||||
this.pendingGitUploadFolderId = folderId;
|
|
||||||
await this.handleRepoSelectedForBranches(repoName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =============================================
|
// =============================================
|
||||||
// 项目管理方法
|
// 项目管理方法
|
||||||
// =============================================
|
// =============================================
|
||||||
@@ -755,7 +763,14 @@ export class ConfigPanel {
|
|||||||
console.log(`📥 开始克隆分支: ${branch}`);
|
console.log(`📥 开始克隆分支: ${branch}`);
|
||||||
try {
|
try {
|
||||||
const folderNames = GitService.generateModuleFolderName(url, branch);
|
const folderNames = GitService.generateModuleFolderName(url, branch);
|
||||||
await this.addGitModuleFolder(url,repoDisplayName,folderNames.folderName,branch,this.currentRepoForBranches?.username,this.currentRepoForBranches?.token);
|
await this.addGitModuleFolder(
|
||||||
|
url,
|
||||||
|
repoDisplayName,
|
||||||
|
folderNames.folderName,
|
||||||
|
branch,
|
||||||
|
this.currentRepoForBranches?.username,
|
||||||
|
this.currentRepoForBranches?.token
|
||||||
|
);
|
||||||
|
|
||||||
successCount++;
|
successCount++;
|
||||||
console.log(`✅ 分支克隆成功: ${branch}`);
|
console.log(`✅ 分支克隆成功: ${branch}`);
|
||||||
@@ -779,13 +794,13 @@ export class ConfigPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async addGitModuleFolder(
|
private async addGitModuleFolder(
|
||||||
url: string,
|
url: string,
|
||||||
displayName: string,
|
displayName: string,
|
||||||
folderName: string,
|
folderName: string,
|
||||||
branch?: string,
|
branch?: string,
|
||||||
username?: string,
|
username?: string,
|
||||||
token?: string
|
token?: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (!url || !url.startsWith('http')) {
|
if (!url || !url.startsWith('http')) {
|
||||||
vscode.window.showErrorMessage('请输入有效的 Git 仓库 URL');
|
vscode.window.showErrorMessage('请输入有效的 Git 仓库 URL');
|
||||||
@@ -1100,7 +1115,7 @@ export class ConfigPanel {
|
|||||||
await GitService.initRepository(fullPath, branchName);
|
await GitService.initRepository(fullPath, branchName);
|
||||||
|
|
||||||
progress.report({ increment: 20, message: '添加远程仓库...' });
|
progress.report({ increment: 20, message: '添加远程仓库...' });
|
||||||
await GitService.addRemote(fullPath, repoUrl);
|
await GitService.addRemote(fullPath, repoUrl, username, token);
|
||||||
|
|
||||||
progress.report({ increment: 40, message: '提交初始文件...' });
|
progress.report({ increment: 40, message: '提交初始文件...' });
|
||||||
await GitService.commitInitialFiles(fullPath);
|
await GitService.commitInitialFiles(fullPath);
|
||||||
@@ -1505,4 +1520,4 @@ export class ConfigPanel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// src/panels/views/BaseView.ts
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
export abstract class BaseView {
|
export abstract class BaseView {
|
||||||
@@ -261,7 +260,7 @@ export abstract class BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取仓库选择对话框的脚本(仅ConfigView需要)
|
* 获取仓库选择对话框的脚本(ConfigView 使用)
|
||||||
*/
|
*/
|
||||||
protected getRepoSelectScript(): string {
|
protected getRepoSelectScript(): string {
|
||||||
return `
|
return `
|
||||||
@@ -273,6 +272,7 @@ export abstract class BaseView {
|
|||||||
}
|
}
|
||||||
window.__dcspRepoDialogInitialized = true;
|
window.__dcspRepoDialogInitialized = true;
|
||||||
|
|
||||||
|
// ① 仅用于“获取仓库 -> 拉取分支”的弹窗
|
||||||
function showRepoSelectDialog(repos) {
|
function showRepoSelectDialog(repos) {
|
||||||
// 移除已有弹窗
|
// 移除已有弹窗
|
||||||
var existing = document.getElementById('repoSelectModal');
|
var existing = document.getElementById('repoSelectModal');
|
||||||
@@ -356,11 +356,120 @@ export abstract class BaseView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ② 专门用于“上传代码”的仓库+分支弹窗
|
||||||
|
function showUploadRepoSelectDialog(repos, folderId, folderType) {
|
||||||
|
var existing = document.getElementById('uploadRepoSelectModal');
|
||||||
|
if (existing) {
|
||||||
|
existing.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
var overlay = document.createElement('div');
|
||||||
|
overlay.className = 'modal-overlay';
|
||||||
|
overlay.id = 'uploadRepoSelectModal';
|
||||||
|
|
||||||
|
var hasRepos = Array.isArray(repos) && repos.length > 0;
|
||||||
|
var optionsHtml = '';
|
||||||
|
if (hasRepos) {
|
||||||
|
for (var i = 0; i < repos.length; i++) {
|
||||||
|
var r = repos[i];
|
||||||
|
if (!r || !r.name) continue;
|
||||||
|
optionsHtml += '<option value="' + r.name + '">' + r.name + '</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var disabledAttr = hasRepos ? '' : 'disabled';
|
||||||
|
|
||||||
|
var noRepoTip = '';
|
||||||
|
if (!hasRepos) {
|
||||||
|
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在"仓库配置"中添加。</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
overlay.innerHTML =
|
||||||
|
'<div class="modal-dialog">' +
|
||||||
|
'<div class="modal-title">上传到仓库</div>' +
|
||||||
|
'<div style="margin-bottom: 10px;">' +
|
||||||
|
'<label style="display:block; margin-bottom:6px;">请选择仓库:</label>' +
|
||||||
|
'<select id="uploadRepoSelect" style="width:100%; padding:6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border:1px solid var(--vscode-input-border); border-radius:4px;">' +
|
||||||
|
optionsHtml +
|
||||||
|
'</select>' +
|
||||||
|
noRepoTip +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="margin-bottom: 10px;">' +
|
||||||
|
'<label style="display:block; margin-bottom:6px;">请输入分支名称:</label>' +
|
||||||
|
'<input type="text" id="uploadBranchInput" style="width:100%; padding:6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border:1px solid var(--vscode-input-border); border-radius:4px;" placeholder="如:main、develop、feature/xxx">' +
|
||||||
|
'<div style="font-size:12px; color: var(--vscode-descriptionForeground); margin-top:4px;">将把代码推送到该分支,如不存在则自动创建</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="modal-buttons">' +
|
||||||
|
'<button class="modal-btn modal-btn-secondary" id="uploadRepoSelectCancelBtn">取消</button>' +
|
||||||
|
'<button class="modal-btn modal-btn-primary" id="uploadRepoSelectOkBtn" ' + disabledAttr + '>确定</button>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
var cancelBtn = document.getElementById('uploadRepoSelectCancelBtn');
|
||||||
|
var okBtn = document.getElementById('uploadRepoSelectOkBtn');
|
||||||
|
var repoSelect = document.getElementById('uploadRepoSelect');
|
||||||
|
var branchInput = document.getElementById('uploadBranchInput');
|
||||||
|
|
||||||
|
if (cancelBtn) {
|
||||||
|
cancelBtn.addEventListener('click', function () {
|
||||||
|
if (typeof vscode !== 'undefined') {
|
||||||
|
vscode.postMessage({
|
||||||
|
type: 'uploadRepoSelectCanceled',
|
||||||
|
folderId: folderId,
|
||||||
|
folderType: folderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
overlay.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (okBtn) {
|
||||||
|
okBtn.addEventListener('click', function () {
|
||||||
|
if (!hasRepos || !repoSelect) {
|
||||||
|
overlay.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var repoName = repoSelect.value;
|
||||||
|
var branchName = branchInput ? branchInput.value.trim() : '';
|
||||||
|
if (!repoName) {
|
||||||
|
alert('请选择一个仓库');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!branchName) {
|
||||||
|
alert('请输入分支名称');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof vscode !== 'undefined') {
|
||||||
|
vscode.postMessage({
|
||||||
|
type: 'uploadRepoSelected',
|
||||||
|
repoName: repoName,
|
||||||
|
branchName: branchName,
|
||||||
|
folderId: folderId,
|
||||||
|
folderType: folderType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
overlay.remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
if (branchInput) {
|
||||||
|
branchInput.focus();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener('message', function (event) {
|
window.addEventListener('message', function (event) {
|
||||||
var message = event.data;
|
var message = event.data;
|
||||||
if (!message || !message.type) return;
|
if (!message || !message.type) return;
|
||||||
if (message.type === 'showRepoSelect') {
|
if (message.type === 'showRepoSelect') {
|
||||||
|
// 旧逻辑:仅用于获取分支
|
||||||
showRepoSelectDialog(message.repos || []);
|
showRepoSelectDialog(message.repos || []);
|
||||||
|
} else if (message.type === 'showUploadRepoSelect') {
|
||||||
|
// 新逻辑:上传代码用(仓库 + 分支)
|
||||||
|
showUploadRepoSelectDialog(message.repos || [], message.folderId, message.folderType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
@@ -374,4 +483,4 @@ export abstract class BaseView {
|
|||||||
protected getStyles(): string {
|
protected getStyles(): string {
|
||||||
return this.getBaseStylesAndScripts();
|
return this.getBaseStylesAndScripts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user