feat: 添加工作空间面板 - 右侧终端/文件浏览器

- 新增主进程 workspace.ts:spawn 进程管理,流式输出,安全检查
- IPC 双向通信:workspace:exec(on/send 模式,无超时限制)
- preload 暴露 workspace API
- 渲染进程 workspace-panel.ts:多终端 Tab、ANSI 颜色渲染、文件浏览器
- 设置面板添加工作空间目录配置
- 启动时自动创建 workspace 目录
- 窗口关闭时自动清理所有子进程
- 帮助文档更新
This commit is contained in:
thzxx
2026-04-07 18:30:45 +08:00
parent 9485b4c09e
commit 0e1f216aa4
10 changed files with 1555 additions and 0 deletions
+416
View File
@@ -2659,3 +2659,419 @@ html, body {
color: var(--accent-cyan, #00f5d4);
opacity: 0.7;
}
/* ═══════════════ 工作空间面板 ═══════════════ */
.workspace-panel {
position: fixed;
top: 0;
right: 0;
bottom: 0;
width: 420px;
background: var(--bg-solid, #202020);
border-left: 1px solid var(--border-default, rgba(255,255,255,0.08));
display: flex;
flex-direction: column;
z-index: 10;
font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
}
.ws-resizer {
position: absolute;
left: -3px;
top: 0;
bottom: 0;
width: 6px;
cursor: col-resize;
z-index: 11;
}
.ws-resizer:hover {
background: var(--accent, #60CDFF);
opacity: 0.3;
}
.ws-header {
display: flex;
align-items: center;
padding: 8px 12px;
border-bottom: 1px solid var(--border-default, rgba(255,255,255,0.08));
background: var(--bg-layer-alt, #2a2a2a);
min-height: 44px;
gap: 8px;
}
.ws-title {
font-size: 13px;
font-weight: 600;
color: var(--text-primary, #fff);
white-space: nowrap;
font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
}
.ws-tabs {
display: flex;
gap: 2px;
margin-left: auto;
}
.ws-tab {
background: transparent;
border: 1px solid transparent;
color: var(--text-secondary, #999);
padding: 4px 10px;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
transition: all 0.15s;
}
.ws-tab:hover {
background: var(--bg-card-hover, #323232);
color: var(--text-primary, #fff);
}
.ws-tab.active {
background: var(--bg-layer, #383838);
color: var(--accent, #60CDFF);
border-color: var(--border-strong, rgba(255,255,255,0.12));
}
.ws-toggle-btn {
margin-left: 4px;
padding: 4px;
}
/* ── 终端内容区 ── */
.ws-content {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.ws-term-tab-bar {
display: flex;
gap: 1px;
padding: 4px 8px 0;
background: var(--bg-layer-alt, #2a2a2a);
border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
overflow-x: auto;
min-height: 30px;
}
.ws-term-tab-bar .ws-tab {
font-size: 11px;
padding: 3px 8px;
border-radius: 4px 4px 0 0;
border-bottom: none;
display: flex;
align-items: center;
gap: 4px;
flex-shrink: 0;
}
.ws-term-tab-bar .ws-tab.active {
background: var(--bg-solid, #202020);
border-color: var(--border-default, rgba(255,255,255,0.08));
border-bottom: 1px solid var(--bg-solid, #202020);
}
.ws-tab-title {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ws-tab-close {
background: none;
border: none;
color: var(--text-tertiary, #666);
cursor: pointer;
font-size: 10px;
padding: 0 2px;
line-height: 1;
border-radius: 2px;
}
.ws-tab-close:hover {
background: rgba(255,255,255,0.1);
color: var(--text-primary, #fff);
}
.ws-term-output {
flex: 1;
overflow-y: auto;
padding: 8px 12px;
font-size: 12px;
line-height: 1.5;
color: var(--text-primary, #fff);
background: var(--bg-solid, #202020);
word-break: break-all;
white-space: pre-wrap;
}
.ws-term-placeholder {
color: var(--text-tertiary, #666);
text-align: center;
padding: 40px 20px;
font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
}
.ws-term-line {
min-height: 1.5em;
}
.ws-term-stdout {
color: #ccc;
}
.ws-term-stderr {
color: #ff6b68;
}
.ws-term-system {
color: var(--accent, #60CDFF);
font-weight: 500;
opacity: 0.9;
}
.ws-term-toolbar {
display: flex;
align-items: center;
gap: 4px;
padding: 6px 8px;
border-top: 1px solid var(--border-default, rgba(255,255,255,0.08));
background: var(--bg-layer-alt, #2a2a2a);
}
.ws-term-input {
flex: 1;
background: var(--bg-layer, #383838);
border: 1px solid var(--border-default, rgba(255,255,255,0.08));
border-radius: 4px;
color: var(--text-primary, #fff);
padding: 6px 10px;
font-size: 12px;
font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
outline: none;
transition: border-color 0.15s;
}
.ws-term-input:focus {
border-color: var(--accent, #60CDFF);
}
.ws-term-input::placeholder {
color: var(--text-tertiary, #666);
}
.ws-toolbar-btn {
background: transparent;
border: 1px solid transparent;
color: var(--text-secondary, #999);
cursor: pointer;
padding: 5px 7px;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
}
.ws-toolbar-btn svg {
width: 14px;
height: 14px;
}
.ws-toolbar-btn:hover:not(:disabled) {
background: var(--bg-card-hover, #323232);
color: var(--text-primary, #fff);
}
.ws-toolbar-btn:disabled {
opacity: 0.3;
cursor: not-allowed;
}
.ws-stop-btn.active {
color: #ff6b68;
}
.ws-stop-btn.active:hover {
background: rgba(255, 107, 104, 0.15);
}
/* ── 文件浏览器 ── */
.ws-file-toolbar {
display: flex;
align-items: center;
gap: 4px;
padding: 6px 8px;
border-bottom: 1px solid var(--border-default, rgba(255,255,255,0.08));
background: var(--bg-layer-alt, #2a2a2a);
}
.ws-file-path {
flex: 1;
font-size: 11px;
color: var(--text-secondary, #999);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ws-file-list {
flex: 1;
overflow-y: auto;
padding: 4px 0;
}
.ws-file-empty {
color: var(--text-tertiary, #666);
text-align: center;
padding: 40px 20px;
font-size: 13px;
font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
}
.ws-file-item {
display: flex;
align-items: center;
padding: 5px 12px;
cursor: pointer;
transition: background 0.1s;
gap: 8px;
}
.ws-file-item:hover {
background: var(--bg-card-hover, #323232);
}
.ws-file-icon {
font-size: 14px;
flex-shrink: 0;
width: 20px;
text-align: center;
}
.ws-file-name {
flex: 1;
font-size: 12px;
color: var(--text-primary, #fff);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ws-file-size {
font-size: 11px;
color: var(--text-tertiary, #666);
flex-shrink: 0;
}
/* ── 文件预览 ── */
.ws-preview {
border-top: 1px solid var(--border-default, rgba(255,255,255,0.08));
display: flex;
flex-direction: column;
max-height: 50%;
}
.ws-preview-header {
display: flex;
align-items: center;
padding: 6px 12px;
background: var(--bg-layer-alt, #2a2a2a);
gap: 8px;
}
.ws-preview-title {
flex: 1;
font-size: 12px;
color: var(--text-primary, #fff);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ws-preview-content {
flex: 1;
overflow-y: auto;
padding: 0;
background: var(--bg-solid, #202020);
}
.ws-preview-pre {
margin: 0;
padding: 8px 0;
font-size: 11px;
line-height: 1.5;
font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
color: var(--text-primary, #fff);
}
.ws-preview-line {
display: block;
padding: 0 12px;
}
.ws-preview-line:hover {
background: rgba(255,255,255,0.03);
}
.ws-line-num {
display: inline-block;
width: 40px;
text-align: right;
padding-right: 12px;
color: var(--text-tertiary, #666);
user-select: none;
border-right: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
margin-right: 8px;
}
/* ── 滚动条 ── */
.ws-term-output::-webkit-scrollbar,
.ws-file-list::-webkit-scrollbar,
.ws-preview-content::-webkit-scrollbar,
.ws-term-tab-bar::-webkit-scrollbar {
width: 6px;
}
.ws-term-output::-webkit-scrollbar-track,
.ws-file-list::-webkit-scrollbar-track,
.ws-preview-content::-webkit-scrollbar-track {
background: transparent;
}
.ws-term-output::-webkit-scrollbar-thumb,
.ws-file-list::-webkit-scrollbar-thumb,
.ws-preview-content::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.1);
border-radius: 3px;
}
.ws-term-output::-webkit-scrollbar-thumb:hover,
.ws-file-list::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.2);
}
/* ── Header 按钮高亮 ── */
#btnWorkspace.active {
color: var(--accent, #60CDFF);
background: var(--accent-subtle, rgba(96,205,255,0.06));
}
/* ── 主内容区自适应 ── */
.main-wrap.with-workspace {
margin-right: 420px;
}