简化TabPage标签布局:使用tab-spacer元素占据中间空间,实现标题靠左显示、关闭按钮靠右显示

This commit is contained in:
zqm
2025-11-05 15:38:25 +08:00
parent 5c6a6c8d5a
commit 721643cce4

View File

@@ -8,23 +8,18 @@
:class="['tab-item', { 'active': activeTabIndex === index }]"
@click="setActiveTab(index)"
>
<div class="flex items-center justify-between w-full">
<div class="tab-title-container">
<span class="tab-title-text">{{ panel.title }}</span>
</div>
<div class="tab-buttons-container">
<button
class="button-icon p-[2px] rounded hover:opacity-100 opacity-80"
@click.stop="closeTab(panel.id)"
aria-label="关闭"
>
<svg width="11" height="11" viewBox="0 0 11 11" aria-hidden="true">
<line x1="2" y1="2" x2="9" y2="9" stroke="#e6efff" stroke-width="1" />
<line x1="2" y1="9" x2="9" y2="2" stroke="#e6efff" stroke-width="1" />
</svg>
</button>
</div>
</div>
<span class="tab-title">{{ panel.title }}</span>
<span class="tab-spacer"></span>
<button
class="button-icon p-[2px] rounded hover:opacity-100 opacity-80"
@click.stop="closeTab(panel.id)"
aria-label="关闭"
>
<svg width="11" height="11" viewBox="0 0 11 11" aria-hidden="true">
<line x1="2" y1="2" x2="9" y2="9" stroke="#e6efff" stroke-width="1" />
<line x1="2" y1="9" x2="9" y2="2" stroke="#e6efff" stroke-width="1" />
</svg>
</button>
</div>
<div class="tab-placeholder"></div>
</div>
@@ -121,24 +116,18 @@ const closeTab = (tabId) => {
width: fit-content;
}
.tab-title-container {
display: flex;
align-items: center;
flex: 1;
margin-right: 8px;
}
.tab-title-text {
.tab-title {
text-align: left;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 8px;
}
.tab-buttons-container {
display: flex;
align-items: center;
.tab-spacer {
flex: 1;
min-width: 0;
}
.tab-item.active {