feat: 状态监视器添加IP地址显示
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import apiClient from '../utils/apiClient'; // 使用统一的 apiClient
|
||||
import router from '../router'; // 引入 router 用于重定向
|
||||
import { setLocale } from '../i18n'; // 导入 setLocale
|
||||
import apiClient from '../utils/apiClient';
|
||||
import router from '../router';
|
||||
import { setLocale } from '../i18n';
|
||||
|
||||
// 扩展的用户信息接口,包含 2FA 状态和语言偏好
|
||||
interface UserInfo {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { ref, computed, readonly, watch, nextTick } from 'vue'; // Import nextTick
|
||||
import { ref, computed, readonly, watch, nextTick } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useSessionStore } from './session.store'; // 导入会话 Store
|
||||
import type { SaveStatus, SftpReadFileSuccessPayload } from '../types/sftp.types'; // 移除 SftpReadFileRequestPayload, 因为 readFile 不再需要它
|
||||
import * as iconv from '@vscode/iconv-lite-umd'; // +++ 导入 iconv-lite +++
|
||||
import { Buffer } from 'buffer/'; // +++ 导入 Buffer (需要安装 buffer 依赖) +++
|
||||
import { useSessionStore } from './session.store';
|
||||
import type { SaveStatus, SftpReadFileSuccessPayload } from '../types/sftp.types';
|
||||
import * as iconv from '@vscode/iconv-lite-umd';
|
||||
import { Buffer } from 'buffer/';
|
||||
|
||||
// --- 类型定义 ---
|
||||
// 文件信息,用于打开文件操作
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import apiClient from '../utils/apiClient'; // 使用统一的 apiClient
|
||||
import { ref, computed, watch } from 'vue'; // Import watch
|
||||
import apiClient from '../utils/apiClient';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { useUiNotificationsStore } from './uiNotifications.store';
|
||||
import { useQuickCommandTagsStore, type QuickCommandTag } from './quickCommandTags.store'; // +++ Import new tag store +++
|
||||
import { useI18n } from 'vue-i18n'; // +++ Import i18n for "Untagged" +++
|
||||
// Assuming QuickCommand type in types includes tagIds now, or define it here
|
||||
// import type { QuickCommand } from '../types/quick-commands.types';
|
||||
import { useQuickCommandTagsStore, type QuickCommandTag } from './quickCommandTags.store';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
|
||||
|
||||
// 定义前端使用的快捷指令接口 (包含 tagIds)
|
||||
export interface QuickCommandFE { // Renamed from QuickCommand if necessary
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// packages/frontend/src/stores/session.store.ts
|
||||
|
||||
|
||||
import { defineStore } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useConnectionsStore, type ConnectionInfo } from './connections.store';
|
||||
|
||||
// 从新模块导入状态
|
||||
|
||||
import {
|
||||
sessions,
|
||||
activeSessionId,
|
||||
@@ -13,30 +13,30 @@ import {
|
||||
rdpConnectionInfo,
|
||||
isVncModalOpen,
|
||||
vncConnectionInfo,
|
||||
// SSH Suspend Mode State
|
||||
|
||||
suspendedSshSessions,
|
||||
isLoadingSuspendedSessions,
|
||||
} from './session/state';
|
||||
|
||||
// 从新模块导入 Getters
|
||||
|
||||
import {
|
||||
sessionTabs,
|
||||
sessionTabsWithStatus,
|
||||
activeSession,
|
||||
} from './session/getters';
|
||||
|
||||
// 从新模块导入 Actions
|
||||
|
||||
import * as sessionActions from './session/actions/sessionActions';
|
||||
import * as editorActions from './session/actions/editorActions';
|
||||
import * as sftpManagerActions from './session/actions/sftpManagerActions';
|
||||
import * as modalActions from './session/actions/modalActions';
|
||||
import * as commandInputActions from './session/actions/commandInputActions';
|
||||
import * as sshSuspendActions from './session/actions/sshSuspendActions'; // 导入 SSH 挂起 Actions
|
||||
import * as sshSuspendActions from './session/actions/sshSuspendActions';
|
||||
|
||||
|
||||
// 导入需要的类型 (例如 FileInfo 可能会在参数中使用)
|
||||
import type { FileInfo } from './fileEditor.store';
|
||||
// SftpManagerInstance 类型主要在 action 文件内部使用,但如果 store 直接暴露它,则需要导入
|
||||
// import type { SftpManagerInstance } from './session/types';
|
||||
|
||||
|
||||
|
||||
|
||||
export const useSessionStore = defineStore('session', () => {
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
// packages/frontend/src/stores/session/actions/sessionActions.ts
|
||||
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useConnectionsStore, type ConnectionInfo } from '../../connections.store'; // 路径: packages/frontend/src/stores/connections.store.ts
|
||||
import { useConnectionsStore, type ConnectionInfo } from '../../connections.store';
|
||||
import { sessions, activeSessionId } from '../state';
|
||||
import { generateSessionId } from '../utils';
|
||||
import type { SessionState, SshTerminalInstance, StatusMonitorInstance, DockerManagerInstance, SftpManagerInstance, WsManagerInstance } from '../types';
|
||||
|
||||
// Composables for manager creation - 路径相对于此文件
|
||||
|
||||
import { createWebSocketConnectionManager } from '../../../composables/useWebSocketConnection';
|
||||
import { createSshTerminalManager, type SshTerminalDependencies } from '../../../composables/useSshTerminal';
|
||||
import { createStatusMonitorManager, type StatusMonitorDependencies } from '../../../composables/useStatusMonitor';
|
||||
import { createDockerManager, type DockerManagerDependencies } from '../../../composables/useDockerManager';
|
||||
import { registerSshSuspendHandlers } from './sshSuspendActions'; // 导入 SSH 挂起处理器注册函数
|
||||
// getOrCreateSftpManager 将在 sftpManagerActions.ts 中定义,并在主 store 中协调
|
||||
import { registerSshSuspendHandlers } from './sshSuspendActions';
|
||||
|
||||
|
||||
// --- 辅助函数 (特定于此模块的 actions) ---
|
||||
const findConnectionInfo = (connectionId: number | string, connectionsStore: ReturnType<typeof useConnectionsStore>): ConnectionInfo | undefined => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// packages/frontend/src/stores/session/actions/sshSuspendActions.ts
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { sessions, suspendedSshSessions, isLoadingSuspendedSessions, activeSessionId } from '../state';
|
||||
import type {
|
||||
@@ -8,8 +8,8 @@ import type {
|
||||
SshSuspendResumeReqMessage,
|
||||
SshSuspendTerminateReqMessage,
|
||||
SshSuspendRemoveEntryReqMessage,
|
||||
// SshSuspendEditNameReqMessage, // Removed, using HTTP API
|
||||
// S2C Payloads
|
||||
|
||||
|
||||
SshMarkedForSuspendAckPayload,
|
||||
SshUnmarkedForSuspendAckPayload,
|
||||
SshSuspendListResponsePayload,
|
||||
@@ -17,19 +17,19 @@ import type {
|
||||
SshOutputCachedChunkPayload,
|
||||
SshSuspendTerminatedRespPayload,
|
||||
SshSuspendEntryRemovedRespPayload,
|
||||
// SshSuspendNameEditedRespPayload, // Removed, using HTTP API
|
||||
|
||||
SshSuspendAutoTerminatedNotifPayload,
|
||||
} from '../../../types/websocket.types'; // 路径: packages/frontend/src/types/websocket.types.ts
|
||||
import type { WsManagerInstance, SessionState } from '../types'; // 路径: packages/frontend/src/stores/session/types.ts // Re-add WsManagerInstance
|
||||
import { closeSession as closeSessionAction, activateSession as activateSessionAction, openNewSession, closeSession } from './sessionActions'; // 使用 openNewSession 和 closeSession
|
||||
import { useConnectionsStore } from '../../connections.store'; // 用于获取连接信息
|
||||
import { useUiNotificationsStore } from '../../uiNotifications.store'; // 用于显示通知
|
||||
import type { SuspendedSshSession } from '../../../types/ssh-suspend.types'; // 路径: packages/frontend/src/types/ssh-suspend.types.ts
|
||||
import i18n from '../../../i18n'; // 直接导入 i18n 实例
|
||||
import type { ComposerTranslation } from 'vue-i18n'; // 导入 ComposerTranslation 类型
|
||||
import apiClient from '../../../utils/apiClient'; // +++ 导入 apiClient +++
|
||||
} from '../../../types/websocket.types';
|
||||
import type { WsManagerInstance, SessionState } from '../types';
|
||||
import { closeSession as closeSessionAction, activateSession as activateSessionAction, openNewSession, closeSession } from './sessionActions';
|
||||
import { useConnectionsStore } from '../../connections.store';
|
||||
import { useUiNotificationsStore } from '../../uiNotifications.store';
|
||||
import type { SuspendedSshSession } from '../../../types/ssh-suspend.types';
|
||||
import i18n from '../../../i18n';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import apiClient from '../../../utils/apiClient';
|
||||
|
||||
const t: ComposerTranslation = i18n.global.t; // 从全局 i18n 实例获取 t 函数并显式注解类型
|
||||
const t: ComposerTranslation = i18n.global.t;
|
||||
|
||||
// 辅助函数:获取一个可用的 WebSocket 管理器
|
||||
// 优先使用当前激活的会话,或者任意一个已连接的 SSH 会话
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// packages/frontend/src/stores/session/types.ts
|
||||
|
||||
|
||||
import type { Ref } from 'vue';
|
||||
import type { FileTab as OriginalFileTab } from '../fileEditor.store'; // 路径: packages/frontend/src/stores/fileEditor.store.ts
|
||||
import type { WsConnectionStatus } from '../../composables/useWebSocketConnection'; // 路径: packages/frontend/src/composables/useWebSocketConnection.ts
|
||||
|
||||
// 从源模块导入 DockerManagerInstance 类型并使用别名
|
||||
import type { DockerManagerInstance as OriginalDockerManagerInstance } from '../../composables/useDockerManager'; // 路径: packages/frontend/src/composables/useDockerManager.ts
|
||||
import type { FileTab as OriginalFileTab } from '../fileEditor.store';
|
||||
import type { WsConnectionStatus } from '../../composables/useWebSocketConnection';
|
||||
import type { DockerManagerInstance as OriginalDockerManagerInstance } from '../../composables/useDockerManager';
|
||||
|
||||
// 导入工厂函数仅用于通过 ReturnType 推导实例类型
|
||||
// 这些导入仅用于类型推断,不在运行时使用
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import apiClient from '../utils/apiClient'; // 使用统一的 apiClient
|
||||
import { ref, computed } from 'vue'; // 移除 watch
|
||||
import i18n, { setLocale, defaultLng, availableLocales } from '../i18n'; // Import i18n instance, setLocale, defaultLng, and availableLocales
|
||||
import apiClient from '../utils/apiClient';
|
||||
import { ref, computed } from 'vue';
|
||||
import i18n, { setLocale, defaultLng, availableLocales } from '../i18n';
|
||||
import type { PaneName } from './layout.store';
|
||||
import { useAuthStore } from './auth.store';
|
||||
import type { ConnectionInfo } from './connections.store';
|
||||
@@ -62,6 +62,7 @@ interface SettingsState {
|
||||
terminalScrollbackLimit?: string; // 终端回滚行数上限 (e.g., '5000', '0' for unlimited)
|
||||
fileManagerShowDeleteConfirmation?: string; // 'true' or 'false' - 文件管理器删除确认提示
|
||||
terminalEnableRightClickPaste?: string; // 'true' or 'false' - 终端右键粘贴
|
||||
showStatusMonitorIpAddress?: string; // 'true' or 'false' - 状态监视器显示IP地址
|
||||
[key: string]: string | undefined;
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
if (settings.value.showPopupFileEditor === undefined) {
|
||||
settings.value.showPopupFileEditor = 'true';
|
||||
}
|
||||
// +++ 添加 showPopupFileManager 默认值 (改为 false) +++
|
||||
// +++ showPopupFileManager 默认值 (改为 false) +++
|
||||
if (settings.value.showPopupFileManager === undefined) {
|
||||
settings.value.showPopupFileManager = 'false'; // 默认禁用弹窗文件管理器
|
||||
}
|
||||
@@ -304,6 +305,10 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
settings.value.terminalEnableRightClickPaste = 'true'; // 默认启用右键粘贴
|
||||
console.log(`[SettingsStore] terminalEnableRightClickPaste not found, set to default: ${settings.value.terminalEnableRightClickPaste}`);
|
||||
}
|
||||
if (settings.value.showStatusMonitorIpAddress === undefined) {
|
||||
settings.value.showStatusMonitorIpAddress = 'false'; // 默认禁用状态监视器显示IP
|
||||
console.log(`[SettingsStore] showStatusMonitorIpAddress not found, set to default: ${settings.value.showStatusMonitorIpAddress}`);
|
||||
}
|
||||
|
||||
|
||||
// --- 语言设置 ---
|
||||
@@ -375,28 +380,29 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
// 移除外观相关的键检查
|
||||
const allowedKeys: Array<keyof SettingsState> = [
|
||||
'language', 'ipWhitelist', 'maxLoginAttempts', 'loginBanDuration',
|
||||
'showPopupFileEditor', 'showPopupFileManager', 'shareFileEditorTabs', 'ipWhitelistEnabled', // +++ 添加 showPopupFileManager +++
|
||||
'showPopupFileEditor', 'showPopupFileManager', 'shareFileEditorTabs', 'ipWhitelistEnabled', // +++ showPopupFileManager +++
|
||||
'autoCopyOnSelect', 'dockerStatusIntervalSeconds', 'dockerDefaultExpand',
|
||||
'statusMonitorIntervalSeconds', // +++ 添加状态监控间隔键 +++
|
||||
'workspaceSidebarPersistent', // +++ 添加侧边栏固定键 +++
|
||||
'sidebarPaneWidths', // +++ 添加侧边栏宽度对象键 +++
|
||||
'fileManagerRowSizeMultiplier', // +++ 添加文件管理器行大小键 +++
|
||||
'fileManagerColWidths', // +++ 添加文件管理器列宽键 +++
|
||||
'commandInputSyncTarget', // +++ 添加命令输入同步目标键 +++
|
||||
'timezone', // 添加时区键
|
||||
'rdpModalWidth', // 添加 RDP 模态框宽度键
|
||||
'rdpModalHeight', // 添加 RDP 模态框高度键
|
||||
'vncModalWidth', // 添加 VNC 模态框宽度键
|
||||
'vncModalHeight', // 添加 VNC 模态框高度键
|
||||
'statusMonitorIntervalSeconds', // +++ 状态监控间隔键 +++
|
||||
'workspaceSidebarPersistent', // +++ 侧边栏固定键 +++
|
||||
'sidebarPaneWidths', // +++ 侧边栏宽度对象键 +++
|
||||
'fileManagerRowSizeMultiplier', // +++ 文件管理器行大小键 +++
|
||||
'fileManagerColWidths', // +++ 文件管理器列宽键 +++
|
||||
'commandInputSyncTarget', // +++ 命令输入同步目标键 +++
|
||||
'timezone', // 时区键
|
||||
'rdpModalWidth', // RDP 模态框宽度键
|
||||
'rdpModalHeight', // RDP 模态框高度键
|
||||
'vncModalWidth', // VNC 模态框宽度键
|
||||
'vncModalHeight', // VNC 模态框高度键
|
||||
'ipBlacklistEnabled',
|
||||
'dashboardSortBy',
|
||||
'dashboardSortOrder',
|
||||
'showConnectionTags',
|
||||
'showQuickCommandTags',
|
||||
'layoutLocked',
|
||||
'terminalScrollbackLimit',
|
||||
'fileManagerShowDeleteConfirmation',
|
||||
'terminalEnableRightClickPaste'
|
||||
'showConnectionTags',
|
||||
'showQuickCommandTags',
|
||||
'layoutLocked',
|
||||
'terminalScrollbackLimit',
|
||||
'fileManagerShowDeleteConfirmation',
|
||||
'terminalEnableRightClickPaste',
|
||||
'showStatusMonitorIpAddress'
|
||||
];
|
||||
if (!allowedKeys.includes(key)) {
|
||||
console.error(`[SettingsStore] 尝试更新不允许的设置键: ${key}`);
|
||||
@@ -470,28 +476,29 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
// 移除外观相关的键检查
|
||||
const allowedKeys: Array<keyof SettingsState> = [
|
||||
'language', 'ipWhitelist', 'maxLoginAttempts', 'loginBanDuration',
|
||||
'showPopupFileEditor', 'showPopupFileManager', 'shareFileEditorTabs', 'ipWhitelistEnabled', // +++ 添加 showPopupFileManager +++
|
||||
'showPopupFileEditor', 'showPopupFileManager', 'shareFileEditorTabs', 'ipWhitelistEnabled', // +++ showPopupFileManager +++
|
||||
'autoCopyOnSelect', 'dockerStatusIntervalSeconds', 'dockerDefaultExpand',
|
||||
'statusMonitorIntervalSeconds', // +++ 添加状态监控间隔键 +++
|
||||
'workspaceSidebarPersistent', // +++ 添加侧边栏固定键 +++
|
||||
'sidebarPaneWidths', // +++ 添加侧边栏宽度对象键 +++
|
||||
'fileManagerRowSizeMultiplier', // +++ 添加文件管理器行大小键 +++
|
||||
'fileManagerColWidths', // +++ 添加文件管理器列宽键 +++
|
||||
'commandInputSyncTarget', // +++ 添加命令输入同步目标键 +++
|
||||
'timezone', // 添加时区键
|
||||
'rdpModalWidth', // 添加 RDP 模态框宽度键
|
||||
'rdpModalHeight', // 添加 RDP 模态框高度键
|
||||
'vncModalWidth', // 添加 VNC 模态框宽度键
|
||||
'vncModalHeight', // 添加 VNC 模态框高度键
|
||||
'statusMonitorIntervalSeconds', // +++ 状态监控间隔键 +++
|
||||
'workspaceSidebarPersistent', // +++ 侧边栏固定键 +++
|
||||
'sidebarPaneWidths', // +++ 侧边栏宽度对象键 +++
|
||||
'fileManagerRowSizeMultiplier', // +++ 文件管理器行大小键 +++
|
||||
'fileManagerColWidths', // +++ 文件管理器列宽键 +++
|
||||
'commandInputSyncTarget', // +++ 命令输入同步目标键 +++
|
||||
'timezone', // 时区键
|
||||
'rdpModalWidth', // RDP 模态框宽度键
|
||||
'rdpModalHeight', // RDP 模态框高度键
|
||||
'vncModalWidth', // VNC 模态框宽度键
|
||||
'vncModalHeight', // VNC 模态框高度键
|
||||
'ipBlacklistEnabled',
|
||||
'dashboardSortBy',
|
||||
'dashboardSortOrder',
|
||||
'showConnectionTags',
|
||||
'showQuickCommandTags',
|
||||
'layoutLocked',
|
||||
'terminalScrollbackLimit',
|
||||
'fileManagerShowDeleteConfirmation',
|
||||
'terminalEnableRightClickPaste'
|
||||
'showConnectionTags',
|
||||
'showQuickCommandTags',
|
||||
'layoutLocked',
|
||||
'terminalScrollbackLimit',
|
||||
'fileManagerShowDeleteConfirmation',
|
||||
'terminalEnableRightClickPaste',
|
||||
'showStatusMonitorIpAddress'
|
||||
];
|
||||
const filteredUpdates: Partial<SettingsState> = {};
|
||||
let languageUpdate: string | undefined = undefined;
|
||||
@@ -793,6 +800,10 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
const terminalEnableRightClickPasteBoolean = computed(() => {
|
||||
return settings.value.terminalEnableRightClickPaste !== 'false'; // Default to true
|
||||
});
|
||||
|
||||
const statusMonitorShowIpBoolean = computed(() => {
|
||||
return settings.value.showStatusMonitorIpAddress === 'true';
|
||||
});
|
||||
|
||||
return {
|
||||
settings, // 只包含通用设置
|
||||
@@ -838,5 +849,6 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
terminalScrollbackLimitNumber, // Expose terminal scrollback limit getter
|
||||
fileManagerShowDeleteConfirmationBoolean, // Expose file manager delete confirmation getter
|
||||
terminalEnableRightClickPasteBoolean, // Expose terminal right click paste getter
|
||||
statusMonitorShowIpBoolean, // 暴露状态监视器显示IP getter
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user