feat: npm 源可配置,支持淘宝/官方/华为云镜像切换

- 所有 npm 操作使用用户配置的 registry,默认淘宝镜像
- 服务管理页面新增 npm 源设置区域(预设 + 自定义)
- 版本检测 API 同步使用配置源
- 配置持久化到 ~/.openclaw/npm-registry.txt
This commit is contained in:
晴天
2026-02-28 14:10:09 +08:00
parent da8932a3e0
commit a5c7760f25
4 changed files with 96 additions and 4 deletions

View File

@@ -99,6 +99,8 @@ function mockInvoke(cmd, args) {
upgrade_openclaw: () => '升级成功,当前版本: 2026.2.26-zh.3 (mock)',
install_gateway: () => 'Gateway 服务已安装 (mock)',
uninstall_gateway: () => 'Gateway 服务已卸载 (mock)',
get_npm_registry: () => 'https://registry.npmmirror.com',
set_npm_registry: () => true,
test_model: ({ modelId }) => `模型 ${modelId} 连通正常 (mock)`,
list_remote_models: () => ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo', 'gpt-3.5-turbo', 'o3-mini', 'dall-e-3', 'text-embedding-3-small'],
write_env_file: () => true,
@@ -144,6 +146,8 @@ export const api = {
upgradeOpenclaw: (source = 'chinese') => invoke('upgrade_openclaw', { source }),
installGateway: () => invoke('install_gateway'),
uninstallGateway: () => invoke('uninstall_gateway'),
getNpmRegistry: () => invoke('get_npm_registry'),
setNpmRegistry: (registry) => invoke('set_npm_registry', { registry }),
testModel: (baseUrl, apiKey, modelId) => invoke('test_model', { baseUrl, apiKey, modelId }),
listRemoteModels: (baseUrl, apiKey) => invoke('list_remote_models', { baseUrl, apiKey }),