@lobehub/lobehub 2.0.0-next.242 → 2.0.0-next.243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/.cursor/rules/desktop-feature-implementation.mdc +2 -2
  2. package/.cursor/rules/desktop-local-tools-implement.mdc +2 -2
  3. package/CHANGELOG.md +27 -0
  4. package/apps/desktop/Development.md +1 -6
  5. package/apps/desktop/README.md +2 -17
  6. package/apps/desktop/README.zh-CN.md +1 -15
  7. package/apps/desktop/src/main/controllers/index.ts +1 -1
  8. package/apps/desktop/src/main/controllers/registry.ts +0 -9
  9. package/apps/desktop/src/main/core/App.ts +1 -11
  10. package/apps/desktop/src/main/core/browser/Browser.ts +278 -457
  11. package/apps/desktop/src/main/core/browser/WindowStateManager.ts +180 -0
  12. package/apps/desktop/src/main/core/browser/WindowThemeManager.ts +167 -0
  13. package/apps/desktop/src/main/core/browser/__tests__/WindowStateManager.test.ts +237 -0
  14. package/apps/desktop/src/main/core/browser/__tests__/WindowThemeManager.test.ts +240 -0
  15. package/apps/desktop/src/main/exports.d.ts +1 -1
  16. package/apps/desktop/src/main/exports.ts +1 -1
  17. package/apps/desktop/src/main/utils/__tests__/http-headers.test.ts +131 -0
  18. package/apps/desktop/src/main/utils/http-headers.ts +61 -0
  19. package/apps/desktop/src/main/utils/ipc/__tests__/base.test.ts +1 -22
  20. package/apps/desktop/src/main/utils/ipc/base.ts +0 -20
  21. package/apps/desktop/src/main/utils/ipc/index.ts +1 -9
  22. package/changelog/v1.json +5 -0
  23. package/package.json +1 -1
  24. package/src/features/ChatInput/InputEditor/Placeholder.tsx +4 -1
  25. package/apps/desktop/src/main/controllers/UploadFileServerCtr.ts +0 -33
  26. package/apps/desktop/src/main/controllers/__tests__/UploadFileServerCtr.test.ts +0 -55
  27. package/src/server/modules/ElectronIPCClient/index.ts +0 -92
@@ -1,92 +0,0 @@
1
- import { type CreateFileParams, ElectronIpcClient, type FileMetadata } from '@lobechat/electron-server-ipc';
2
- import type { DesktopServerIpcServices } from '@lobehub/desktop-ipc-typings';
3
-
4
- import packageJSON from '@/../apps/desktop/package.json';
5
-
6
- const createServerInvokeProxy = <IpcServices>(
7
- invoke: (channel: string, payload?: unknown) => Promise<unknown>,
8
- ): IpcServices =>
9
- new Proxy(
10
- {},
11
- {
12
- get(_target, groupKey) {
13
- if (typeof groupKey !== 'string') return undefined;
14
-
15
- return new Proxy(
16
- {},
17
- {
18
- get(_methodTarget, methodKey) {
19
- if (typeof methodKey !== 'string') return undefined;
20
-
21
- const channel = `${groupKey}.${methodKey}`;
22
- return (payload?: unknown) =>
23
- payload === undefined ? invoke(channel) : invoke(channel, payload);
24
- },
25
- },
26
- );
27
- },
28
- },
29
- ) as IpcServices;
30
-
31
- class LobeHubElectronIpcClient extends ElectronIpcClient {
32
- private _services: DesktopServerIpcServices | null = null;
33
-
34
- private ensureServices(): DesktopServerIpcServices {
35
- if (this._services) return this._services;
36
-
37
- this._services = createServerInvokeProxy<DesktopServerIpcServices>((channel, payload) =>
38
- payload === undefined ? this.sendRequest(channel) : this.sendRequest(channel, payload),
39
- );
40
-
41
- return this.services;
42
- }
43
-
44
- private get ipc() {
45
- return this.ensureServices();
46
- }
47
-
48
- public get services(): DesktopServerIpcServices {
49
- return this.ipc;
50
- }
51
-
52
- getDatabasePath = async (): Promise<string> => {
53
- return this.ipc.system.getDatabasePath();
54
- };
55
-
56
- getUserDataPath = async (): Promise<string> => {
57
- return this.ipc.system.getUserDataPath();
58
- };
59
-
60
- getDatabaseSchemaHash = async () => {
61
- return this.ipc.system.getDatabaseSchemaHash();
62
- };
63
-
64
- setDatabaseSchemaHash = async (hash: string | undefined) => {
65
- if (!hash) return;
66
-
67
- return this.ipc.system.setDatabaseSchemaHash(hash);
68
- };
69
-
70
- getFilePathById = async (id: string) => {
71
- return this.ipc.upload.getFileUrlById(id);
72
- };
73
-
74
- getFileHTTPURL = async (path: string) => {
75
- return this.ipc.upload.getFileHTTPURL(path);
76
- };
77
-
78
- deleteFiles = async (paths: string[]) => {
79
- return this.ipc.upload.deleteFiles(paths);
80
- };
81
-
82
- createFile = async (params: CreateFileParams) => {
83
- return this.ipc.upload.createFile(params) as Promise<{
84
- metadata: FileMetadata;
85
- success: boolean;
86
- }>;
87
- };
88
- }
89
-
90
- export const electronIpcClient = new LobeHubElectronIpcClient(packageJSON.name);
91
-
92
- export const ensureElectronServerIpc = (): DesktopServerIpcServices => electronIpcClient.services;