feat: implement task management store with IPC integration
- Added a new task store in `src-react/stores/task.ts` to manage tasks and their statuses. - Implemented functions for creating, executing, and retrying tasks, along with handling task progress and completion. - Introduced persistence for tasks using IPC. - Created utility functions for normalizing room types and building subtasks. - Added a new CSS file for global styles in `src-react/styles.css`. - Created runtime types in `src-react/types/runtime.ts` and exported them. - Updated the main entry points for Vue and React applications to support dynamic framework loading. - Refactored chat model interfaces and utility functions into `src/shared/chat-model.ts`. - Updated TypeScript configuration to include paths for React components and types. - Enhanced Vite configuration to support both Vue and React frameworks.
This commit is contained in:
104
src-react/types/runtime.ts
Normal file
104
src-react/types/runtime.ts
Normal 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 {};
|
||||
Reference in New Issue
Block a user