重构为 HTTP SSO 扫码方案并引入 Vue3 前端
移除 Playwright 浏览器自动化,改用 passport/SSO HTTP 接口获取二维码与轮询登录;后端模块化拆分,前端替换为 Vue3 SPA。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE || '',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
timeout: 120000,
|
||||
})
|
||||
|
||||
export async function post(path, body = {}, axiosConfig = {}) {
|
||||
const { data } = await http.post(path, body, axiosConfig)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function get(path, params = {}, axiosConfig = {}) {
|
||||
const { data } = await http.get(path, { ...axiosConfig, params })
|
||||
return data
|
||||
}
|
||||
|
||||
export function formatApiError(err, fallback = '请求失败') {
|
||||
const d = err?.response?.data
|
||||
if (typeof d?.message === 'string' && d.message.trim()) return d.message
|
||||
if (typeof d === 'string' && d.trim()) return d
|
||||
return err?.message || fallback
|
||||
}
|
||||
|
||||
export default http
|
||||
Reference in New Issue
Block a user