2025-11-18 18:45:30 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
|
exports.ConfigView = void 0;
|
|
|
|
|
|
const BaseView_1 = require("./BaseView");
|
|
|
|
|
|
class ConfigView extends BaseView_1.BaseView {
|
|
|
|
|
|
render(data) {
|
2025-11-18 09:10:47 +08:00
|
|
|
|
const container = data?.container;
|
|
|
|
|
|
const configs = data?.configs || [];
|
2025-11-24 17:53:48 +08:00
|
|
|
|
const gitRepos = data?.gitRepos || [];
|
|
|
|
|
|
const currentGitRepo = data?.currentGitRepo;
|
|
|
|
|
|
const gitFileTree = data?.gitFileTree || [];
|
|
|
|
|
|
const gitLoading = data?.gitLoading || false;
|
|
|
|
|
|
const gitBranches = data?.gitBranches || [];
|
|
|
|
|
|
const gitRepoUrl = data?.gitRepoUrl || '';
|
2025-11-25 14:30:54 +08:00
|
|
|
|
// 生成配置列表的 HTML - 包含配置文件和 Git 仓库
|
2025-11-18 18:45:30 +08:00
|
|
|
|
const configsHtml = configs.map((config) => `
|
2025-11-18 09:10:47 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<span class="editable" onclick="editConfigName('${config.id}', '${config.name}')">🔧 ${config.name}</span>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
2025-11-25 21:13:41 +08:00
|
|
|
|
<span class="clickable" onclick="openConfigFileInVSCode('${config.id}')">📄 ${config.fileName}</span>
|
2025-11-18 09:10:47 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<button class="btn-delete" onclick="deleteConfig('${config.id}')">删除</button>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
`).join('');
|
2025-11-25 16:32:06 +08:00
|
|
|
|
// 生成 Git 仓库列表的 HTML - 修改显示方式
|
|
|
|
|
|
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;
|
|
|
|
|
|
return `
|
2025-11-24 17:53:48 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td>
|
2025-11-25 16:32:06 +08:00
|
|
|
|
<span class="editable">📁 ${repoName}</span>
|
2025-11-24 17:53:48 +08:00
|
|
|
|
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
2025-11-25 16:32:06 +08:00
|
|
|
|
<span class="clickable" onclick="openGitRepoInVSCode('${repo.id}')">${branchName}</span>
|
2025-11-24 17:53:48 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<button class="btn-delete" onclick="deleteGitRepo('${repo.id}')">删除</button>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2025-11-25 16:32:06 +08:00
|
|
|
|
`;
|
|
|
|
|
|
}).join('');
|
2025-11-24 17:53:48 +08:00
|
|
|
|
// 生成分支选择的 HTML
|
|
|
|
|
|
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesHtml(gitBranches) : '';
|
2025-11-18 09:10:47 +08:00
|
|
|
|
return `<!DOCTYPE html>
|
|
|
|
|
|
<html lang="zh-CN">
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2025-11-18 18:45:30 +08:00
|
|
|
|
<title>配置管理</title>
|
2025-11-18 09:10:47 +08:00
|
|
|
|
${this.getStyles()}
|
2025-11-24 17:53:48 +08:00
|
|
|
|
<style>
|
|
|
|
|
|
.url-input-section {
|
|
|
|
|
|
background: var(--vscode-panel-background);
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
border: 1px solid var(--vscode-input-border);
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-title {
|
|
|
|
|
|
margin: 30px 0 15px 0;
|
|
|
|
|
|
padding-bottom: 10px;
|
|
|
|
|
|
border-bottom: 2px solid var(--vscode-panel-border);
|
|
|
|
|
|
color: var(--vscode-titleBar-activeForeground);
|
|
|
|
|
|
}
|
2025-11-25 14:30:54 +08:00
|
|
|
|
.config-section {
|
|
|
|
|
|
margin-bottom: 30px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.branch-selection {
|
|
|
|
|
|
border: 1px solid var(--vscode-input-border);
|
|
|
|
|
|
}
|
|
|
|
|
|
.branch-item:hover {
|
|
|
|
|
|
background: var(--vscode-list-hoverBackground);
|
|
|
|
|
|
}
|
2025-11-25 14:52:39 +08:00
|
|
|
|
.btn-delete {
|
|
|
|
|
|
background: var(--vscode-inputValidation-errorBackground);
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
|
border: none;
|
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
.btn-delete:hover {
|
|
|
|
|
|
background: var(--vscode-inputValidation-errorBackground);
|
|
|
|
|
|
opacity: 0.8;
|
|
|
|
|
|
}
|
2025-11-24 17:53:48 +08:00
|
|
|
|
</style>
|
2025-11-18 09:10:47 +08:00
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<div class="header">
|
2025-11-18 18:45:30 +08:00
|
|
|
|
<h2>⚙️ 配置管理 - <span style="color: var(--vscode-textLink-foreground);">${container?.name || '未知容器'}</span></h2>
|
|
|
|
|
|
<button class="back-btn" onclick="goBackToContainers()">← 返回容器管理</button>
|
2025-11-18 09:10:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-25 14:30:54 +08:00
|
|
|
|
<!-- 配置文件管理部分 -->
|
|
|
|
|
|
<div class="config-section">
|
|
|
|
|
|
<h3 class="section-title">📋 配置文件管理</h3>
|
|
|
|
|
|
<table class="table">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<th width="30%">配置</th>
|
|
|
|
|
|
<th width="40%">文件</th>
|
|
|
|
|
|
<th width="30%">操作</th>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
${configsHtml}
|
|
|
|
|
|
${gitReposHtml}
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td colspan="3" style="text-align: center; padding: 20px;">
|
|
|
|
|
|
<button class="btn-new" onclick="createNewConfig()">+ 新建配置</button>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
2025-11-24 17:53:48 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-25 14:30:54 +08:00
|
|
|
|
<!-- Git 仓库管理部分 -->
|
|
|
|
|
|
<div class="config-section">
|
|
|
|
|
|
<h3 class="section-title">📚 Git 仓库管理</h3>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- URL 输入区域 -->
|
|
|
|
|
|
<div class="url-input-section">
|
|
|
|
|
|
<h4>🔗 添加 Git 仓库</h4>
|
|
|
|
|
|
<div style="display: flex; gap: 10px; margin-top: 10px;">
|
|
|
|
|
|
<input type="text" id="repoUrlInput"
|
|
|
|
|
|
placeholder="请输入 Git 仓库 URL,例如: https://github.com/username/repo.git"
|
|
|
|
|
|
value="${gitRepoUrl}"
|
|
|
|
|
|
style="flex: 1; padding: 8px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border: 1px solid var(--vscode-input-border); border-radius: 4px;">
|
|
|
|
|
|
<button class="btn-new" onclick="fetchBranches()">获取分支</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div id="branchSelectionContainer">
|
|
|
|
|
|
${branchesHtml}
|
2025-11-24 17:53:48 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-11-18 09:10:47 +08:00
|
|
|
|
<script>
|
|
|
|
|
|
const vscode = acquireVsCodeApi();
|
|
|
|
|
|
let currentConfigId = null;
|
2025-11-24 17:53:48 +08:00
|
|
|
|
let selectedBranches = new Set();
|
|
|
|
|
|
let currentRepoUrl = '';
|
2025-11-18 09:10:47 +08:00
|
|
|
|
|
2025-11-24 17:53:48 +08:00
|
|
|
|
// 配置管理功能
|
2025-11-18 09:10:47 +08:00
|
|
|
|
function editConfigName(configId, currentName) {
|
|
|
|
|
|
showPromptDialog(
|
|
|
|
|
|
'修改配置名称',
|
|
|
|
|
|
'请输入新的配置名称:',
|
|
|
|
|
|
currentName,
|
|
|
|
|
|
function(newName) {
|
|
|
|
|
|
if (newName && newName !== currentName) {
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'updateConfigName',
|
|
|
|
|
|
configId: configId,
|
|
|
|
|
|
name: newName
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 21:13:41 +08:00
|
|
|
|
// 新功能:在 VSCode 中打开配置文件
|
|
|
|
|
|
function openConfigFileInVSCode(configId) {
|
|
|
|
|
|
console.log('📄 在 VSCode 中打开配置文件:', configId);
|
2025-11-18 09:10:47 +08:00
|
|
|
|
vscode.postMessage({
|
2025-11-25 21:13:41 +08:00
|
|
|
|
type: 'openConfigFileInVSCode',
|
2025-11-18 09:10:47 +08:00
|
|
|
|
configId: configId
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function createNewConfig() {
|
|
|
|
|
|
showPromptDialog(
|
|
|
|
|
|
'新建配置',
|
|
|
|
|
|
'请输入配置名称:',
|
|
|
|
|
|
'',
|
|
|
|
|
|
function(name) {
|
|
|
|
|
|
if (name) {
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'createConfig',
|
|
|
|
|
|
name: name
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function deleteConfig(configId) {
|
|
|
|
|
|
showConfirmDialog(
|
|
|
|
|
|
'确认删除',
|
|
|
|
|
|
'确定删除这个配置文件吗?',
|
|
|
|
|
|
function() {
|
2025-11-25 14:52:39 +08:00
|
|
|
|
console.log('🗑️ 删除配置文件:', configId);
|
2025-11-18 09:10:47 +08:00
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'deleteConfig',
|
|
|
|
|
|
configId: configId
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
function() {
|
|
|
|
|
|
// 用户取消删除
|
2025-11-25 14:52:39 +08:00
|
|
|
|
console.log('❌ 用户取消删除配置文件');
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 16:32:06 +08:00
|
|
|
|
// Git 仓库删除功能
|
2025-11-25 14:52:39 +08:00
|
|
|
|
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 仓库');
|
2025-11-18 09:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 16:32:06 +08:00
|
|
|
|
// 新功能:在 VSCode 中打开 Git 仓库
|
|
|
|
|
|
function openGitRepoInVSCode(repoId) {
|
|
|
|
|
|
console.log('📂 在 VSCode 中打开 Git 仓库:', repoId);
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'openGitRepoInVSCode',
|
|
|
|
|
|
repoId: repoId
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-18 18:45:30 +08:00
|
|
|
|
function goBackToContainers() {
|
|
|
|
|
|
vscode.postMessage({ type: 'goBackToContainers' });
|
2025-11-18 09:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-24 17:53:48 +08:00
|
|
|
|
// Git 仓库管理功能
|
|
|
|
|
|
function fetchBranches() {
|
|
|
|
|
|
const urlInput = document.getElementById('repoUrlInput');
|
|
|
|
|
|
const repoUrl = urlInput.value.trim();
|
|
|
|
|
|
|
|
|
|
|
|
if (!repoUrl) {
|
|
|
|
|
|
alert('请输入 Git 仓库 URL');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!repoUrl.startsWith('http')) {
|
|
|
|
|
|
alert('请输入有效的 Git 仓库 URL');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
currentRepoUrl = repoUrl;
|
|
|
|
|
|
console.log('🌿 获取分支列表:', repoUrl);
|
|
|
|
|
|
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'fetchBranches',
|
|
|
|
|
|
url: repoUrl
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toggleBranch(branchName) {
|
|
|
|
|
|
const checkbox = document.getElementById('branch-' + branchName.replace(/[^a-zA-Z0-9]/g, '-'));
|
|
|
|
|
|
if (checkbox.checked) {
|
|
|
|
|
|
selectedBranches.add(branchName);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
selectedBranches.delete(branchName);
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log('选中的分支:', Array.from(selectedBranches));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cloneSelectedBranches() {
|
|
|
|
|
|
if (selectedBranches.size === 0) {
|
|
|
|
|
|
alert('请至少选择一个分支');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('🚀 开始克隆选中的分支:', Array.from(selectedBranches));
|
|
|
|
|
|
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'cloneBranches',
|
|
|
|
|
|
url: currentRepoUrl,
|
|
|
|
|
|
branches: Array.from(selectedBranches)
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 重置选择
|
|
|
|
|
|
selectedBranches.clear();
|
|
|
|
|
|
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
|
|
|
|
|
checkboxes.forEach(checkbox => checkbox.checked = false);
|
|
|
|
|
|
|
|
|
|
|
|
// 隐藏分支选择区域
|
|
|
|
|
|
document.getElementById('branchSelectionContainer').innerHTML = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cancelBranchSelection() {
|
|
|
|
|
|
selectedBranches.clear();
|
|
|
|
|
|
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
|
|
|
|
|
checkboxes.forEach(checkbox => checkbox.checked = false);
|
|
|
|
|
|
|
|
|
|
|
|
// 隐藏分支选择区域
|
|
|
|
|
|
document.getElementById('branchSelectionContainer').innerHTML = '';
|
|
|
|
|
|
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'cancelBranchSelection'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadGitRepo(repoId) {
|
|
|
|
|
|
console.log('📂 加载仓库:', repoId);
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'loadGitRepo',
|
|
|
|
|
|
repoId: repoId
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function syncGitRepo(repoId) {
|
|
|
|
|
|
console.log('🔄 同步仓库:', repoId);
|
|
|
|
|
|
vscode.postMessage({
|
|
|
|
|
|
type: 'syncGitRepo',
|
|
|
|
|
|
repoId: repoId
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 动态渲染分支选择区域
|
|
|
|
|
|
function renderBranchSelection(branches, repoUrl) {
|
|
|
|
|
|
const container = document.getElementById('branchSelectionContainer');
|
|
|
|
|
|
|
|
|
|
|
|
if (branches.length === 0) {
|
|
|
|
|
|
container.innerHTML = '<div style="text-align: center; padding: 10px; color: var(--vscode-descriptionForeground);">未找到分支</div>';
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let branchesHtml = '<div class="branch-selection" style="margin: 15px 0; padding: 15px; background: var(--vscode-panel-background); border-radius: 4px;">';
|
|
|
|
|
|
branchesHtml += '<h4>🌿 选择要克隆的分支 (共 ' + branches.length + ' 个)</h4>';
|
|
|
|
|
|
branchesHtml += '<div style="max-height: 200px; overflow-y: auto; margin: 10px 0;">';
|
|
|
|
|
|
|
|
|
|
|
|
branches.forEach(branch => {
|
|
|
|
|
|
branchesHtml += '<div class="branch-item" style="padding: 8px; border-bottom: 1px solid var(--vscode-panel-border); display: flex; align-items: center;">';
|
|
|
|
|
|
branchesHtml += '<input type="checkbox" id="branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-') + '" ';
|
|
|
|
|
|
branchesHtml += (branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\\'' + branch.name + '\\')" style="margin-right: 10px;">';
|
|
|
|
|
|
branchesHtml += '<label for="branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-') + '" style="flex: 1; cursor: pointer;">';
|
|
|
|
|
|
branchesHtml += (branch.isCurrent ? '⭐ ' : '') + branch.name;
|
2025-11-25 16:32:06 +08:00
|
|
|
|
branchesHtml += '</label></div>';
|
2025-11-24 17:53:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
branchesHtml += '</div>';
|
|
|
|
|
|
branchesHtml += '<div style="margin-top: 15px;">';
|
|
|
|
|
|
branchesHtml += '<button class="btn-new" onclick="cloneSelectedBranches()" style="margin-right: 10px;">✅ 克隆选中分支</button>';
|
|
|
|
|
|
branchesHtml += '<button class="back-btn" onclick="cancelBranchSelection()">取消</button>';
|
|
|
|
|
|
branchesHtml += '</div></div>';
|
|
|
|
|
|
|
|
|
|
|
|
container.innerHTML = branchesHtml;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-18 09:10:47 +08:00
|
|
|
|
// 对话框函数
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-24 17:53:48 +08:00
|
|
|
|
// 消息监听
|
2025-11-18 09:10:47 +08:00
|
|
|
|
window.addEventListener('message', event => {
|
|
|
|
|
|
const message = event.data;
|
2025-11-24 17:53:48 +08:00
|
|
|
|
console.log('📨 前端收到后端消息:', message);
|
|
|
|
|
|
|
|
|
|
|
|
if (message.type === 'branchesFetched') {
|
|
|
|
|
|
console.log('🌿 收到分支数据:', message.branches);
|
|
|
|
|
|
renderBranchSelection(message.branches, message.repoUrl);
|
|
|
|
|
|
}
|
2025-11-18 09:10:47 +08:00
|
|
|
|
});
|
2025-11-18 14:03:22 +08:00
|
|
|
|
|
2025-11-25 16:32:06 +08:00
|
|
|
|
// 初始化
|
2025-11-24 17:53:48 +08:00
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
|
console.log('📄 ConfigView 页面加载完成');
|
|
|
|
|
|
});
|
2025-11-18 09:10:47 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>`;
|
|
|
|
|
|
}
|
2025-11-24 17:53:48 +08:00
|
|
|
|
generateBranchesHtml(branches) {
|
|
|
|
|
|
if (branches.length === 0)
|
|
|
|
|
|
return '';
|
|
|
|
|
|
let html = '<div class="branch-selection" style="margin: 15px 0; padding: 15px; background: var(--vscode-panel-background); border-radius: 4px;">';
|
|
|
|
|
|
html += '<h4>🌿 选择要克隆的分支 (共 ' + branches.length + ' 个)</h4>';
|
|
|
|
|
|
html += '<div style="max-height: 200px; overflow-y: auto; margin: 10px 0;">';
|
|
|
|
|
|
branches.forEach(branch => {
|
|
|
|
|
|
const branchId = 'branch-' + branch.name.replace(/[^a-zA-Z0-9]/g, '-');
|
|
|
|
|
|
html += '<div class="branch-item" style="padding: 8px; border-bottom: 1px solid var(--vscode-panel-border); display: flex; align-items: center;">';
|
|
|
|
|
|
html += '<input type="checkbox" id="' + branchId + '" ';
|
|
|
|
|
|
html += (branch.selected ? 'checked' : '') + ' onchange="toggleBranch(\'' + branch.name + '\')" style="margin-right: 10px;">';
|
|
|
|
|
|
html += '<label for="' + branchId + '" style="flex: 1; cursor: pointer;">';
|
|
|
|
|
|
html += (branch.isCurrent ? '⭐ ' : '') + branch.name;
|
|
|
|
|
|
html += (branch.isRemote ? '(远程)' : '(本地)') + '</label></div>';
|
|
|
|
|
|
});
|
|
|
|
|
|
html += '<div style="margin-top: 15px;">';
|
|
|
|
|
|
html += '<button class="btn-new" onclick="cloneSelectedBranches()" style="margin-right: 10px;">✅ 克隆选中分支</button>';
|
|
|
|
|
|
html += '<button class="back-btn" onclick="cancelBranchSelection()">取消</button>';
|
|
|
|
|
|
html += '</div></div>';
|
|
|
|
|
|
return html;
|
|
|
|
|
|
}
|
2025-11-18 18:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
exports.ConfigView = ConfigView;
|
|
|
|
|
|
//# sourceMappingURL=ConfigView.js.map
|