Skip to content

Commit 89cd4ef

Browse files
committed
feat: 来自不同路径的同名文件现在会有明确的路径提示
1 parent cd6b370 commit 89cd4ef

2 files changed

Lines changed: 50 additions & 17 deletions

File tree

src/renderer/components/workspace/TabBar.vue

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ onUnmounted(() => {
330330
:data-tab-id="tab.id"
331331
@click="handleTabClick(tab.id)"
332332
>
333-
<p>{{ `${tab.readOnly ? "[只读] " : ""}${tab.displayName}` }}</p>
333+
<p>
334+
<span class="tab-name">{{ tab.displayName }}</span>
335+
<span v-if="tab.pathHint" class="tab-path" :title="tab.pathHint">{{ tab.pathHint }}</span>
336+
</p>
334337

335338
<div class="closeIcon">
336339
<span class="iconfont icon-close" @click="handleCloseTab(tab.id, $event)"></span>
@@ -451,19 +454,26 @@ onUnmounted(() => {
451454
font-size: 12px;
452455
color: var(--text-color-3);
453456
overflow: hidden;
454-
text-overflow: ellipsis;
455457
white-space: nowrap;
456458
flex: 1;
457459
min-width: 0;
458-
}
460+
display: flex;
461+
align-items: center;
462+
gap: 6px;
459463
460-
span {
461-
font-size: 12px;
462-
cursor: pointer;
463-
color: var(--text-color-3);
464+
.tab-name {
465+
flex-shrink: 0;
466+
min-width: 0;
467+
color: inherit;
468+
}
464469
465-
&:hover {
466-
color: var(--border-color-2);
470+
.tab-path {
471+
min-width: 0;
472+
overflow: hidden;
473+
text-overflow: ellipsis;
474+
white-space: nowrap;
475+
color: var(--text-color-4, var(--text-color-3));
476+
opacity: 0.8;
467477
}
468478
}
469479
@@ -474,6 +484,11 @@ onUnmounted(() => {
474484
475485
p {
476486
color: var(--text-color-1);
487+
488+
.tab-path {
489+
color: var(--text-color-2);
490+
opacity: 0.9;
491+
}
477492
}
478493
479494
span {
@@ -494,12 +509,6 @@ onUnmounted(() => {
494509
}
495510
496511
&:hover {
497-
z-index: 1;
498-
499-
p {
500-
color: var(--text-color-2);
501-
}
502-
503512
.closeIcon {
504513
span {
505514
color: var(--text-color-2);
@@ -636,10 +645,26 @@ onUnmounted(() => {
636645
font-size: 12px;
637646
color: var(--text-color-1); /* 激活态颜色 */
638647
overflow: hidden;
639-
text-overflow: ellipsis;
640648
white-space: nowrap;
641649
flex: 1;
642650
min-width: 0;
651+
display: flex;
652+
align-items: center;
653+
gap: 6px;
654+
}
655+
656+
:global(.tab-drag-fallback .tab-name) {
657+
flex-shrink: 0;
658+
min-width: 0;
659+
}
660+
661+
:global(.tab-drag-fallback .tab-path) {
662+
min-width: 0;
663+
overflow: hidden;
664+
text-overflow: ellipsis;
665+
white-space: nowrap;
666+
color: var(--text-color-2);
667+
opacity: 0.85;
643668
}
644669
645670
:global(.tab-drag-fallback .closeIcon) {

src/renderer/hooks/useTab.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,13 +930,21 @@ function cleanupInertiaScroll(container: HTMLElement) {
930930
// 计算属性:格式化tab显示名称
931931
// 仅依赖渲染所需的属性,避免 content/originalContent 变化(如归一化)触发不必要的重算
932932
const formattedTabs = computed(() => {
933+
const nameCountMap = new Map<string, number>();
934+
935+
for (const tab of tabs.value) {
936+
nameCountMap.set(tab.name, (nameCountMap.get(tab.name) || 0) + 1);
937+
}
938+
933939
return tabs.value.map((tab) => ({
934940
id: tab.id,
935941
name: tab.name,
942+
filePath: tab.filePath,
936943
readOnly: tab.readOnly,
937944
isModified: tab.isModified,
938945
isMergePreview: tab.isMergePreview,
939-
displayName: tab.isModified ? `*${tab.name}` : tab.name,
946+
displayName: `${tab.readOnly ? "[只读] " : ""}${tab.isModified ? "*" : ""}${tab.name}`,
947+
pathHint: nameCountMap.get(tab.name)! > 1 && tab.filePath ? tab.filePath : "",
940948
}));
941949
});
942950

0 commit comments

Comments
 (0)