Refactor UUID generation, remove unused logger and encryption utilities, and clean up request handling

- Updated `generateUUID` function for improved readability and performance.
- Deleted `logger.ts`, `other.ts`, `request.ts`, `storage.ts`, `tansParams.ts`, and `validate.ts` as they were no longer needed.
- Simplified TypeScript configuration by removing unnecessary paths and aliases.
- Enhanced Vite configuration for better project structure and maintainability.
This commit is contained in:
DEV_DSW
2026-04-17 15:38:08 +08:00
parent b1dea9a5c2
commit 79bea4f107
360 changed files with 14495 additions and 30856 deletions

1
src/types/index.ts Normal file
View File

@@ -0,0 +1 @@
export * from './runtime';

104
src/types/runtime.ts Normal file
View File

@@ -0,0 +1,104 @@
import type { Task } from '../lib/task-types';
import type { RawMessage } from '../shared/chat-model';
export type ThemeMode = 'light' | 'dark' | 'system';
export type ResolvedThemeMode = 'light' | 'dark';
export type LanguageCode = 'en' | 'zh' | 'ja';
export type RuntimePlatform = 'win32' | 'darwin' | 'linux' | 'web' | 'unknown';
export type WindowName = 'main' | 'setting' | 'dialog' | 'loading';
export type IpcArgs = readonly unknown[];
export type IpcListener = (...args: unknown[]) => void;
export const CONFIG_KEYS = {
THEME_MODE: 'themeMode',
PRIMARY_COLOR: 'primaryColor',
LANGUAGE: 'language',
FONT_SIZE: 'fontSize',
MINIMIZE_TO_TRAY: 'minimizeToTray',
PROVIDER: 'provider',
DEFAULT_MODEL: 'defaultModel',
SELECTED_CHANNELS: 'selectedChannels',
IMAGE_CACHE: 'imageCache',
TASK_LIST: 'taskList',
} as const;
export type ConfigKey = (typeof CONFIG_KEYS)[keyof typeof CONFIG_KEYS];
export type ConfigValueKey = keyof ConfigValueMap;
export interface ConfigValueMap {
themeMode: ThemeMode;
primaryColor: string;
language: LanguageCode;
fontSize: number;
minimizeToTray: boolean;
provider: string | null;
defaultModel: string | null;
selectedChannels: Array<{ id: string; channelName: string; channelUrl: string }>;
imageCache: Array<[string, unknown]>;
taskList: Task[];
}
export interface WindowApiBridge {
versions?: Record<string, string>;
platform?: string;
invoke?<T = unknown>(channel: string, ...args: IpcArgs): Promise<T>;
invokeAsync?<T = unknown>(channel: string, ...args: IpcArgs): Promise<T>;
on?(channel: string, callback: IpcListener): () => void;
send?(channel: string, ...args: IpcArgs): void;
getCurrentWindowId?(): string | number;
}
export interface WindowIdentity {
platform: RuntimePlatform;
windowId: string | number | null;
windowName: WindowName;
isElectron: boolean;
}
export interface HostApiResult<T = unknown> {
success?: boolean;
ok?: boolean;
json?: T;
data?: T | { json?: T };
text?: string;
error?: string;
status?: number;
}
export type GatewayEvent =
| {
type: 'chat:delta';
sessionKey: string;
runId: string;
delta: string;
}
| {
type: 'chat:final';
sessionKey: string;
runId: string;
message: RawMessage;
}
| {
type: 'chat:error';
sessionKey: string;
runId: string;
error: string;
}
| {
type: 'chat:aborted';
sessionKey: string;
runId: string;
}
| {
type: 'gateway:status';
status: 'connected' | 'disconnected' | 'reconnecting';
};
export {};