0
0
Files
vs-p/out/panels/views/ContainerView.js

124 lines
4.0 KiB
JavaScript
Raw Normal View History

2025-11-18 18:45:30 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContainerView = void 0;
// src/panels/views/ContainerView.ts
const BaseView_1 = require("./BaseView");
class ContainerView extends BaseView_1.BaseView {
render(data) {
2025-11-18 09:10:47 +08:00
const project = data?.project;
2025-12-03 16:08:14 +08:00
const aircraft = data?.aircraft;
2025-11-18 09:10:47 +08:00
const containers = data?.containers || [];
2025-11-18 18:45:30 +08:00
const containersHtml = containers.map((container) => `
2025-11-18 09:10:47 +08:00
<tr>
<td>
<span class="editable" onclick="editContainerName('${container.id}', '${container.name}')">📦 ${container.name}</span>
</td>
<td>
<span class="clickable" onclick="openContainerConfig('${container.id}')">配置文件</span>
</td>
<td>
<button class="btn-delete" onclick="deleteContainer('${container.id}')">删除</button>
</td>
</tr>
`).join('');
return `<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2025-11-18 18:45:30 +08:00
<title>容器管理</title>
2025-11-18 09:10:47 +08:00
${this.getStyles()}
</head>
<body>
<div class="header">
2025-11-21 16:07:48 +08:00
<h2>📋 容器管理 - <span style="color: var(--vscode-textLink-foreground);">${aircraft?.name || '未知飞行器'}</span></h2>
2025-11-18 18:45:30 +08:00
<button class="back-btn" onclick="goBackToAircrafts()"> 返回飞行器管理</button>
2025-11-18 09:10:47 +08:00
</div>
<table class="table">
<thead>
<tr>
<th width="40%">容器</th>
<th width="40%">配置文件</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
${containersHtml}
<tr>
<td colspan="3" style="text-align: center; padding: 20px;">
<button class="btn-new" onclick="createNewContainer()">+ 新建容器</button>
</td>
</tr>
</tbody>
</table>
<script>
const vscode = acquireVsCodeApi();
function editContainerName(containerId, currentName) {
showPromptDialog(
'修改容器名称',
'请输入新的容器名称:',
currentName,
function(newName) {
if (newName && newName !== currentName) {
vscode.postMessage({
type: 'updateContainerName',
containerId: containerId,
name: newName
});
}
}
);
}
function openContainerConfig(containerId) {
vscode.postMessage({
type: 'openContainerConfig',
containerId: containerId
});
}
function createNewContainer() {
showPromptDialog(
'新建容器',
'请输入容器名称:',
'',
function(name) {
if (name) {
vscode.postMessage({
type: 'createContainer',
name: name
});
}
}
);
}
2025-11-18 18:45:30 +08:00
function goBackToAircrafts() {
vscode.postMessage({ type: 'goBackToAircrafts' });
2025-11-18 09:10:47 +08:00
}
function deleteContainer(containerId) {
showConfirmDialog(
'确认删除',
'确定删除这个容器吗?',
function() {
vscode.postMessage({
type: 'deleteContainer',
containerId: containerId
});
},
function() {
// 用户取消删除
}
);
}
</script>
</body>
</html>`;
}
2025-11-18 18:45:30 +08:00
}
exports.ContainerView = ContainerView;
//# sourceMappingURL=ContainerView.js.map