feat: 共享标签页模式下文件便编辑器会显示会话名
防止多文件状态下混淆文件所属的会话
This commit is contained in:
@@ -7,9 +7,15 @@ import FileEditorTabs from './FileEditorTabs.vue'; // 导入标签栏组件 (路
|
|||||||
// import { useFileEditorStore } from '../stores/fileEditor.store'; // 移除 Store 导入
|
// import { useFileEditorStore } from '../stores/fileEditor.store'; // 移除 Store 导入
|
||||||
import type { FileTab } from '../stores/fileEditor.store'; // 保留类型导入
|
import type { FileTab } from '../stores/fileEditor.store'; // 保留类型导入
|
||||||
import { useFocusSwitcherStore } from '../stores/focusSwitcher.store'; // +++ 导入焦点切换 Store +++
|
import { useFocusSwitcherStore } from '../stores/focusSwitcher.store'; // +++ 导入焦点切换 Store +++
|
||||||
|
import { useSessionStore } from '../stores/session.store'; // +++ 导入会话 Store +++
|
||||||
|
import { useSettingsStore } from '../stores/settings.store'; // +++ 导入设置 Store +++
|
||||||
|
import { storeToRefs } from 'pinia'; // +++ 导入 storeToRefs +++
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const focusSwitcherStore = useFocusSwitcherStore(); // +++ 实例化焦点切换 Store +++
|
const focusSwitcherStore = useFocusSwitcherStore(); // +++ 实例化焦点切换 Store +++
|
||||||
|
const sessionStore = useSessionStore(); // +++ 实例化会话 Store +++
|
||||||
|
const settingsStore = useSettingsStore(); // +++ 实例化设置 Store +++
|
||||||
|
const { shareFileEditorTabsBoolean } = storeToRefs(settingsStore); // +++ 获取共享设置 +++
|
||||||
|
|
||||||
// --- Props ---
|
// --- Props ---
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -125,6 +131,12 @@ const currentTabFilePath = computed(() => activeTab.value?.filePath ?? '');
|
|||||||
const currentTabIsModified = computed(() => activeTab.value?.isModified ?? false); // 用于显示修改状态
|
const currentTabIsModified = computed(() => activeTab.value?.isModified ?? false); // 用于显示修改状态
|
||||||
// +++ 新增:计算当前选择的编码 +++
|
// +++ 新增:计算当前选择的编码 +++
|
||||||
const currentSelectedEncoding = computed(() => activeTab.value?.selectedEncoding ?? 'utf-8');
|
const currentSelectedEncoding = computed(() => activeTab.value?.selectedEncoding ?? 'utf-8');
|
||||||
|
// +++ 新增:计算当前活动标签的会话名称 +++
|
||||||
|
const currentTabSessionName = computed(() => {
|
||||||
|
const sessionId = activeTab.value?.sessionId;
|
||||||
|
if (!sessionId) return null;
|
||||||
|
return sessionStore.sessions.get(sessionId)?.connectionName ?? null; // 修正:使用 connectionName
|
||||||
|
});
|
||||||
|
|
||||||
// Watch for changes in the selected encoding to update width
|
// Watch for changes in the selected encoding to update width
|
||||||
watch(currentSelectedEncoding, () => {
|
watch(currentSelectedEncoding, () => {
|
||||||
@@ -291,7 +303,7 @@ const handleKeyDown = (event: KeyboardEvent) => {
|
|||||||
<!-- 移除关闭/最小化按钮,这些由 WorkspaceView 控制 -->
|
<!-- 移除关闭/最小化按钮,这些由 WorkspaceView 控制 -->
|
||||||
<div v-if="activeTab" class="editor-header">
|
<div v-if="activeTab" class="editor-header">
|
||||||
<span>
|
<span>
|
||||||
{{ t('fileManager.editingFile') }}: {{ currentTabFilePath }}
|
{{ t('fileManager.editingFile') }}<template v-if="shareFileEditorTabsBoolean && currentTabSessionName">({{ currentTabSessionName }})</template>: {{ currentTabFilePath }}
|
||||||
<span v-if="currentTabIsModified" class="modified-indicator">*</span>
|
<span v-if="currentTabIsModified" class="modified-indicator">*</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="editor-actions">
|
<div class="editor-actions">
|
||||||
|
|||||||
@@ -160,6 +160,13 @@ const currentTabSaveError = computed(() => activeTab.value?.saveError ?? null);
|
|||||||
const currentTabLanguage = computed(() => activeTab.value?.language ?? 'plaintext');
|
const currentTabLanguage = computed(() => activeTab.value?.language ?? 'plaintext');
|
||||||
const currentTabFilePath = computed(() => activeTab.value?.filePath ?? '');
|
const currentTabFilePath = computed(() => activeTab.value?.filePath ?? '');
|
||||||
const currentTabIsModified = computed(() => activeTab.value?.isModified ?? false);
|
const currentTabIsModified = computed(() => activeTab.value?.isModified ?? false);
|
||||||
|
// +++ 新增:计算当前活动标签的会话名称 (与 Container 逻辑一致) +++
|
||||||
|
const currentTabSessionName = computed(() => {
|
||||||
|
const sessionId = activeTab.value?.sessionId;
|
||||||
|
if (!sessionId) return null;
|
||||||
|
// sessionStore 已在 setup 中实例化
|
||||||
|
return sessionStore.sessions.get(sessionId)?.connectionName ?? null; // 修正:使用 connectionName
|
||||||
|
});
|
||||||
|
|
||||||
// --- 事件处理 (根据模式调用不同 action) ---
|
// --- 事件处理 (根据模式调用不同 action) ---
|
||||||
|
|
||||||
@@ -352,7 +359,7 @@ onBeforeUnmount(() => {
|
|||||||
<!-- 编辑器头部 (使用动态计算属性) -->
|
<!-- 编辑器头部 (使用动态计算属性) -->
|
||||||
<div v-if="activeTab" class="editor-header">
|
<div v-if="activeTab" class="editor-header">
|
||||||
<span>
|
<span>
|
||||||
{{ t('fileManager.editingFile') }}: {{ currentTabFilePath }}
|
{{ t('fileManager.editingFile') }}<template v-if="shareFileEditorTabsBoolean && currentTabSessionName">({{ currentTabSessionName }})</template>: {{ currentTabFilePath }}
|
||||||
<span v-if="currentTabIsModified" class="modified-indicator">*</span>
|
<span v-if="currentTabIsModified" class="modified-indicator">*</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="editor-actions">
|
<div class="editor-actions">
|
||||||
|
|||||||
Reference in New Issue
Block a user