mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-07 06:22:53 +08:00
fix: 修复 Linux 系统下 OpenClaw 安装检测问题
- 新增 isWindows 平台判断,正确区分 Windows/macOS/Linux - 修复 npm 命令选择逻辑(Linux 使用 npm 而非 npm.cmd) - 新增 Linux 下 OpenClaw CLI 安装路径检测 - /usr/bin/openclaw(全局安装) - /usr/local/bin/openclaw(全局安装) - ~/.openclaw/bin/openclaw(用户目录安装) Fixes #4
This commit is contained in:
@@ -17,6 +17,7 @@ const BACKUPS_DIR = path.join(OPENCLAW_DIR, 'backups')
|
||||
const DEVICE_KEY_FILE = path.join(OPENCLAW_DIR, 'clawpanel-device-key.json')
|
||||
const DEVICES_DIR = path.join(OPENCLAW_DIR, 'devices')
|
||||
const PAIRED_PATH = path.join(DEVICES_DIR, 'paired.json')
|
||||
const isWindows = process.platform === 'win32'
|
||||
const isMac = process.platform === 'darwin'
|
||||
const SCOPES = ['operator.admin', 'operator.approvals', 'operator.pairing', 'operator.read', 'operator.write']
|
||||
|
||||
@@ -274,12 +275,20 @@ const handlers = {
|
||||
get_services_status() {
|
||||
const label = 'ai.openclaw.gateway'
|
||||
const { running, pid } = isMac ? macCheckService(label) : winCheckGateway()
|
||||
const cliInstalled = isMac
|
||||
? fs.existsSync('/opt/homebrew/bin/openclaw') || fs.existsSync('/usr/local/bin/openclaw')
|
||||
: (() => {
|
||||
try { return fs.existsSync(path.join(process.env.APPDATA || '', 'npm', 'openclaw.cmd')) }
|
||||
catch { return false }
|
||||
})()
|
||||
|
||||
let cliInstalled = false
|
||||
if (isMac) {
|
||||
cliInstalled = fs.existsSync('/opt/homebrew/bin/openclaw') || fs.existsSync('/usr/local/bin/openclaw')
|
||||
} else if (isWindows) {
|
||||
try { cliInstalled = fs.existsSync(path.join(process.env.APPDATA || '', 'npm', 'openclaw.cmd')) }
|
||||
catch { cliInstalled = false }
|
||||
} else {
|
||||
// Linux
|
||||
cliInstalled = fs.existsSync('/usr/bin/openclaw') ||
|
||||
fs.existsSync('/usr/local/bin/openclaw') ||
|
||||
fs.existsSync(path.join(homedir(), '.openclaw/bin/openclaw'))
|
||||
}
|
||||
|
||||
return [{ label, running, pid, description: 'OpenClaw Gateway', cli_installed: cliInstalled }]
|
||||
},
|
||||
|
||||
@@ -564,7 +573,7 @@ const handlers = {
|
||||
upgrade_openclaw({ source = 'chinese' } = {}) {
|
||||
const OPENCLAW_DIR = path.join(homedir(), '.openclaw')
|
||||
const pkg = source === 'official' ? '@anthropic-ai/claw' : '@qingchencloud/openclaw-zh'
|
||||
const npmBin = isMac ? 'npm' : 'npm.cmd'
|
||||
const npmBin = isWindows ? 'npm.cmd' : 'npm'
|
||||
try {
|
||||
const out = execSync(`${npmBin} install ${pkg}@latest --prefix "${OPENCLAW_DIR}" 2>&1`, { timeout: 120000 }).toString()
|
||||
return `升级完成 (${source})\n${out.slice(-200)}`
|
||||
|
||||
Reference in New Issue
Block a user