0
0

不再提供模板

This commit is contained in:
xubing
2025-11-18 18:45:30 +08:00
parent 53e9307157
commit 7d249f4882
18 changed files with 1245 additions and 230 deletions

View File

@@ -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';

View File

@@ -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' });
}
// 对话框函数

View File

@@ -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) {

View File

@@ -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();