Files
37duAutomation/desktop/webhost/frontend/src/api.js
T
puddy b32f8e8fe2 feat: 新增xq0031_xq0032 ERP报表导出插件,完成功能与基建更新
1. 新增xq0031_xq0032插件:包含前后端源码、打包脚本、配置文件与插件元数据
2. 新增内网文件服务器组件:exe、启停脚本、打包脚本与配置
3. 新增敏感凭证RSA加密下发能力与存储结构
4. 新增大文件源管理表与相关API
5. 优化登录流程与会话管理,新增Chrome自动化安装工具链
6. 清理废弃插件与示例代码
7. 更新版本号至1.1.3,完善安装包与.gitignore配置
2026-09-17 12:42:44 +08:00

101 lines
2.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 与 FastAPI 后端交互 + WebSocket 实时流
const WS_BASE = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host
async function j(url, opts) {
const res = await fetch(url, opts)
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 async function fetchMeta() {
return j('/api/meta')
}
export async function syncPlugins() {
return j('/api/plugins/sync', { method: 'POST' })
}
export async function getShellStatus() {
return j('/api/shell/update-status')
}
export async function checkShellUpdate() {
return j('/api/shell/check', { method: 'POST' })
}
export async function downloadShellUpdate() {
return j('/api/shell/download', { method: 'POST' })
}
export async function applyShellUpdate() {
return j('/api/shell/apply', { method: 'POST' })
}
// ===== 浏览器(Chrome)安装 =====
export async function getChromeStatus() {
return j('/api/chrome/status')
}
export async function checkChrome() {
return j('/api/chrome/check', { method: 'POST' })
}
export async function downloadChrome() {
return j('/api/chrome/download', { method: 'POST' })
}
export async function installChrome() {
return j('/api/chrome/install', { method: 'POST' })
}
export async function loginPlatform(id) {
return j(`/api/platforms/${id}/login`, { method: 'POST' })
}
export async function logoutPlatform(id) {
return j(`/api/platforms/${id}/logout`, { method: 'POST' })
}
export async function startRun(pluginId, fields) {
return j('/api/runs', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ plugin_id: pluginId, fields }),
})
}
export async function getRun(runId) {
return j(`/api/runs/${runId}`)
}
export function connectWS(onEvent) {
const ws = new WebSocket(WS_BASE + '/ws')
ws.onmessage = (e) => {
try { onEvent(JSON.parse(e.data)) } catch (_) {}
}
return ws
}
// ===== 统一账户登录/会话(底座仅保留认证与个人密码,管理走中心机控制面) =====
export async function adminMe() {
return j('/api/admin/me')
}
export async function adminLogin(account, password) {
return j('/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ account, password }) })
}
// v3 钉钉直连接登录:生成钉钉授权 URL(redirect_uri=本机 /auth/done),前端当前窗口跳转到该 URL
export async function authDingtalk() {
return j('/api/auth/dingtalk')
}
export async function adminLogout() {
return j('/api/admin/logout', { method: 'POST' })
}
export async function adminPassword(body) {
return j('/api/admin/password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
}
export async function adminAvatarUpload(file) {
const fd = new FormData()
fd.append('file', file)
return j('/api/avatar', { method: 'POST', body: fd })
}