unis_crm/frontend/seed-admin.html

20 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!doctype html>
<html lang="zh-CN"><head><meta charset="UTF-8"><title>seed</title></head><body>
<!-- dev-only 压测脚手架:写入假登录态后直落 /admin,用来量接口瀑布。
只在 vite dev 下用(npm run dev 的目录里),不会进构建产物。 -->
<script>
// 一个 exp 很远、形状像 JWT 的假 token,只为让 isAuthed() 为真且不触发续期请求
var b64 = function (o) { return btoa(JSON.stringify(o)).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); };
var params = new URLSearchParams(location.search);
// 打桩后端用假 token 就够;打真后端要带 ?token=<真 access>&rt=<真 refresh>,
// 否则画像和权限全是 401,页面只剩空壳,截图也看不出真实观感。
var token = params.get('token')
|| b64({ alg: 'none' }) + '.' + b64({ exp: Math.floor(Date.now() / 1000) + 86400 }) + '.sig';
localStorage.setItem('accessToken', token);
localStorage.setItem('refreshToken', params.get('rt') || 'seed-refresh');
localStorage.setItem('username', 'tester');
localStorage.setItem('activeTenantId', params.get('tenantId') || '1');
location.replace('/admin' + (params.get('to') || ''));
</script>
</body></html>