feat: 渠道插件安装自动 pin 版本,兼容旧版 OpenClaw

- messaging.rs: install_channel_plugin/install_qqbot_plugin/run_channel_action 新增 version 参数
- 微信插件 npx 安装也支持版本 pin(@tencent-weixin/openclaw-weixin-cli@{version})
- channels.js: 安装前自动获取用户 OpenClaw 版本,pin 到基础版本号
- tauri-api.js/dev-api.js: 同步支持 version 参数传递
This commit is contained in:
晴天
2026-03-26 02:57:43 +08:00
parent ee09ebbc98
commit 540da00b91
4 changed files with 69 additions and 31 deletions

View File

@@ -225,9 +225,9 @@ export const api = {
},
listConfiguredPlatforms: () => cachedInvoke('list_configured_platforms', {}, 5000),
getChannelPluginStatus: (pluginId) => invoke('get_channel_plugin_status', { pluginId }),
installQqbotPlugin: () => invoke('install_qqbot_plugin'),
installChannelPlugin: (packageName, pluginId) => invoke('install_channel_plugin', { packageName, pluginId }),
runChannelAction: (platform, action) => invoke('run_channel_action', { platform, action }),
installQqbotPlugin: (version = null) => invoke('install_qqbot_plugin', { version }),
installChannelPlugin: (packageName, pluginId, version = null) => invoke('install_channel_plugin', { packageName, pluginId, version }),
runChannelAction: (platform, action, version = null) => invoke('run_channel_action', { platform, action, version }),
checkWeixinPluginStatus: () => invoke('check_weixin_plugin_status'),
// Agent 渠道绑定管理

View File

@@ -1441,7 +1441,15 @@ async function openConfigDialog(pid, page, state, accountId) {
if (progressText) progressText.textContent = `${pct}%`
})
const output = await api.runChannelAction(pid, actionId)
// 自动 pin 插件版本到用户的 OpenClaw 版本(仅 install 动作)
let actionVersion = null
if (actionId === 'install') {
try {
const vInfo = await api.getVersionInfo()
if (vInfo?.current) actionVersion = vInfo.current.split('-')[0]
} catch {}
}
const output = await api.runChannelAction(pid, actionId, actionVersion)
_flushQr() // 命令结束后刷新残留 QR 缓冲
if (progressBar) progressBar.style.width = '100%'
if (progressText) progressText.textContent = '100%'
@@ -1772,7 +1780,15 @@ async function openConfigDialog(pid, page, state, accountId) {
}
})
const output = await api.runChannelAction(pid, actionId)
// 自动 pin 插件版本(仅 install 动作)
let actionVer2 = null
if (actionId === 'install') {
try {
const vInfo = await api.getVersionInfo()
if (vInfo?.current) actionVer2 = vInfo.current.split('-')[0]
} catch {}
}
const output = await api.runChannelAction(pid, actionId, actionVer2)
toast(t('channels.actionDone'), 'success')
if (logBox && output && !String(output).includes(logBox.textContent)) {
logBox.textContent += (logBox.textContent ? '\n' : '') + String(output)
@@ -1930,11 +1946,17 @@ async function openConfigDialog(pid, page, state, accountId) {
} catch {}
try {
// 自动 pin 插件版本到用户的 OpenClaw 版本,避免 minHostVersion 不兼容
let pluginVersion = null
try {
const vInfo = await api.getVersionInfo()
if (vInfo?.current) pluginVersion = vInfo.current.split('-')[0]
} catch {}
// QQ 必须用专用安装命令:官方包目录为 openclaw-qqbot与 install_channel_plugin(…, "qqbot") 的备份路径不一致
if (pid === 'qqbot') {
await api.installQqbotPlugin()
await api.installQqbotPlugin(pluginVersion)
} else {
await api.installChannelPlugin(pluginPackage, pluginId)
await api.installChannelPlugin(pluginPackage, pluginId, pluginVersion)
}
} catch (e) {
toast(t('channels.pluginInstallFailed') + ': ' + e, 'error')