修复显示bug和项目回读bug
This commit is contained in:
16
.vscodeignore
Normal file
16
.vscodeignore
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
.vscode/**
|
||||||
|
src/**
|
||||||
|
.gitignore
|
||||||
|
.yarnrc
|
||||||
|
vsc-extension-quickstart.md
|
||||||
|
**/tsconfig.json
|
||||||
|
**/*.map
|
||||||
|
**/*.ts
|
||||||
|
node_modules/**/*.ts
|
||||||
|
node_modules/.bin
|
||||||
|
node_modules/**/test
|
||||||
|
node_modules/**/tests
|
||||||
|
node_modules/**/*.md
|
||||||
|
node_modules/**/LICENSE
|
||||||
|
node_modules/**/CHANGELOG.md
|
||||||
|
node_modules/**/README.md
|
||||||
Binary file not shown.
BIN
dsc-platform-1.1.0.vsix
Normal file
BIN
dsc-platform-1.1.0.vsix
Normal file
Binary file not shown.
BIN
dsc-platform-1.1.1.vsix
Normal file
BIN
dsc-platform-1.1.1.vsix
Normal file
Binary file not shown.
@@ -168,50 +168,48 @@ class ConfigPanel {
|
|||||||
}
|
}
|
||||||
// === 数据持久化方法 ===
|
// === 数据持久化方法 ===
|
||||||
/**
|
/**
|
||||||
* 保存所有数据到项目路径
|
* 保存当前项目数据到项目路径
|
||||||
*/
|
*/
|
||||||
async saveAllData() {
|
async saveCurrentProjectData() {
|
||||||
try {
|
try {
|
||||||
console.log('开始保存数据...');
|
console.log('开始保存当前项目数据...');
|
||||||
console.log('当前项目ID:', this.currentProjectId);
|
console.log('当前项目ID:', this.currentProjectId);
|
||||||
console.log('项目路径映射:', Array.from(this.projectPaths.entries()));
|
if (!this.currentProjectId) {
|
||||||
// 找到当前项目的路径
|
console.log('未找到当前项目ID,跳过保存数据');
|
||||||
let projectPath;
|
vscode.window.showWarningMessage('未找到当前项目,数据将不会保存');
|
||||||
// 首先尝试使用当前项目ID
|
return;
|
||||||
if (this.currentProjectId) {
|
|
||||||
projectPath = this.projectPaths.get(this.currentProjectId);
|
|
||||||
}
|
|
||||||
// 如果没有找到,尝试使用第一个项目
|
|
||||||
if (!projectPath && this.projects.length > 0) {
|
|
||||||
projectPath = this.projectPaths.get(this.projects[0].id);
|
|
||||||
}
|
}
|
||||||
|
const projectPath = this.projectPaths.get(this.currentProjectId);
|
||||||
if (!projectPath) {
|
if (!projectPath) {
|
||||||
console.log('未找到项目路径,跳过保存数据');
|
console.log('未找到项目路径,跳过保存数据');
|
||||||
vscode.window.showWarningMessage('未找到项目存储路径,数据将不会保存');
|
vscode.window.showWarningMessage('未找到项目存储路径,数据将不会保存');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
||||||
|
// 只保存与当前项目相关的数据
|
||||||
|
const currentProjectAircrafts = this.aircrafts.filter(a => a.projectId === this.currentProjectId);
|
||||||
|
const currentAircraftIds = currentProjectAircrafts.map(a => a.id);
|
||||||
|
const currentProjectContainers = this.containers.filter(c => currentAircraftIds.includes(c.aircraftId));
|
||||||
|
const currentContainerIds = currentProjectContainers.map(c => c.id);
|
||||||
|
const currentProjectConfigs = this.configs.filter(cfg => currentContainerIds.includes(cfg.containerId));
|
||||||
const data = {
|
const data = {
|
||||||
projects: this.projects,
|
projects: this.projects.filter(p => p.id === this.currentProjectId),
|
||||||
aircrafts: this.aircrafts,
|
aircrafts: currentProjectAircrafts,
|
||||||
containers: this.containers,
|
containers: currentProjectContainers,
|
||||||
configs: this.configs,
|
configs: currentProjectConfigs
|
||||||
projectPaths: Object.fromEntries(this.projectPaths)
|
|
||||||
};
|
};
|
||||||
console.log('要保存的数据:', {
|
console.log('要保存的当前项目数据:', {
|
||||||
projects: this.projects.length,
|
projects: data.projects.length,
|
||||||
aircrafts: this.aircrafts.length,
|
aircrafts: data.aircrafts.length,
|
||||||
containers: this.containers.length,
|
containers: data.containers.length,
|
||||||
configs: this.configs.length,
|
configs: data.configs.length
|
||||||
projectPaths: this.projectPaths.size
|
|
||||||
});
|
});
|
||||||
const uint8Array = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
const uint8Array = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
||||||
await vscode.workspace.fs.writeFile(dataUri, uint8Array);
|
await vscode.workspace.fs.writeFile(dataUri, uint8Array);
|
||||||
console.log('项目数据已保存到:', dataUri.fsPath);
|
console.log('当前项目数据已保存到:', dataUri.fsPath);
|
||||||
vscode.window.showInformationMessage('项目数据已保存');
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
console.error('保存项目数据时出错:', error);
|
console.error('保存当前项目数据时出错:', error);
|
||||||
vscode.window.showErrorMessage(`保存项目数据失败: ${error}`);
|
vscode.window.showErrorMessage(`保存项目数据失败: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,7 +237,6 @@ class ConfigPanel {
|
|||||||
this.aircrafts = [];
|
this.aircrafts = [];
|
||||||
this.containers = [];
|
this.containers = [];
|
||||||
this.configs = [];
|
this.configs = [];
|
||||||
this.projectPaths = new Map();
|
|
||||||
// 验证数据格式并加载
|
// 验证数据格式并加载
|
||||||
if (data.projects && Array.isArray(data.projects)) {
|
if (data.projects && Array.isArray(data.projects)) {
|
||||||
this.projects = data.projects;
|
this.projects = data.projects;
|
||||||
@@ -253,19 +250,16 @@ class ConfigPanel {
|
|||||||
if (data.configs && Array.isArray(data.configs)) {
|
if (data.configs && Array.isArray(data.configs)) {
|
||||||
this.configs = data.configs;
|
this.configs = data.configs;
|
||||||
}
|
}
|
||||||
if (data.projectPaths && typeof data.projectPaths === 'object') {
|
|
||||||
this.projectPaths = new Map(Object.entries(data.projectPaths));
|
|
||||||
}
|
|
||||||
console.log('加载后的数据状态:', {
|
console.log('加载后的数据状态:', {
|
||||||
projects: this.projects.length,
|
projects: this.projects.length,
|
||||||
aircrafts: this.aircrafts.length,
|
aircrafts: this.aircrafts.length,
|
||||||
containers: this.containers.length,
|
containers: this.containers.length,
|
||||||
configs: this.configs.length,
|
configs: this.configs.length
|
||||||
projectPaths: this.projectPaths.size
|
|
||||||
});
|
});
|
||||||
// 设置当前项目为第一个项目(如果有的话)
|
// 设置当前项目为第一个项目(如果有的话)
|
||||||
if (this.projects.length > 0) {
|
if (this.projects.length > 0) {
|
||||||
this.currentProjectId = this.projects[0].id;
|
this.currentProjectId = this.projects[0].id;
|
||||||
|
this.projectPaths.set(this.currentProjectId, projectPath);
|
||||||
this.currentView = 'aircrafts';
|
this.currentView = 'aircrafts';
|
||||||
}
|
}
|
||||||
vscode.window.showInformationMessage(`项目数据已从 ${projectPath} 加载`);
|
vscode.window.showInformationMessage(`项目数据已从 ${projectPath} 加载`);
|
||||||
@@ -344,7 +338,7 @@ class ConfigPanel {
|
|||||||
this.projectPaths.set(projectId, selectedPath);
|
this.projectPaths.set(projectId, selectedPath);
|
||||||
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
|
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
|
||||||
// 保存初始数据
|
// 保存初始数据
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
return selectedPath;
|
return selectedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,7 +362,7 @@ class ConfigPanel {
|
|||||||
this.projectPaths.set(projectId, pathInput);
|
this.projectPaths.set(projectId, pathInput);
|
||||||
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
|
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
|
||||||
// 保存初始数据
|
// 保存初始数据
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
return pathInput;
|
return pathInput;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -390,7 +384,7 @@ class ConfigPanel {
|
|||||||
if (project) {
|
if (project) {
|
||||||
project.name = newName;
|
project.name = newName;
|
||||||
vscode.window.showInformationMessage(`项目名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`项目名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,7 +397,6 @@ class ConfigPanel {
|
|||||||
};
|
};
|
||||||
this.projects.push(newProject);
|
this.projects.push(newProject);
|
||||||
vscode.window.showInformationMessage(`新建项目: ${name}`);
|
vscode.window.showInformationMessage(`新建项目: ${name}`);
|
||||||
await this.saveAllData();
|
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 删除项目
|
// 删除项目
|
||||||
@@ -424,7 +417,7 @@ class ConfigPanel {
|
|||||||
// 删除项目路径映射
|
// 删除项目路径映射
|
||||||
this.projectPaths.delete(projectId);
|
this.projectPaths.delete(projectId);
|
||||||
vscode.window.showInformationMessage(`删除项目: ${project.name}`);
|
vscode.window.showInformationMessage(`删除项目: ${project.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 更新飞行器名
|
// 更新飞行器名
|
||||||
@@ -433,7 +426,7 @@ class ConfigPanel {
|
|||||||
if (aircraft) {
|
if (aircraft) {
|
||||||
aircraft.name = newName;
|
aircraft.name = newName;
|
||||||
vscode.window.showInformationMessage(`飞行器名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`飞行器名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,7 +444,7 @@ class ConfigPanel {
|
|||||||
};
|
};
|
||||||
this.aircrafts.push(newAircraft);
|
this.aircrafts.push(newAircraft);
|
||||||
vscode.window.showInformationMessage(`新建飞行器: ${name}`);
|
vscode.window.showInformationMessage(`新建飞行器: ${name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 删除飞行器
|
// 删除飞行器
|
||||||
@@ -466,7 +459,7 @@ class ConfigPanel {
|
|||||||
const containerIds = this.containers.filter(c => c.aircraftId === aircraftId).map(c => c.id);
|
const containerIds = this.containers.filter(c => c.aircraftId === aircraftId).map(c => c.id);
|
||||||
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
||||||
vscode.window.showInformationMessage(`删除飞行器: ${aircraft.name}`);
|
vscode.window.showInformationMessage(`删除飞行器: ${aircraft.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 更新容器名
|
// 更新容器名
|
||||||
@@ -475,11 +468,11 @@ class ConfigPanel {
|
|||||||
if (container) {
|
if (container) {
|
||||||
container.name = newName;
|
container.name = newName;
|
||||||
vscode.window.showInformationMessage(`容器名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`容器名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 创建新容器 - 修复版本
|
// 创建新容器
|
||||||
async createContainer(name) {
|
async createContainer(name) {
|
||||||
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
||||||
if (!this.currentAircraftId) {
|
if (!this.currentAircraftId) {
|
||||||
@@ -516,7 +509,7 @@ class ConfigPanel {
|
|||||||
configs: this.configs.length
|
configs: this.configs.length
|
||||||
});
|
});
|
||||||
vscode.window.showInformationMessage(`新建容器: ${name} (包含2个默认配置文件)`);
|
vscode.window.showInformationMessage(`新建容器: ${name} (包含2个默认配置文件)`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 删除容器
|
// 删除容器
|
||||||
@@ -529,7 +522,7 @@ class ConfigPanel {
|
|||||||
// 删除相关的配置
|
// 删除相关的配置
|
||||||
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
||||||
vscode.window.showInformationMessage(`删除容器: ${container.name}`);
|
vscode.window.showInformationMessage(`删除容器: ${container.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 更新配置名
|
// 更新配置名
|
||||||
@@ -538,7 +531,7 @@ class ConfigPanel {
|
|||||||
if (config) {
|
if (config) {
|
||||||
config.name = newName;
|
config.name = newName;
|
||||||
vscode.window.showInformationMessage(`配置名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`配置名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,7 +541,7 @@ class ConfigPanel {
|
|||||||
if (config) {
|
if (config) {
|
||||||
config.fileName = fileName;
|
config.fileName = fileName;
|
||||||
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
|
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -558,13 +551,13 @@ class ConfigPanel {
|
|||||||
const newConfig = {
|
const newConfig = {
|
||||||
id: newId,
|
id: newId,
|
||||||
name: name,
|
name: name,
|
||||||
fileName: name.toLowerCase().replace(/\s+/g, '_') + '.yaml',
|
fileName: name.toLowerCase().replace(/\s+/g, '_'),
|
||||||
content: `# ${name} 配置文件\n# 创建时间: ${new Date().toLocaleString()}\n# 您可以在此编辑配置内容\n\n`,
|
content: `# ${name} 配置文件\n# 创建时间: ${new Date().toLocaleString()}\n# 您可以在此编辑配置内容\n\n`,
|
||||||
containerId: this.currentContainerId
|
containerId: this.currentContainerId
|
||||||
};
|
};
|
||||||
this.configs.push(newConfig);
|
this.configs.push(newConfig);
|
||||||
vscode.window.showInformationMessage(`新建配置: ${name}`);
|
vscode.window.showInformationMessage(`新建配置: ${name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
// 删除配置文件
|
// 删除配置文件
|
||||||
@@ -573,7 +566,7 @@ class ConfigPanel {
|
|||||||
if (config) {
|
if (config) {
|
||||||
this.configs = this.configs.filter(c => c.id !== configId);
|
this.configs = this.configs.filter(c => c.id !== configId);
|
||||||
vscode.window.showInformationMessage(`删除配置: ${config.name}`);
|
vscode.window.showInformationMessage(`删除配置: ${config.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -630,7 +623,7 @@ class ConfigPanel {
|
|||||||
config.content = content;
|
config.content = content;
|
||||||
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
|
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
|
||||||
// 保存数据到JSON文件
|
// 保存数据到JSON文件
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
|
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
|
||||||
@@ -670,9 +663,11 @@ class ConfigPanel {
|
|||||||
});
|
});
|
||||||
case 'containers':
|
case 'containers':
|
||||||
const currentProject = this.projects.find(p => p.id === this.currentProjectId);
|
const currentProject = this.projects.find(p => p.id === this.currentProjectId);
|
||||||
|
const currentAircraft = this.aircrafts.find(a => a.id === this.currentAircraftId);
|
||||||
const projectContainers = this.containers.filter(c => c.aircraftId === this.currentAircraftId);
|
const projectContainers = this.containers.filter(c => c.aircraftId === this.currentAircraftId);
|
||||||
return this.containerView.render({
|
return this.containerView.render({
|
||||||
project: currentProject,
|
project: currentProject,
|
||||||
|
aircraft: currentAircraft,
|
||||||
containers: projectContainers
|
containers: projectContainers
|
||||||
});
|
});
|
||||||
case 'configs':
|
case 'configs':
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@ class AircraftView extends BaseView_1.BaseView {
|
|||||||
const aircraftsHtml = aircrafts.map(aircraft => `
|
const aircraftsHtml = aircrafts.map(aircraft => `
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span class="aircraft-name" data-aircraft-id="${aircraft.id}">✈️ ${aircraft.name}</span>
|
<span class="aircraft-name" data-aircraft-id="${aircraft.id}">🛸 ${aircraft.name}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="clickable" onclick="openAircraftConfig('${aircraft.id}', '${aircraft.projectId}')">配置容器</span>
|
<span class="clickable" onclick="openAircraftConfig('${aircraft.id}', '${aircraft.projectId}')">配置容器</span>
|
||||||
@@ -83,7 +83,7 @@ class AircraftView extends BaseView_1.BaseView {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>飞行器配置</h2>
|
<h2>🚀飞行器配置</h2>
|
||||||
<button class="back-btn" onclick="goBackToProjects()">← 返回项目</button>
|
<button class="back-btn" onclick="goBackToProjects()">← 返回项目</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ class ConfigView extends BaseView_1.BaseView {
|
|||||||
render(data) {
|
render(data) {
|
||||||
const container = data?.container;
|
const container = data?.container;
|
||||||
const configs = data?.configs || [];
|
const configs = data?.configs || [];
|
||||||
// 生成配置列表的 HTML - 添加文件名编辑功能
|
// 生成配置列表的 HTML - 移除文件名编辑功能
|
||||||
const configsHtml = configs.map((config) => `
|
const configsHtml = configs.map((config) => `
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
|
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="editable" onclick="editFileName('${config.id}', '${config.fileName}')">📄 ${config.fileName}</span>
|
<span class="clickable" onclick="openConfigFile('${config.id}')">📄 ${config.fileName}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
|
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
|
||||||
@@ -84,23 +84,6 @@ class ConfigView extends BaseView_1.BaseView {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function editFileName(configId, currentFileName) {
|
|
||||||
showPromptDialog(
|
|
||||||
'修改文件名',
|
|
||||||
'请输入新的文件名(包含扩展名):',
|
|
||||||
currentFileName,
|
|
||||||
function(newFileName) {
|
|
||||||
if (newFileName && newFileName !== currentFileName) {
|
|
||||||
vscode.postMessage({
|
|
||||||
type: 'updateConfigFileName',
|
|
||||||
configId: configId,
|
|
||||||
fileName: newFileName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openConfigFile(configId) {
|
function openConfigFile(configId) {
|
||||||
currentConfigId = configId;
|
currentConfigId = configId;
|
||||||
document.getElementById('configEditor').style.display = 'block';
|
document.getElementById('configEditor').style.display = 'block';
|
||||||
@@ -249,19 +232,7 @@ class ConfigView extends BaseView_1.BaseView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 修改:点击文件名时打开编辑器
|
// 移除原来的复杂点击事件处理,现在文件名直接调用 openConfigFile
|
||||||
document.addEventListener('click', function(event) {
|
|
||||||
if (event.target.classList.contains('editable') && event.target.textContent.includes('📄')) {
|
|
||||||
const row = event.target.closest('tr');
|
|
||||||
if (row) {
|
|
||||||
const configNameCell = row.querySelector('td:first-child .editable');
|
|
||||||
if (configNameCell) {
|
|
||||||
const configId = configNameCell.onclick.toString().match(/'([^']+)'/)[1];
|
|
||||||
openConfigFile(configId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"ConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/ConfigView.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yCAAsC;AAGtC,MAAa,UAAW,SAAQ,mBAAQ;IACpC,MAAM,CAAC,IAA0B;QAC7B,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QAEpC,2BAA2B;QAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAsB,EAAE,EAAE,CAAC;;;sEAGE,MAAM,CAAC,EAAE,OAAO,MAAM,CAAC,IAAI,UAAU,MAAM,CAAC,IAAI;;;oEAGlD,MAAM,CAAC,EAAE,OAAO,MAAM,CAAC,QAAQ,UAAU,MAAM,CAAC,QAAQ;;;wEAGpD,MAAM,CAAC,EAAE;;;SAGxE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;gFAI0D,SAAS,EAAE,IAAI,IAAI,MAAM;;;;;;;;;;;;;cAa3F,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4NjB,CAAC;IACL,CAAC;CACJ;AAzQD,gCAyQC"}
|
{"version":3,"file":"ConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/ConfigView.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yCAAsC;AAGtC,MAAa,UAAW,SAAQ,mBAAQ;IACpC,MAAM,CAAC,IAA0B;QAC7B,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QAEpC,2BAA2B;QAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAsB,EAAE,EAAE,CAAC;;;sEAGE,MAAM,CAAC,EAAE,OAAO,MAAM,CAAC,IAAI,UAAU,MAAM,CAAC,IAAI;;;uEAG/C,MAAM,CAAC,EAAE,UAAU,MAAM,CAAC,QAAQ;;;wEAGjC,MAAM,CAAC,EAAE;;;SAGxE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;gFAI0D,SAAS,EAAE,IAAI,IAAI,MAAM;;;;;;;;;;;;;cAa3F,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+LjB,CAAC;IACL,CAAC;CACJ;AA5OD,gCA4OC"}
|
||||||
@@ -6,6 +6,7 @@ const BaseView_1 = require("./BaseView");
|
|||||||
class ContainerView extends BaseView_1.BaseView {
|
class ContainerView extends BaseView_1.BaseView {
|
||||||
render(data) {
|
render(data) {
|
||||||
const project = data?.project;
|
const project = data?.project;
|
||||||
|
const aircraft = data?.aircraft; // 新增:获取飞行器数据
|
||||||
const containers = data?.containers || [];
|
const containers = data?.containers || [];
|
||||||
// 生成容器列表的 HTML
|
// 生成容器列表的 HTML
|
||||||
const containersHtml = containers.map((container) => `
|
const containersHtml = containers.map((container) => `
|
||||||
@@ -31,7 +32,7 @@ class ContainerView extends BaseView_1.BaseView {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${project?.name || '未知项目'}</span></h2>
|
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${aircraft?.name || '未知飞行器'}</span></h2>
|
||||||
<button class="back-btn" onclick="goBackToAircrafts()">← 返回飞行器管理</button>
|
<button class="back-btn" onclick="goBackToAircrafts()">← 返回飞行器管理</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"ContainerView.js","sourceRoot":"","sources":["../../../src/panels/views/ContainerView.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,yCAAsC;AAGtC,MAAa,aAAc,SAAQ,mBAAQ;IACvC,MAAM,CAAC,IAAyB;QAC5B,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC;QAC9B,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC;QAE1C,eAAe;QACf,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAA4B,EAAE,EAAE,CAAC;;;yEAGP,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC,IAAI,UAAU,SAAS,CAAC,IAAI;;;4EAGtD,SAAS,CAAC,EAAE;;;2EAGb,SAAS,CAAC,EAAE;;;SAG9E,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;gFAI0D,OAAO,EAAE,IAAI,IAAI,MAAM;;;;;;;;;;;;;cAazF,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyJpB,CAAC;IACL,CAAC;CACJ;AAtMD,sCAsMC"}
|
{"version":3,"file":"ContainerView.js","sourceRoot":"","sources":["../../../src/panels/views/ContainerView.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,yCAAsC;AAGtC,MAAa,aAAc,SAAQ,mBAAQ;IACvC,MAAM,CAAC,IAAyB;QAC5B,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,aAAa;QAC9C,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC;QAE1C,eAAe;QACf,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAA4B,EAAE,EAAE,CAAC;;;yEAGP,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC,IAAI,UAAU,SAAS,CAAC,IAAI;;;4EAGtD,SAAS,CAAC,EAAE;;;2EAGb,SAAS,CAAC,EAAE;;;SAG9E,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;gFAI0D,QAAQ,EAAE,IAAI,IAAI,OAAO;;;;;;;;;;;;;cAa3F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyJpB,CAAC;IACL,CAAC;CACJ;AAvMD,sCAuMC"}
|
||||||
15
package.json
15
package.json
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dsc_platform",
|
"name": "dsc-platform",
|
||||||
"displayName": "数字卫星构建平台",
|
"displayName": "数字卫星构建平台",
|
||||||
"version": "1.0.0",
|
"version": "1.1.1",
|
||||||
"publisher": "njust_Micro-Nano Satellite Laboratory",
|
"publisher": "njust-micro-nano-lab",
|
||||||
"description": "一个用于快速构建数字卫星的平台",
|
"description": "一个用于快速构建数字卫星的平台",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/your-username/DSCP.git"
|
"url": "http://117.72.162.127:3000/xb/vs-p.git"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.67.0"
|
"vscode": "^1.67.0"
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"Other"
|
"Other"
|
||||||
],
|
],
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"DSCP"
|
"onCommand:open_DSCP"
|
||||||
],
|
],
|
||||||
"main": "./out/extension.js",
|
"main": "./out/extension.js",
|
||||||
"contributes": {
|
"contributes": {
|
||||||
@@ -30,10 +30,11 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"vscode:prepublish": "npm run compile",
|
"vscode:prepublish": "npm run compile",
|
||||||
"compile": "tsc -p ./",
|
"compile": "tsc -p ./",
|
||||||
"watch": "tsc -watch -p ./"
|
"watch": "tsc -watch -p ./",
|
||||||
|
"package": "vsce package"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/vscode": "^1.67.0",
|
"@types/vscode": "^1.67.0",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,6 @@ interface ProjectData {
|
|||||||
aircrafts: Aircraft[];
|
aircrafts: Aircraft[];
|
||||||
containers: Container[];
|
containers: Container[];
|
||||||
configs: Config[];
|
configs: Config[];
|
||||||
projectPaths: { [key: string]: string };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ConfigPanel {
|
export class ConfigPanel {
|
||||||
@@ -105,66 +104,66 @@ export class ConfigPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setupMessageListener() {
|
private setupMessageListener() {
|
||||||
this.panel.webview.onDidReceiveMessage(async (data) => {
|
this.panel.webview.onDidReceiveMessage(async (data) => {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'openExistingProject':
|
case 'openExistingProject':
|
||||||
await this.openExistingProject();
|
await this.openExistingProject();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'configureProject':
|
case 'configureProject':
|
||||||
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
|
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
|
||||||
if (selectedPath) {
|
if (selectedPath) {
|
||||||
|
this.currentView = 'aircrafts';
|
||||||
|
this.currentProjectId = data.projectId;
|
||||||
|
this.updateWebview();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'openProject':
|
||||||
|
// 已配置的项目直接打开
|
||||||
this.currentView = 'aircrafts';
|
this.currentView = 'aircrafts';
|
||||||
this.currentProjectId = data.projectId;
|
this.currentProjectId = data.projectId;
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'openProject':
|
|
||||||
// 已配置的项目直接打开
|
|
||||||
this.currentView = 'aircrafts';
|
|
||||||
this.currentProjectId = data.projectId;
|
|
||||||
this.updateWebview();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'openAircraftConfig':
|
|
||||||
this.currentView = 'containers';
|
|
||||||
this.currentProjectId = data.projectId;
|
|
||||||
this.currentAircraftId = data.aircraftId;
|
|
||||||
this.updateWebview();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'openContainerConfig':
|
|
||||||
this.currentView = 'configs';
|
|
||||||
this.currentContainerId = data.containerId;
|
|
||||||
this.updateWebview();
|
|
||||||
break;
|
|
||||||
|
|
||||||
// 修复返回按钮的消息处理
|
|
||||||
case 'goBackToProjects':
|
|
||||||
this.currentView = 'projects';
|
|
||||||
// 清空当前选择的ID
|
|
||||||
this.currentProjectId = '';
|
|
||||||
this.currentAircraftId = '';
|
|
||||||
this.currentContainerId = '';
|
|
||||||
this.updateWebview();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'goBackToAircrafts':
|
|
||||||
this.currentView = 'aircrafts';
|
|
||||||
// 保持 currentProjectId,清空其他ID
|
|
||||||
this.currentAircraftId = '';
|
|
||||||
this.currentContainerId = '';
|
|
||||||
this.updateWebview();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'goBackToContainers':
|
|
||||||
this.currentView = 'containers';
|
|
||||||
// 保持 currentProjectId 和 currentAircraftId,清空 currentContainerId
|
|
||||||
this.currentContainerId = '';
|
|
||||||
this.updateWebview();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
case 'openAircraftConfig':
|
||||||
|
this.currentView = 'containers';
|
||||||
|
this.currentProjectId = data.projectId;
|
||||||
|
this.currentAircraftId = data.aircraftId;
|
||||||
|
this.updateWebview();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'openContainerConfig':
|
||||||
|
this.currentView = 'configs';
|
||||||
|
this.currentContainerId = data.containerId;
|
||||||
|
this.updateWebview();
|
||||||
|
break;
|
||||||
|
|
||||||
|
// 修复返回按钮的消息处理
|
||||||
|
case 'goBackToProjects':
|
||||||
|
this.currentView = 'projects';
|
||||||
|
// 清空当前选择的ID
|
||||||
|
this.currentProjectId = '';
|
||||||
|
this.currentAircraftId = '';
|
||||||
|
this.currentContainerId = '';
|
||||||
|
this.updateWebview();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'goBackToAircrafts':
|
||||||
|
this.currentView = 'aircrafts';
|
||||||
|
// 保持 currentProjectId,清空其他ID
|
||||||
|
this.currentAircraftId = '';
|
||||||
|
this.currentContainerId = '';
|
||||||
|
this.updateWebview();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'goBackToContainers':
|
||||||
|
this.currentView = 'containers';
|
||||||
|
// 保持 currentProjectId 和 currentAircraftId,清空 currentContainerId
|
||||||
|
this.currentContainerId = '';
|
||||||
|
this.updateWebview();
|
||||||
|
break;
|
||||||
|
|
||||||
case 'updateProjectName':
|
case 'updateProjectName':
|
||||||
await this.updateProjectName(data.projectId, data.name);
|
await this.updateProjectName(data.projectId, data.name);
|
||||||
break;
|
break;
|
||||||
@@ -251,27 +250,20 @@ export class ConfigPanel {
|
|||||||
// === 数据持久化方法 ===
|
// === 数据持久化方法 ===
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存所有数据到项目路径
|
* 保存当前项目数据到项目路径
|
||||||
*/
|
*/
|
||||||
private async saveAllData(): Promise<void> {
|
private async saveCurrentProjectData(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
console.log('开始保存数据...');
|
console.log('开始保存当前项目数据...');
|
||||||
console.log('当前项目ID:', this.currentProjectId);
|
console.log('当前项目ID:', this.currentProjectId);
|
||||||
console.log('项目路径映射:', Array.from(this.projectPaths.entries()));
|
|
||||||
|
|
||||||
// 找到当前项目的路径
|
if (!this.currentProjectId) {
|
||||||
let projectPath: string | undefined;
|
console.log('未找到当前项目ID,跳过保存数据');
|
||||||
|
vscode.window.showWarningMessage('未找到当前项目,数据将不会保存');
|
||||||
// 首先尝试使用当前项目ID
|
return;
|
||||||
if (this.currentProjectId) {
|
|
||||||
projectPath = this.projectPaths.get(this.currentProjectId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有找到,尝试使用第一个项目
|
const projectPath = this.projectPaths.get(this.currentProjectId);
|
||||||
if (!projectPath && this.projects.length > 0) {
|
|
||||||
projectPath = this.projectPaths.get(this.projects[0].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!projectPath) {
|
if (!projectPath) {
|
||||||
console.log('未找到项目路径,跳过保存数据');
|
console.log('未找到项目路径,跳过保存数据');
|
||||||
vscode.window.showWarningMessage('未找到项目存储路径,数据将不会保存');
|
vscode.window.showWarningMessage('未找到项目存储路径,数据将不会保存');
|
||||||
@@ -280,29 +272,33 @@ export class ConfigPanel {
|
|||||||
|
|
||||||
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
const dataUri = vscode.Uri.joinPath(vscode.Uri.file(projectPath), '.dcsp-data.json');
|
||||||
|
|
||||||
|
// 只保存与当前项目相关的数据
|
||||||
|
const currentProjectAircrafts = this.aircrafts.filter(a => a.projectId === this.currentProjectId);
|
||||||
|
const currentAircraftIds = currentProjectAircrafts.map(a => a.id);
|
||||||
|
const currentProjectContainers = this.containers.filter(c => currentAircraftIds.includes(c.aircraftId));
|
||||||
|
const currentContainerIds = currentProjectContainers.map(c => c.id);
|
||||||
|
const currentProjectConfigs = this.configs.filter(cfg => currentContainerIds.includes(cfg.containerId));
|
||||||
|
|
||||||
const data: ProjectData = {
|
const data: ProjectData = {
|
||||||
projects: this.projects,
|
projects: this.projects.filter(p => p.id === this.currentProjectId), // 只保存当前项目
|
||||||
aircrafts: this.aircrafts,
|
aircrafts: currentProjectAircrafts,
|
||||||
containers: this.containers,
|
containers: currentProjectContainers,
|
||||||
configs: this.configs,
|
configs: currentProjectConfigs
|
||||||
projectPaths: Object.fromEntries(this.projectPaths)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('要保存的数据:', {
|
console.log('要保存的当前项目数据:', {
|
||||||
projects: this.projects.length,
|
projects: data.projects.length,
|
||||||
aircrafts: this.aircrafts.length,
|
aircrafts: data.aircrafts.length,
|
||||||
containers: this.containers.length,
|
containers: data.containers.length,
|
||||||
configs: this.configs.length,
|
configs: data.configs.length
|
||||||
projectPaths: this.projectPaths.size
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const uint8Array = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
const uint8Array = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
||||||
await vscode.workspace.fs.writeFile(dataUri, uint8Array);
|
await vscode.workspace.fs.writeFile(dataUri, uint8Array);
|
||||||
|
|
||||||
console.log('项目数据已保存到:', dataUri.fsPath);
|
console.log('当前项目数据已保存到:', dataUri.fsPath);
|
||||||
vscode.window.showInformationMessage('项目数据已保存');
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('保存项目数据时出错:', error);
|
console.error('保存当前项目数据时出错:', error);
|
||||||
vscode.window.showErrorMessage(`保存项目数据失败: ${error}`);
|
vscode.window.showErrorMessage(`保存项目数据失败: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,7 +330,6 @@ export class ConfigPanel {
|
|||||||
this.aircrafts = [];
|
this.aircrafts = [];
|
||||||
this.containers = [];
|
this.containers = [];
|
||||||
this.configs = [];
|
this.configs = [];
|
||||||
this.projectPaths = new Map();
|
|
||||||
|
|
||||||
// 验证数据格式并加载
|
// 验证数据格式并加载
|
||||||
if (data.projects && Array.isArray(data.projects)) {
|
if (data.projects && Array.isArray(data.projects)) {
|
||||||
@@ -349,21 +344,18 @@ export class ConfigPanel {
|
|||||||
if (data.configs && Array.isArray(data.configs)) {
|
if (data.configs && Array.isArray(data.configs)) {
|
||||||
this.configs = data.configs;
|
this.configs = data.configs;
|
||||||
}
|
}
|
||||||
if (data.projectPaths && typeof data.projectPaths === 'object') {
|
|
||||||
this.projectPaths = new Map(Object.entries(data.projectPaths));
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('加载后的数据状态:', {
|
console.log('加载后的数据状态:', {
|
||||||
projects: this.projects.length,
|
projects: this.projects.length,
|
||||||
aircrafts: this.aircrafts.length,
|
aircrafts: this.aircrafts.length,
|
||||||
containers: this.containers.length,
|
containers: this.containers.length,
|
||||||
configs: this.configs.length,
|
configs: this.configs.length
|
||||||
projectPaths: this.projectPaths.size
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 设置当前项目为第一个项目(如果有的话)
|
// 设置当前项目为第一个项目(如果有的话)
|
||||||
if (this.projects.length > 0) {
|
if (this.projects.length > 0) {
|
||||||
this.currentProjectId = this.projects[0].id;
|
this.currentProjectId = this.projects[0].id;
|
||||||
|
this.projectPaths.set(this.currentProjectId, projectPath);
|
||||||
this.currentView = 'aircrafts';
|
this.currentView = 'aircrafts';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +450,7 @@ export class ConfigPanel {
|
|||||||
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
|
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
|
||||||
|
|
||||||
// 保存初始数据
|
// 保存初始数据
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
|
|
||||||
return selectedPath;
|
return selectedPath;
|
||||||
}
|
}
|
||||||
@@ -485,7 +477,7 @@ export class ConfigPanel {
|
|||||||
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
|
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
|
||||||
|
|
||||||
// 保存初始数据
|
// 保存初始数据
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
|
|
||||||
return pathInput;
|
return pathInput;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -508,7 +500,7 @@ export class ConfigPanel {
|
|||||||
if (project) {
|
if (project) {
|
||||||
project.name = newName;
|
project.name = newName;
|
||||||
vscode.window.showInformationMessage(`项目名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`项目名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -523,7 +515,6 @@ export class ConfigPanel {
|
|||||||
this.projects.push(newProject);
|
this.projects.push(newProject);
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`新建项目: ${name}`);
|
vscode.window.showInformationMessage(`新建项目: ${name}`);
|
||||||
await this.saveAllData();
|
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,7 +537,7 @@ export class ConfigPanel {
|
|||||||
this.projectPaths.delete(projectId);
|
this.projectPaths.delete(projectId);
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`删除项目: ${project.name}`);
|
vscode.window.showInformationMessage(`删除项目: ${project.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +547,7 @@ export class ConfigPanel {
|
|||||||
if (aircraft) {
|
if (aircraft) {
|
||||||
aircraft.name = newName;
|
aircraft.name = newName;
|
||||||
vscode.window.showInformationMessage(`飞行器名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`飞行器名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +568,7 @@ export class ConfigPanel {
|
|||||||
this.aircrafts.push(newAircraft);
|
this.aircrafts.push(newAircraft);
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`新建飞行器: ${name}`);
|
vscode.window.showInformationMessage(`新建飞行器: ${name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,7 +585,7 @@ export class ConfigPanel {
|
|||||||
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`删除飞行器: ${aircraft.name}`);
|
vscode.window.showInformationMessage(`删除飞行器: ${aircraft.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,12 +595,12 @@ export class ConfigPanel {
|
|||||||
if (container) {
|
if (container) {
|
||||||
container.name = newName;
|
container.name = newName;
|
||||||
vscode.window.showInformationMessage(`容器名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`容器名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建新容器 - 修复版本
|
// 创建新容器
|
||||||
private async createContainer(name: string) {
|
private async createContainer(name: string) {
|
||||||
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
||||||
|
|
||||||
@@ -654,7 +645,7 @@ export class ConfigPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`新建容器: ${name} (包含2个默认配置文件)`);
|
vscode.window.showInformationMessage(`新建容器: ${name} (包含2个默认配置文件)`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -670,7 +661,7 @@ export class ConfigPanel {
|
|||||||
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`删除容器: ${container.name}`);
|
vscode.window.showInformationMessage(`删除容器: ${container.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,7 +671,7 @@ export class ConfigPanel {
|
|||||||
if (config) {
|
if (config) {
|
||||||
config.name = newName;
|
config.name = newName;
|
||||||
vscode.window.showInformationMessage(`配置名称更新: ${newName}`);
|
vscode.window.showInformationMessage(`配置名称更新: ${newName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -691,7 +682,7 @@ export class ConfigPanel {
|
|||||||
if (config) {
|
if (config) {
|
||||||
config.fileName = fileName;
|
config.fileName = fileName;
|
||||||
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
|
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,14 +693,14 @@ export class ConfigPanel {
|
|||||||
const newConfig: Config = {
|
const newConfig: Config = {
|
||||||
id: newId,
|
id: newId,
|
||||||
name: name,
|
name: name,
|
||||||
fileName: name.toLowerCase().replace(/\s+/g, '_') + '.yaml',
|
fileName: name.toLowerCase().replace(/\s+/g, '_'),
|
||||||
content: `# ${name} 配置文件\n# 创建时间: ${new Date().toLocaleString()}\n# 您可以在此编辑配置内容\n\n`,
|
content: `# ${name} 配置文件\n# 创建时间: ${new Date().toLocaleString()}\n# 您可以在此编辑配置内容\n\n`,
|
||||||
containerId: this.currentContainerId
|
containerId: this.currentContainerId
|
||||||
};
|
};
|
||||||
this.configs.push(newConfig);
|
this.configs.push(newConfig);
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`新建配置: ${name}`);
|
vscode.window.showInformationMessage(`新建配置: ${name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,7 +710,7 @@ export class ConfigPanel {
|
|||||||
if (config) {
|
if (config) {
|
||||||
this.configs = this.configs.filter(c => c.id !== configId);
|
this.configs = this.configs.filter(c => c.id !== configId);
|
||||||
vscode.window.showInformationMessage(`删除配置: ${config.name}`);
|
vscode.window.showInformationMessage(`删除配置: ${config.name}`);
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
this.updateWebview();
|
this.updateWebview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -786,7 +777,7 @@ export class ConfigPanel {
|
|||||||
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
|
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
|
||||||
|
|
||||||
// 保存数据到JSON文件
|
// 保存数据到JSON文件
|
||||||
await this.saveAllData();
|
await this.saveCurrentProjectData();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
|
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
|
||||||
}
|
}
|
||||||
@@ -827,10 +818,12 @@ export class ConfigPanel {
|
|||||||
});
|
});
|
||||||
case 'containers':
|
case 'containers':
|
||||||
const currentProject = this.projects.find(p => p.id === this.currentProjectId);
|
const currentProject = this.projects.find(p => p.id === this.currentProjectId);
|
||||||
|
const currentAircraft = this.aircrafts.find(a => a.id === this.currentAircraftId);
|
||||||
const projectContainers = this.containers.filter(c => c.aircraftId === this.currentAircraftId);
|
const projectContainers = this.containers.filter(c => c.aircraftId === this.currentAircraftId);
|
||||||
|
|
||||||
return this.containerView.render({
|
return this.containerView.render({
|
||||||
project: currentProject,
|
project: currentProject,
|
||||||
|
aircraft: currentAircraft,
|
||||||
containers: projectContainers
|
containers: projectContainers
|
||||||
});
|
});
|
||||||
case 'configs':
|
case 'configs':
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ export interface AircraftViewData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ProjectListData {
|
export interface ProjectListData {
|
||||||
aircrafts?: AircraftViewData[];
|
aircraft?: AircraftViewData[];
|
||||||
projects: ProjectViewData[];
|
projects: ProjectViewData[];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AircraftConfigData {
|
export interface AircraftConfigData {
|
||||||
project?: ProjectViewData;
|
project?: ProjectViewData;
|
||||||
|
aircraft?: AircraftViewData;
|
||||||
containers: ContainerViewData[];
|
containers: ContainerViewData[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class AircraftView extends BaseView {
|
|||||||
const aircraftsHtml = aircrafts.map(aircraft => `
|
const aircraftsHtml = aircrafts.map(aircraft => `
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span class="aircraft-name" data-aircraft-id="${aircraft.id}">✈️ ${aircraft.name}</span>
|
<span class="aircraft-name" data-aircraft-id="${aircraft.id}">🛸 ${aircraft.name}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="clickable" onclick="openAircraftConfig('${aircraft.id}', '${aircraft.projectId}')">配置容器</span>
|
<span class="clickable" onclick="openAircraftConfig('${aircraft.id}', '${aircraft.projectId}')">配置容器</span>
|
||||||
@@ -90,7 +90,7 @@ export class AircraftView extends BaseView {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>飞行器配置</h2>
|
<h2>🚀飞行器配置</h2>
|
||||||
<button class="back-btn" onclick="goBackToProjects()">← 返回项目</button>
|
<button class="back-btn" onclick="goBackToProjects()">← 返回项目</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ export class ConfigView extends BaseView {
|
|||||||
const container = data?.container;
|
const container = data?.container;
|
||||||
const configs = data?.configs || [];
|
const configs = data?.configs || [];
|
||||||
|
|
||||||
// 生成配置列表的 HTML - 添加文件名编辑功能
|
// 生成配置列表的 HTML - 移除文件名编辑功能
|
||||||
const configsHtml = configs.map((config: ConfigViewData) => `
|
const configsHtml = configs.map((config: ConfigViewData) => `
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
|
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="editable" onclick="editFileName('${config.id}', '${config.fileName}')">📄 ${config.fileName}</span>
|
<span class="clickable" onclick="openConfigFile('${config.id}')">📄 ${config.fileName}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
|
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
|
||||||
@@ -85,23 +85,6 @@ export class ConfigView extends BaseView {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function editFileName(configId, currentFileName) {
|
|
||||||
showPromptDialog(
|
|
||||||
'修改文件名',
|
|
||||||
'请输入新的文件名(包含扩展名):',
|
|
||||||
currentFileName,
|
|
||||||
function(newFileName) {
|
|
||||||
if (newFileName && newFileName !== currentFileName) {
|
|
||||||
vscode.postMessage({
|
|
||||||
type: 'updateConfigFileName',
|
|
||||||
configId: configId,
|
|
||||||
fileName: newFileName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function openConfigFile(configId) {
|
function openConfigFile(configId) {
|
||||||
currentConfigId = configId;
|
currentConfigId = configId;
|
||||||
document.getElementById('configEditor').style.display = 'block';
|
document.getElementById('configEditor').style.display = 'block';
|
||||||
@@ -250,19 +233,7 @@ export class ConfigView extends BaseView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 修改:点击文件名时打开编辑器
|
// 移除原来的复杂点击事件处理,现在文件名直接调用 openConfigFile
|
||||||
document.addEventListener('click', function(event) {
|
|
||||||
if (event.target.classList.contains('editable') && event.target.textContent.includes('📄')) {
|
|
||||||
const row = event.target.closest('tr');
|
|
||||||
if (row) {
|
|
||||||
const configNameCell = row.querySelector('td:first-child .editable');
|
|
||||||
if (configNameCell) {
|
|
||||||
const configId = configNameCell.onclick.toString().match(/'([^']+)'/)[1];
|
|
||||||
openConfigFile(configId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { AircraftConfigData, ContainerViewData } from '../types/ViewTypes';
|
|||||||
export class ContainerView extends BaseView {
|
export class ContainerView extends BaseView {
|
||||||
render(data?: AircraftConfigData): string {
|
render(data?: AircraftConfigData): string {
|
||||||
const project = data?.project;
|
const project = data?.project;
|
||||||
|
const aircraft = data?.aircraft; // 新增:获取飞行器数据
|
||||||
const containers = data?.containers || [];
|
const containers = data?.containers || [];
|
||||||
|
|
||||||
// 生成容器列表的 HTML
|
// 生成容器列表的 HTML
|
||||||
@@ -32,7 +33,7 @@ export class ContainerView extends BaseView {
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${project?.name || '未知项目'}</span></h2>
|
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${aircraft?.name || '未知飞行器'}</span></h2>
|
||||||
<button class="back-btn" onclick="goBackToAircrafts()">← 返回飞行器管理</button>
|
<button class="back-btn" onclick="goBackToAircrafts()">← 返回飞行器管理</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user