refactor: 完成项目目录重构与代码迁移

本次提交完成了整体项目的目录梳理与代码迁移:
1.  将根级controlplane、webhost等目录的代码迁移至desktop/对应子目录,统一桌面端架构
2.  移动并整理了插件目录结构,将插件统一放入根级plugins/
3.  调整了前端项目的路径与配置,统一前后端开发构建流程
4.  清理了废弃的旧版app/目录与冗余的构建中间文件
5.  更新了.gitignore与README.md,适配新的项目结构
This commit is contained in:
2026-09-14 17:46:09 +08:00
parent a1a06504a5
commit 0ab43d0ed8
131 changed files with 4071 additions and 38034 deletions
+116
View File
@@ -0,0 +1,116 @@
// 与 FastAPI 后端交互,控制面前端直连 /api/*
import { store } from './store.js'
async function req(url, opts) {
const res = await fetch(url, opts)
if (!res.ok) {
let msg = `HTTP ${res.status}`
try { msg = (await res.json()).detail || msg } catch (_) {}
throw new Error(msg)
}
return res.json()
}
// 管理接口无状态鉴权:携带登录后签发的签名票据(X-Admin-Token),后端验票解得当前账号
function adminHeaders(extra = {}) {
return { 'X-Admin-Token': store.token || '', ...extra }
}
export async function adminLogin(account, password) {
return req('/api/admin/auth', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ account, password })
})
}
export async function adminPassword(body) {
return req('/api/admin/password', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminMe() {
return req('/api/admin/me', { headers: adminHeaders() })
}
export async function adminOverview() {
return req('/api/admin/overview', { headers: adminHeaders() })
}
export async function adminPlatforms() {
return req('/api/admin/platforms', { headers: adminHeaders() })
}
export async function adminGrant(body) {
return req('/api/admin/account_plugins', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminPlatformGrant(body) {
return req('/api/admin/account_platforms', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminAccounts() {
return req('/api/admin/accounts', { headers: adminHeaders() })
}
export async function adminAccountCreate(body) {
return req('/api/admin/account', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminAccountUpdate(body) {
return req('/api/admin/account/update', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminAccountReset(body) {
return req('/api/admin/account/reset_pwd', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminAccountDelete(body) {
return req('/api/admin/account/delete', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminPluginDelete(body) {
return req('/api/admin/plugin/delete', {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminPluginPatch(pluginId, body) {
const qs = new URLSearchParams({ plugin_id: pluginId })
return req('/api/admin/plugin/patch?' + qs.toString(), {
method: 'POST',
headers: adminHeaders({ 'Content-Type': 'application/json' }),
body: JSON.stringify(body)
})
}
export async function adminAudit(limit = 300) {
return req('/api/admin/audit?limit=' + limit, { headers: adminHeaders() })
}
export async function adminReports(limit = 300) {
return req('/api/admin/reports?limit=' + limit, { headers: adminHeaders() })
}
export async function adminStats() {
return req('/api/admin/stats', { headers: adminHeaders() })
}
export async function adminUpload(pluginId, name, version, file) {
const fd = new FormData()
fd.append('upload', file)
const qs = new URLSearchParams({ plugin_id: pluginId, name, version })
return req('/api/admin/pkg?' + qs.toString(), { method: 'POST', headers: adminHeaders(), body: fd })
}