0
0

修复了保存的绝对路径问题

This commit is contained in:
xubing
2025-11-27 22:04:32 +08:00
parent 2970f64587
commit 17e9dc1451
13 changed files with 911 additions and 984 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,7 @@ export interface Container {
name: string;
aircraftId: string;
configs: Config[];
moduleFolders: ModuleFolder[]; // 新增:模块文件夹列表
}
export interface Config {
@@ -24,4 +25,13 @@ export interface Config {
fileName: string;
content: string;
containerId: string;
}
// 新增:统一的模块文件夹接口
export interface ModuleFolder {
id: string;
name: string;
type: 'git' | 'merged'; // 类型标识
localPath: string; // 相对路径,如 "/项目1/飞行器1/容器1/test-code"
containerId: string;
}

View File

@@ -0,0 +1,45 @@
// src/types/DataTypes.ts
// 统一的模块文件夹接口
export interface ModuleFolder {
id: string;
name: string;
type: 'git' | 'merged'; // 类型标识
localPath: string; // 相对路径,如 "/项目1/飞行器1/容器1/test-code"
containerId: string;
}
// 项目数据接口
export interface ProjectData {
projects: Project[];
aircrafts: Aircraft[];
containers: Container[];
configs: Config[];
moduleFolders: ModuleFolder[]; // 统一的模块文件夹数据
}
// 基础数据接口
export interface Project {
id: string;
name: string;
}
export interface Aircraft {
id: string;
name: string;
projectId: string;
}
export interface Container {
id: string;
name: string;
aircraftId: string;
}
export interface Config {
id: string;
name: string;
fileName: string;
content: string;
containerId: string;
}

9
src/panels/types/ViewTypes.ts Normal file → Executable file
View File

@@ -39,14 +39,13 @@ export interface ContainerConfigData {
configs: ConfigViewData[];
}
// 新增 Git 相关类型
export interface GitRepoData {
// 新增模块文件夹相关类型
export interface ModuleFolderData {
id: string;
name: string;
url: string;
type: 'git' | 'merged';
localPath: string;
branch: string;
lastSync: string;
containerId: string;
}
export interface GitFileTree {

View File

@@ -1,5 +1,6 @@
import { BaseView } from './BaseView';
import { ContainerConfigData, ConfigViewData } from '../types/ViewTypes';
import { ModuleFolder } from '../types/DataTypes';
// Git 分支接口
interface GitBranch {
@@ -26,29 +27,6 @@ interface GitFileTree {
children?: GitFileTree[];
}
// Git 仓库接口
interface GitRepo {
id: string;
name: string;
url: string;
localPath: string;
branch: string;
lastSync: string;
containerId: string;
}
// 合并文件夹接口
interface MergedFolder {
id: string;
displayName: string; // 配置栏显示的名称
folderName: string; // 实际文件夹名称
path: string;
fileCount: number;
containerId: string;
originalConfigIds: string[];
createdAt: string;
}
// 树状分支节点接口
interface BranchTreeNode {
name: string;
@@ -62,25 +40,23 @@ interface BranchTreeNode {
export class ConfigView extends BaseView {
render(data?: ContainerConfigData & {
gitRepos?: GitRepo[];
currentGitRepo?: GitRepo;
gitFileTree?: GitFileTree[];
gitLoading?: boolean;
moduleFolders?: ModuleFolder[];
currentModuleFolder?: ModuleFolder;
moduleFolderFileTree?: GitFileTree[];
moduleFolderLoading?: boolean;
gitBranches?: GitBranch[];
gitRepoUrl?: string;
mergedFolders?: MergedFolder[];
}): string {
const container = data?.container;
const configs = data?.configs || [];
const gitRepos = data?.gitRepos || [];
const currentGitRepo = data?.currentGitRepo;
const gitFileTree = data?.gitFileTree || [];
const gitLoading = data?.gitLoading || false;
const moduleFolders = data?.moduleFolders || [];
const currentModuleFolder = data?.currentModuleFolder;
const moduleFolderFileTree = data?.moduleFolderFileTree || [];
const moduleFolderLoading = data?.moduleFolderLoading || false;
const gitBranches = data?.gitBranches || [];
const gitRepoUrl = data?.gitRepoUrl || '';
const mergedFolders = data?.mergedFolders || [];
// 生成配置列表的 HTML - 包含配置文件和 Git 仓库
// 生成配置列表的 HTML - 包含配置文件和模块文件夹
const configsHtml = configs.map((config: ConfigViewData) => `
<tr>
<td>
@@ -96,41 +72,23 @@ export class ConfigView extends BaseView {
</tr>
`).join('');
// 生成合并文件夹的 HTML - 显示在配置列表中
const mergedFoldersHtml = mergedFolders.map((folder: MergedFolder) => `
<tr>
<td>
<span class="editable">📁 ${folder.displayName}</span>
</td>
<td>
<span class="clickable" onclick="openTheModuleFolder('${folder.id}', 'merged')">${folder.folderName}</span>
</td>
<td>
<button class="btn-delete" onclick="deleteMergedFolder('${folder.id}')">删除</button>
</td>
</tr>
`).join('');
// 生成 Git 仓库列表的 HTML - 修改显示方式Git 仓库不可勾选
const gitReposHtml = gitRepos.map(repo => {
// 提取仓库名称从URL中获取或使用name
const repoName = repo.name.split(' (')[0]; // 移除分支名部分
// 提取分支名
const branchMatch = repo.name.match(/\(([^)]+)\)/);
const branchName = branchMatch ? branchMatch[1] : repo.branch;
// 生成模块文件夹的 HTML - 统一显示 Git 和合并文件夹
const moduleFoldersHtml = moduleFolders.map((folder: ModuleFolder) => {
const icon = folder.type === 'git' ? '📁' : '📁';
return `
<tr>
<td>
<span class="editable">📁 ${repoName}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
</div>
<span class="editable">${icon} ${folder.name}</span>
</td>
<td>
<span class="clickable" onclick="openTheModuleFolder('${repo.id}', 'git')">${branchName}</span>
<span class="clickable" onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">${folder.localPath.split('/').pop()}</span>
</td>
<td>
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
${folder.type === 'git' ? `
<button class="btn-sync" onclick="syncModuleFolder('${folder.id}')" style="margin-right: 5px;">同步</button>
` : ''}
<button class="btn-delete" onclick="deleteModuleFolder('${folder.id}')">删除</button>
</td>
</tr>
`;
@@ -182,6 +140,19 @@ export class ConfigView extends BaseView {
opacity: 0.8;
}
.btn-sync {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
padding: 4px 8px;
border: none;
border-radius: 2px;
cursor: pointer;
}
.btn-sync:hover {
background: var(--vscode-button-hoverBackground);
}
/* 树状分支样式 */
.branch-tree {
font-family: 'Courier New', monospace;
@@ -323,21 +294,20 @@ export class ConfigView extends BaseView {
<thead>
<tr>
<th width="30%">配置</th>
<th width="40%">文件</th>
<th width="40%">文件/文件夹</th>
<th width="30%">操作</th>
</tr>
</thead>
<tbody>
${configsHtml}
${mergedFoldersHtml}
${gitReposHtml}
${moduleFoldersHtml}
</tbody>
</table>
</div>
<!-- Git 仓库管理部分 -->
<!-- 模块文件夹管理部分 -->
<div class="config-section">
<h3 class="section-title">📚 Git 仓库管理</h3>
<h3 class="section-title">📚 模块云仓库</h3>
<!-- URL 输入区域 -->
<div class="url-input-section">
@@ -391,8 +361,7 @@ export class ConfigView extends BaseView {
});
}
// 统一功能:打开模块文件夹(合并 Git 仓库和合并文件夹功能)
// 统一功能:打开模块文件夹
function openTheModuleFolder(id, type) {
console.log('📂 打开模块文件夹:', { id, type });
vscode.postMessage({
@@ -436,46 +405,34 @@ export class ConfigView extends BaseView {
);
}
// 删除合并文件夹功能
function deleteMergedFolder(folderId) {
console.log('🗑️ 尝试删除合并文件夹:', folderId);
// 删除模块文件夹功能
function deleteModuleFolder(folderId) {
console.log('🗑️ 尝试删除模块文件夹:', folderId);
showConfirmDialog(
'确认删除合并文件夹',
'确定删除这个合并文件夹吗?这将删除文件夹及其所有内容。',
'确认删除模块文件夹',
'确定删除这个模块文件夹吗?这将删除文件夹及其所有内容。',
function() {
console.log('✅ 用户确认删除合并文件夹:', folderId);
console.log('✅ 用户确认删除模块文件夹:', folderId);
vscode.postMessage({
type: 'deleteMergedFolder',
type: 'deleteModuleFolder',
folderId: folderId
});
},
function() {
// 用户取消删除
console.log('❌ 用户取消删除合并文件夹');
console.log('❌ 用户取消删除模块文件夹');
}
);
}
// Git 仓库删除功能
function deleteGitRepo(repoId) {
console.log('🗑️ 尝试删除 Git 仓库:', repoId);
showConfirmDialog(
'确认删除 Git 仓库',
'确定删除这个 Git 仓库吗?这将删除本地克隆的代码文件夹。',
function() {
console.log('✅ 用户确认删除 Git 仓库:', repoId);
vscode.postMessage({
type: 'deleteGitRepo',
repoId: repoId
});
},
function() {
// 用户取消删除
console.log('❌ 用户取消删除 Git 仓库');
}
);
// 同步 Git 模块文件夹
function syncModuleFolder(folderId) {
console.log('🔄 同步模块文件夹:', folderId);
vscode.postMessage({
type: 'syncGitModuleFolder',
folderId: folderId
});
}
function goBackToContainers() {
@@ -552,14 +509,6 @@ export class ConfigView extends BaseView {
});
}
function syncGitRepo(repoId) {
console.log('🔄 同步仓库:', repoId);
vscode.postMessage({
type: 'syncGitRepo',
repoId: repoId
});
}
// 配置文件合并功能
function toggleConfigSelection(configId) {
const checkbox = document.querySelector('.config-checkbox[data-id="' + configId + '"]');