0
0

卫星模块获取功能已实现,仅简单测试,未深度测试

This commit is contained in:
xubing
2025-12-02 16:30:53 +08:00
parent 07acf9f617
commit 3f512e8646
9 changed files with 475 additions and 297 deletions

View File

@@ -9,16 +9,6 @@ interface GitBranch {
selected?: boolean;
}
interface BranchTreeNode {
name: string;
fullName: string;
isLeaf: boolean;
children: BranchTreeNode[];
level: number;
expanded?: boolean;
branch?: GitBranch;
}
// Git 文件树接口
interface GitFileTree {
name: string;
@@ -73,28 +63,31 @@ export class ConfigView extends BaseView {
// 生成模块文件夹的 HTML - 按类别分类显示
const moduleFoldersHtml = moduleFolders.map((folder: ModuleFolder) => {
const icon = folder.type === 'git' ? '📁' : '📁';
const icon = '📁';
// 根据类型和上传状态确定类别显示
let category = folder.type === 'git' ? 'git' : 'local';
if (folder.uploaded) {
category += '(已上传)';
}
const fileName = folder.localPath.split('/').pop() || '';
return `
<tr>
<td>
<span class="editable clickable" onclick="renameModuleFolder('${folder.id}')">
${icon} ${folder.name}
</span>
<!-- 左侧:📁 动力学仓库 / 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="renameModuleFolder('${folder.id}', '${folder.localPath.split('/').pop()}')">
📄 ${folder.localPath.split('/').pop()}
</span>
</td>
<!-- 右侧:文件/文件夹栏,只负责选择并打开文件,不再触发重命名 -->
<span class="clickable"
onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">
📄 ${fileName}
</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>
@@ -369,24 +362,23 @@ 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()
});
}
showPromptDialog(
'重命名模块文件夹',
'请输入新的名称:',
oldName || '',
function(newName) {
if (newName && newName.trim() && newName !== oldName) {
vscode.postMessage({
type: 'renameModuleFolder',
folderId: folderId,
newName: newName.trim()
});
}
}
);
}
);
}
// 配置管理功能
function editConfigName(configId, currentName) {
@@ -415,7 +407,7 @@ export class ConfigView extends BaseView {
});
}
// 统一功能:打开模块文件夹
// 统一功能:打开模块文件夹(这里只负责打开,而不是改名)
function openTheModuleFolder(id, type) {
console.log('📂 打开模块文件夹:', { id, type });
vscode.postMessage({
@@ -453,7 +445,6 @@ export class ConfigView extends BaseView {
});
},
function() {
// 用户取消删除
console.log('❌ 用户取消删除配置文件');
}
);
@@ -474,34 +465,23 @@ export class ConfigView extends BaseView {
});
},
function() {
// 用户取消删除
console.log('❌ 用户取消删除模块文件夹');
}
);
}
// 上传模块文件夹功能
// 上传模块文件夹功能(区分 local / git
function uploadModuleFolder(folderId, folderType) {
console.log('📤 上传模块文件夹:', { folderId, folderType });
if (folderType === 'git') {
// Git 类型:直接上传(相当于 push
showConfirmDialog(
'确认上传',
'确定要将 Git 文件夹的内容上传到远程仓库吗?这将执行 git push 操作。',
function() {
vscode.postMessage({
type: 'uploadGitModuleFolder',
folderId: folderId
});
},
function() {
console.log('❌ 用户取消上传 Git 文件夹');
}
);
} else if (folderType === 'local') {
// Local 类型:不再手动输入 URL改为复用“获取仓库”弹窗
// 后端将根据选择的仓库 + 本地文件夹名 自动确定 repoUrl 和 分支名
// git 类型:先选仓库,然后后端根据是否改名/是否同仓库判断是更新原分支还是新分支上传
vscode.postMessage({
type: 'openRepoSelectForGitUpload',
folderId: folderId
});
} else {
// local 类型:走 local → git 的初始化上传逻辑
vscode.postMessage({
type: 'openRepoSelectForUpload',
folderId: folderId
@@ -544,12 +524,10 @@ export class ConfigView extends BaseView {
branches: Array.from(selectedBranches)
});
// 重置选择
selectedBranches.clear();
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(checkbox => checkbox.checked = false);
// 隐藏分支选择区域
document.getElementById('branchSelectionContainer').innerHTML = '';
}
@@ -558,7 +536,6 @@ export class ConfigView extends BaseView {
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(checkbox => checkbox.checked = false);
// 隐藏分支选择区域
document.getElementById('branchSelectionContainer').innerHTML = '';
vscode.postMessage({
@@ -575,7 +552,6 @@ export class ConfigView extends BaseView {
selectedConfigs.delete(configId);
}
// 更新合并按钮状态
updateMergeButtonState();
console.log('选中的配置文件:', Array.from(selectedConfigs));
}
@@ -595,7 +571,6 @@ export class ConfigView extends BaseView {
console.log('🔄 开始合并选中的配置文件:', Array.from(selectedConfigs));
// 弹出新的合并对话框
showMergeDialog();
}
@@ -631,7 +606,6 @@ export class ConfigView extends BaseView {
document.body.appendChild(overlay);
// 自动聚焦到第一个输入框
setTimeout(() => {
const displayNameInput = document.getElementById('displayNameInput');
if (displayNameInput) {
@@ -666,7 +640,6 @@ export class ConfigView extends BaseView {
folderName: folderName
});
// 重置选择
selectedConfigs.clear();
const checkboxes = document.querySelectorAll('.config-checkbox');
checkboxes.forEach(checkbox => checkbox.checked = false);
@@ -736,7 +709,6 @@ export class ConfigView extends BaseView {
let html = '<div class="branch-selection" style="margin: 10px 0; padding: 10px; background: var(--vscode-panel-background); border-radius: 4px;">';
html += '<h4 class="branch-tree-title" style="margin: 0 0 8px 0;"><span class="tree-icon">🌳</span> 分支树</h4>';
// 展开/收起按钮
html += '<div style="margin-bottom: 8px;">';
html += '<button class="back-btn" onclick="expandAllBranches()" style="margin-right: 8px; padding: 2px 6px; font-size: 11px;">展开全部</button>';
html += '<button class="back-btn" onclick="collapseAllBranches()" style="padding: 2px 6px; font-size: 11px;">收起全部</button>';
@@ -761,7 +733,6 @@ export class ConfigView extends BaseView {
const nodeId = node.fullName.replace(/[^a-zA-Z0-9-]/g, '-');
if (node.isLeaf) {
// 叶子节点(实际分支)
html += '<div class="branch-node branch-leaf" style="margin-left: ' + indent + 'px;">';
html += '<input type="checkbox" id="branch-' + nodeId + '" class="branch-checkbox" ';
html += (node.branch && node.branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\\'' + node.fullName + '\\')">';
@@ -772,7 +743,6 @@ export class ConfigView extends BaseView {
html += '</span>';
html += '</div>';
} else {
// 文件夹节点
html += '<div class="branch-node" style="margin-left: ' + indent + 'px;">';
html += '<span class="branch-expand" onclick="toggleBranchNode(\\'' + node.fullName + '\\')">';
html += (node.expanded ? '🪵' : '🪵');
@@ -791,18 +761,6 @@ export class ConfigView extends BaseView {
return html;
}
function countLeafNodes(nodes) {
let count = 0;
nodes.forEach(node => {
if (node.isLeaf) {
count++;
} else if (node.children) {
count += countLeafNodes(node.children);
}
});
return count;
}
// 对话框函数
function showConfirmDialog(title, message, onConfirm, onCancel) {
const overlay = document.createElement('div');
@@ -900,7 +858,6 @@ export class ConfigView extends 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');
@@ -916,7 +873,6 @@ export class ConfigView extends BaseView {
private generateBranchesTreeHtml(branches: GitBranch[]): string {
if (branches.length === 0) return '';
// 构建分支树
const branchTree = this.buildBranchTree(branches);
let html = '<div class="branch-selection" style="margin: 10px 0; padding: 10px; background: var(--vscode-panel-background); border-radius: 4px;">';
@@ -936,9 +892,6 @@ export class ConfigView extends BaseView {
return html;
}
/**
* 构建分支树状结构
*/
private buildBranchTree(branches: GitBranch[]): BranchTreeNode[] {
const root: BranchTreeNode[] = [];
@@ -959,15 +912,14 @@ export class ConfigView extends BaseView {
fullName: fullName,
isLeaf: isLeaf,
children: [],
level: i
level: i,
expanded: true
};
currentLevel.push(node);
}
if (isLeaf) {
node.branch = branch;
} else {
node.expanded = node.expanded || true; // 默认展开
}
currentLevel = node.children;
@@ -977,9 +929,6 @@ export class ConfigView extends BaseView {
return root;
}
/**
* 渲染分支树节点
*/
private renderBranchTreeNodes(nodes: BranchTreeNode[], level: number): string {
let html = '';
@@ -988,7 +937,6 @@ export class ConfigView extends BaseView {
const nodeId = node.fullName.replace(/[^a-zA-Z0-9-]/g, '-');
if (node.isLeaf) {
// 叶子节点(实际分支)
html += '<div class="branch-node branch-leaf" style="margin-left: ' + indent + 'px;">';
html += '<input type="checkbox" id="branch-' + nodeId + '" class="branch-checkbox" ';
html += (node.branch && node.branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\'' + node.fullName + '\')">';
@@ -999,7 +947,6 @@ export class ConfigView extends BaseView {
html += '</span>';
html += '</div>';
} else {
// 文件夹节点
html += '<div class="branch-node" style="margin-left: ' + indent + 'px;">';
html += '<span class="branch-expand" onclick="toggleBranchNode(\'' + node.fullName + '\')">';
html += (node.expanded ? '🪵' : '🪵');
@@ -1019,9 +966,6 @@ export class ConfigView extends BaseView {
return html;
}
/**
* 计算叶子节点数量
*/
private countLeafNodes(nodes: BranchTreeNode[]): number {
let count = 0;
nodes.forEach(node => {