Files
hms/apps/miniprogram/audit-pages.cjs
iven 50eae8b809 feat(miniprogram): 温润东方风全面 UI 重设计
73 文件变更,覆盖全部 40 个页面 SCSS + TabBar 图标 + 组件样式。
统一赤陶主色 #C4623A + 暖米背景 + 衬线标题字体 + 12px 圆角体系。
2026-04-28 00:19:52 +08:00

113 lines
3.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 批量审计页面(使用 reLaunch 避免页面栈限制)
*/
const automator = require('miniprogram-automator');
const ALL_PAGES = [
'pages/health/input/index',
'pages/health/trend/index',
'pages/health/daily-monitoring/index',
'pages/appointment/index',
'pages/appointment/create/index',
'pages/article/index',
'pages/ai-report/list/index',
'pages/followup/detail/index',
'pages/consultation/detail/index',
'pages/mall/orders/index',
'pages/profile/family/index',
'pages/profile/reports/index',
'pages/profile/followups/index',
'pages/profile/medication/index',
'pages/profile/settings/index',
'pages/legal/user-agreement',
'pages/legal/privacy-policy',
'pages/doctor/index',
'pages/doctor/patients/index',
'pages/doctor/consultation/index',
'pages/doctor/followup/index',
'pages/doctor/report/index',
'pages/events/index',
'pages/device-sync/index',
];
// 带参数的页面(需要 id 等参数)
const PAGES_WITH_PARAMS = {
'pages/appointment/detail/index': '?id=test-123',
'pages/article/detail/index': '?id=test-123',
'pages/report/detail/index': '?id=test-123',
'pages/ai-report/detail/index': '?id=test-123',
'pages/mall/exchange/index': '?id=test-123',
'pages/mall/detail/index': '?id=test-123',
'pages/profile/family-add/index': '?id=test-123',
'pages/doctor/patients/detail/index': '?id=test-123',
'pages/doctor/consultation/detail/index': '?id=test-123',
'pages/doctor/followup/detail/index': '?id=test-123',
'pages/doctor/report/detail/index': '?id=test-123',
};
async function main() {
console.log('连接 DevTools...');
const mp = await automator.connect({ wsEndpoint: 'ws://localhost:9420' });
// 验证 token
const tokenLen = await mp.evaluate(() => {
const t = wx.getStorageSync('access_token');
return t ? t.length : 0;
});
if (tokenLen === 0) {
console.log('ERROR: 无 token请先运行 inject-auth.cjs');
process.exit(1);
}
console.log(`Token: ${tokenLen} chars\n`);
const results = { ok: [], redirectToLogin: [], redirectOther: [], error: [] };
for (const pagePath of ALL_PAGES) {
const param = PAGES_WITH_PARAMS[pagePath] || '';
const url = `/${pagePath}${param}`;
try {
await mp.reLaunch(url);
await new Promise(r => setTimeout(r, 2000));
const current = await mp.currentPage();
if (current.path === pagePath) {
results.ok.push(pagePath);
console.log(` OK: ${pagePath}`);
} else if (current.path === 'pages/login/index') {
results.redirectToLogin.push(pagePath);
console.log(` AUTH: ${pagePath} → login (需登录)`);
} else {
results.redirectOther.push(`${pagePath}${current.path}`);
console.log(` REDIR: ${pagePath}${current.path}`);
}
} catch (e) {
const msg = e.message.slice(0, 60);
results.error.push(`${pagePath}: ${msg}`);
console.log(` ERR: ${pagePath} - ${msg}`);
}
}
console.log(`\n===== 审计摘要 =====`);
console.log(`正常: ${results.ok.length}/${ALL_PAGES.length}`);
console.log(`需登录: ${results.redirectToLogin.length}`);
console.log(`重定向: ${results.redirectOther.length}`);
console.log(`错误: ${results.error.length}`);
if (results.redirectToLogin.length > 0) {
console.log(`\n需登录页面 (API 401 → login):`);
results.redirectToLogin.forEach(p => console.log(` - ${p}`));
}
if (results.error.length > 0) {
console.log(`\n错误页面:`);
results.error.forEach(p => console.log(` - ${p}`));
}
if (results.ok.length > 0) {
console.log(`\n正常页面:`);
results.ok.forEach(p => console.log(` - ${p}`));
}
await mp.disconnect();
}
main().catch(e => { console.error(e); process.exit(1); });