现在代码上传逻辑存在问题
This commit is contained in:
@@ -11,7 +11,7 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
const moduleFolderFileTree = data?.moduleFolderFileTree || [];
|
||||
const moduleFolderLoading = data?.moduleFolderLoading || false;
|
||||
const gitBranches = data?.gitBranches || [];
|
||||
// 生成配置列表的 HTML - 包含配置文件和模块文件夹
|
||||
// 生成配置列表的 HTML
|
||||
const configsHtml = configs.map((config) => `
|
||||
<tr>
|
||||
<td>
|
||||
@@ -27,10 +27,9 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
// 生成模块文件夹的 HTML - 按类别分类显示
|
||||
// 生成模块文件夹的 HTML
|
||||
const moduleFoldersHtml = moduleFolders.map((folder) => {
|
||||
const icon = '📁';
|
||||
// 根据类型和上传状态确定类别显示
|
||||
let category = folder.type === 'git' ? 'git' : 'local';
|
||||
if (folder.uploaded) {
|
||||
category += '(已上传)';
|
||||
@@ -39,14 +38,12 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<!-- 左侧:📁 动力学仓库 / test,仅用于重命名 -->
|
||||
<span class="editable clickable" onclick="renameModuleFolder('${folder.id}', '${folder.name}')">
|
||||
${icon} ${folder.name}
|
||||
</span>
|
||||
</td>
|
||||
<td class="category-${folder.type}">${category}</td>
|
||||
<td>
|
||||
<!-- 右侧:文件/文件夹栏,只负责选择并打开文件,不再触发重命名 -->
|
||||
<span class="clickable"
|
||||
onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">
|
||||
📄 ${fileName}
|
||||
@@ -59,7 +56,7 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
</tr>
|
||||
`;
|
||||
}).join('');
|
||||
// 生成分支选择的 HTML - 使用树状结构(首次渲染可以为空,后续通过 message 更新)
|
||||
// 生成分支选择的 HTML
|
||||
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesTreeHtml(gitBranches) : '';
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
@@ -67,7 +64,8 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>配置管理</title>
|
||||
${this.getStyles()}
|
||||
${this.getBaseStylesAndScripts()}
|
||||
${this.getRepoSelectScript()}
|
||||
<style>
|
||||
.url-input-section {
|
||||
background: var(--vscode-panel-background);
|
||||
@@ -253,16 +251,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
color: var(--vscode-charts-orange);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.category-git(已上传) {
|
||||
color: var(--vscode-gitDecoration-addedResourceForeground);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.category-local(已上传) {
|
||||
color: var(--vscode-gitDecoration-addedResourceForeground);
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -319,12 +307,11 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
|
||||
<script>
|
||||
const vscode = acquireVsCodeApi();
|
||||
let currentConfigId = null;
|
||||
let selectedBranches = new Set();
|
||||
let branchTreeData = [];
|
||||
let selectedConfigs = new Set();
|
||||
|
||||
// 只负责“改名”的函数
|
||||
// 只负责"改名"的函数
|
||||
function renameModuleFolder(folderId, oldName) {
|
||||
showPromptDialog(
|
||||
'重命名模块文件夹',
|
||||
@@ -362,16 +349,14 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
|
||||
// 在 VSCode 中打开配置文件
|
||||
function openConfigFileInVSCode(configId) {
|
||||
console.log('📄 在 VSCode 中打开配置文件:', configId);
|
||||
vscode.postMessage({
|
||||
type: 'openConfigFileInVSCode',
|
||||
configId: configId
|
||||
});
|
||||
}
|
||||
|
||||
// 统一功能:打开模块文件夹(这里只负责打开,而不是改名)
|
||||
// 统一功能:打开模块文件夹
|
||||
function openTheModuleFolder(id, type) {
|
||||
console.log('📂 打开模块文件夹:', { id, type });
|
||||
vscode.postMessage({
|
||||
type: 'openTheModuleFolder',
|
||||
id: id,
|
||||
@@ -400,50 +385,40 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
'确认删除',
|
||||
'确定删除这个配置文件吗?',
|
||||
function() {
|
||||
console.log('🗑️ 删除配置文件:', configId);
|
||||
vscode.postMessage({
|
||||
type: 'deleteConfig',
|
||||
configId: configId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
console.log('❌ 用户取消删除配置文件');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 删除模块文件夹功能
|
||||
function deleteModuleFolder(folderId) {
|
||||
console.log('🗑️ 尝试删除模块文件夹:', folderId);
|
||||
|
||||
showConfirmDialog(
|
||||
'确认删除模块文件夹',
|
||||
'确定删除这个模块文件夹吗?这将删除文件夹及其所有内容。',
|
||||
function() {
|
||||
console.log('✅ 用户确认删除模块文件夹:', folderId);
|
||||
vscode.postMessage({
|
||||
type: 'deleteModuleFolder',
|
||||
folderId: folderId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
console.log('❌ 用户取消删除模块文件夹');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 上传模块文件夹功能(区分 local / git)
|
||||
// 上传模块文件夹功能
|
||||
function uploadModuleFolder(folderId, folderType) {
|
||||
console.log('📤 上传模块文件夹:', { folderId, folderType });
|
||||
|
||||
if (folderType === 'git') {
|
||||
// git 类型:先选仓库,然后后端根据是否改名/是否同仓库判断是更新原分支还是新分支上传
|
||||
vscode.postMessage({
|
||||
type: 'openRepoSelectForGitUpload',
|
||||
folderId: folderId
|
||||
});
|
||||
} else {
|
||||
// local 类型:走 local → git 的初始化上传逻辑
|
||||
vscode.postMessage({
|
||||
type: 'openRepoSelectForUpload',
|
||||
folderId: folderId
|
||||
@@ -455,9 +430,8 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
vscode.postMessage({ type: 'goBackToContainers' });
|
||||
}
|
||||
|
||||
// 🔁 通过弹窗获取仓库(用于克隆)
|
||||
// 通过弹窗获取仓库
|
||||
function openRepoSelect() {
|
||||
console.log('📦 请求仓库列表以选择 Git 仓库(用于克隆分支)');
|
||||
vscode.postMessage({
|
||||
type: 'openRepoSelect'
|
||||
});
|
||||
@@ -470,7 +444,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
} else {
|
||||
selectedBranches.delete(branchName);
|
||||
}
|
||||
console.log('选中的分支:', Array.from(selectedBranches));
|
||||
}
|
||||
|
||||
function cloneSelectedBranches() {
|
||||
@@ -479,8 +452,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches));
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'cloneBranches',
|
||||
branches: Array.from(selectedBranches)
|
||||
@@ -515,7 +486,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
}
|
||||
|
||||
updateMergeButtonState();
|
||||
console.log('选中的配置文件:', Array.from(selectedConfigs));
|
||||
}
|
||||
|
||||
function updateMergeButtonState() {
|
||||
@@ -530,8 +500,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
alert('请至少选择两个配置文件进行合并');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🔄 开始合并选中的配置文件:', Array.from(selectedConfigs));
|
||||
|
||||
showMergeDialog();
|
||||
}
|
||||
@@ -723,94 +691,11 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
return html;
|
||||
}
|
||||
|
||||
// 对话框函数
|
||||
function showConfirmDialog(title, message, onConfirm, onCancel) {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'modal-overlay';
|
||||
overlay.id = 'confirmModal';
|
||||
|
||||
overlay.innerHTML = \`
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-title">\${title}</div>
|
||||
<div>\${message}</div>
|
||||
<div class="modal-buttons">
|
||||
<button class="modal-btn modal-btn-secondary" onclick="closeConfirmDialog(false)">取消</button>
|
||||
<button class="modal-btn modal-btn-primary" onclick="closeConfirmDialog(true)">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
\`;
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
window.confirmCallback = function(result) {
|
||||
if (result && onConfirm) {
|
||||
onConfirm();
|
||||
} else if (!result && onCancel) {
|
||||
onCancel();
|
||||
}
|
||||
delete window.confirmCallback;
|
||||
};
|
||||
}
|
||||
|
||||
function closeConfirmDialog(result) {
|
||||
const modal = document.getElementById('confirmModal');
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
}
|
||||
if (window.confirmCallback) {
|
||||
window.confirmCallback(result);
|
||||
}
|
||||
}
|
||||
|
||||
function showPromptDialog(title, message, defaultValue, onConfirm) {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'modal-overlay';
|
||||
overlay.id = 'promptModal';
|
||||
|
||||
overlay.innerHTML = \`
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-title">\${title}</div>
|
||||
<div>\${message}</div>
|
||||
<input type="text" id="promptInput" value="\${defaultValue}" style="width: 100%; margin: 10px 0; padding: 6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border);">
|
||||
<div class="modal-buttons">
|
||||
<button class="modal-btn modal-btn-secondary" onclick="closePromptDialog(null)">取消</button>
|
||||
<button class="modal-btn modal-btn-primary" onclick="closePromptDialog(document.getElementById('promptInput').value)">确定</button>
|
||||
</div>
|
||||
</div>
|
||||
\`;
|
||||
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
setTimeout(() => {
|
||||
const input = document.getElementById('promptInput');
|
||||
if (input) {
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
window.promptCallback = onConfirm;
|
||||
}
|
||||
|
||||
function closePromptDialog(result) {
|
||||
const modal = document.getElementById('promptModal');
|
||||
if (modal) {
|
||||
modal.remove();
|
||||
}
|
||||
if (window.promptCallback) {
|
||||
window.promptCallback(result);
|
||||
}
|
||||
delete window.promptCallback;
|
||||
}
|
||||
|
||||
// 消息监听
|
||||
window.addEventListener('message', event => {
|
||||
const message = event.data;
|
||||
console.log('📨 前端收到后端消息:', message);
|
||||
|
||||
if (message.type === 'branchesFetched') {
|
||||
console.log('🌿 收到分支数据:', message.branches);
|
||||
console.log('🌳 收到分支树数据:', message.branchTree);
|
||||
branchTreeData = message.branchTree || [];
|
||||
renderBranchTree(branchTreeData);
|
||||
}
|
||||
@@ -818,8 +703,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
|
||||
// 初始化
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('📄 ConfigView 页面加载完成');
|
||||
|
||||
document.addEventListener('change', function(event) {
|
||||
if (event.target.classList.contains('config-checkbox')) {
|
||||
const configId = event.target.getAttribute('data-id');
|
||||
@@ -912,18 +795,6 @@ class ConfigView extends BaseView_1.BaseView {
|
||||
});
|
||||
return html;
|
||||
}
|
||||
countLeafNodes(nodes) {
|
||||
let count = 0;
|
||||
nodes.forEach(node => {
|
||||
if (node.isLeaf) {
|
||||
count++;
|
||||
}
|
||||
else {
|
||||
count += this.countLeafNodes(node.children);
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
}
|
||||
exports.ConfigView = ConfigView;
|
||||
//# sourceMappingURL=ConfigView.js.map
|
||||
Reference in New Issue
Block a user