0841b1a103
- 前端:Vue3 + TS + Element Plus,24 个页面路由(课件/组题/教案/动画/思维导图/作文批改/命题/课堂/资源/社区等) - 后端:FastAPI + SQLAlchemy + SQLite,17 个路由模块,AI 服务层含降级模板 - AI:glm-5.x 推理模型已禁用思维链,确保输出真实内容 - 修复:ai_service 两处请求体注入 enable_thinking/thinking disabled - 测试账号:13900999999 / test1234
59 lines
2.4 KiB
JavaScript
59 lines
2.4 KiB
JavaScript
import { chromium } from 'playwright-core';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
const loginRes = await fetch('http://127.0.0.1:8010/api/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ phone: '13943441149', password: 'Test1234' })
|
|
});
|
|
const loginData = await loginRes.json();
|
|
const accessToken = loginData.access_token;
|
|
const refreshToken = loginData.refresh_token;
|
|
|
|
const browser = await chromium.launch({
|
|
channel: 'chrome', headless: true,
|
|
executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
|
|
});
|
|
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
|
await ctx.addInitScript(([at, rt]) => {
|
|
localStorage.setItem('access_token', at);
|
|
localStorage.setItem('refresh_token', rt);
|
|
}, [accessToken, refreshToken]);
|
|
const page = await ctx.newPage();
|
|
const errors = [];
|
|
page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
|
|
page.on('pageerror', e => errors.push('PAGEERROR: ' + e.message));
|
|
|
|
const shotDir = path.resolve('audit_shots');
|
|
if (!fs.existsSync(shotDir)) fs.mkdirSync(shotDir);
|
|
|
|
const pages = [
|
|
{ name: 'home', path: '/home' },
|
|
{ name: 'courseware_list', path: '/courseware' },
|
|
{ name: 'courseware_create', path: '/courseware/create' },
|
|
{ name: 'animation', path: '/animation' },
|
|
{ name: 'exercise', path: '/exercise' },
|
|
{ name: 'exam', path: '/exam' },
|
|
{ name: 'lesson_plan', path: '/lesson-plan' },
|
|
{ name: 'mindmap', path: '/mindmap' },
|
|
{ name: 'essay_grade', path: '/essay-grade' },
|
|
{ name: 'materials', path: '/materials' },
|
|
{ name: 'profile', path: '/profile' },
|
|
{ name: 'classroom', path: '/classroom' },
|
|
{ name: 'assistant', path: '/assistant' },
|
|
{ name: 'admin', path: '/admin' },
|
|
];
|
|
for (const p of pages) {
|
|
await page.goto('http://127.0.0.1:5175' + p.path, { waitUntil: 'networkidle', timeout: 15000 }).catch(() => {});
|
|
await page.waitForTimeout(1500);
|
|
await page.screenshot({ path: path.join(shotDir, p.name + '.png'), fullPage: false });
|
|
const url = page.url();
|
|
const redirected = url.includes('login');
|
|
const h = await page.textContent('h1, h2').catch(() => '');
|
|
console.log('[' + p.name + '] ' + (redirected ? 'REDIRECT_LOGIN' : url.split('/').slice(-2).join('/')) + ' h="' + (h||'').trim().substring(0,30) + '"');
|
|
}
|
|
console.log('ERRORS:', errors.length);
|
|
errors.slice(0,10).forEach(e => console.log(' ', e.substring(0,140)));
|
|
await browser.close();
|