Skip to content

Commit c1ecfb7

Browse files
committed
chore: adjust desktop shell config and ui
Made-with: Cursor
1 parent cbcb553 commit c1ecfb7

5 files changed

Lines changed: 6 additions & 73 deletions

File tree

resources/bundle-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"shellVersion": "0.2.0",
2+
"shellVersion": "0.1.0",
33
"bundledOpenClawVersion": "2026.3.8"
44
}

src/main/gateway/rpc-client.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { randomUUID } from 'node:crypto'
77
import WebSocket from 'ws'
88
import { DEFAULT_GATEWAY_PORT } from '../../shared/constants.js'
9+
import { readShellConfig, readOpenClawConfig } from '../config/index.js'
910

1011
const PROTOCOL_VERSION = 3
1112
const CLIENT_ID = 'openclaw-desktop'
@@ -342,13 +343,10 @@ function mapErrorCode(code?: string): GatewayRpcErrorCode {
342343
* 从 ShellConfig + OpenClawConfig 创建 GatewayRpcClient
343344
* port: shellConfig.lastGatewayPort
344345
* token: openclawConfig.gateway?.auth?.token
345-
* 使用动态 import 避免在非 Electron 环境加载 config(依赖 electron.app)
346346
*/
347347
export async function createGatewayRpcClientFromConfig(
348348
overrides?: Partial<GatewayRpcClientOptions>
349349
): Promise<GatewayRpcClient> {
350-
const { readShellConfig } = await import('../config/shell-config.js')
351-
const { readOpenClawConfig } = await import('../config/openclaw-config.js')
352350
const shellConfig = readShellConfig()
353351
const openclawConfig = readOpenClawConfig()
354352
const port = overrides?.port ?? shellConfig.lastGatewayPort ?? DEFAULT_GATEWAY_PORT

src/main/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ app.whenReady().then(() => {
217217
resizeForMainInterface: () => {
218218
const win = windowManager.getMainWindow()
219219
if (win && !win.isDestroyed() && !win.isMaximized()) {
220-
// 主界面尺寸保持当前值,不在向导完成后强制改宽
220+
const [, currentHeight] = win.getSize()
221+
win.setSize(1280, currentHeight)
221222
win.center()
222223
}
223224
},

src/main/tray/manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export class TrayManager {
141141
},
142142
{
143143
label: 'Settings',
144+
visible: false,
144145
click: () => {
145146
if (this.options.onOpenSettings) {
146147
this.options.onOpenSettings()

src/main/utils/paths.ts

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,74 +17,7 @@ import { OPENCLAW_USER_DIR } from '../../shared/constants.js'
1717
export function getInstallDir(): string {
1818
if (app.isPackaged) {
1919
return path.dirname(app.getPath('exe'))
20-
}
21-
return process.cwd()
22-
}
23-
24-
/**
25-
* 获取 OpenClaw 用户数据目录(%USERPROFILE%\.openclaw)
26-
*/
27-
export function getUserDataDir(): string {
28-
return path.join(os.homedir(), OPENCLAW_USER_DIR)
29-
}
30-
31-
function resolveDevResourcePath(resourceName: 'node' | 'openclaw'): string {
32-
const installDir = getInstallDir()
33-
const resourcesPath = path.join(installDir, 'resources', resourceName)
34-
const resourceReady =
35-
resourceName === 'node'
36-
? fs.existsSync(path.join(resourcesPath, 'node.exe'))
37-
: fs.existsSync(path.join(resourcesPath, 'openclaw.mjs'))
38-
if (resourceReady) {
39-
return resourcesPath
40-
}
41-
return path.join(installDir, 'build', resourceName)
42-
}
43-
44-
export function getBundledOpenClawDir(): string {
45-
if (app.isPackaged) {
46-
return path.join(getInstallDir(), 'resources', 'openclaw')
47-
}
48-
return resolveDevResourcePath('openclaw')
49-
}
50-
51-
/**
52-
* 获取捆绑 Node.js 的 node.exe 路径
53-
* 打包后:{installDir}/resources/node/node.exe
54-
*/
55-
export function getBundledNodePath(): string {
56-
if (app.isPackaged) {
57-
return path.join(getInstallDir(), 'resources', 'node', 'node.exe')
58-
}
59-
return path.join(resolveDevResourcePath('node'), 'node.exe')
60-
}
61-
62-
/**
63-
* 获取捆绑 OpenClaw 的 openclaw.mjs 路径
64-
* 打包后:{installDir}/resources/openclaw/openclaw.mjs
65-
*/
66-
export function getBundledOpenClawPath(): string {
67-
return path.join(getBundledOpenClawDir(), 'openclaw.mjs')
68-
}
69-
/**
70-
* 路径工具 — 安装目录、用户数据目录、捆绑资源路径
71-
* 与 constants.ts 配合使用
72-
*/
73-
74-
import { app } from 'electron'
75-
import path from 'path'
76-
import os from 'os'
77-
import fs from 'node:fs'
78-
import { OPENCLAW_USER_DIR } from '../../shared/constants.js'
79-
80-
/**
81-
* 获取应用安装目录
82-
* - 打包后:exe 所在目录
83-
* - 开发时:项目根目录(process.cwd)
84-
*/
85-
export function getInstallDir(): string {
86-
if (app.isPackaged) {
87-
return path.dirname(app.getPath('exe'))
20+
8821
}
8922
return process.cwd()
9023
}

0 commit comments

Comments
 (0)