Files
37duAutomation/desktop/electron-shell/frontend/src/composables/useShellCheck.js
T
puddy 843ff244a6 feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
2026-10-26 15:42:50 +08:00

40 lines
1.2 KiB
JavaScript

import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { checkShellUpdate, getShellStatus } from '../api'
// 手动「检查更新」:触发秒级版本比对 → 轮询检查结束后交回结果处理。
// statusRef 为壳子状态(useDownloadJob.state),轮询期间同步回写,保证顶栏/状态栏一致。
export function useShellCheck(statusRef, onResult) {
const checking = ref(false)
async function check() {
if (checking.value) return
try {
await checkShellUpdate()
} catch (e) {
ElMessage.error('检查更新失败:' + (e.message || e))
return
}
checking.value = true
const timer = setInterval(async () => {
try {
const s = await getShellStatus()
statusRef.value = s
if (s.checking) return
clearInterval(timer)
checking.value = false
onResult(s)
} catch (_) { /* 首次拿不到状态:继续轮询 */ }
}, 800)
// 兜底:30s 仍未结束则停止轮询,避免无限等待
setTimeout(() => {
if (checking.value) {
clearInterval(timer)
checking.value = false
}
}, 30000)
}
return { checking, check }
}