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:
@@ -3,7 +3,7 @@ import { createProvider } from '@electron/providers';
|
||||
import type { BaseProvider } from '@electron/providers/BaseProvider';
|
||||
import { providerApiService } from '@electron/service/provider-api-service';
|
||||
import logManager from '@electron/service/logger';
|
||||
import type { RawMessage } from '@shared/chat-model';
|
||||
import type { RawMessage } from '@runtime/shared/chat-model';
|
||||
import { sessionStore } from '../session-store';
|
||||
import type { GatewayEvent, GatewayRpcParams, GatewayRpcReturns } from '../types';
|
||||
import { appendTranscriptLine } from '@electron/utils/token-usage-writer';
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { app } from 'electron';
|
||||
import logManager from '@electron/service/logger';
|
||||
import type { RawMessage } from '@shared/chat-model';
|
||||
import type { RawMessage } from '@runtime/shared/chat-model';
|
||||
|
||||
let sessionsFilePath: string | null = null;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { RawMessage } from '@shared/chat-model';
|
||||
import type { RawMessage } from '@runtime/shared/chat-model';
|
||||
|
||||
/// Gateway 向 Renderer 推送的事件类型
|
||||
export type GatewayEvent =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { app, BrowserWindow, ipcMain } from 'electron'
|
||||
import { CONFIG_KEYS } from '@lib/constants'
|
||||
import { CONFIG_KEYS } from '@runtime/lib/constants'
|
||||
import { setupMainWindow } from './wins';
|
||||
import started from 'electron-squirrel-startup'
|
||||
import configManager from '@electron/service/config-service'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { contextBridge, ipcRenderer } from 'electron'
|
||||
import { IPC_EVENTS } from '@lib/constants';
|
||||
import { IPC_EVENTS } from '@runtime/lib/constants';
|
||||
|
||||
const api: WindowApi = {
|
||||
versions: process.versions,
|
||||
@@ -89,4 +89,4 @@ const api: WindowApi = {
|
||||
},
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('api', api)
|
||||
contextBridge.exposeInMainWorld('api', api)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import { ipcMain, app, BrowserWindow } from 'electron';
|
||||
import { IPC_EVENTS } from '@lib/constants';
|
||||
import { IPC_EVENTS } from '@runtime/lib/constants';
|
||||
import { launchLocalChrome } from '@electron/utils/chrome/launchLocalChrome'
|
||||
import { executeScriptService } from '@electron/service/execute-script-service';
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BaseProvider } from "./BaseProvider";
|
||||
import { OpenAIProvider } from "./OpenAIProvider";
|
||||
import { providerApiService } from '@electron/service/provider-api-service';
|
||||
import { getProviderTypeInfo } from '@lib/providers';
|
||||
import { getProviderTypeInfo } from '@runtime/lib/providers';
|
||||
|
||||
export function createProvider(accountId: string): BaseProvider {
|
||||
const account = providerApiService.getAccounts().find((a) => a.id === accountId);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BrowserWindow, ipcMain } from 'electron'
|
||||
import type { ConfigKeys, IConfig } from '@lib/types'
|
||||
import { CONFIG_KEYS, IPC_EVENTS } from '@lib/constants'
|
||||
import { debounce } from '@lib/utils'
|
||||
import type { ConfigKeys, IConfig } from '@runtime/lib/types'
|
||||
import { CONFIG_KEYS, IPC_EVENTS } from '@runtime/lib/constants'
|
||||
import { debounce } from '@runtime/lib/utils'
|
||||
|
||||
import logManager from '@electron/service/logger'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IPC_EVENTS } from '@lib/constants';
|
||||
import { IPC_EVENTS } from '@runtime/lib/constants';
|
||||
import { promisify } from 'util';
|
||||
import { app, ipcMain } from 'electron';
|
||||
import log from 'electron-log';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ipcMain, Menu, type MenuItemConstructorOptions } from 'electron';
|
||||
import { CONFIG_KEYS, IPC_EVENTS } from '@lib/constants';
|
||||
import { cloneDeep } from '@lib/utils';
|
||||
import { CONFIG_KEYS, IPC_EVENTS } from '@runtime/lib/constants';
|
||||
import { cloneDeep } from '@runtime/lib/utils';
|
||||
import { createTranslator } from '@electron/utils'
|
||||
import logManager from '@electron/service/logger'
|
||||
import configManager from '@electron/service/config-service'
|
||||
|
||||
@@ -2,12 +2,12 @@ import { app } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import logManager from '@electron/service/logger';
|
||||
import { PROVIDER_TYPE_INFO } from '@lib/providers';
|
||||
import { PROVIDER_TYPE_INFO } from '@runtime/lib/providers';
|
||||
import type {
|
||||
ProviderAccount,
|
||||
ProviderVendorInfo,
|
||||
ProviderWithKeyInfo,
|
||||
} from '@lib/providers';
|
||||
} from '@runtime/lib/providers';
|
||||
|
||||
interface ProviderStore {
|
||||
accounts: ProviderAccount[];
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
getScriptPathById,
|
||||
updateLastRun,
|
||||
} from '@electron/service/script-store-service';
|
||||
import type { ScriptExecutionResult } from '@lib/script-types';
|
||||
import type { ScriptExecutionResult } from '@runtime/lib/script-types';
|
||||
|
||||
const executor = new executeScriptService();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
ScriptMetaItem,
|
||||
ScriptsMeta,
|
||||
ScriptSaveInput,
|
||||
} from '@lib/script-types';
|
||||
} from '@runtime/lib/script-types';
|
||||
|
||||
const META_FILENAME = 'scripts.meta.json';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BrowserView, BrowserWindow, ipcMain, IpcMainInvokeEvent } from 'electron'
|
||||
import { randomUUID } from 'crypto'
|
||||
import { IPC_EVENTS } from '@lib/constants'
|
||||
import { IPC_EVENTS } from '@runtime/lib/constants'
|
||||
import path from 'node:path'
|
||||
|
||||
declare const MAIN_WINDOW_VITE_DEV_SERVER_URL: string | undefined;
|
||||
@@ -231,4 +231,4 @@ export class TabManager {
|
||||
canGoForward: wc.canGoForward()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ipcMain } from 'electron'
|
||||
import { IPC_EVENTS } from '@lib/constants'
|
||||
import { IPC_EVENTS } from '@runtime/lib/constants'
|
||||
import { spawn } from 'child_process'
|
||||
|
||||
|
||||
|
||||
export function runTaskOperationService() {}
|
||||
export function runTaskOperationService() {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BrowserWindow, ipcMain, nativeTheme } from 'electron'
|
||||
import { configManager } from '@electron/service/config-service'
|
||||
import { logManager } from '@electron/service/logger'
|
||||
import { IPC_EVENTS, CONFIG_KEYS } from '@lib/constants'
|
||||
import { IPC_EVENTS, CONFIG_KEYS } from '@runtime/lib/constants'
|
||||
|
||||
class ThemeService {
|
||||
private static _instance: ThemeService;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Tray, Menu, ipcMain, app } from 'electron'
|
||||
import { createTranslator, createLogo } from '@electron/utils'
|
||||
import { CONFIG_KEYS, IPC_EVENTS, WINDOW_NAMES, MAIN_WIN_SIZE } from '@lib/constants'
|
||||
import { CONFIG_KEYS, IPC_EVENTS, WINDOW_NAMES, MAIN_WIN_SIZE } from '@runtime/lib/constants'
|
||||
|
||||
import logManager from '@electron/service/logger'
|
||||
// TODO: shortcutManager
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import { BrowserWindow, ipcMain, app } from 'electron';
|
||||
import { IPC_EVENTS } from '@lib/constants';
|
||||
import { IPC_EVENTS } from '@runtime/lib/constants';
|
||||
|
||||
export class AppUpdater {
|
||||
private mainWindow: BrowserWindow | null = null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { WindowNames } from '@lib/types'
|
||||
import type { WindowNames } from '@runtime/lib/types'
|
||||
|
||||
import { CONFIG_KEYS, IPC_EVENTS, WINDOW_NAMES } from '@lib/constants'
|
||||
import { CONFIG_KEYS, IPC_EVENTS, WINDOW_NAMES } from '@runtime/lib/constants'
|
||||
import { BrowserWindow, BrowserWindowConstructorOptions, ipcMain, IpcMainInvokeEvent, type IpcMainEvent } from 'electron'
|
||||
import { createLogo } from '@electron/utils'
|
||||
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
import { CONFIG_KEYS } from '@lib/constants'
|
||||
import { CONFIG_KEYS } from '@runtime/lib/constants'
|
||||
import logManager from '@electron/service/logger'
|
||||
import configManager from '@electron/service/config-service'
|
||||
import path from 'node:path'
|
||||
import { app } from 'electron'
|
||||
import { runtimeLocaleMessages, type RuntimeMessageTree } from '@runtime/locales/messages'
|
||||
|
||||
import en from '@locales/en.json'
|
||||
import zh from '@locales/zh.json'
|
||||
|
||||
type MessageSchema = typeof zh;
|
||||
const messages: Record<string, MessageSchema> = { en, zh }
|
||||
const messages: Record<string, RuntimeMessageTree> = runtimeLocaleMessages
|
||||
|
||||
export function createTranslator() {
|
||||
return (key?: string) => {
|
||||
if (!key) return void 0;
|
||||
try {
|
||||
const keys = key?.split('.');
|
||||
let result: any = messages[configManager.get(CONFIG_KEYS.LANGUAGE)];
|
||||
let result: any = messages[configManager.get(CONFIG_KEYS.LANGUAGE)] ?? messages.zh;
|
||||
for (const _key of keys) {
|
||||
result = result[_key];
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BrowserWindow } from 'electron'
|
||||
import { ipcMain } from 'electron';
|
||||
import { WINDOW_NAMES, MAIN_WIN_SIZE, IPC_EVENTS, MENU_IDS, CONVERSATION_ITEM_MENU_IDS, CONVERSATION_LIST_MENU_IDS, MESSAGE_ITEM_MENU_IDS, CONFIG_KEYS } from '@lib/constants'
|
||||
import { WINDOW_NAMES, MAIN_WIN_SIZE, IPC_EVENTS, MENU_IDS, CONVERSATION_ITEM_MENU_IDS, CONVERSATION_LIST_MENU_IDS, MESSAGE_ITEM_MENU_IDS, CONFIG_KEYS } from '@runtime/lib/constants'
|
||||
import { windowManager } from '@electron/service/window-service'
|
||||
import { menuManager } from '@electron/service/menu-service'
|
||||
import { logManager } from '@electron/service/logger'
|
||||
|
||||
Reference in New Issue
Block a user