0
0

新增加了项目管理页面

This commit is contained in:
xubing
2025-11-18 14:03:22 +08:00
parent 64a411e463
commit 53e9307157
12 changed files with 974 additions and 45 deletions

View File

@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigPanel = void 0;
// src/panels/ConfigPanel.ts
const vscode = require("vscode");
const ProjectManagementView_1 = require("./views/ProjectManagementView");
const ProjectListView_1 = require("./views/ProjectListView");
const AircraftConfigView_1 = require("./views/AircraftConfigView");
const ContainerConfigView_1 = require("./views/ContainerConfigView");
@@ -21,14 +22,14 @@ class ConfigPanel {
ConfigPanel.currentPanel = new ConfigPanel(panel, extensionUri);
}
constructor(panel, extensionUri) {
this.currentView = 'projects';
this.currentView = 'management';
this.currentProjectId = '';
this.currentAircraftId = '';
this.currentContainerId = '';
// 数据存储
this.projects = [
{ id: 'p1', name: '飞行器1' },
{ id: 'p2', name: '飞行器2' }
{ id: 'p1', name: '项目1' },
{ id: 'p2', name: '项目2' }
];
this.aircrafts = [
{ id: 'a1', name: '飞行器配置1', projectId: 'p1' },
@@ -45,9 +46,12 @@ class ConfigPanel {
{ id: 'cfg3', name: '配置1', fileName: 'docker-compose.yml', content: '# 配置1内容', containerId: 'c2' },
{ id: 'cfg4', name: '配置1', fileName: 'config.yaml', content: '# 配置1内容', containerId: 'c3' }
];
// 项目存储路径映射
this.projectPaths = new Map();
this.panel = panel;
this.extensionUri = extensionUri;
// 初始化各个视图
this.projectManagementView = new ProjectManagementView_1.ProjectManagementView(extensionUri);
this.projectListView = new ProjectListView_1.ProjectListView(extensionUri);
this.aircraftConfigView = new AircraftConfigView_1.AircraftConfigView(extensionUri);
this.containerConfigView = new ContainerConfigView_1.ContainerConfigView(extensionUri);
@@ -60,6 +64,20 @@ class ConfigPanel {
setupMessageListener() {
this.panel.webview.onDidReceiveMessage(async (data) => {
switch (data.type) {
case 'configureProject':
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
if (selectedPath) {
this.currentView = 'projects';
this.currentProjectId = data.projectId;
this.updateWebview();
}
break;
case 'openProject':
// 已配置的项目直接打开
this.currentView = 'projects';
this.currentProjectId = data.projectId;
this.updateWebview();
break;
case 'openAircraftConfig':
this.currentView = 'aircrafts';
this.currentProjectId = data.projectId;
@@ -75,6 +93,10 @@ class ConfigPanel {
this.currentContainerId = data.containerId;
this.updateWebview();
break;
case 'goBackToManagement':
this.currentView = 'management';
this.updateWebview();
break;
case 'goBackToProjects':
this.currentView = 'projects';
this.updateWebview();
@@ -98,11 +120,14 @@ class ConfigPanel {
case 'updateConfigName':
this.updateConfigName(data.configId, data.name);
break;
case 'updateConfigFileName':
await this.updateConfigFileName(data.configId, data.fileName);
break;
case 'createConfig':
this.createConfig(data.name);
break;
case 'saveConfigFile':
this.saveConfigFile(data.configId, data.content);
await this.saveConfigFileToDisk(data.configId, data.content);
break;
case 'loadConfigFile':
this.loadConfigFile(data.configId);
@@ -113,12 +138,83 @@ class ConfigPanel {
case 'deleteContainer':
this.deleteContainer(data.containerId);
break;
case 'deleteConfig': // 新增:删除配置文件的处理
case 'deleteConfig':
this.deleteConfig(data.configId);
break;
}
});
}
// === 项目路径选择 ===
async selectProjectPath(projectId, projectName) {
try {
// 提供两种方式:选择现有路径或输入新路径
const choice = await vscode.window.showQuickPick([
{
label: '$(folder) 选择现有文件夹',
description: '从文件系统中选择已存在的文件夹',
value: 'select'
},
{
label: '$(new-folder) 创建新文件夹',
description: '输入新文件夹路径(将自动创建)',
value: 'create'
}
], {
placeHolder: '选择项目存储方式'
});
if (!choice) {
return null;
}
if (choice.value === 'select') {
// 选择现有路径
const result = await vscode.window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
openLabel: `选择 ${projectName} 的存储位置`,
title: `为项目 "${projectName}" 选择存储文件夹`
});
if (result && result.length > 0) {
const selectedPath = result[0].fsPath;
this.projectPaths.set(projectId, selectedPath);
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
return selectedPath;
}
}
else {
// 创建新路径
const pathInput = await vscode.window.showInputBox({
prompt: '请输入项目存储路径(绝对路径)',
placeHolder: `/path/to/your/project/${projectName}`,
validateInput: (value) => {
if (!value) {
return '路径不能为空';
}
return null;
}
});
if (pathInput) {
try {
// 尝试创建目录
const dirUri = vscode.Uri.file(pathInput);
await vscode.workspace.fs.createDirectory(dirUri);
this.projectPaths.set(projectId, pathInput);
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
return pathInput;
}
catch (error) {
vscode.window.showErrorMessage(`创建目录失败: ${error}`);
return null;
}
}
}
return null;
}
catch (error) {
vscode.window.showErrorMessage(`选择存储路径时出错: ${error}`);
return null;
}
}
// === 项目相关方法 ===
updateProjectName(projectId, newName) {
const project = this.projects.find(p => p.id === projectId);
@@ -157,6 +253,8 @@ class ConfigPanel {
// 删除相关的配置
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}`);
this.updateWebview();
}
@@ -220,6 +318,15 @@ class ConfigPanel {
this.updateWebview();
}
}
async updateConfigFileName(configId, fileName) {
const config = this.configs.find(c => c.id === configId);
if (config) {
config.fileName = fileName;
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
this.updateWebview();
}
}
// 创建配置文件
createConfig(name) {
const newId = 'cfg' + (this.configs.length + 1);
const newConfig = {
@@ -233,7 +340,7 @@ class ConfigPanel {
vscode.window.showInformationMessage(`新建配置: ${name}`);
this.updateWebview();
}
// 新增:删除配置文件方法
// 删除配置文件
deleteConfig(configId) {
const config = this.configs.find(c => c.id === configId);
if (config) {
@@ -242,13 +349,62 @@ class ConfigPanel {
this.updateWebview();
}
}
saveConfigFile(configId, content) {
const config = this.configs.find(c => c.id === configId);
if (config) {
config.content = content;
vscode.window.showInformationMessage(`配置文件已保存: ${config.name}`);
// 保存配置文件到磁盘
async saveConfigFileToDisk(configId, content) {
try {
const config = this.configs.find(c => c.id === configId);
if (!config) {
vscode.window.showErrorMessage('未找到配置文件');
return;
}
const container = this.containers.find(c => c.id === config.containerId);
if (!container) {
vscode.window.showErrorMessage('未找到容器');
return;
}
const aircraft = this.aircrafts.find(a => a.id === container.aircraftId);
if (!aircraft) {
vscode.window.showErrorMessage('未找到飞行器');
return;
}
const project = this.projects.find(p => p.id === aircraft.projectId);
if (!project) {
vscode.window.showErrorMessage('未找到项目');
return;
}
const projectPath = this.projectPaths.get(aircraft.projectId);
if (!projectPath) {
vscode.window.showErrorMessage('未设置项目存储路径,请先配置项目');
return;
}
// 构建文件路径:项目路径/飞行器名/容器名/文件名
const aircraftDir = vscode.Uri.joinPath(vscode.Uri.file(projectPath), aircraft.name);
const containerDir = vscode.Uri.joinPath(aircraftDir, container.name);
const fileUri = vscode.Uri.joinPath(containerDir, config.fileName);
// 确保飞行器目录存在
try {
await vscode.workspace.fs.createDirectory(aircraftDir);
}
catch (error) {
// 目录可能已存在,忽略错误
}
// 确保容器目录存在
try {
await vscode.workspace.fs.createDirectory(containerDir);
}
catch (error) {
// 目录可能已存在,忽略错误
}
// 写入文件
const uint8Array = new TextEncoder().encode(content);
await vscode.workspace.fs.writeFile(fileUri, uint8Array);
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
}
catch (error) {
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
}
}
// 加载配置文件
loadConfigFile(configId) {
const config = this.configs.find(c => c.id === configId);
if (config) {
@@ -264,11 +420,17 @@ class ConfigPanel {
});
}
}
// 更新视图
updateWebview() {
this.panel.webview.html = this.getWebviewContent();
}
getWebviewContent() {
switch (this.currentView) {
case 'management':
return this.projectManagementView.render({
projects: this.projects,
projectPaths: this.projectPaths
});
case 'projects':
return this.projectListView.render({
projects: this.projects
@@ -292,8 +454,9 @@ class ConfigPanel {
configs: containerConfigs
});
default:
return this.projectListView.render({
projects: this.projects
return this.projectManagementView.render({
projects: this.projects,
projectPaths: this.projectPaths
});
}
}

File diff suppressed because one or more lines are too long

View File

@@ -7,14 +7,14 @@ class ContainerConfigView extends BaseView_1.BaseView {
render(data) {
const container = data?.container;
const configs = data?.configs || [];
// 生成配置列表的 HTML - 添加删除按钮
// 生成配置列表的 HTML - 添加文件名编辑功能
const configsHtml = configs.map((config) => `
<tr>
<td>
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
</td>
<td>
<span class="clickable" onclick="openConfigFile('${config.id}')">${config.fileName}</span>
<span class="editable" onclick="editFileName('${config.id}', '${config.fileName}')">📄 ${config.fileName}</span>
</td>
<td>
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
@@ -38,9 +38,9 @@ class ContainerConfigView extends BaseView_1.BaseView {
<table class="table">
<thead>
<tr>
<th width="40%">配置</th>
<th width="30%">配置</th>
<th width="40%">文件</th>
<th width="20%">操作</th>
<th width="30%">操作</th>
</tr>
</thead>
<tbody>
@@ -58,7 +58,7 @@ class ContainerConfigView extends BaseView_1.BaseView {
<h3>📝 编辑配置文件</h3>
<textarea id="configContent" placeholder="在此编辑配置文件内容..."></textarea>
<div style="margin-top: 15px;">
<button class="btn-primary" onclick="saveConfigFile()">💾 保存</button>
<button class="btn-primary" onclick="saveConfigFile()">💾 保存到文件系统</button>
<button class="back-btn" onclick="closeEditor()">取消</button>
</div>
</div>
@@ -84,6 +84,23 @@ class ContainerConfigView 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) {
currentConfigId = configId;
document.getElementById('configEditor').style.display = 'block';
@@ -110,7 +127,6 @@ class ContainerConfigView extends BaseView_1.BaseView {
);
}
// 新增:删除配置函数
function deleteConfig(configId) {
showConfirmDialog(
'确认删除',
@@ -232,6 +248,20 @@ class ContainerConfigView extends BaseView_1.BaseView {
document.getElementById('configContent').value = message.content;
}
});
// 修改:点击文件名时打开编辑器
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>
</body>
</html>`;

View File

@@ -1 +1 @@
{"version":3,"file":"ContainerConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/ContainerConfigView.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,yCAAsC;AAGtC,MAAa,mBAAoB,SAAQ,mBAAQ;IAC7C,MAAM,CAAC,IAA0B;QAC7B,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;QAEpC,wBAAwB;QACxB,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,OAAO,MAAM,CAAC,QAAQ;;;wEAG9B,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8LjB,CAAC;IACL,CAAC;CACJ;AA3OD,kDA2OC"}
{"version":3,"file":"ContainerConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/ContainerConfigView.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,yCAAsC;AAGtC,MAAa,mBAAoB,SAAQ,mBAAQ;IAC7C,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,kDAyQC"}

View File

@@ -25,11 +25,14 @@ class ProjectListView extends BaseView_1.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>
<h2>🚀 飞行器项目管理</h2>
<div class="header">
<h2>🚀 飞行器项目管理</h2>
<button class="back-btn" onclick="goBackToManagement()">← 返回项目管理</button>
</div>
<table class="table">
<thead>
<tr>
@@ -107,6 +110,10 @@ class ProjectListView extends BaseView_1.BaseView {
);
}
function goBackToManagement() {
vscode.postMessage({ type: 'goBackToManagement' });
}
// 对话框函数(与之前相同)
function showConfirmDialog(title, message, onConfirm, onCancel) {
const overlay = document.createElement('div');

View File

@@ -1 +1 @@
{"version":3,"file":"ProjectListView.js","sourceRoot":"","sources":["../../../src/panels/views/ProjectListView.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,yCAAsC;AAGtC,MAAa,eAAgB,SAAQ,mBAAQ;IACzC,MAAM,CAAC,IAAsB;QACzB,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC;QAEtC,eAAe;QACf,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE,CAAC;;;uEAGD,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC,IAAI,UAAU,OAAO,CAAC,IAAI;;;2EAG/C,OAAO,CAAC,EAAE;;;yEAGZ,OAAO,CAAC,EAAE;;;SAG1E,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;;;;;;;;;;cAaR,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqJlB,CAAC;IACL,CAAC;CACJ;AA7LD,0CA6LC"}
{"version":3,"file":"ProjectListView.js","sourceRoot":"","sources":["../../../src/panels/views/ProjectListView.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,yCAAsC;AAGtC,MAAa,eAAgB,SAAQ,mBAAQ;IACzC,MAAM,CAAC,IAAsB;QACzB,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC;QAEtC,eAAe;QACf,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE,CAAC;;;uEAGD,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC,IAAI,UAAU,OAAO,CAAC,IAAI;;;2EAG/C,OAAO,CAAC,EAAE;;;yEAGZ,OAAO,CAAC,EAAE;;;SAG1E,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;;;;;;;;;;;;;cAgBR,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyJlB,CAAC;IACL,CAAC;CACJ;AApMD,0CAoMC"}

View File

@@ -0,0 +1,256 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProjectManagementView = void 0;
// src/panels/views/ProjectManagementView.ts
const BaseView_1 = require("./BaseView");
class ProjectManagementView extends BaseView_1.BaseView {
render(data) {
const projects = data?.projects || [];
const projectPaths = data?.projectPaths || new Map();
const projectsHtml = projects.map((project) => {
const isConfigured = projectPaths.has(project.id);
const statusIcon = isConfigured ? '✅' : '⚙️';
const statusText = isConfigured ? '已配置' : '待配置';
return `
<tr>
<td>
<span class="project-name" data-project-id="${project.id}">${statusIcon} ${project.name}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
${statusText}${isConfigured ? ` - ${projectPaths.get(project.id)}` : ''}
</div>
</td>
<td>
<span class="clickable" onclick="configureProject('${project.id}', '${project.name}', ${isConfigured})">
${isConfigured ? '打开' : '配置'}
</span>
</td>
<td>
<button class="btn-delete" onclick="deleteProject('${project.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">
<title>数字卫星构建平台</title>
${this.getStyles()}
<style>
.satellite-icon {
font-size: 2.5em;
vertical-align: middle;
margin-right: 10px;
line-height: 1;
display: inline-block;
position: relative;
top: -5px;
}
.header-title {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
}
.project-name {
cursor: pointer;
padding: 4px 8px;
border-radius: 4px;
transition: background-color 0.2s;
}
.project-name:hover {
background: var(--vscode-input-background);
}
</style>
</head>
<body>
<h2><span class="satellite-icon">🛰️</span>数字卫星构建平台</h2>
<table class="table">
<thead>
<tr>
<th width="40%">项目</th>
<th width="40%">配置</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
${projectsHtml}
<tr>
<td colspan="3" style="text-align: center; padding: 20px;">
<button class="btn-new" onclick="createNewProject()">+ 新建项目</button>
</td>
</tr>
</tbody>
</table>
<script>
const vscode = acquireVsCodeApi();
function configureProject(projectId, projectName, isConfigured) {
if (isConfigured) {
// 已配置的项目直接打开
vscode.postMessage({
type: 'openProject',
projectId: projectId
});
} else {
// 未配置的项目需要设置路径
vscode.postMessage({
type: 'configureProject',
projectId: projectId,
projectName: projectName
});
}
}
function createNewProject() {
showPromptDialog(
'新建项目',
'请输入项目名称:',
'',
function(name) {
if (name) {
vscode.postMessage({
type: 'createProject',
name: name
});
}
}
);
}
function deleteProject(projectId) {
showConfirmDialog(
'确认删除',
'确定删除这个项目吗?',
function() {
vscode.postMessage({
type: 'deleteProject',
projectId: projectId
});
},
function() {
// 用户取消删除
}
);
}
// 项目名称编辑功能 - 修复版本
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('click', function(event) {
if (event.target.classList.contains('project-name')) {
const projectNameElement = event.target;
const projectId = projectNameElement.getAttribute('data-project-id');
const currentName = projectNameElement.textContent.trim().split(' ').slice(1).join(' ');
if (projectId) {
editProjectName(projectId, currentName);
}
}
});
});
function editProjectName(projectId, currentName) {
showPromptDialog(
'修改项目名称',
'请输入新的项目名称:',
currentName,
function(newName) {
if (newName && newName !== currentName) {
vscode.postMessage({
type: 'updateProjectName',
projectId: projectId,
name: newName
});
}
}
);
}
// 对话框函数 - 只保留一份
function showConfirmDialog(title, message, onConfirm, onCancel) {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.id = 'confirmModal';
overlay.innerHTML = \`
<div class="modal-dialog">
<div class="modal-title">\${title}</div>
<div>\${message}</div>
<div class="modal-buttons">
<button class="modal-btn modal-btn-secondary" onclick="closeConfirmDialog(false)">取消</button>
<button class="modal-btn modal-btn-primary" onclick="closeConfirmDialog(true)">确定</button>
</div>
</div>
\`;
document.body.appendChild(overlay);
window.confirmCallback = function(result) {
if (result && onConfirm) {
onConfirm();
} else if (!result && onCancel) {
onCancel();
}
delete window.confirmCallback;
};
}
function closeConfirmDialog(result) {
const modal = document.getElementById('confirmModal');
if (modal) {
modal.remove();
}
if (window.confirmCallback) {
window.confirmCallback(result);
}
}
function showPromptDialog(title, message, defaultValue, onConfirm) {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.id = 'promptModal';
overlay.innerHTML = \`
<div class="modal-dialog">
<div class="modal-title">\${title}</div>
<div>\${message}</div>
<input type="text" id="promptInput" value="\${defaultValue}" style="width: 100%; margin: 10px 0; padding: 6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border);">
<div class="modal-buttons">
<button class="modal-btn modal-btn-secondary" onclick="closePromptDialog(null)">取消</button>
<button class="modal-btn modal-btn-primary" onclick="closePromptDialog(document.getElementById('promptInput').value)">确定</button>
</div>
</div>
\`;
document.body.appendChild(overlay);
setTimeout(() => {
const input = document.getElementById('promptInput');
if (input) {
input.focus();
input.select();
}
}, 100);
window.promptCallback = onConfirm;
}
function closePromptDialog(result) {
const modal = document.getElementById('promptModal');
if (modal) {
modal.remove();
}
if (window.promptCallback) {
window.promptCallback(result);
}
delete window.promptCallback;
}
</script>
</body>
</html>`;
}
}
exports.ProjectManagementView = ProjectManagementView;
//# sourceMappingURL=ProjectManagementView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ProjectManagementView.js","sourceRoot":"","sources":["../../../src/panels/views/ProjectManagementView.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,yCAAsC;AAGtC,MAAa,qBAAsB,SAAQ,mBAAQ;IAC/C,MAAM,CAAC,IAA0E;QAC7E,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC;QACtC,MAAM,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,IAAI,GAAG,EAAE,CAAC;QAErD,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE;YAC3D,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7C,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YAEhD,OAAO;;;kEAG+C,OAAO,CAAC,EAAE,KAAK,UAAU,IAAI,OAAO,CAAC,IAAI;;0BAEjF,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;;;;yEAItB,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC,IAAI,MAAM,YAAY;0BAC9F,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;;;;yEAIqB,OAAO,CAAC,EAAE;;;SAG1E,CAAA;QAAA,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEb,OAAO;;;;;;MAMT,IAAI,CAAC,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuCR,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8KlB,CAAC;IACL,CAAC;CACJ;AA1PD,sDA0PC"}

View File

@@ -1,5 +1,6 @@
// 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';
@@ -35,15 +36,15 @@ export class ConfigPanel {
private readonly panel: vscode.WebviewPanel;
private readonly extensionUri: vscode.Uri;
private currentView: 'projects' | 'aircrafts' | 'container' = 'projects';
private currentView: 'management' | 'projects' | 'aircrafts' | 'container' = 'management';
private currentProjectId: string = '';
private currentAircraftId: string = '';
private currentContainerId: string = '';
// 数据存储
private projects: Project[] = [
{ id: 'p1', name: '飞行器1' },
{ id: 'p2', name: '飞行器2' }
{ id: 'p1', name: '项目1' },
{ id: 'p2', name: '项目2' }
];
private aircrafts: Aircraft[] = [
@@ -64,7 +65,11 @@ export class ConfigPanel {
{ id: 'cfg4', name: '配置1', fileName: 'config.yaml', content: '# 配置1内容', containerId: 'c3' }
];
// 项目存储路径映射
private projectPaths: Map<string, string> = new Map();
// 视图实例
private readonly projectManagementView: ProjectManagementView;
private readonly projectListView: ProjectListView;
private readonly aircraftConfigView: AircraftConfigView;
private readonly containerConfigView: ContainerConfigView;
@@ -96,6 +101,7 @@ 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);
@@ -111,6 +117,22 @@ export class ConfigPanel {
private setupMessageListener() {
this.panel.webview.onDidReceiveMessage(async (data) => {
switch (data.type) {
case 'configureProject':
const selectedPath = await this.selectProjectPath(data.projectId, data.projectName);
if (selectedPath) {
this.currentView = 'projects';
this.currentProjectId = data.projectId;
this.updateWebview();
}
break;
case 'openProject':
// 已配置的项目直接打开
this.currentView = 'projects';
this.currentProjectId = data.projectId;
this.updateWebview();
break;
case 'openAircraftConfig':
this.currentView = 'aircrafts';
this.currentProjectId = data.projectId;
@@ -128,6 +150,11 @@ export class ConfigPanel {
this.updateWebview();
break;
case 'goBackToManagement':
this.currentView = 'management';
this.updateWebview();
break;
case 'goBackToProjects':
this.currentView = 'projects';
this.updateWebview();
@@ -158,12 +185,16 @@ export class ConfigPanel {
this.updateConfigName(data.configId, data.name);
break;
case 'updateConfigFileName':
await this.updateConfigFileName(data.configId, data.fileName);
break;
case 'createConfig':
this.createConfig(data.name);
break;
case 'saveConfigFile':
this.saveConfigFile(data.configId, data.content);
await this.saveConfigFileToDisk(data.configId, data.content);
break;
case 'loadConfigFile':
@@ -178,13 +209,91 @@ export class ConfigPanel {
this.deleteContainer(data.containerId);
break;
case 'deleteConfig': // 新增:删除配置文件的处理
case 'deleteConfig':
this.deleteConfig(data.configId);
break;
}
});
}
// === 项目路径选择 ===
private async selectProjectPath(projectId: string, projectName: string): Promise<string | null> {
try {
// 提供两种方式:选择现有路径或输入新路径
const choice = await vscode.window.showQuickPick(
[
{
label: '$(folder) 选择现有文件夹',
description: '从文件系统中选择已存在的文件夹',
value: 'select'
},
{
label: '$(new-folder) 创建新文件夹',
description: '输入新文件夹路径(将自动创建)',
value: 'create'
}
],
{
placeHolder: '选择项目存储方式'
}
);
if (!choice) {
return null;
}
if (choice.value === 'select') {
// 选择现有路径
const result = await vscode.window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
openLabel: `选择 ${projectName} 的存储位置`,
title: `为项目 "${projectName}" 选择存储文件夹`
});
if (result && result.length > 0) {
const selectedPath = result[0].fsPath;
this.projectPaths.set(projectId, selectedPath);
vscode.window.showInformationMessage(`项目存储位置已设置: ${selectedPath}`);
return selectedPath;
}
} else {
// 创建新路径
const pathInput = await vscode.window.showInputBox({
prompt: '请输入项目存储路径(绝对路径)',
placeHolder: `/path/to/your/project/${projectName}`,
validateInput: (value) => {
if (!value) {
return '路径不能为空';
}
return null;
}
});
if (pathInput) {
try {
// 尝试创建目录
const dirUri = vscode.Uri.file(pathInput);
await vscode.workspace.fs.createDirectory(dirUri);
this.projectPaths.set(projectId, pathInput);
vscode.window.showInformationMessage(`项目存储位置已创建: ${pathInput}`);
return pathInput;
} catch (error) {
vscode.window.showErrorMessage(`创建目录失败: ${error}`);
return null;
}
}
}
return null;
} catch (error) {
vscode.window.showErrorMessage(`选择存储路径时出错: ${error}`);
return null;
}
}
// === 项目相关方法 ===
private updateProjectName(projectId: string, newName: string) {
const project = this.projects.find(p => p.id === projectId);
@@ -231,6 +340,9 @@ export class ConfigPanel {
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}`);
this.updateWebview();
}
@@ -308,6 +420,15 @@ export class ConfigPanel {
}
}
private async updateConfigFileName(configId: string, fileName: string): Promise<void> {
const config = this.configs.find(c => c.id === configId);
if (config) {
config.fileName = fileName;
vscode.window.showInformationMessage(`文件名更新: ${fileName}`);
this.updateWebview();
}
}
// 创建配置文件
private createConfig(name: string) {
const newId = 'cfg' + (this.configs.length + 1);
@@ -334,12 +455,65 @@ export class ConfigPanel {
}
}
// 保存配置文件
private saveConfigFile(configId: string, content: string) {
const config = this.configs.find(c => c.id === configId);
if (config) {
config.content = content;
vscode.window.showInformationMessage(`配置文件已保存: ${config.name}`);
// 保存配置文件到磁盘
private async saveConfigFileToDisk(configId: string, content: string): Promise<void> {
try {
const config = this.configs.find(c => c.id === configId);
if (!config) {
vscode.window.showErrorMessage('未找到配置文件');
return;
}
const container = this.containers.find(c => c.id === config.containerId);
if (!container) {
vscode.window.showErrorMessage('未找到容器');
return;
}
const aircraft = this.aircrafts.find(a => a.id === container.aircraftId);
if (!aircraft) {
vscode.window.showErrorMessage('未找到飞行器');
return;
}
const project = this.projects.find(p => p.id === aircraft.projectId);
if (!project) {
vscode.window.showErrorMessage('未找到项目');
return;
}
const projectPath = this.projectPaths.get(aircraft.projectId);
if (!projectPath) {
vscode.window.showErrorMessage('未设置项目存储路径,请先配置项目');
return;
}
// 构建文件路径:项目路径/飞行器名/容器名/文件名
const aircraftDir = vscode.Uri.joinPath(vscode.Uri.file(projectPath), aircraft.name);
const containerDir = vscode.Uri.joinPath(aircraftDir, container.name);
const fileUri = vscode.Uri.joinPath(containerDir, config.fileName);
// 确保飞行器目录存在
try {
await vscode.workspace.fs.createDirectory(aircraftDir);
} catch (error) {
// 目录可能已存在,忽略错误
}
// 确保容器目录存在
try {
await vscode.workspace.fs.createDirectory(containerDir);
} catch (error) {
// 目录可能已存在,忽略错误
}
// 写入文件
const uint8Array = new TextEncoder().encode(content);
await vscode.workspace.fs.writeFile(fileUri, uint8Array);
vscode.window.showInformationMessage(`配置文件已保存: ${fileUri.fsPath}`);
} catch (error) {
vscode.window.showErrorMessage(`保存文件时出错: ${error}`);
}
}
@@ -366,6 +540,11 @@ export class ConfigPanel {
private getWebviewContent(): string {
switch (this.currentView) {
case 'management':
return this.projectManagementView.render({
projects: this.projects,
projectPaths: this.projectPaths
});
case 'projects':
return this.projectListView.render({
projects: this.projects
@@ -393,8 +572,9 @@ export class ConfigPanel {
configs: containerConfigs
});
default:
return this.projectListView.render({
projects: this.projects
return this.projectManagementView.render({
projects: this.projects,
projectPaths: this.projectPaths
});
}
}

View File

@@ -7,14 +7,14 @@ export class ContainerConfigView extends BaseView {
const container = data?.container;
const configs = data?.configs || [];
// 生成配置列表的 HTML - 添加删除按钮
// 生成配置列表的 HTML - 添加文件名编辑功能
const configsHtml = configs.map((config: ConfigViewData) => `
<tr>
<td>
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
</td>
<td>
<span class="clickable" onclick="openConfigFile('${config.id}')">${config.fileName}</span>
<span class="editable" onclick="editFileName('${config.id}', '${config.fileName}')">📄 ${config.fileName}</span>
</td>
<td>
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
@@ -39,9 +39,9 @@ export class ContainerConfigView extends BaseView {
<table class="table">
<thead>
<tr>
<th width="40%">配置</th>
<th width="30%">配置</th>
<th width="40%">文件</th>
<th width="20%">操作</th>
<th width="30%">操作</th>
</tr>
</thead>
<tbody>
@@ -59,7 +59,7 @@ export class ContainerConfigView extends BaseView {
<h3>📝 编辑配置文件</h3>
<textarea id="configContent" placeholder="在此编辑配置文件内容..."></textarea>
<div style="margin-top: 15px;">
<button class="btn-primary" onclick="saveConfigFile()">💾 保存</button>
<button class="btn-primary" onclick="saveConfigFile()">💾 保存到文件系统</button>
<button class="back-btn" onclick="closeEditor()">取消</button>
</div>
</div>
@@ -85,6 +85,23 @@ export class ContainerConfigView 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) {
currentConfigId = configId;
document.getElementById('configEditor').style.display = 'block';
@@ -111,7 +128,6 @@ export class ContainerConfigView extends BaseView {
);
}
// 新增:删除配置函数
function deleteConfig(configId) {
showConfirmDialog(
'确认删除',
@@ -233,6 +249,20 @@ export class ContainerConfigView extends BaseView {
document.getElementById('configContent').value = message.content;
}
});
// 修改:点击文件名时打开编辑器
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>
</body>
</html>`;

View File

@@ -26,11 +26,14 @@ export class ProjectListView 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>
<h2>🚀 飞行器项目管理</h2>
<div class="header">
<h2>🚀 飞行器项目管理</h2>
<button class="back-btn" onclick="goBackToManagement()">← 返回项目管理</button>
</div>
<table class="table">
<thead>
<tr>
@@ -108,6 +111,10 @@ export class ProjectListView extends BaseView {
);
}
function goBackToManagement() {
vscode.postMessage({ type: 'goBackToManagement' });
}
// 对话框函数(与之前相同)
function showConfirmDialog(title, message, onConfirm, onCancel) {
const overlay = document.createElement('div');

View File

@@ -0,0 +1,255 @@
// src/panels/views/ProjectManagementView.ts
import { BaseView } from './BaseView';
import { ProjectViewData } from '../types/ViewTypes';
export class ProjectManagementView extends BaseView {
render(data?: { projects: ProjectViewData[], projectPaths?: Map<string, string> }): string {
const projects = data?.projects || [];
const projectPaths = data?.projectPaths || new Map();
const projectsHtml = projects.map((project: ProjectViewData) => {
const isConfigured = projectPaths.has(project.id);
const statusIcon = isConfigured ? '✅' : '⚙️';
const statusText = isConfigured ? '已配置' : '待配置';
return `
<tr>
<td>
<span class="project-name" data-project-id="${project.id}">${statusIcon} ${project.name}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
${statusText}${isConfigured ? ` - ${projectPaths.get(project.id)}` : ''}
</div>
</td>
<td>
<span class="clickable" onclick="configureProject('${project.id}', '${project.name}', ${isConfigured})">
${isConfigured ? '打开' : '配置'}
</span>
</td>
<td>
<button class="btn-delete" onclick="deleteProject('${project.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">
<title>数字卫星构建平台</title>
${this.getStyles()}
<style>
.satellite-icon {
font-size: 2.5em;
vertical-align: middle;
margin-right: 10px;
line-height: 1;
display: inline-block;
position: relative;
top: -5px;
}
.header-title {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
}
.project-name {
cursor: pointer;
padding: 4px 8px;
border-radius: 4px;
transition: background-color 0.2s;
}
.project-name:hover {
background: var(--vscode-input-background);
}
</style>
</head>
<body>
<h2><span class="satellite-icon">🛰️</span>数字卫星构建平台</h2>
<table class="table">
<thead>
<tr>
<th width="40%">项目</th>
<th width="40%">配置</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
${projectsHtml}
<tr>
<td colspan="3" style="text-align: center; padding: 20px;">
<button class="btn-new" onclick="createNewProject()">+ 新建项目</button>
</td>
</tr>
</tbody>
</table>
<script>
const vscode = acquireVsCodeApi();
function configureProject(projectId, projectName, isConfigured) {
if (isConfigured) {
// 已配置的项目直接打开
vscode.postMessage({
type: 'openProject',
projectId: projectId
});
} else {
// 未配置的项目需要设置路径
vscode.postMessage({
type: 'configureProject',
projectId: projectId,
projectName: projectName
});
}
}
function createNewProject() {
showPromptDialog(
'新建项目',
'请输入项目名称:',
'',
function(name) {
if (name) {
vscode.postMessage({
type: 'createProject',
name: name
});
}
}
);
}
function deleteProject(projectId) {
showConfirmDialog(
'确认删除',
'确定删除这个项目吗?',
function() {
vscode.postMessage({
type: 'deleteProject',
projectId: projectId
});
},
function() {
// 用户取消删除
}
);
}
// 项目名称编辑功能 - 修复版本
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('click', function(event) {
if (event.target.classList.contains('project-name')) {
const projectNameElement = event.target;
const projectId = projectNameElement.getAttribute('data-project-id');
const currentName = projectNameElement.textContent.trim().split(' ').slice(1).join(' ');
if (projectId) {
editProjectName(projectId, currentName);
}
}
});
});
function editProjectName(projectId, currentName) {
showPromptDialog(
'修改项目名称',
'请输入新的项目名称:',
currentName,
function(newName) {
if (newName && newName !== currentName) {
vscode.postMessage({
type: 'updateProjectName',
projectId: projectId,
name: newName
});
}
}
);
}
// 对话框函数 - 只保留一份
function showConfirmDialog(title, message, onConfirm, onCancel) {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.id = 'confirmModal';
overlay.innerHTML = \`
<div class="modal-dialog">
<div class="modal-title">\${title}</div>
<div>\${message}</div>
<div class="modal-buttons">
<button class="modal-btn modal-btn-secondary" onclick="closeConfirmDialog(false)">取消</button>
<button class="modal-btn modal-btn-primary" onclick="closeConfirmDialog(true)">确定</button>
</div>
</div>
\`;
document.body.appendChild(overlay);
window.confirmCallback = function(result) {
if (result && onConfirm) {
onConfirm();
} else if (!result && onCancel) {
onCancel();
}
delete window.confirmCallback;
};
}
function closeConfirmDialog(result) {
const modal = document.getElementById('confirmModal');
if (modal) {
modal.remove();
}
if (window.confirmCallback) {
window.confirmCallback(result);
}
}
function showPromptDialog(title, message, defaultValue, onConfirm) {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.id = 'promptModal';
overlay.innerHTML = \`
<div class="modal-dialog">
<div class="modal-title">\${title}</div>
<div>\${message}</div>
<input type="text" id="promptInput" value="\${defaultValue}" style="width: 100%; margin: 10px 0; padding: 6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border);">
<div class="modal-buttons">
<button class="modal-btn modal-btn-secondary" onclick="closePromptDialog(null)">取消</button>
<button class="modal-btn modal-btn-primary" onclick="closePromptDialog(document.getElementById('promptInput').value)">确定</button>
</div>
</div>
\`;
document.body.appendChild(overlay);
setTimeout(() => {
const input = document.getElementById('promptInput');
if (input) {
input.focus();
input.select();
}
}, 100);
window.promptCallback = onConfirm;
}
function closePromptDialog(result) {
const modal = document.getElementById('promptModal');
if (modal) {
modal.remove();
}
if (window.promptCallback) {
window.promptCallback(result);
}
delete window.promptCallback;
}
</script>
</body>
</html>`;
}
}