0
0

添加了一个可视化仓库功能

This commit is contained in:
xubing
2025-12-02 12:52:41 +08:00
parent b94305476f
commit fb8e31babb
13 changed files with 740 additions and 396 deletions

View File

@@ -115,59 +115,154 @@ class BaseView {
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);
}
.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>
<script>
(function () {
// 避免在同一个 Webview 中重复注册
if (window.__dcspRepoDialogInitialized) {
return;
}
window.__dcspRepoDialogInitialized = true;
function showRepoSelectDialog(repos) {
// 移除已有弹窗
var existing = document.getElementById('repoSelectModal');
if (existing) {
existing.remove();
}
var overlay = document.createElement('div');
overlay.className = 'modal-overlay';
overlay.id = 'repoSelectModal';
var hasRepos = Array.isArray(repos) && repos.length > 0;
var optionsHtml = '';
if (hasRepos) {
for (var i = 0; i < repos.length; i++) {
var r = repos[i];
if (!r || !r.name) continue;
optionsHtml += '<option value="' + r.name + '">' + r.name + '</option>';
}
}
var disabledAttr = hasRepos ? '' : 'disabled';
var noRepoTip = '';
if (!hasRepos) {
noRepoTip = '<div style="margin-top:8px; font-size:12px; color: var(--vscode-descriptionForeground);">当前配置中没有仓库,请先在“仓库配置”中添加。</div>';
}
overlay.innerHTML =
'<div class="modal-dialog">' +
'<div class="modal-title">获取仓库</div>' +
'<div style="margin-bottom: 10px;">' +
'<label style="display:block; margin-bottom:6px;">请选择仓库:</label>' +
'<select id="repoSelect" style="width:100%; padding:6px; background: var(--vscode-input-background); color: var(--vscode-input-foreground); border:1px solid var(--vscode-input-border); border-radius:4px;">' +
optionsHtml +
'</select>' +
noRepoTip +
'</div>' +
'<div class="modal-buttons">' +
'<button class="modal-btn modal-btn-secondary" id="repoSelectCancelBtn">取消</button>' +
'<button class="modal-btn modal-btn-primary" id="repoSelectOkBtn" ' + disabledAttr + '>确定</button>' +
'</div>' +
'</div>';
document.body.appendChild(overlay);
var cancelBtn = document.getElementById('repoSelectCancelBtn');
var okBtn = document.getElementById('repoSelectOkBtn');
var select = document.getElementById('repoSelect');
if (cancelBtn) {
cancelBtn.addEventListener('click', function () {
overlay.remove();
});
}
if (okBtn) {
okBtn.addEventListener('click', function () {
if (!select || !(select instanceof HTMLSelectElement)) {
overlay.remove();
return;
}
var repoName = select.value;
if (!repoName) {
alert('请选择一个仓库');
return;
}
if (typeof vscode !== 'undefined') {
vscode.postMessage({
type: 'repoSelectedForBranches',
repoName: repoName
});
}
overlay.remove();
});
}
}
window.addEventListener('message', function (event) {
var message = event.data;
if (!message || !message.type) return;
if (message.type === 'showRepoSelect') {
showRepoSelectDialog(message.repos || []);
}
});
})();
</script>
`;
}
}

View File

@@ -1 +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"}
{"version":3,"file":"BaseView.js","sourceRoot":"","sources":["../../../src/panels/views/BaseView.ts"],"names":[],"mappings":";;;AAEA,MAAsB,QAAQ;IAG1B,YAAY,YAAwB;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAIS,SAAS;QACf,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAiQN,CAAC;IACN,CAAC;CACJ;AA7QD,4BA6QC"}

View File

@@ -11,7 +11,6 @@ class ConfigView extends BaseView_1.BaseView {
const moduleFolderFileTree = data?.moduleFolderFileTree || [];
const moduleFolderLoading = data?.moduleFolderLoading || false;
const gitBranches = data?.gitBranches || [];
const gitRepoUrl = data?.gitRepoUrl || '';
// 生成配置列表的 HTML - 包含配置文件和模块文件夹
const configsHtml = configs.map((config) => `
<tr>
@@ -37,22 +36,22 @@ class ConfigView extends BaseView_1.BaseView {
category += '(已上传)';
}
return `
<tr>
<td>
<span class="editable">${icon} ${folder.name}</span>
</td>
<td class="category-${folder.type}">${category}</td>
<td>
<span class="clickable" onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">${folder.localPath.split('/').pop()}</span>
</td>
<td>
<button class="btn-upload" onclick="uploadModuleFolder('${folder.id}', '${folder.type}')" style="margin-right: 5px;">上传</button>
<button class="btn-delete" onclick="deleteModuleFolder('${folder.id}')">删除</button>
</td>
</tr>
`;
<tr>
<td>
<span class="editable">${icon} ${folder.name}</span>
</td>
<td class="category-${folder.type}">${category}</td>
<td>
<span class="clickable" onclick="openTheModuleFolder('${folder.id}', '${folder.type}')">${folder.localPath.split('/').pop()}</span>
</td>
<td>
<button class="btn-upload" onclick="uploadModuleFolder('${folder.id}', '${folder.type}')" style="margin-right: 5px;">上传</button>
<button class="btn-delete" onclick="deleteModuleFolder('${folder.id}')">删除</button>
</td>
</tr>
`;
}).join('');
// 生成分支选择的 HTML - 使用树状结构
// 生成分支选择的 HTML - 使用树状结构(首次渲染可以为空,后续通过 message 更新)
const branchesHtml = gitBranches.length > 0 ? this.generateBranchesTreeHtml(gitBranches) : '';
return `<!DOCTYPE html>
<html lang="zh-CN">
@@ -237,25 +236,25 @@ class ConfigView extends BaseView_1.BaseView {
}
/* 类别标签样式 */
.category-git {
color: var(--vscode-gitDecoration-untrackedResourceForeground);
font-weight: bold;
}
.category-git {
color: var(--vscode-gitDecoration-untrackedResourceForeground);
font-weight: bold;
}
.category-local {
color: var(--vscode-charts-orange);
font-weight: bold;
}
.category-local {
color: var(--vscode-charts-orange);
font-weight: bold;
}
.category-git已上传 {
color: var(--vscode-gitDecoration-addedResourceForeground);
font-weight: bold;
}
.category-git已上传 {
color: var(--vscode-gitDecoration-addedResourceForeground);
font-weight: bold;
}
.category-local已上传 {
color: var(--vscode-gitDecoration-addedResourceForeground);
font-weight: bold;
}
.category-local已上传 {
color: var(--vscode-gitDecoration-addedResourceForeground);
font-weight: bold;
}
</style>
</head>
<body>
@@ -294,15 +293,14 @@ class ConfigView extends BaseView_1.BaseView {
<div class="config-section">
<h3 class="section-title">📚 模块云仓库</h3>
<!-- URL 输入区域 -->
<!-- 仓库选择区域:不再手动输入 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>
<h4>🔗 获取仓库</h4>
<div style="display: flex; gap: 10px; margin-top: 10px; align-items: center;">
<button class="btn-new" onclick="openRepoSelect()">获取仓库</button>
<span style="font-size: 12px; color: var(--vscode-descriptionForeground);">
从仓库配置中选择 Git 仓库,随后可以选择分支并克隆到本地
</span>
</div>
<div id="branchSelectionContainer">
${branchesHtml}
@@ -315,7 +313,6 @@ class ConfigView extends BaseView_1.BaseView {
const vscode = acquireVsCodeApi();
let currentConfigId = null;
let selectedBranches = new Set();
let currentRepoUrl = '';
let branchTreeData = [];
let selectedConfigs = new Set();
@@ -337,7 +334,7 @@ class ConfigView extends BaseView_1.BaseView {
);
}
// 新功能:在 VSCode 中打开配置文件
// 在 VSCode 中打开配置文件
function openConfigFileInVSCode(configId) {
console.log('📄 在 VSCode 中打开配置文件:', configId);
vscode.postMessage({
@@ -436,7 +433,7 @@ class ConfigView extends BaseView_1.BaseView {
}
}
// 添加上传对话框函数
// 上传对话框函数(本地->Git
function showUploadDialog(folderId) {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';
@@ -522,30 +519,16 @@ class ConfigView extends BaseView_1.BaseView {
vscode.postMessage({ type: 'goBackToContainers' });
}
// 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);
// 🔁 新逻辑:通过弹窗获取仓库(不再手动输入 URL
function openRepoSelect() {
console.log('📦 请求仓库列表以选择 Git 仓库');
vscode.postMessage({
type: 'fetchBranches',
url: repoUrl
type: 'openRepoSelect'
});
}
// 不再在前端手动输入/校验 URL分支拉取由 repo 选择 + 后端完成
function toggleBranch(branchName) {
const checkbox = document.getElementById('branch-' + branchName.replace(/[^a-zA-Z0-9-]/g, '-'));
if (checkbox.checked) {
@@ -566,7 +549,6 @@ class ConfigView extends BaseView_1.BaseView {
vscode.postMessage({
type: 'cloneBranches',
url: currentRepoUrl,
branches: Array.from(selectedBranches)
});
@@ -625,7 +607,7 @@ class ConfigView extends BaseView_1.BaseView {
showMergeDialog();
}
// 新的合并对话框函数
// 合并对话框
function showMergeDialog() {
const overlay = document.createElement('div');
overlay.className = 'modal-overlay';

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProjectView = void 0;
// src/panels/views/ProjectView.ts
const BaseView_1 = require("./BaseView");
class ProjectView extends BaseView_1.BaseView {
render(data) {
@@ -95,7 +94,10 @@ class ProjectView extends BaseView_1.BaseView {
</style>
</head>
<body>
<h2><span class="satellite-icon">🛰️</span>数字卫星构建平台</h2>
<div class="header">
<h2><span class="satellite-icon">🛰️</span>数字卫星构建平台</h2>
<button class="back-btn" onclick="openRepoConfig()">⚙️ 仓库配置</button>
</div>
<table class="table">
<thead>
@@ -125,6 +127,12 @@ class ProjectView extends BaseView_1.BaseView {
<script>
const vscode = acquireVsCodeApi();
function openRepoConfig() {
vscode.postMessage({
type: 'openRepoConfig'
});
}
function configureProject(projectId, projectName, isConfigured) {
if (isConfigured) {
// 已配置的项目直接打开

View File

@@ -1 +1 @@
{"version":3,"file":"ProjectView.js","sourceRoot":"","sources":["../../../src/panels/views/ProjectView.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,yCAAsC;AAGtC,MAAa,WAAY,SAAQ,mBAAQ;IACrC,MAAM,CAAC,IAA0E;QAC7E,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC;QACtC,MAAM,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,IAAI,GAAG,EAAE,CAAC;QAErD,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE;YAC3D,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7C,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YAEhD,OAAO;;;kEAG+C,OAAO,CAAC,EAAE,KAAK,UAAU,IAAI,OAAO,CAAC,IAAI;;0BAEjF,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;;;;yEAItB,OAAO,CAAC,EAAE,OAAO,OAAO,CAAC,IAAI,MAAM,YAAY;0BAC9F,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;;;;yEAIqB,OAAO,CAAC,EAAE;;;SAG1E,CAAA;QAAA,CAAC,CAAC,CAAC,I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