0
0
Files
vs-p/out/panels/views/ProjectView.js

227 lines
7.5 KiB
JavaScript
Raw Normal View History

2025-11-18 18:45:30 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProjectView = void 0;
2025-12-03 16:08:14 +08:00
// src/panels/views/ProjectView.ts
2025-11-18 18:45:30 +08:00
const BaseView_1 = require("./BaseView");
class ProjectView extends BaseView_1.BaseView {
render(data) {
2025-11-18 14:03:22 +08:00
const projects = data?.projects || [];
const projectPaths = data?.projectPaths || new Map();
2025-11-18 18:45:30 +08:00
const projectsHtml = projects.map((project) => {
2025-11-18 14:03:22 +08:00
const isConfigured = projectPaths.has(project.id);
const statusIcon = isConfigured ? '✅' : '⚙️';
const statusText = isConfigured ? '已配置' : '待配置';
return `
<tr>
<td>
<span class="project-name" data-project-id="${project.id}">${statusIcon} ${project.name}</span>
<div style="font-size: 12px; color: var(--vscode-descriptionForeground); margin-top: 4px;">
${statusText}${isConfigured ? ` - ${projectPaths.get(project.id)}` : ''}
</div>
</td>
<td>
<span class="clickable" onclick="configureProject('${project.id}', '${project.name}', ${isConfigured})">
${isConfigured ? '打开' : '配置'}
</span>
</td>
<td>
<button class="btn-delete" onclick="deleteProject('${project.id}')">删除</button>
</td>
</tr>
2025-11-18 18:45:30 +08:00
`;
}).join('');
2025-11-18 14:03:22 +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">
<title>数字卫星构建平台</title>
${this.getStyles()}
<style>
.satellite-icon {
font-size: 2.5em;
vertical-align: middle;
margin-right: 10px;
line-height: 1;
display: inline-block;
position: relative;
top: -5px;
}
.header-title {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
}
.project-name {
cursor: pointer;
padding: 4px 8px;
border-radius: 4px;
transition: background-color 0.2s;
}
.project-name:hover {
background: var(--vscode-input-background);
}
2025-11-18 21:14:10 +08:00
.table-actions {
display: flex;
justify-content: center;
gap: 10px;
margin-top: 20px;
}
.btn-action {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
border: none;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-size: 13px;
display: flex;
align-items: center;
gap: 6px;
}
.btn-action:hover {
background: var(--vscode-button-hoverBackground);
}
.btn-new {
background: var(--vscode-button-background);
color: var(--vscode-button-foreground);
}
.btn-open {
background: var(--vscode-input-background);
color: var(--vscode-input-foreground);
border: 1px solid var(--vscode-input-border);
}
2025-11-18 14:03:22 +08:00
</style>
</head>
<body>
2025-12-02 12:52:41 +08:00
<div class="header">
<h2><span class="satellite-icon">🛰</span></h2>
<button class="back-btn" onclick="openRepoConfig()"> 仓库配置</button>
</div>
2025-11-18 21:14:10 +08:00
2025-11-18 14:03:22 +08:00
<table class="table">
<thead>
<tr>
<th width="40%">项目</th>
<th width="40%">配置</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
${projectsHtml}
<tr>
2025-11-18 21:14:10 +08:00
<td colspan="3" style="padding: 20px;">
<div class="table-actions">
<button class="btn-action btn-open" onclick="openExistingProject()">
<span style="font-size: 14px;">📂</span>
</button>
<button class="btn-action btn-new" onclick="createNewProject()">
<span style="font-size: 14px;">+</span>
</button>
</div>
2025-11-18 14:03:22 +08:00
</td>
</tr>
</tbody>
</table>
<script>
const vscode = acquireVsCodeApi();
2025-12-02 12:52:41 +08:00
function openRepoConfig() {
vscode.postMessage({
type: 'openRepoConfig'
});
}
2025-11-18 14:03:22 +08:00
function configureProject(projectId, projectName, isConfigured) {
if (isConfigured) {
vscode.postMessage({
type: 'openProject',
projectId: projectId
});
} else {
vscode.postMessage({
type: 'configureProject',
projectId: projectId,
projectName: projectName
});
}
}
2025-11-18 21:14:10 +08:00
function openExistingProject() {
vscode.postMessage({
type: 'openExistingProject'
});
}
2025-11-18 14:03:22 +08:00
function createNewProject() {
showPromptDialog(
'新建项目',
'请输入项目名称:',
'',
function(name) {
if (name) {
vscode.postMessage({
type: 'createProject',
name: name
});
}
}
);
}
function deleteProject(projectId) {
showConfirmDialog(
'确认删除',
'确定删除这个项目吗?',
function() {
vscode.postMessage({
type: 'deleteProject',
projectId: projectId
});
},
function() {
// 用户取消删除
}
);
}
2025-12-03 16:08:14 +08:00
// 项目名称编辑功能
2025-11-18 14:03:22 +08:00
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('click', function(event) {
if (event.target.classList.contains('project-name')) {
const projectNameElement = event.target;
const projectId = projectNameElement.getAttribute('data-project-id');
const currentName = projectNameElement.textContent.trim().split(' ').slice(1).join(' ');
if (projectId) {
editProjectName(projectId, currentName);
}
}
});
});
function editProjectName(projectId, currentName) {
showPromptDialog(
'修改项目名称',
'请输入新的项目名称:',
currentName,
function(newName) {
if (newName && newName !== currentName) {
vscode.postMessage({
type: 'updateProjectName',
projectId: projectId,
name: newName
});
}
}
);
}
</script>
</body>
</html>`;
}
2025-11-18 18:45:30 +08:00
}
exports.ProjectView = ProjectView;
//# sourceMappingURL=ProjectView.js.map