mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-10 17:42:49 +08:00
优化:初始设置页面自动创建默认配置文件
当检测到 OpenClaw CLI 已安装但 openclaw.json 不存在时: 1. 自动创建包含合理默认值的配置文件(mode:local, tools:full 等) 2. 如果自动创建失败,显示「一键初始化配置」按钮供手动操作 3. 新增 init_openclaw_config API(dev-api.js + Tauri Rust 后端) 4. 用户不再需要去终端手动执行 openclaw configure
This commit is contained in:
@@ -583,6 +583,26 @@ const handlers = {
|
||||
return 'Gateway 服务已卸载'
|
||||
},
|
||||
|
||||
// 自动初始化配置文件(CLI 已装但 openclaw.json 不存在时)
|
||||
init_openclaw_config() {
|
||||
if (fs.existsSync(CONFIG_PATH)) return { created: false, message: '配置文件已存在' }
|
||||
if (!fs.existsSync(OPENCLAW_DIR)) fs.mkdirSync(OPENCLAW_DIR, { recursive: true })
|
||||
const defaultConfig = {
|
||||
"$schema": "https://openclaw.ai/schema/config.json",
|
||||
meta: { lastTouchedVersion: "2026.1.1" },
|
||||
mode: "local",
|
||||
models: { providers: {} },
|
||||
gateway: {
|
||||
port: 18789,
|
||||
auth: { mode: "none" },
|
||||
controlUi: { allowedOrigins: ["*"], allowInsecureAuth: true }
|
||||
},
|
||||
tools: { profile: "full", sessions: { visibility: "all" } }
|
||||
}
|
||||
fs.writeFileSync(CONFIG_PATH, JSON.stringify(defaultConfig, null, 2))
|
||||
return { created: true, message: '配置文件已创建' }
|
||||
},
|
||||
|
||||
get_deploy_config() {
|
||||
try {
|
||||
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'))
|
||||
|
||||
Reference in New Issue
Block a user