修复了保存的绝对路径问题
This commit is contained in:
@@ -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 + '"]');
|
||||
|
||||
Reference in New Issue
Block a user