Compare commits

...

2 Commits

Author SHA1 Message Date
3bede583bf update 2025-12-30 10:59:25 +08:00
40f5578f85 更新路由定义,添加对 'auth' 的描述,优化列表获取逻辑 2025-12-30 03:00:35 +08:00
3 changed files with 38 additions and 2 deletions

View File

@@ -20,7 +20,10 @@ app.route({
key: 'list' key: 'list'
}).define(async (ctx) => { }).define(async (ctx) => {
ctx.body = { ctx.body = {
list: app.router.getList() list: app.router.getList((item) => {
if (item.id === 'auth') return false
return true
})
} }
}).addTo(app); }).addTo(app);

View File

@@ -5,7 +5,8 @@ import './routes/index.ts';
// 如果是直接运行,则启动应用 // 如果是直接运行,则启动应用
app.route({ app.route({
id: 'auth' id: 'auth',
description: 'Token 权限验证,临时方案',
}).define(async (ctx) => { }).define(async (ctx) => {
// token authentication // token authentication

32
src/playwright/actions.ts Normal file
View File

@@ -0,0 +1,32 @@
import { Page } from 'playwright';
export interface Action {
type: string;
payload: Record<string, any>;
}
export class PlaywrightExecutor {
constructor(private page: Page) { }
async execute(action: Action): Promise<void> {
switch (action.type) {
case 'goto':
await this.page.goto(action.payload.url);
break;
case 'type':
await this.page.fill(action.payload.selector, action.payload.text);
break;
case 'click':
await this.page.click(action.payload.selector);
break;
case 'waitForLoad':
await this.page.waitForLoadState('networkidle');
break;
case 'screenshot':
await this.page.screenshot({ path: action.payload.path });
break;
default:
throw new Error(`未知动作: ${action.type}`);
}
}
}