第一次提交vscode插件代码
This commit is contained in:
16
out/extension.js
Normal file
16
out/extension.js
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.deactivate = exports.activate = void 0;
|
||||
const vscode = require("vscode");
|
||||
const ConfigPanel_1 = require("./panels/ConfigPanel");
|
||||
function activate(context) {
|
||||
console.log('数字卫星构建平台已激活');
|
||||
let disposable = vscode.commands.registerCommand('open_DSCP', () => {
|
||||
ConfigPanel_1.ConfigPanel.createOrShow(context.extensionUri);
|
||||
});
|
||||
context.subscriptions.push(disposable);
|
||||
}
|
||||
exports.activate = activate;
|
||||
function deactivate() { }
|
||||
exports.deactivate = deactivate;
|
||||
//# sourceMappingURL=extension.js.map
|
||||
1
out/extension.js.map
Normal file
1
out/extension.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,sDAAmD;AAEnD,SAAgB,QAAQ,CAAC,OAAgC;IACrD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAE3B,IAAI,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,WAAW,EAAE,GAAG,EAAE;QAC/D,yBAAW,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC;AARD,4BAQC;AAED,SAAgB,UAAU,KAAI,CAAC;AAA/B,gCAA+B"}
|
||||
302
out/panels/ConfigPanel.js
Normal file
302
out/panels/ConfigPanel.js
Normal file
@@ -0,0 +1,302 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConfigPanel = void 0;
|
||||
// src/panels/ConfigPanel.ts
|
||||
const vscode = require("vscode");
|
||||
const ProjectListView_1 = require("./views/ProjectListView");
|
||||
const AircraftConfigView_1 = require("./views/AircraftConfigView");
|
||||
const ContainerConfigView_1 = require("./views/ContainerConfigView");
|
||||
class ConfigPanel {
|
||||
static createOrShow(extensionUri) {
|
||||
const column = vscode.window.activeTextEditor?.viewColumn || vscode.ViewColumn.One;
|
||||
if (ConfigPanel.currentPanel) {
|
||||
ConfigPanel.currentPanel.panel.reveal(column);
|
||||
return;
|
||||
}
|
||||
const panel = vscode.window.createWebviewPanel('dockerConfigTest', 'Docker配置测试', column, {
|
||||
enableScripts: true,
|
||||
localResourceRoots: [extensionUri],
|
||||
retainContextWhenHidden: true
|
||||
});
|
||||
ConfigPanel.currentPanel = new ConfigPanel(panel, extensionUri);
|
||||
}
|
||||
constructor(panel, extensionUri) {
|
||||
this.currentView = 'projects';
|
||||
this.currentProjectId = '';
|
||||
this.currentAircraftId = '';
|
||||
this.currentContainerId = '';
|
||||
// 数据存储
|
||||
this.projects = [
|
||||
{ id: 'p1', name: '飞行器1' },
|
||||
{ id: 'p2', name: '飞行器2' }
|
||||
];
|
||||
this.aircrafts = [
|
||||
{ id: 'a1', name: '飞行器配置1', projectId: 'p1' },
|
||||
{ id: 'a2', name: '飞行器配置2', projectId: 'p2' }
|
||||
];
|
||||
this.containers = [
|
||||
{ id: 'c1', name: '容器1', aircraftId: 'a1' },
|
||||
{ id: 'c2', name: '容器2', aircraftId: 'a1' },
|
||||
{ id: 'c3', name: '容器1', aircraftId: 'a2' }
|
||||
];
|
||||
this.configs = [
|
||||
{ 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' }
|
||||
];
|
||||
this.panel = panel;
|
||||
this.extensionUri = extensionUri;
|
||||
// 初始化各个视图
|
||||
this.projectListView = new ProjectListView_1.ProjectListView(extensionUri);
|
||||
this.aircraftConfigView = new AircraftConfigView_1.AircraftConfigView(extensionUri);
|
||||
this.containerConfigView = new ContainerConfigView_1.ContainerConfigView(extensionUri);
|
||||
this.updateWebview();
|
||||
this.setupMessageListener();
|
||||
this.panel.onDidDispose(() => {
|
||||
ConfigPanel.currentPanel = undefined;
|
||||
});
|
||||
}
|
||||
setupMessageListener() {
|
||||
this.panel.webview.onDidReceiveMessage(async (data) => {
|
||||
switch (data.type) {
|
||||
case 'openAircraftConfig':
|
||||
this.currentView = 'aircrafts';
|
||||
this.currentProjectId = data.projectId;
|
||||
// 找到对应的飞行器ID
|
||||
const aircraft = this.aircrafts.find(a => a.projectId === data.projectId);
|
||||
if (aircraft) {
|
||||
this.currentAircraftId = aircraft.id;
|
||||
}
|
||||
this.updateWebview();
|
||||
break;
|
||||
case 'openContainerConfig':
|
||||
this.currentView = 'container';
|
||||
this.currentContainerId = data.containerId;
|
||||
this.updateWebview();
|
||||
break;
|
||||
case 'goBackToProjects':
|
||||
this.currentView = 'projects';
|
||||
this.updateWebview();
|
||||
break;
|
||||
case 'goBackToAircraft':
|
||||
this.currentView = 'aircrafts';
|
||||
this.updateWebview();
|
||||
break;
|
||||
case 'updateProjectName':
|
||||
this.updateProjectName(data.projectId, data.name);
|
||||
break;
|
||||
case 'createProject':
|
||||
this.createProject(data.name);
|
||||
break;
|
||||
case 'updateContainerName':
|
||||
this.updateContainerName(data.containerId, data.name);
|
||||
break;
|
||||
case 'createContainer':
|
||||
this.createContainer(data.name);
|
||||
break;
|
||||
case 'updateConfigName':
|
||||
this.updateConfigName(data.configId, data.name);
|
||||
break;
|
||||
case 'createConfig':
|
||||
this.createConfig(data.name);
|
||||
break;
|
||||
case 'saveConfigFile':
|
||||
this.saveConfigFile(data.configId, data.content);
|
||||
break;
|
||||
case 'loadConfigFile':
|
||||
this.loadConfigFile(data.configId);
|
||||
break;
|
||||
case 'deleteProject':
|
||||
this.deleteProject(data.projectId);
|
||||
break;
|
||||
case 'deleteContainer':
|
||||
this.deleteContainer(data.containerId);
|
||||
break;
|
||||
case 'deleteConfig': // 新增:删除配置文件的处理
|
||||
this.deleteConfig(data.configId);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
// === 项目相关方法 ===
|
||||
updateProjectName(projectId, newName) {
|
||||
const project = this.projects.find(p => p.id === projectId);
|
||||
if (project) {
|
||||
project.name = newName;
|
||||
vscode.window.showInformationMessage(`项目名称更新: ${newName}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
createProject(name) {
|
||||
const newId = 'p' + (this.projects.length + 1);
|
||||
const newProject = {
|
||||
id: newId,
|
||||
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();
|
||||
}
|
||||
deleteProject(projectId) {
|
||||
// 删除项目
|
||||
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));
|
||||
vscode.window.showInformationMessage(`删除项目: ${projectId}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
// === 容器相关方法 ===
|
||||
updateContainerName(containerId, newName) {
|
||||
const container = this.containers.find(c => c.id === containerId);
|
||||
if (container) {
|
||||
container.name = newName;
|
||||
vscode.window.showInformationMessage(`容器名称更新: ${newName}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
createContainer(name) {
|
||||
console.log('创建容器,当前飞行器ID:', this.currentAircraftId);
|
||||
if (!this.currentAircraftId) {
|
||||
vscode.window.showErrorMessage('无法创建容器:未找到当前飞行器');
|
||||
return;
|
||||
}
|
||||
const newId = 'c' + (this.containers.length + 1);
|
||||
const newContainer = {
|
||||
id: newId,
|
||||
name: name,
|
||||
aircraftId: this.currentAircraftId
|
||||
};
|
||||
this.containers.push(newContainer);
|
||||
// 创建两个默认配置文件
|
||||
const configCount = this.configs.length;
|
||||
// 第一个配置文件:Dockerfile
|
||||
this.configs.push({
|
||||
id: 'cfg' + (configCount + 1),
|
||||
name: 'Docker配置',
|
||||
fileName: 'Dockerfile',
|
||||
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',
|
||||
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
|
||||
});
|
||||
vscode.window.showInformationMessage(`新建容器: ${name} (包含2个默认配置文件)`);
|
||||
this.updateWebview();
|
||||
}
|
||||
deleteContainer(containerId) {
|
||||
// 删除容器
|
||||
this.containers = this.containers.filter(c => c.id !== containerId);
|
||||
// 删除相关的配置
|
||||
this.configs = this.configs.filter(cfg => cfg.containerId !== containerId);
|
||||
vscode.window.showInformationMessage(`删除容器: ${containerId}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
// === 配置相关方法 ===
|
||||
updateConfigName(configId, newName) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
config.name = newName;
|
||||
vscode.window.showInformationMessage(`配置名称更新: ${newName}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
createConfig(name) {
|
||||
const newId = 'cfg' + (this.configs.length + 1);
|
||||
const newConfig = {
|
||||
id: newId,
|
||||
name: name,
|
||||
fileName: name.toLowerCase().replace(/\s+/g, '_') + '.yaml',
|
||||
content: `# ${name} 配置文件\n# 创建时间: ${new Date().toLocaleString()}\n# 您可以在此编辑配置内容\n\n`,
|
||||
containerId: this.currentContainerId
|
||||
};
|
||||
this.configs.push(newConfig);
|
||||
vscode.window.showInformationMessage(`新建配置: ${name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
// 新增:删除配置文件方法
|
||||
deleteConfig(configId) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
this.configs = this.configs.filter(c => c.id !== configId);
|
||||
vscode.window.showInformationMessage(`删除配置: ${config.name}`);
|
||||
this.updateWebview();
|
||||
}
|
||||
}
|
||||
saveConfigFile(configId, content) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
config.content = content;
|
||||
vscode.window.showInformationMessage(`配置文件已保存: ${config.name}`);
|
||||
}
|
||||
}
|
||||
loadConfigFile(configId) {
|
||||
const config = this.configs.find(c => c.id === configId);
|
||||
if (config) {
|
||||
this.panel.webview.postMessage({
|
||||
type: 'configFileLoaded',
|
||||
content: config.content || `# ${config.name} 的配置文件\n# 您可以在此编辑配置内容\n\n`
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.panel.webview.postMessage({
|
||||
type: 'configFileLoaded',
|
||||
content: `# 这是 ${configId} 的配置文件\n# 您可以在此编辑配置内容\n\napp.name = "示例应用"\napp.port = 8080\napp.debug = true`
|
||||
});
|
||||
}
|
||||
}
|
||||
updateWebview() {
|
||||
this.panel.webview.html = this.getWebviewContent();
|
||||
}
|
||||
getWebviewContent() {
|
||||
switch (this.currentView) {
|
||||
case 'projects':
|
||||
return this.projectListView.render({
|
||||
projects: this.projects
|
||||
});
|
||||
case 'aircrafts':
|
||||
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({
|
||||
project: currentProject,
|
||||
containers: projectContainers
|
||||
});
|
||||
case 'container':
|
||||
const currentContainer = this.containers.find(c => c.id === this.currentContainerId);
|
||||
const containerConfigs = this.configs.filter(cfg => cfg.containerId === this.currentContainerId);
|
||||
return this.containerConfigView.render({
|
||||
container: currentContainer,
|
||||
configs: containerConfigs
|
||||
});
|
||||
default:
|
||||
return this.projectListView.render({
|
||||
projects: this.projects
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ConfigPanel = ConfigPanel;
|
||||
//# sourceMappingURL=ConfigPanel.js.map
|
||||
1
out/panels/ConfigPanel.js.map
Normal file
1
out/panels/ConfigPanel.js.map
Normal file
File diff suppressed because one or more lines are too long
3
out/panels/types/DataModel.js
Normal file
3
out/panels/types/DataModel.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=DataModel.js.map
|
||||
1
out/panels/types/DataModel.js.map
Normal file
1
out/panels/types/DataModel.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DataModel.js","sourceRoot":"","sources":["../../../src/panels/types/DataModel.ts"],"names":[],"mappings":""}
|
||||
3
out/panels/types/ViewTypes.js
Normal file
3
out/panels/types/ViewTypes.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=ViewTypes.js.map
|
||||
1
out/panels/types/ViewTypes.js.map
Normal file
1
out/panels/types/ViewTypes.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ViewTypes.js","sourceRoot":"","sources":["../../../src/panels/types/ViewTypes.ts"],"names":[],"mappings":""}
|
||||
3
out/panels/types/WebviewMessage.js
Normal file
3
out/panels/types/WebviewMessage.js
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=WebviewMessage.js.map
|
||||
1
out/panels/types/WebviewMessage.js.map
Normal file
1
out/panels/types/WebviewMessage.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WebviewMessage.js","sourceRoot":"","sources":["../../../src/panels/types/WebviewMessage.ts"],"names":[],"mappings":""}
|
||||
204
out/panels/views/AircraftConfigView.js
Normal file
204
out/panels/views/AircraftConfigView.js
Normal file
@@ -0,0 +1,204 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AircraftConfigView = void 0;
|
||||
// src/panels/views/AircraftConfigView.ts
|
||||
const BaseView_1 = require("./BaseView");
|
||||
class AircraftConfigView extends BaseView_1.BaseView {
|
||||
render(data) {
|
||||
const project = data?.project;
|
||||
const containers = data?.containers || [];
|
||||
// 生成容器列表的 HTML
|
||||
const containersHtml = containers.map((container) => `
|
||||
<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">
|
||||
<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>
|
||||
</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
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function goBackToProjects() {
|
||||
vscode.postMessage({ type: 'goBackToProjects' });
|
||||
}
|
||||
|
||||
function deleteContainer(containerId) {
|
||||
showConfirmDialog(
|
||||
'确认删除',
|
||||
'确定删除这个容器吗?',
|
||||
function() {
|
||||
vscode.postMessage({
|
||||
type: 'deleteContainer',
|
||||
containerId: containerId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
// 用户取消删除
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 对话框函数(与之前相同)
|
||||
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.AircraftConfigView = AircraftConfigView;
|
||||
//# sourceMappingURL=AircraftConfigView.js.map
|
||||
1
out/panels/views/AircraftConfigView.js.map
Normal file
1
out/panels/views/AircraftConfigView.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AircraftConfigView.js","sourceRoot":"","sources":["../../../src/panels/views/AircraftConfigView.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,yCAAsC;AAGtC,MAAa,kBAAmB,SAAQ,mBAAQ;IAC5C,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;;;;iFAI2D,OAAO,EAAE,IAAI,IAAI,MAAM;;;;;;;;;;;;;cAa1F,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAyJpB,CAAC;IACL,CAAC;CACJ;AAtMD,gDAsMC"}
|
||||
175
out/panels/views/BaseView.js
Normal file
175
out/panels/views/BaseView.js
Normal file
@@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BaseView = void 0;
|
||||
class BaseView {
|
||||
constructor(extensionUri) {
|
||||
this.extensionUri = extensionUri;
|
||||
}
|
||||
getStyles() {
|
||||
return `
|
||||
<style>
|
||||
body {
|
||||
font-family: var(--vscode-font-family);
|
||||
padding: 20px;
|
||||
background: var(--vscode-editor-background);
|
||||
color: var(--vscode-editor-foreground);
|
||||
margin: 0;
|
||||
}
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.table th, .table td {
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--vscode-panel-border);
|
||||
}
|
||||
.table th {
|
||||
background: var(--vscode-panel-background);
|
||||
font-weight: bold;
|
||||
}
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
color: var(--vscode-textLink-foreground);
|
||||
}
|
||||
.clickable:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.editable {
|
||||
border: 1px dashed transparent;
|
||||
padding: 2px 4px;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.editable:hover {
|
||||
border-color: var(--vscode-input-border);
|
||||
background: var(--vscode-input-background);
|
||||
}
|
||||
.btn-new {
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-new:hover {
|
||||
background: var(--vscode-button-hoverBackground);
|
||||
}
|
||||
.btn-delete {
|
||||
background: var(--vscode-inputValidation-errorBackground);
|
||||
color: white;
|
||||
padding: 4px 8px;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.back-btn {
|
||||
background: var(--vscode-button-secondaryBackground);
|
||||
color: var(--vscode-button-secondaryForeground);
|
||||
padding: 6px 12px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.back-btn:hover {
|
||||
background: var(--vscode-button-secondaryHoverBackground);
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid var(--vscode-panel-border);
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
h2 {
|
||||
color: var(--vscode-titleBar-activeForeground);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.config-editor {
|
||||
margin-top: 30px;
|
||||
border: 1px solid var(--vscode-panel-border);
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
background: var(--vscode-panel-background);
|
||||
}
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
font-family: 'Courier New', monospace;
|
||||
background: var(--vscode-input-background);
|
||||
color: var(--vscode-input-foreground);
|
||||
border: 1px solid var(--vscode-input-border);
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
resize: vertical;
|
||||
}
|
||||
.btn-primary {
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal-dialog {
|
||||
background: var(--vscode-editor-background);
|
||||
border: 1px solid var(--vscode-panel-border);
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
min-width: 300px;
|
||||
max-width: 500px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
margin-bottom: 15px;
|
||||
font-weight: bold;
|
||||
color: var(--vscode-editor-foreground);
|
||||
}
|
||||
|
||||
.modal-buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.modal-btn {
|
||||
padding: 6px 12px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-btn-primary {
|
||||
background: var(--vscode-button-background);
|
||||
color: var(--vscode-button-foreground);
|
||||
}
|
||||
|
||||
.modal-btn-secondary {
|
||||
background: var(--vscode-button-secondaryBackground);
|
||||
color: var(--vscode-button-secondaryForeground);
|
||||
}
|
||||
</style>
|
||||
`;
|
||||
}
|
||||
}
|
||||
exports.BaseView = BaseView;
|
||||
//# sourceMappingURL=BaseView.js.map
|
||||
1
out/panels/views/BaseView.js.map
Normal file
1
out/panels/views/BaseView.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BaseView.js","sourceRoot":"","sources":["../../../src/panels/views/BaseView.ts"],"names":[],"mappings":";;;AAGA,MAAsB,QAAQ;IAG1B,YAAY,YAAwB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAIS,SAAS;QACf,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAkKN,CAAC;IACN,CAAC;CACJ;AA9KD,4BA8KC"}
|
||||
241
out/panels/views/ContainerConfigView.js
Normal file
241
out/panels/views/ContainerConfigView.js
Normal file
@@ -0,0 +1,241 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ContainerConfigView = void 0;
|
||||
// src/panels/views/ContainerConfigView.ts
|
||||
const BaseView_1 = require("./BaseView");
|
||||
class ContainerConfigView extends BaseView_1.BaseView {
|
||||
render(data) {
|
||||
const container = data?.container;
|
||||
const configs = data?.configs || [];
|
||||
// 生成配置列表的 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>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-delete" onclick="deleteConfig('${config.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()}
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h2>⚙️ 容器配置 - <span style="color: var(--vscode-textLink-foreground);">${container?.name || '未知容器'}</span></h2>
|
||||
<button class="back-btn" onclick="goBackToAircraft()">← 返回飞行器</button>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="40%">配置</th>
|
||||
<th width="40%">文件</th>
|
||||
<th width="20%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${configsHtml}
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 20px;">
|
||||
<button class="btn-new" onclick="createNewConfig()">+ 新建配置</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 配置文件编辑器 -->
|
||||
<div class="config-editor" id="configEditor" style="display: none;">
|
||||
<h3>📝 编辑配置文件</h3>
|
||||
<textarea id="configContent" placeholder="在此编辑配置文件内容..."></textarea>
|
||||
<div style="margin-top: 15px;">
|
||||
<button class="btn-primary" onclick="saveConfigFile()">💾 保存</button>
|
||||
<button class="back-btn" onclick="closeEditor()">取消</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const vscode = acquireVsCodeApi();
|
||||
let currentConfigId = null;
|
||||
|
||||
function editConfigName(configId, currentName) {
|
||||
showPromptDialog(
|
||||
'修改配置名称',
|
||||
'请输入新的配置名称:',
|
||||
currentName,
|
||||
function(newName) {
|
||||
if (newName && newName !== currentName) {
|
||||
vscode.postMessage({
|
||||
type: 'updateConfigName',
|
||||
configId: configId,
|
||||
name: newName
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function openConfigFile(configId) {
|
||||
currentConfigId = configId;
|
||||
document.getElementById('configEditor').style.display = 'block';
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'loadConfigFile',
|
||||
configId: configId
|
||||
});
|
||||
}
|
||||
|
||||
function createNewConfig() {
|
||||
showPromptDialog(
|
||||
'新建配置',
|
||||
'请输入配置名称:',
|
||||
'',
|
||||
function(name) {
|
||||
if (name) {
|
||||
vscode.postMessage({
|
||||
type: 'createConfig',
|
||||
name: name
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 新增:删除配置函数
|
||||
function deleteConfig(configId) {
|
||||
showConfirmDialog(
|
||||
'确认删除',
|
||||
'确定删除这个配置文件吗?',
|
||||
function() {
|
||||
vscode.postMessage({
|
||||
type: 'deleteConfig',
|
||||
configId: configId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
// 用户取消删除
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function saveConfigFile() {
|
||||
const content = document.getElementById('configContent').value;
|
||||
vscode.postMessage({
|
||||
type: 'saveConfigFile',
|
||||
configId: currentConfigId,
|
||||
content: content
|
||||
});
|
||||
closeEditor();
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
document.getElementById('configEditor').style.display = 'none';
|
||||
currentConfigId = null;
|
||||
}
|
||||
|
||||
function goBackToAircraft() {
|
||||
vscode.postMessage({ type: 'goBackToAircraft' });
|
||||
}
|
||||
|
||||
// 对话框函数
|
||||
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;
|
||||
}
|
||||
|
||||
window.addEventListener('message', event => {
|
||||
const message = event.data;
|
||||
if (message.type === 'configFileLoaded') {
|
||||
document.getElementById('configContent').value = message.content;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
}
|
||||
exports.ContainerConfigView = ContainerConfigView;
|
||||
//# sourceMappingURL=ContainerConfigView.js.map
|
||||
1
out/panels/views/ContainerConfigView.js.map
Normal file
1
out/panels/views/ContainerConfigView.js.map
Normal file
@@ -0,0 +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"}
|
||||
195
out/panels/views/ProjectListView.js
Normal file
195
out/panels/views/ProjectListView.js
Normal file
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ProjectListView = void 0;
|
||||
// src/panels/views/ProjectListView.ts
|
||||
const BaseView_1 = require("./BaseView");
|
||||
class ProjectListView extends BaseView_1.BaseView {
|
||||
render(data) {
|
||||
const projects = data?.projects || [];
|
||||
// 生成项目列表的 HTML
|
||||
const projectsHtml = projects.map((project) => `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="editable" onclick="editProjectName('${project.id}', '${project.name}')">🛸 ${project.name}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="clickable" onclick="openAircraftConfig('${project.id}')">配置</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()}
|
||||
</head>
|
||||
<body>
|
||||
<h2>🚀 飞行器项目管理</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 editProjectName(projectId, currentName) {
|
||||
showPromptDialog(
|
||||
'修改项目名称',
|
||||
'请输入新的项目名称:',
|
||||
currentName,
|
||||
function(newName) {
|
||||
if (newName && newName !== currentName) {
|
||||
vscode.postMessage({
|
||||
type: 'updateProjectName',
|
||||
projectId: projectId,
|
||||
name: newName
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function openAircraftConfig(projectId) {
|
||||
vscode.postMessage({
|
||||
type: 'openAircraftConfig',
|
||||
projectId: projectId
|
||||
});
|
||||
}
|
||||
|
||||
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() {
|
||||
// 用户取消删除
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 对话框函数(与之前相同)
|
||||
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.ProjectListView = ProjectListView;
|
||||
//# sourceMappingURL=ProjectListView.js.map
|
||||
1
out/panels/views/ProjectListView.js.map
Normal file
1
out/panels/views/ProjectListView.js.map
Normal file
@@ -0,0 +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"}
|
||||
Reference in New Issue
Block a user