现在代码上传逻辑存在问题
This commit is contained in:
88
src/panels/views/AircraftView.ts
Normal file → Executable file
88
src/panels/views/AircraftView.ts
Normal file → Executable file
@@ -6,8 +6,6 @@ export class AircraftView extends BaseView {
|
||||
render(data?: { aircrafts: AircraftViewData[] }): string {
|
||||
const aircrafts = data?.aircrafts || [];
|
||||
|
||||
console.log('AircraftView 渲染数据:', aircrafts);
|
||||
|
||||
const aircraftsHtml = aircrafts.map(aircraft => `
|
||||
<tr>
|
||||
<td>
|
||||
@@ -62,7 +60,7 @@ export class AircraftView extends BaseView {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0 auto; /* 确保按钮在容器内居中 */
|
||||
margin: 0 auto;
|
||||
}
|
||||
.btn-new:hover {
|
||||
background: var(--vscode-button-hoverBackground);
|
||||
@@ -76,7 +74,6 @@ export class AircraftView extends BaseView {
|
||||
.aircraft-name:hover {
|
||||
background: var(--vscode-input-background);
|
||||
}
|
||||
/* 专门为新建按钮的容器添加样式 */
|
||||
.new-button-container {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
@@ -99,7 +96,6 @@ export class AircraftView extends BaseView {
|
||||
</thead>
|
||||
<tbody>
|
||||
${aircraftsHtml}
|
||||
<!-- 修复:使用专门的容器类确保居中 -->
|
||||
<tr>
|
||||
<td colspan="3" class="new-button-container">
|
||||
<button class="btn-new" onclick="createNewAircraft()">+ 新建飞行器</button>
|
||||
@@ -188,88 +184,8 @@ export class AircraftView extends BaseView {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 对话框函数
|
||||
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>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/panels/views/BaseView.ts
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export abstract class BaseView {
|
||||
@@ -9,7 +10,10 @@ export abstract class BaseView {
|
||||
|
||||
abstract render(data?: any): string;
|
||||
|
||||
protected getStyles(): string {
|
||||
/**
|
||||
* 获取通用的样式和脚本
|
||||
*/
|
||||
protected getBaseStylesAndScripts(): string {
|
||||
return `
|
||||
<style>
|
||||
body {
|
||||
@@ -173,6 +177,95 @@ export abstract class BaseView {
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// 对话框工具函数
|
||||
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>
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取仓库选择对话框的脚本(仅ConfigView需要)
|
||||
*/
|
||||
protected getRepoSelectScript(): string {
|
||||
return `
|
||||
<script>
|
||||
(function () {
|
||||
// 避免在同一个 Webview 中重复注册
|
||||
if (window.__dcspRepoDialogInitialized) {
|
||||
@@ -205,7 +298,7 @@ export abstract class BaseView {
|
||||
|
||||
var noRepoTip = '';
|
||||
if (!hasRepos) {
|
||||
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在“仓库配置”中添加。</div>';
|
||||
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在"仓库配置"中添加。</div>';
|
||||
}
|
||||
|
||||
overlay.innerHTML =
|
||||
@@ -232,7 +325,6 @@ export abstract class BaseView {
|
||||
|
||||
if (cancelBtn) {
|
||||
cancelBtn.addEventListener('click', function () {
|
||||
// 通知后端取消,清理可能的状态(例如待上传的本地文件夹)
|
||||
if (typeof vscode !== 'undefined') {
|
||||
vscode.postMessage({
|
||||
type: 'repoSelectCanceled'
|
||||
@@ -275,4 +367,11 @@ export abstract class BaseView {
|
||||
</script>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取样式(被子类覆盖)
|
||||
*/
|
||||
protected getStyles(): string {
|
||||
return this.getBaseStylesAndScripts();
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,12 @@ import { BaseView } from './BaseView';
|
||||
import { ContainerConfigData, ConfigViewData } from '../types/ViewTypes';
|
||||
import { ModuleFolder } from '../types/CommonTypes';
|
||||
|
||||
// Git 分支接口
|
||||
interface GitBranch {
|
||||
name: string;
|
||||
isCurrent: boolean;
|
||||
selected?: boolean;
|
||||
}
|
||||
|
||||
// Git 文件树接口
|
||||
interface GitFileTree {
|
||||
name: string;
|
||||
type: 'file' | 'folder';
|
||||
path: string;
|
||||
children?: GitFileTree[];
|
||||
}
|
||||
|
||||
// 树状分支节点接口
|
||||
interface BranchTreeNode {
|
||||
name: string;
|
||||
fullName: string;
|
||||
@@ -32,7 +22,7 @@ export class ConfigView extends BaseView {
|
||||
render(data?: ContainerConfigData & {
|
||||
moduleFolders?: ModuleFolder[];
|
||||
currentModuleFolder?: ModuleFolder;
|
||||
moduleFolderFileTree?: GitFileTree[];
|
||||
moduleFolderFileTree?: any[];
|
||||
moduleFolderLoading?: boolean;
|
||||
gitBranches?: GitBranch[];
|
||||
}): string {
|
||||
@@ -44,7 +34,7 @@ export class ConfigView extends BaseView {
|
||||
const moduleFolderLoading = data?.moduleFolderLoading || false;
|
||||
const gitBranches = data?.gitBranches || [];
|
||||
|
||||
// 生成配置列表的 HTML - 包含配置文件和模块文件夹
|
||||
// 生成配置列表的 HTML
|
||||
const configsHtml = configs.map((config: ConfigViewData) => `
|
||||
<tr>
|
||||
<td>
|
||||
@@ -61,10 +51,9 @@ export class ConfigView extends BaseView {
|
||||
</tr>
|
||||
`).join('');
|
||||
|
||||
// 生成模块文件夹的 HTML - 按类别分类显示
|
||||
// 生成模块文件夹的 HTML
|
||||
const moduleFoldersHtml = moduleFolders.map((folder: ModuleFolder) => {
|
||||
const icon = '📁';
|
||||
// 根据类型和上传状态确定类别显示
|
||||
let category = folder.type === 'git' ? 'git' : 'local';
|
||||
if (folder.uploaded) {
|
||||
category += '(已上传)';
|
||||
@@ -75,14 +64,12 @@ export class ConfigView extends BaseView {
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<!-- 左侧:📁 动力学仓库 / test,仅用于重命名 -->
|
||||
<span class="editable clickable" onclick="renameModuleFolder('${folder.id}', '${folder.name}')">
|
||||
${icon} ${folder.name}
|
||||
</span>
|
||||
</td>
|
||||
<td class="category-${folder.type}">${category}</td>
|
||||
<td>
|
||||
<!-- 右侧:文件/文件夹栏,只负责选择并打开文件,不再触发重命名 -->
|
||||
<span class="clickable"
|
||||
onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">
|
||||
📄 ${fileName}
|
||||
@@ -96,7 +83,7 @@ export class ConfigView extends BaseView {
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
// 生成分支选择的 HTML - 使用树状结构(首次渲染可以为空,后续通过 message 更新)
|
||||
// 生成分支选择的 HTML
|
||||
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesTreeHtml(gitBranches) : '';
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
@@ -105,7 +92,8 @@ export class ConfigView extends BaseView {
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>配置管理</title>
|
||||
${this.getStyles()}
|
||||
${this.getBaseStylesAndScripts()}
|
||||
${this.getRepoSelectScript()}
|
||||
<style>
|
||||
.url-input-section {
|
||||
background: var(--vscode-panel-background);
|
||||
@@ -291,16 +279,6 @@ export class ConfigView extends BaseView {
|
||||
color: var(--vscode-charts-orange);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.category-git(已上传) {
|
||||
color: var(--vscode-gitDecoration-addedResourceForeground);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.category-local(已上传) {
|
||||
color: var(--vscode-gitDecoration-addedResourceForeground);
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -357,12 +335,11 @@ export class ConfigView extends BaseView {
|
||||
|
||||
<script>
|
||||
const vscode = acquireVsCodeApi();
|
||||
let currentConfigId = null;
|
||||
let selectedBranches = new Set();
|
||||
let branchTreeData = [];
|
||||
let selectedConfigs = new Set();
|
||||
|
||||
// 只负责“改名”的函数
|
||||
// 只负责"改名"的函数
|
||||
function renameModuleFolder(folderId, oldName) {
|
||||
showPromptDialog(
|
||||
'重命名模块文件夹',
|
||||
@@ -400,16 +377,14 @@ export class ConfigView extends BaseView {
|
||||
|
||||
// 在 VSCode 中打开配置文件
|
||||
function openConfigFileInVSCode(configId) {
|
||||
console.log('📄 在 VSCode 中打开配置文件:', configId);
|
||||
vscode.postMessage({
|
||||
type: 'openConfigFileInVSCode',
|
||||
configId: configId
|
||||
});
|
||||
}
|
||||
|
||||
// 统一功能:打开模块文件夹(这里只负责打开,而不是改名)
|
||||
// 统一功能:打开模块文件夹
|
||||
function openTheModuleFolder(id, type) {
|
||||
console.log('📂 打开模块文件夹:', { id, type });
|
||||
vscode.postMessage({
|
||||
type: 'openTheModuleFolder',
|
||||
id: id,
|
||||
@@ -438,50 +413,40 @@ export class ConfigView extends BaseView {
|
||||
'确认删除',
|
||||
'确定删除这个配置文件吗?',
|
||||
function() {
|
||||
console.log('🗑️ 删除配置文件:', configId);
|
||||
vscode.postMessage({
|
||||
type: 'deleteConfig',
|
||||
configId: configId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
console.log('❌ 用户取消删除配置文件');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 删除模块文件夹功能
|
||||
function deleteModuleFolder(folderId) {
|
||||
console.log('🗑️ 尝试删除模块文件夹:', folderId);
|
||||
|
||||
showConfirmDialog(
|
||||
'确认删除模块文件夹',
|
||||
'确定删除这个模块文件夹吗?这将删除文件夹及其所有内容。',
|
||||
function() {
|
||||
console.log('✅ 用户确认删除模块文件夹:', folderId);
|
||||
vscode.postMessage({
|
||||
type: 'deleteModuleFolder',
|
||||
folderId: folderId
|
||||
});
|
||||
},
|
||||
function() {
|
||||
console.log('❌ 用户取消删除模块文件夹');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 上传模块文件夹功能(区分 local / git)
|
||||
// 上传模块文件夹功能
|
||||
function uploadModuleFolder(folderId, folderType) {
|
||||
console.log('📤 上传模块文件夹:', { folderId, folderType });
|
||||
|
||||
if (folderType === 'git') {
|
||||
// git 类型:先选仓库,然后后端根据是否改名/是否同仓库判断是更新原分支还是新分支上传
|
||||
vscode.postMessage({
|
||||
type: 'openRepoSelectForGitUpload',
|
||||
folderId: folderId
|
||||
});
|
||||
} else {
|
||||
// local 类型:走 local → git 的初始化上传逻辑
|
||||
vscode.postMessage({
|
||||
type: 'openRepoSelectForUpload',
|
||||
folderId: folderId
|
||||
@@ -493,9 +458,8 @@ export class ConfigView extends BaseView {
|
||||
vscode.postMessage({ type: 'goBackToContainers' });
|
||||
}
|
||||
|
||||
// 🔁 通过弹窗获取仓库(用于克隆)
|
||||
// 通过弹窗获取仓库
|
||||
function openRepoSelect() {
|
||||
console.log('📦 请求仓库列表以选择 Git 仓库(用于克隆分支)');
|
||||
vscode.postMessage({
|
||||
type: 'openRepoSelect'
|
||||
});
|
||||
@@ -508,7 +472,6 @@ export class ConfigView extends BaseView {
|
||||
} else {
|
||||
selectedBranches.delete(branchName);
|
||||
}
|
||||
console.log('选中的分支:', Array.from(selectedBranches));
|
||||
}
|
||||
|
||||
function cloneSelectedBranches() {
|
||||
@@ -517,8 +480,6 @@ export class ConfigView extends BaseView {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches));
|
||||
|
||||
vscode.postMessage({
|
||||
type: 'cloneBranches',
|
||||
branches: Array.from(selectedBranches)
|
||||
@@ -553,7 +514,6 @@ export class ConfigView extends BaseView {
|
||||
}
|
||||
|
||||
updateMergeButtonState();
|
||||
console.log('选中的配置文件:', Array.from(selectedConfigs));
|
||||
}
|
||||
|
||||
function updateMergeButtonState() {
|
||||
@@ -568,8 +528,6 @@ export class ConfigView extends BaseView {
|
||||
alert('请至少选择两个配置文件进行合并');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('🔄 开始合并选中的配置文件:', Array.from(selectedConfigs));
|
||||
|
||||
showMergeDialog();
|
||||
}
|
||||
@@ -761,94 +719,11 @@ export class ConfigView extends BaseView {
|
||||
return html;
|
||||
}
|
||||
|
||||
// 对话框函数
|
||||
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;
|
||||
console.log('📨 前端收到后端消息:', message);
|
||||
|
||||
if (message.type === 'branchesFetched') {
|
||||
console.log('🌿 收到分支数据:', message.branches);
|
||||
console.log('🌳 收到分支树数据:', message.branchTree);
|
||||
branchTreeData = message.branchTree || [];
|
||||
renderBranchTree(branchTreeData);
|
||||
}
|
||||
@@ -856,8 +731,6 @@ export class ConfigView extends BaseView {
|
||||
|
||||
// 初始化
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('📄 ConfigView 页面加载完成');
|
||||
|
||||
document.addEventListener('change', function(event) {
|
||||
if (event.target.classList.contains('config-checkbox')) {
|
||||
const configId = event.target.getAttribute('data-id');
|
||||
@@ -965,16 +838,4 @@ export class ConfigView extends BaseView {
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
private countLeafNodes(nodes: BranchTreeNode[]): number {
|
||||
let count = 0;
|
||||
nodes.forEach(node => {
|
||||
if (node.isLeaf) {
|
||||
count++;
|
||||
} else {
|
||||
count += this.countLeafNodes(node.children);
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
83
src/panels/views/ContainerView.ts
Normal file → Executable file
83
src/panels/views/ContainerView.ts
Normal file → Executable file
@@ -5,10 +5,9 @@ import { AircraftConfigData, ContainerViewData } from '../types/ViewTypes';
|
||||
export class ContainerView extends BaseView {
|
||||
render(data?: AircraftConfigData): string {
|
||||
const project = data?.project;
|
||||
const aircraft = data?.aircraft; // 新增:获取飞行器数据
|
||||
const aircraft = data?.aircraft;
|
||||
const containers = data?.containers || [];
|
||||
|
||||
// 生成容器列表的 HTML
|
||||
const containersHtml = containers.map((container: ContainerViewData) => `
|
||||
<tr>
|
||||
<td>
|
||||
@@ -117,86 +116,6 @@ export class ContainerView extends BaseView {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 对话框函数(与之前相同)
|
||||
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>`;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// src/panels/views/ProjectView.ts
|
||||
import { BaseView } from './BaseView';
|
||||
import { ProjectViewData } from '../types/ViewTypes';
|
||||
|
||||
@@ -136,13 +137,11 @@ export class ProjectView extends BaseView {
|
||||
|
||||
function configureProject(projectId, projectName, isConfigured) {
|
||||
if (isConfigured) {
|
||||
// 已配置的项目直接打开
|
||||
vscode.postMessage({
|
||||
type: 'openProject',
|
||||
projectId: projectId
|
||||
});
|
||||
} else {
|
||||
// 未配置的项目需要设置路径
|
||||
vscode.postMessage({
|
||||
type: 'configureProject',
|
||||
projectId: projectId,
|
||||
@@ -189,7 +188,7 @@ export class ProjectView extends BaseView {
|
||||
);
|
||||
}
|
||||
|
||||
// 项目名称编辑功能 - 修复版本
|
||||
// 项目名称编辑功能
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('click', function(event) {
|
||||
if (event.target.classList.contains('project-name')) {
|
||||
@@ -220,88 +219,8 @@ export class ProjectView extends BaseView {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 对话框函数 - 只保留一份
|
||||
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>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user