后端 (Go/Gin/GORM): - 配置(viper+env)、SQLite/Postgres 迁移、argon2id、AES-GCM 渠道密钥、JWT+refresh cookie - 用户注册/登录/刷新/登出、API Key CRUD(仅存哈希、明文一次展示) - 代理网关: /v1/chat/completions、/v1/responses、/v1/models 直通 OpenAI 渠道 非流式+流式(SSE 零缓冲转发), 用量捕获(chat 末块/responses completed 嵌套), OpenAI 错误格式(401/402/404/502), 余额检查 - 异步批量记账 + 余额流水 + 日聚合, admin 用户/余额/配置 API - 单测: crypto/jwt/apikey/流式 usage 提取 前端 (Vue3+TS+Vite+Tailwind v4): - taste-skill 设计 tokens: 深色仪表盘, 石墨+信号铜色, Outfit+JetBrains Mono - Landing/登录/注册, 控制台(仪表盘图表/密钥管理/用量明细) - 基础组件 Button/Input/Badge/Modal, ECharts 用量图 部署: docker-compose(nginx+api+postgres), 双 Dockerfile, nginx SSE 反代 联调: scripts/mockupstream 本地 mock 上游, 端到端验证通过
33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
const { chromium } = require('playwright')
|
|
async function main() {
|
|
const browser = await chromium.launch()
|
|
const page = await browser.newPage()
|
|
const uname = 'probe' + Date.now().toString().slice(-6)
|
|
await page.goto('http://localhost:5173/register', { waitUntil: 'networkidle' })
|
|
await page.fill('input[autocomplete="username"]', uname)
|
|
await page.fill('input[autocomplete="email"]', uname + '@test.com')
|
|
await page.fill('input[autocomplete="new-password"]', 'password123')
|
|
await page.locator('input[autocomplete="new-password"]').nth(1).fill('password123')
|
|
await page.click('button[type="submit"]')
|
|
await page.waitForURL('**/console/dashboard', { timeout: 10000 })
|
|
await page.waitForTimeout(500)
|
|
const results = await page.evaluate(async () => {
|
|
const out = {}
|
|
for (const [name, url] of Object.entries({
|
|
balance: '/api/v1/user/balance',
|
|
stats: '/api/v1/usage/stats?group=day',
|
|
logs: '/api/v1/usage/logs?page_size=8',
|
|
})) {
|
|
try {
|
|
const r = await fetch(url, { headers: { Authorization: 'Bearer ' + localStorage.getItem('ot_access') } })
|
|
const j = await r.json()
|
|
out[name] = { status: r.status, body: JSON.stringify(j).slice(0, 220) }
|
|
} catch (e) { out[name] = { err: String(e) } }
|
|
}
|
|
return out
|
|
})
|
|
console.log(JSON.stringify(results, null, 1))
|
|
await browser.close()
|
|
}
|
|
main().catch(e => { console.error(e); process.exit(1) })
|