不再提供模板
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// src/panels/ConfigPanel.ts
|
||||
import * as vscode from 'vscode';
|
||||
import { ProjectManagementView } from './views/ProjectManagementView';
|
||||
import { ProjectListView } from './views/ProjectListView';
|
||||
import { AircraftConfigView } from './views/AircraftConfigView';
|
||||
import { ContainerConfigView } from './views/ContainerConfigView';
|
||||
import { ProjectView } from './views/ProjectView';
|
||||
import { AircraftView } from './views/AircraftView';
|
||||
import { ContainerView } from './views/ContainerView';
|
||||
import { ConfigView } from './views/ConfigView';
|
||||
|
||||
// 数据模型接口
|
||||
interface Project {
|
||||
@@ -36,43 +36,25 @@ export class ConfigPanel {
|
||||
private readonly panel: vscode.WebviewPanel;
|
||||
private readonly extensionUri: vscode.Uri;
|
||||
|
||||
private currentView: 'management' | 'projects' | 'aircrafts' | 'container' = 'management';
|
||||
private currentView: 'projects' | 'aircrafts' | 'containers' | 'configs' = 'projects';
|
||||
private currentProjectId: string = '';
|
||||
private currentAircraftId: string = '';
|
||||
private currentContainerId: string = '';
|
||||
|
||||
// 数据存储
|
||||
private projects: Project[] = [
|
||||
{ id: 'p1', name: '项目1' },
|
||||
{ id: 'p2', name: '项目2' }
|
||||
];
|
||||
|
||||
private aircrafts: Aircraft[] = [
|
||||
{ id: 'a1', name: '飞行器配置1', projectId: 'p1' },
|
||||
{ id: 'a2', name: '飞行器配置2', projectId: 'p2' }
|
||||
];
|
||||
|
||||
private containers: Container[] = [
|
||||
{ id: 'c1', name: '容器1', aircraftId: 'a1' },
|
||||
{ id: 'c2', name: '容器2', aircraftId: 'a1' },
|
||||
{ id: 'c3', name: '容器1', aircraftId: 'a2' }
|
||||
];
|
||||
|
||||
private configs: Config[] = [
|
||||
{ id: 'cfg1', name: '配置1', fileName: 'config.yaml', content: '# 配置1内容', containerId: 'c1' },
|
||||
{ id: 'cfg2', name: '配置2', fileName: 'settings.json', content: '# 配置2内容', containerId: 'c1' },
|
||||
{ id: 'cfg3', name: '配置1', fileName: 'docker-compose.yml', content: '# 配置1内容', containerId: 'c2' },
|
||||
{ id: 'cfg4', name: '配置1', fileName: 'config.yaml', content: '# 配置1内容', containerId: 'c3' }
|
||||
];
|
||||
private projects: Project[] = [];
|
||||
private aircrafts: Aircraft[] = [];
|
||||
private containers: Container[] = [];
|
||||
private configs: Config[] = [];
|
||||
|
||||
// 项目存储路径映射
|
||||
private projectPaths: Map<string, string> = new Map();
|
||||
|
||||
// 视图实例
|
||||
private readonly projectManagementView: ProjectManagementView;
|
||||
private readonly projectListView: ProjectListView;
|
||||
private readonly aircraftConfigView: AircraftConfigView;
|
||||
private readonly containerConfigView: ContainerConfigView;
|
||||
private readonly projectView: ProjectView;
|
||||
private readonly aircraftView: AircraftView;
|
||||
private readonly containerView: ContainerView;
|
||||
private readonly configView: ConfigView;
|
||||
|
||||
public static createOrShow(extensionUri: vscode.Uri) {
|
||||
const column = vscode.window.activeTextEditor?.viewColumn || vscode.ViewColumn.One;
|
||||
@@ -83,8 +65,8 @@ export class ConfigPanel {
|
||||
}
|
||||
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
'dockerConfigTest',
|
||||
'Docker配置测试',
|
||||
'DCSP',
|
||||
'数字卫星构建平台',
|
||||
column,
|
||||
{
|
||||
enableScripts: true,
|
||||
@@ -101,10 +83,10 @@ export class ConfigPanel {
|
||||
this.extensionUri = extensionUri;
|
||||
|
||||
// 初始化各个视图
|
||||
this.projectManagementView = new ProjectManagementView(extensionUri);
|
||||
this.projectListView = new ProjectListView(extensionUri);
|
||||
this.aircraftConfigView = new AircraftConfigView(extensionUri);
|
||||
this.containerConfigView = new ContainerConfigView(extensionUri);
|
||||
this.projectView = new ProjectView(extensionUri);
|
||||
this.aircraftView = new AircraftView(extensionUri);
|
||||
this.containerView = new ContainerView(extensionUri);
|
||||
this.configView = new ConfigView(extensionUri);
|
||||
|
||||
this.updateWebview();
|
||||
this.setupMessageListener();
|
||||
@@ -120,7 +102,7 @@ export class ConfigPanel {
|
||||
case 'configureProject':
|
||||
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
|
||||
if (selectedPath) {
|
||||
this.currentView = 'projects';
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.updateWebview();
|
||||
}
|
||||
@@ -128,43 +110,40 @@ export class ConfigPanel {
|
||||
|
||||
case 'openProject':
|
||||
// 已配置的项目直接打开
|
||||
this.currentView = 'projects';
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = data.projectId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'openAircraftConfig':
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentView = 'containers';
|
||||
this.currentProjectId = data.projectId;
|
||||
// 找到对应的飞行器ID
|
||||
const aircraft = this.aircrafts.find(a => a.projectId === data.projectId);
|
||||
if (aircraft) {
|
||||
this.currentAircraftId = aircraft.id;
|
||||
}
|
||||
this.currentAircraftId = data.aircraftId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'openContainerConfig':
|
||||
this.currentView = 'container';
|
||||
this.currentView = 'configs';
|
||||
this.currentContainerId = data.containerId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToManagement':
|
||||
this.currentView = 'management';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
// 修复返回按钮的消息处理
|
||||
case 'goBackToProjects':
|
||||
this.currentView = 'projects';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToAircraft':
|
||||
case 'goBackToAircrafts':
|
||||
this.currentView = 'aircrafts';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'goBackToContainers':
|
||||
this.currentView = 'containers';
|
||||
this.updateWebview();
|
||||
break;
|
||||
|
||||
case 'updateProjectName':
|
||||
this.updateProjectName(data.projectId, data.name);
|
||||
break;
|
||||
@@ -173,6 +152,14 @@ export class ConfigPanel {
|
||||
this.createProject(data.name);
|
||||
break;
|
||||
|
||||
case 'updateAircraftName':
|
||||
this.updateAircraftName(data.aircraftId, data.name);
|
||||
break;
|
||||
|
||||
case 'createAircraft':
|
||||
this.createAircraft(data.name);
|
||||
break;
|
||||
|
||||
case 'updateContainerName':
|
||||
this.updateContainerName(data.containerId, data.name);
|
||||
break;
|
||||
@@ -205,6 +192,10 @@ export class ConfigPanel {
|
||||
this.deleteProject(data.projectId);
|
||||
break;
|
||||
|
||||
case 'deleteAircraft':
|
||||
this.deleteAircraft(data.aircraftId);
|
||||
break;
|
||||
|
||||
case 'deleteContainer':
|
||||
this.deleteContainer(data.containerId);
|
||||
break;
|
||||
@@ -216,10 +207,11 @@ export class ConfigPanel {
|
||||
});
|
||||
}
|
||||
|
||||
// ... 其余方法保持不变(selectProjectPath, updateProjectName, createProject等)
|
||||
// === 项目路径选择 ===
|
||||
private async selectProjectPath(projectId: string, projectName: string): Promise<string | null> {
|
||||
try {
|
||||
// 提供两种方式:选择现有路径或输入新路径
|
||||
// 选择现有路径或输入新路径
|
||||
const choice = await vscode.window.showQuickPick(
|
||||
[
|
||||
{
|
||||
@@ -294,7 +286,7 @@ export class ConfigPanel {
|
||||
}
|
||||
}
|
||||
|
||||
// === 项目相关方法 ===
|
||||
// 更新项目名
|
||||
private updateProjectName(projectId: string, newName: string) {
|
||||
const project = this.projects.find(p => p.id === projectId);
|
||||
if (project) {
|
||||
@@ -304,6 +296,7 @@ export class ConfigPanel {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新项目
|
||||
private createProject(name: string) {
|
||||
const newId = 'p' + (this.projects.length + 1);
|
||||
const newProject: Project = {
|
||||
@@ -311,43 +304,79 @@ export class ConfigPanel {
|
||||
name: name
|
||||
};
|
||||
this.projects.push(newProject);
|
||||
|
||||
// 同时创建一个默认的飞行器配置
|
||||
const newAircraftId = 'a' + (this.aircrafts.length + 1);
|
||||
this.aircrafts.push({
|
||||
id: newAircraftId,
|
||||
name: `${name}配置`,
|
||||
projectId: newId
|
||||
});
|
||||
|
||||
|
||||
vscode.window.showInformationMessage(`新建项目: ${name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除项目
|
||||
private deleteProject(projectId: string) {
|
||||
// 删除项目
|
||||
const project = this.projects.find(p => p.id === projectId);
|
||||
if (!project) return;
|
||||
|
||||
this.projects = this.projects.filter(p => p.id !== projectId);
|
||||
|
||||
// 删除相关的飞行器
|
||||
const relatedAircrafts = this.aircrafts.filter(a => a.projectId === projectId);
|
||||
const aircraftIds = relatedAircrafts.map(a => a.id);
|
||||
this.aircrafts = this.aircrafts.filter(a => a.projectId !== projectId);
|
||||
|
||||
// 删除相关的容器
|
||||
this.containers = this.containers.filter(c => !aircraftIds.includes(c.aircraftId));
|
||||
|
||||
// 删除相关的配置
|
||||
const containerIds = this.containers.filter(c => aircraftIds.includes(c.aircraftId)).map(c => c.id);
|
||||
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
||||
|
||||
// 删除项目路径映射
|
||||
this.projectPaths.delete(projectId);
|
||||
|
||||
vscode.window.showInformationMessage(`删除项目: ${projectId}`);
|
||||
vscode.window.showInformationMessage(`删除项目: ${project.name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// === 容器相关方法 ===
|
||||
// 更新飞行器名
|
||||
private updateAircraftName(aircraftId: string, newName: string) {
|
||||
const aircraft = this.aircrafts.find(a => a.id === aircraftId);
|
||||
if (aircraft) {
|
||||
aircraft.name = newName;
|
||||
vscode.window.showInformationMessage(`飞行器名称更新: ${newName}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新飞行器
|
||||
private createAircraft(name: string) {
|
||||
if (!this.currentProjectId) {
|
||||
vscode.window.showErrorMessage('无法创建飞行器:未找到当前项目');
|
||||
return;
|
||||
}
|
||||
|
||||
const newId = 'a' + (this.aircrafts.length + 1);
|
||||
const newAircraft: Aircraft = {
|
||||
id: newId,
|
||||
name: name,
|
||||
projectId: this.currentProjectId
|
||||
};
|
||||
this.aircrafts.push(newAircraft);
|
||||
|
||||
vscode.window.showInformationMessage(`新建飞行器: ${name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除飞行器
|
||||
private deleteAircraft(aircraftId: string) {
|
||||
const aircraft = this.aircrafts.find(a => a.id === aircraftId);
|
||||
if (!aircraft) return;
|
||||
|
||||
this.aircrafts = this.aircrafts.filter(a => a.id !== aircraftId);
|
||||
// 删除相关的容器
|
||||
this.containers = this.containers.filter(c => c.aircraftId !== aircraftId);
|
||||
// 删除相关的配置
|
||||
const containerIds = this.containers.filter(c => c.aircraftId === aircraftId).map(c => c.id);
|
||||
this.configs = this.configs.filter(cfg => !containerIds.includes(cfg.containerId));
|
||||
|
||||
vscode.window.showInformationMessage(`删除飞行器: ${aircraft.name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 更新容器名
|
||||
private updateContainerName(containerId: string, newName: string) {
|
||||
const container = this.containers.find(c => c.id === containerId);
|
||||
if (container) {
|
||||
@@ -357,6 +386,7 @@ export class ConfigPanel {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建新容器
|
||||
private createContainer(name: string) {
|
||||
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
||||
|
||||
@@ -377,20 +407,20 @@ export class ConfigPanel {
|
||||
// 创建两个默认配置文件
|
||||
const configCount = this.configs.length;
|
||||
|
||||
// 第一个配置文件:Dockerfile
|
||||
// 第一个配置文件
|
||||
this.configs.push({
|
||||
id: 'cfg' + (configCount + 1),
|
||||
name: 'Docker配置',
|
||||
fileName: 'Dockerfile',
|
||||
name: '配置1',
|
||||
fileName: 'config.sh',
|
||||
content: `# ${name} 的 Dockerfile\nFROM ubuntu:20.04\n\n# 设置工作目录\nWORKDIR /app\n\n# 复制文件\nCOPY . .\n\n# 安装依赖\nRUN apt-get update && apt-get install -y \\\n python3 \\\n python3-pip\n\n# 暴露端口\nEXPOSE 8080\n\n# 启动命令\nCMD ["python3", "app.py"]`,
|
||||
containerId: newId
|
||||
});
|
||||
|
||||
// 第二个配置文件:docker-compose.yml
|
||||
// 第二个配置文件
|
||||
this.configs.push({
|
||||
id: 'cfg' + (configCount + 2),
|
||||
name: '编排配置',
|
||||
fileName: 'docker-compose.yml',
|
||||
name: '配置2',
|
||||
fileName: 'config.sh',
|
||||
content: `# ${name} 的 Docker Compose 配置\nversion: '3.8'\n\nservices:\n ${name.toLowerCase().replace(/\\s+/g, '-')}:\n build: .\n container_name: ${name}\n ports:\n - "8080:8080"\n environment:\n - NODE_ENV=production\n volumes:\n - ./data:/app/data\n restart: unless-stopped`,
|
||||
containerId: newId
|
||||
});
|
||||
@@ -399,18 +429,22 @@ export class ConfigPanel {
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// 删除容器
|
||||
private deleteContainer(containerId: string) {
|
||||
const container = this.containers.find(c => c.id === containerId);
|
||||
if (!container) return;
|
||||
|
||||
// 删除容器
|
||||
this.containers = this.containers.filter(c => c.id !== containerId);
|
||||
|
||||
// 删除相关的配置
|
||||
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
||||
|
||||
vscode.window.showInformationMessage(`删除容器: ${containerId}`);
|
||||
vscode.window.showInformationMessage(`删除容器: ${container.name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
|
||||
// === 配置相关方法 ===
|
||||
// 更新配置名
|
||||
private updateConfigName(configId: string, newName: string) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
@@ -420,6 +454,7 @@ export class ConfigPanel {
|
||||
}
|
||||
}
|
||||
|
||||
// 更新文件名
|
||||
private async updateConfigFileName(configId: string, fileName: string): Promise<void> {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
@@ -429,7 +464,7 @@ export class ConfigPanel {
|
||||
}
|
||||
}
|
||||
|
||||
// 创建配置文件
|
||||
// 创建新配置文件
|
||||
private createConfig(name: string) {
|
||||
const newId = 'cfg' + (this.configs.length + 1);
|
||||
const newConfig: Config = {
|
||||
@@ -540,39 +575,34 @@ export class ConfigPanel {
|
||||
|
||||
private getWebviewContent(): string {
|
||||
switch (this.currentView) {
|
||||
case 'management':
|
||||
return this.projectManagementView.render({
|
||||
case 'projects':
|
||||
return this.projectView.render({
|
||||
projects: this.projects,
|
||||
projectPaths: this.projectPaths
|
||||
});
|
||||
case 'projects':
|
||||
return this.projectListView.render({
|
||||
projects: this.projects
|
||||
});
|
||||
case 'aircrafts':
|
||||
const projectAircrafts = this.aircrafts.filter(a => a.projectId === this.currentProjectId);
|
||||
return this.aircraftView.render({
|
||||
aircrafts: projectAircrafts
|
||||
});
|
||||
case 'containers':
|
||||
const currentProject = this.projects.find(p => p.id === this.currentProjectId);
|
||||
const projectAircraft = this.aircrafts.find(a => a.projectId === this.currentProjectId);
|
||||
|
||||
if (projectAircraft) {
|
||||
this.currentAircraftId = projectAircraft.id;
|
||||
}
|
||||
|
||||
const projectContainers = this.containers.filter(c => c.aircraftId === this.currentAircraftId);
|
||||
|
||||
return this.aircraftConfigView.render({
|
||||
return this.containerView.render({
|
||||
project: currentProject,
|
||||
containers: projectContainers
|
||||
});
|
||||
case 'container':
|
||||
case 'configs':
|
||||
const currentContainer = this.containers.find(c => c.id === this.currentContainerId);
|
||||
const containerConfigs = this.configs.filter(cfg => cfg.containerId === this.currentContainerId);
|
||||
|
||||
return this.containerConfigView.render({
|
||||
return this.configView.render({
|
||||
container: currentContainer,
|
||||
configs: containerConfigs
|
||||
});
|
||||
default:
|
||||
return this.projectManagementView.render({
|
||||
return this.projectView.render({
|
||||
projects: this.projects,
|
||||
projectPaths: this.projectPaths
|
||||
});
|
||||
|
||||
@@ -17,8 +17,16 @@ export interface ConfigViewData {
|
||||
containerId: string;
|
||||
}
|
||||
|
||||
export interface AircraftViewData {
|
||||
id: string;
|
||||
name: string;
|
||||
projectId: string;
|
||||
}
|
||||
|
||||
export interface ProjectListData {
|
||||
aircrafts?: AircraftViewData[];
|
||||
projects: ProjectViewData[];
|
||||
|
||||
}
|
||||
|
||||
export interface AircraftConfigData {
|
||||
|
||||
@@ -1,52 +1,53 @@
|
||||
// src/panels/views/ProjectListView.ts
|
||||
// src/panels/views/AircraftView.ts
|
||||
import { BaseView } from './BaseView';
|
||||
import { ProjectListData, ProjectViewData } from '../types/ViewTypes';
|
||||
|
||||
export class ProjectListView extends BaseView {
|
||||
render(data?: ProjectListData): string {
|
||||
const projects = data?.projects || [];
|
||||
export class AircraftView extends BaseView {
|
||||
render(data?: { aircrafts: any[] }): string {
|
||||
const aircrafts = data?.aircrafts || [];
|
||||
|
||||
// 生成项目列表的 HTML
|
||||
const projectsHtml = projects.map((project: ProjectViewData) => `
|
||||
// 生成飞行器列表的 HTML
|
||||
const aircraftsHtml = aircrafts.map((aircraft: any) => {
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="editable" onclick="editProjectName('${project.id}', '${project.name}')">🛸 ${project.name}</span>
|
||||
<span class="editable" onclick="editAircraftName('${aircraft.id}', '${aircraft.name}')">🛸 ${aircraft.name}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="clickable" onclick="openAircraftConfig('${project.id}')">配置</span>
|
||||
<span class="clickable" onclick="openAircraftConfig('${aircraft.id}')">配置</span>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-delete" onclick="deleteProject('${project.id}')">删除</button>
|
||||
<button class="btn-delete" onclick="deleteAircraft('${aircraft.id}')">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>飞行器项目管理</title>
|
||||
<title>飞行器管理</title>
|
||||
${this.getStyles()}
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h2>🚀 飞行器项目管理</h2>
|
||||
<button class="back-btn" onclick="goBackToManagement()">← 返回项目管理</button>
|
||||
<h2>🚀 飞行器管理</h2>
|
||||
<button class="back-btn" onclick="goBackToProjects()">← 返回项目管理</button>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="40%">项目</th>
|
||||
<th width="40%">飞行器</th>
|
||||
<th width="40%">配置</th>
|
||||
<th width="20%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${projectsHtml}
|
||||
${aircraftsHtml}
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 20px;">
|
||||
<button class="btn-new" onclick="createNewProject()">+ 新建项目</button>
|
||||
<button class="btn-new" onclick="createNewAircraft()">+ 新建飞行器</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -55,16 +56,16 @@ export class ProjectListView extends BaseView {
|
||||
<script>
|
||||
const vscode = acquireVsCodeApi();
|
||||
|
||||
function editProjectName(projectId, currentName) {
|
||||
function editAircraftName(aircraftId, currentName) {
|
||||
showPromptDialog(
|
||||
'修改项目名称',
|
||||
'请输入新的项目名称:',
|
||||
'修改飞行器名称',
|
||||
'请输入新的飞行器名称:',
|
||||
currentName,
|
||||
function(newName) {
|
||||
if (newName && newName !== currentName) {
|
||||
vscode.postMessage({
|
||||
type: 'updateProjectName',
|
||||
projectId: projectId,
|
||||
type: 'updateAircraftName',
|
||||
aircraftId: aircraftId,
|
||||
name: newName
|
||||
});
|
||||
}
|
||||
@@ -72,22 +73,22 @@ export class ProjectListView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
function openAircraftConfig(projectId) {
|
||||
function openAircraftConfig(aircraftId) {
|
||||
vscode.postMessage({
|
||||
type: 'openAircraftConfig',
|
||||
projectId: projectId
|
||||
aircraftId: aircraftId
|
||||
});
|
||||
}
|
||||
|
||||
function createNewProject() {
|
||||
function createNewAircraft() {
|
||||
showPromptDialog(
|
||||
'新建项目',
|
||||
'请输入项目名称:',
|
||||
'新建飞行器',
|
||||
'请输入飞行器名称:',
|
||||
'',
|
||||
function(name) {
|
||||
if (name) {
|
||||
vscode.postMessage({
|
||||
type: 'createProject',
|
||||
type: 'createAircraft',
|
||||
name: name
|
||||
});
|
||||
}
|
||||
@@ -95,14 +96,14 @@ export class ProjectListView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
function deleteProject(projectId) {
|
||||
function deleteAircraft(aircraftId) {
|
||||
showConfirmDialog(
|
||||
'确认删除',
|
||||
'确定删除这个项目吗?',
|
||||
'确定删除这个飞行器吗?',
|
||||
function() {
|
||||
vscode.postMessage({
|
||||
type: 'deleteProject',
|
||||
projectId: projectId
|
||||
type: 'deleteAircraft',
|
||||
aircraftId: aircraftId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
@@ -111,11 +112,11 @@ export class ProjectListView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
function goBackToManagement() {
|
||||
vscode.postMessage({ type: 'goBackToManagement' });
|
||||
function goBackToProjects() {
|
||||
vscode.postMessage({ type: 'goBackToProjects' });
|
||||
}
|
||||
|
||||
// 对话框函数(与之前相同)
|
||||
// 对话框函数
|
||||
function showConfirmDialog(title, message, onConfirm, onCancel) {
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'modal-overlay';
|
||||
@@ -1,8 +1,8 @@
|
||||
// src/panels/views/ContainerConfigView.ts
|
||||
// src/panels/views/ConfigView.ts
|
||||
import { BaseView } from './BaseView';
|
||||
import { ContainerConfigData, ConfigViewData } from '../types/ViewTypes';
|
||||
|
||||
export class ContainerConfigView extends BaseView {
|
||||
export class ConfigView extends BaseView {
|
||||
render(data?: ContainerConfigData): string {
|
||||
const container = data?.container;
|
||||
const configs = data?.configs || [];
|
||||
@@ -27,13 +27,13 @@ export class ContainerConfigView extends BaseView {
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>容器配置</title>
|
||||
<title>配置管理</title>
|
||||
${this.getStyles()}
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h2>⚙️ 容器配置 - <span style="color: var(--vscode-textLink-foreground);">${container?.name || '未知容器'}</span></h2>
|
||||
<button class="back-btn" onclick="goBackToAircraft()">← 返回飞行器</button>
|
||||
<h2>⚙️ 配置管理 - <span style="color: var(--vscode-textLink-foreground);">${container?.name || '未知容器'}</span></h2>
|
||||
<button class="back-btn" onclick="goBackToContainers()">← 返回容器管理</button>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
@@ -159,8 +159,8 @@ export class ContainerConfigView extends BaseView {
|
||||
currentConfigId = null;
|
||||
}
|
||||
|
||||
function goBackToAircraft() {
|
||||
vscode.postMessage({ type: 'goBackToAircraft' });
|
||||
function goBackToContainers() {
|
||||
vscode.postMessage({ type: 'goBackToContainers' });
|
||||
}
|
||||
|
||||
// 对话框函数
|
||||
@@ -1,8 +1,8 @@
|
||||
// src/panels/views/AircraftConfigView.ts
|
||||
// src/panels/views/ContainerView.ts
|
||||
import { BaseView } from './BaseView';
|
||||
import { AircraftConfigData, ContainerViewData } from '../types/ViewTypes';
|
||||
|
||||
export class AircraftConfigView extends BaseView {
|
||||
export class ContainerView extends BaseView {
|
||||
render(data?: AircraftConfigData): string {
|
||||
const project = data?.project;
|
||||
const containers = data?.containers || [];
|
||||
@@ -27,13 +27,13 @@ export class AircraftConfigView extends BaseView {
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>飞行器配置</title>
|
||||
<title>容器管理</title>
|
||||
${this.getStyles()}
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h2>📋 飞行器配置 - <span style="color: var(--vscode-textLink-foreground);">${project?.name || '未知项目'}</span></h2>
|
||||
<button class="back-btn" onclick="goBackToProjects()">← 返回项目列表</button>
|
||||
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${project?.name || '未知项目'}</span></h2>
|
||||
<button class="back-btn" onclick="goBackToAircrafts()">← 返回飞行器管理</button>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
@@ -97,8 +97,8 @@ export class AircraftConfigView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
function goBackToProjects() {
|
||||
vscode.postMessage({ type: 'goBackToProjects' });
|
||||
function goBackToAircrafts() {
|
||||
vscode.postMessage({ type: 'goBackToAircrafts' });
|
||||
}
|
||||
|
||||
function deleteContainer(containerId) {
|
||||
@@ -1,8 +1,8 @@
|
||||
// src/panels/views/ProjectManagementView.ts
|
||||
// src/panels/views/ProjectView.ts
|
||||
import { BaseView } from './BaseView';
|
||||
import { ProjectViewData } from '../types/ViewTypes';
|
||||
|
||||
export class ProjectManagementView extends BaseView {
|
||||
export class ProjectView extends BaseView {
|
||||
render(data?: { projects: ProjectViewData[], projectPaths?: Map<string, string> }): string {
|
||||
const projects = data?.projects || [];
|
||||
const projectPaths = data?.projectPaths || new Map();
|
||||
Reference in New Issue
Block a user