添加面板区域

This commit is contained in:
JoyD
2025-10-30 22:17:58 +08:00
parent d13afbc199
commit 9d4e008c0e
2 changed files with 206 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
<template>
<div class="vs-area select-none">
<!-- 顶部标题栏 -->
<div class="vs-title-bar">
<div class="vs-title-left">
<span class="vs-app-icon"></span>
<span class="vs-title-text">{{ title || 'GlobalHook_Test' }}</span>
</div>
<div class="vs-title-right">
<button class="vs-btn"></button>
<button class="vs-btn"></button>
<button class="vs-btn vs-close">×</button>
</div>
</div>
<!-- 面板标题/ -->
<div class="vs-pane-headers">
<div class="vs-pane-header">
<span class="hdr-text">输出</span>
<span class="hdr-icon"></span>
<span class="hdr-close">×</span>
</div>
<div class="vs-pane-sep"></div>
<div class="vs-pane-header">
<span class="hdr-text">Git 更改</span>
<span class="hdr-icon"></span>
<span class="hdr-close">×</span>
</div>
</div>
<!-- 内容区域左右分栏 -->
<div class="vs-content">
<!-- 左侧输出 -->
<div class="vs-left">
<div class="left-blank"></div>
</div>
<div class="vs-divider"></div>
<!-- 右侧Git 更改 -->
<div class="vs-right">
<div class="sec-text">初始化备份和共享存储库</div>
<div class="vs-card">
<span class="card-icon">🛠</span>
<span class="card-text">创建 Git 存储库...</span>
</div>
<div class="sec-text"> GitHub Azure DevOps 等联机存储库获取代码</div>
<div class="vs-card">
<span class="card-icon"></span>
<span class="card-text">克隆存储库...</span>
</div>
<div class="hint-text">检出分支创建标签管理子模块...</div>
</div>
</div>
</div>
</template>
<script setup>
import { defineProps } from 'vue'
const props = defineProps({
id: { type: String, required: true },
title: { type: String, default: 'GlobalHook_Test' },
resizable: { type: Boolean, default: true }
})
</script>
<style scoped>
:root { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
/* 颜色(贴近 VS 蓝色主题) */
.vs-area {
--vs-blue-top: #4f72b3;
--vs-blue-bottom: #3c5a99;
--vs-blue-deep: #2c3e7a;
--vs-tab-blue: #4869a8;
--vs-border: #c7d2ea;
--vs-bg: #f5f7fb;
--vs-panel: #ffffff;
--vs-muted: #6b7aa9;
--vs-accent: #f0a000;
}
/* 容器 */
.vs-area {
display: flex;
flex-direction: column;
background: var(--vs-bg);
border: 1px solid var(--vs-border);
min-width: 400px;
min-height: 200px;
}
/* 标题栏 */
.vs-title-bar {
height: 28px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 10px;
color: #ffffff;
background: linear-gradient(to bottom, var(--vs-blue-top), var(--vs-blue-bottom));
border-bottom: 1px solid var(--vs-blue-deep);
}
.vs-title-left { display: flex; align-items: center; gap: 6px; }
.vs-app-icon { font-size: 12px; opacity: 0.9; }
.vs-title-text { font-size: 13px; }
.vs-title-right { display: flex; align-items: center; gap: 6px; }
.vs-btn {
width: 22px; height: 18px; line-height: 18px;
color: #ffffff; background: transparent; border: none; padding: 0; cursor: default;
}
.vs-btn:hover { background: rgba(255,255,255,0.12); }
.vs-close:hover { background: #e81123; }
/* 面板标题行(左右) */
.vs-pane-headers {
display: flex; align-items: center;
height: 26px; background: var(--vs-tab-blue);
border-bottom: 1px solid var(--vs-blue-deep);
color: #eaf1ff;
padding: 0 6px;
}
.vs-pane-header {
display: flex; align-items: center; gap: 8px;
height: 100%; padding: 0 10px;
}
.vs-pane-sep {
width: 1px; height: 18px; background: rgba(255,255,255,0.3);
margin: 0 8px;
}
.hdr-text { font-size: 12px; }
.hdr-icon { font-size: 10px; opacity: 0.9; }
.hdr-close { font-size: 12px; opacity: 0.9; }
.hdr-close:hover { opacity: 1; }
/* 内容区域 */
.vs-content { display: flex; flex: 1; overflow: hidden; }
/* 左侧输出 */
.vs-left { flex: 1; background: var(--vs-panel); display: flex; }
.left-blank { flex: 1; background: #eef1f9; border-right: 1px solid var(--vs-border); }
/* 中间分割线 */
.vs-divider { width: 1px; background: var(--vs-border); }
/* 右侧 Git 更改 */
.vs-right { flex: 1; background: var(--vs-panel); padding: 10px; font-size: 12px; color: #000; }
.sec-text { margin-bottom: 8px; }
.vs-card {
display: inline-flex; align-items: center; gap: 8px;
background: #fff; border: 1px solid var(--vs-border);
padding: 6px 8px; border-radius: 2px; margin-bottom: 10px;
box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.card-icon { color: var(--vs-accent); }
.card-text { color: #000; }
.hint-text { color: #666; }
/* 滚动条(接近 VS */
:deep(::-webkit-scrollbar) { width: 12px; height: 12px; }
:deep(::-webkit-scrollbar-track) { background: var(--vs-bg); border-left: 1px solid var(--vs-border); }
:deep(::-webkit-scrollbar-thumb) {
background: linear-gradient(to bottom, #d0d6ea, #c0c7e0);
border: 1px solid #b0b6d6; border-radius: 6px;
}
:deep(::-webkit-scrollbar-thumb:hover) { background: linear-gradient(to bottom, #c1c7e2, #b2b8d9); }
:deep(*) { box-sizing: border-box; }
</style>

View File

@@ -11,6 +11,12 @@
> >
添加浮动窗口 添加浮动窗口
</button> </button>
<button
@click="addPanelArea()"
class="px-3 py-1 bg-green-50 text-green-600 rounded hover:bg-green-100 text-sm"
>
添加浮动面板区
</button>
</div> </div>
</div> </div>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
@@ -44,6 +50,18 @@
<!-- 预留主区域暂不放面板 --> <!-- 预留主区域暂不放面板 -->
<div ref="panelHost" class="flex-1 w-full h-[calc(100%-4rem)] relative bg-gray-100"> <div ref="panelHost" class="flex-1 w-full h-[calc(100%-4rem)] relative bg-gray-100">
<!-- 浮动面板区域渲染 -->
<div
v-for="area in panelAreas"
:key="area.id"
class="absolute"
:style="{ top: area.y + 'px', left: area.x + 'px', width: area.width + 'px', height: area.height + 'px' }"
>
<Area :id="area.id" :title="area.title">
<!-- 区域内容区域 -->
</Area>
</div>
<!-- 浮动面板渲染区使用抽取的组件 --> <!-- 浮动面板渲染区使用抽取的组件 -->
<Panel <Panel
v-for="panel in floatingPanels" v-for="panel in floatingPanels"
@@ -68,13 +86,17 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import Panel from '../DockLayout/Panel.vue'; import Panel from '../DockLayout/Panel.vue';
import Area from '../DockLayout/Area.vue';
// 顶部控制栏按钮的引用 // 顶部控制栏按钮的引用
const layoutFileInput = ref(null); const layoutFileInput = ref(null);
const panelHost = ref(null); const panelHost = ref(null);
// 浮动面板列表 // 浮动面板列表
const floatingPanels = ref([]); const floatingPanels = ref([]);
// 面板区域列表
const panelAreas = ref([]);
let nextPanelIdx = 1; let nextPanelIdx = 1;
let nextAreaIdx = 1;
function addPanel(position) { function addPanel(position) {
console.log('[DockLayoutTest] addPanel clicked:', position); console.log('[DockLayoutTest] addPanel clicked:', position);
@@ -99,6 +121,22 @@ function addFloatingPanel() {
floatingPanels.value.push(panel); floatingPanels.value.push(panel);
} }
function addPanelArea() {
// 添加浮动面板区域
const defaultSize = { width: 400, height: 300 };
const offset = 24;
const idx = nextAreaIdx++;
const area = {
id: 'area-' + idx,
title: '面板区域 ' + idx,
x: offset * idx,
y: offset * idx,
width: defaultSize.width,
height: defaultSize.height
};
panelAreas.value.push(area);
}
function closePanel(id) { function closePanel(id) {
floatingPanels.value = floatingPanels.value.filter(p => p.id !== id); floatingPanels.value = floatingPanels.value.filter(p => p.id !== id);
} }