主要变更: 1. 整体版本升级至1.1.7,更新安装包与shell版本号 2. 新增API与后端能力: - 新增停止运行接口,支持强制终止插件进程与浏览器子进程 - 云端会话令牌与下载票据落库,适配多worker部署 - 优化Chrome版本读取逻辑,避免弹窗与编码问题 3. xq0031_xq0032插件升级至1.0.8: - 新增仓库中文名自动筛选功能,简化用户操作 - 优化ERP登录与报表导出流程,修复标签页残留问题 - 新增前端强制停止按钮,支持实时终止运行 - 修复中文编码与乱码问题,兼容Windows非UTF-8环境 4. 修复授权校验逻辑,确保账号与授权匹配 5. 更新文档与部署脚本,修正发版流程说明
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// 与壳子后端交互(同源,统一账户会话 cookie 自动携带)+ WebSocket 实时流
|
|
export const PLUGIN_ID = 'xq0031_xq0032'
|
|
|
|
async function j(url, opts) {
|
|
const res = await fetch(url, opts)
|
|
if (res.status === 401) {
|
|
throw Object.assign(new Error('未登录:请先在壳子登录统一账户再打开本界面'), { code: 401 })
|
|
}
|
|
if (!res.ok) {
|
|
let msg = `HTTP ${res.status}`
|
|
try { msg = (await res.json()).detail || msg } catch (e) { /* 保留默认 */ }
|
|
throw new Error(msg)
|
|
}
|
|
return res.json()
|
|
}
|
|
|
|
export function loadConfig() {
|
|
return j(`/api/plugin-config/${PLUGIN_ID}`)
|
|
}
|
|
|
|
export function saveConfig(data) {
|
|
return j(`/api/plugin-config/${PLUGIN_ID}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(data),
|
|
})
|
|
}
|
|
|
|
export function startRun(fields) {
|
|
return j('/api/runs', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ plugin_id: PLUGIN_ID, fields }),
|
|
})
|
|
}
|
|
|
|
export function getRun(runId) {
|
|
return j(`/api/runs/${runId}`)
|
|
}
|
|
|
|
export function stopRun(runId) {
|
|
return j(`/api/runs/${runId}/stop`, { method: 'POST' })
|
|
}
|
|
|
|
export function connectWS(onEvent) {
|
|
const ws = new WebSocket((location.protocol === 'https:' ? 'wss://' : 'ws://')
|
|
+ location.host + '/ws')
|
|
ws.onmessage = (e) => { try { onEvent(JSON.parse(e.data)) } catch (_) { /* 忽略脏帧 */ } }
|
|
return ws
|
|
}
|