This commit is contained in:
Baobhan Sith
2025-04-24 19:53:10 +08:00
parent 2f0b872264
commit a930f43477
14 changed files with 237 additions and 10 deletions
@@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
import { useAppearanceStore } from '../stores/appearance.store'; // 使用新的 store
import { storeToRefs } from 'pinia';
import type { ITheme } from 'xterm';
import type { TerminalTheme } from '../../../backend/src/types/terminal-theme.types'; // 引入类型
import type { TerminalTheme } from '../types/terminal-theme.types'; // 引入本地类型
import { defaultXtermTheme } from '../features/appearance/config/default-themes'; // 引入默认主题
const { t } = useI18n();
@@ -1,6 +1,6 @@
// Generated by scripts/generate-iterm-themes.js
// Source: https://github.com/mbadolato/iTerm2-Color-Schemes
import type { TerminalTheme } from '../../../backend/src/types/terminal-theme.types';
import type { TerminalTheme } from '../../../types/terminal-theme.types'; // 引用本地类型
export const Theme_0x96fPreset: TerminalTheme = {
_id: 'preset-0x96f',
@@ -2,8 +2,8 @@ import { defineStore } from 'pinia';
import apiClient from '../utils/apiClient'; // 使用统一的 apiClient
import { ref, computed, watch, nextTick } from 'vue'; // 导入 nextTick
import type { ITheme } from 'xterm';
import type { TerminalTheme } from '../../../backend/src/types/terminal-theme.types'; // 引用后端类型
import type { AppearanceSettings, UpdateAppearanceDto } from '../../../backend/src/types/appearance.types'; // 引用后端类型
import type { TerminalTheme } from '../types/terminal-theme.types'; // 引用本地类型
import type { AppearanceSettings, UpdateAppearanceDto } from '../types/appearance.types'; // 引用本地类型
import { defaultXtermTheme, defaultUiTheme } from '../features/appearance/config/default-themes'; // 保持 .ts
import { presetTerminalThemes } from '../features/appearance/config/iterm-themes'; // <-- 导入预设主题
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
import apiClient from '../utils/apiClient'; // 使用统一的 apiClient
import { ref, computed } from 'vue';
import { useUiNotificationsStore } from './uiNotifications.store';
import type { QuickCommand } from '../../../backend/src/repositories/quick-commands.repository'; // 复用后端类型定义
import type { QuickCommand } from '../types/quick-commands.types'; // 引入本地 QuickCommand 类型
// 定义前端使用的快捷指令接口 (可以与后端一致)
export type QuickCommandFE = QuickCommand;
@@ -0,0 +1,18 @@
// packages/frontend/src/types/appearance.types.ts
// 前端使用的外观设置结构 (对应 API 响应)
export interface AppearanceSettings {
// 注意:前端可能不需要 _id, userId, updatedAt 等数据库相关的字段
// 但为了与后端导入保持一致,暂时保留,后续可根据 API 精简
customUiTheme?: string; // CSS 变量 JSON 字符串
activeTerminalThemeId?: number | null; // 终端主题 ID
terminalFontFamily?: string;
terminalFontSize?: number;
terminalBackgroundImage?: string;
pageBackgroundImage?: string;
editorFontSize?: number;
}
// 前端用于更新外观设置的数据结构 (对应 API 请求体)
// 使用 Partial<AppearanceSettings> 也可以,但明确定义更清晰
export type UpdateAppearanceDto = Partial<AppearanceSettings>;
@@ -0,0 +1,54 @@
// packages/frontend/src/types/audit.types.ts
// 定义审计日志记录的操作类型 (与后端保持一致,但独立定义)
export type AuditLogActionType =
// Authentication
| 'LOGIN_SUCCESS'
| 'LOGIN_FAILURE'
| 'LOGOUT'
| 'PASSWORD_CHANGED'
| '2FA_ENABLED'
| '2FA_DISABLED'
| 'PASSKEY_REGISTERED'
| 'PASSKEY_DELETED'
// Connections
| 'CONNECTION_CREATED'
| 'CONNECTION_UPDATED'
| 'CONNECTION_DELETED'
| 'CONNECTION_TESTED'
| 'CONNECTIONS_IMPORTED'
| 'CONNECTIONS_EXPORTED'
// Proxies
| 'PROXY_CREATED'
| 'PROXY_UPDATED'
| 'PROXY_DELETED'
// Tags
| 'TAG_CREATED'
| 'TAG_UPDATED'
| 'TAG_DELETED'
// Settings
| 'SETTINGS_UPDATED'
| 'IP_WHITELIST_UPDATED'
// Notifications
| 'NOTIFICATION_SETTING_CREATED'
| 'NOTIFICATION_SETTING_UPDATED'
| 'NOTIFICATION_SETTING_DELETED'
// SFTP
| 'SFTP_ACTION'
// SSH Actions
| 'SSH_CONNECT_SUCCESS'
| 'SSH_CONNECT_FAILURE'
| 'SSH_SHELL_FAILURE'
// System/Error
| 'SERVER_STARTED'
| 'SERVER_ERROR'
| 'DATABASE_MIGRATION'
| 'ADMIN_SETUP_COMPLETE';
// 前端使用的审计日志条目结构 (对应 API 响应)
export interface AuditLogEntry {
id: number;
timestamp: number; // Unix timestamp (seconds)
action_type: AuditLogActionType;
details: string | null; // JSON string or null (前端可能需要解析)
}
@@ -0,0 +1,11 @@
// packages/frontend/src/types/quick-commands.types.ts
// 前端使用的快捷指令结构 (对应 API 响应)
export interface QuickCommand {
id: number;
name: string | null;
command: string;
usage_count: number;
created_at: number; // Unix 时间戳 (秒)
updated_at: number; // Unix 时间戳 (秒)
}
@@ -0,0 +1,13 @@
// packages/frontend/src/types/terminal-theme.types.ts
import type { ITheme } from 'xterm';
// 前端使用的终端主题结构 (对应 API 响应)
export interface TerminalTheme {
// 注意:前端可能不需要 _id, createdAt, updatedAt 等数据库相关的字段
// 但为了与后端导入保持一致,暂时保留,后续可根据 API 精简
_id?: string; // NeDB ID (前端通常不直接使用)
name: string;
themeData: ITheme;
isPreset: boolean;
isSystemDefault?: boolean;
}
@@ -6,7 +6,7 @@ import { useSessionStore } from '../stores/session.store'; // +++ 引入 Session
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import type { ConnectionInfo } from '../stores/connections.store'; // 只导入 ConnectionInfo
import type { AuditLogEntry } from '../../../backend/src/types/audit.types'; // 引入 AuditLogEntry 类型
import type { AuditLogEntry } from '../types/audit.types'; // 引入本地 AuditLogEntry 类型
import { storeToRefs } from 'pinia';
import { formatDistanceToNow } from 'date-fns';
import { zhCN, enUS } from 'date-fns/locale'; // 导入语言包