30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// Local-only visual QA: no request reaches the real backend.
|
|
import { preview } from 'vite';
|
|
|
|
const server = await preview({
|
|
configFile: false,
|
|
build: { outDir: 'dist/build/h5' },
|
|
preview: { host: '127.0.0.1', port: 48138, strictPort: true },
|
|
plugins: [{
|
|
name: 'mock-h5-api',
|
|
configurePreviewServer(server) {
|
|
server.middlewares.use((req, res, next) => {
|
|
if (!req.url.startsWith('/__mock/')) return next();
|
|
let data = {};
|
|
if (req.url.startsWith('/__mock/asset/info')) data = {
|
|
identifier: 'A', asset_type: 'card', bound_phone: '13800000001',
|
|
current_package: '测试套餐', current_package_id: 1, current_package_usage_id: 1,
|
|
real_total_mb: 1024, real_used_mb: 256,
|
|
estimated_final_expires_at: '2026-10-13T16:00:00Z', days_until_final_expiry: 0, is_expiring: true,
|
|
expiry_reminder: { remaining_days: 0, expires_at: '2026-10-13T16:00:00Z', level: 'red', level_name: '即将到期' }
|
|
};
|
|
if (req.url.startsWith('/__mock/notifications')) data = { count: 0, items: [], total: 0 };
|
|
const conflict = req.url.startsWith('/__mock/auth/bind-phone');
|
|
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
res.end(JSON.stringify({ code: conflict ? 1192 : 0, msg: conflict ? '该资产已绑定手机号,如需更换请联系管理员' : 'success', data }));
|
|
});
|
|
}
|
|
}]
|
|
});
|
|
server.printUrls();
|