Compare commits
2 Commits
f15f6f14e4
...
3bede583bf
| Author | SHA1 | Date | |
|---|---|---|---|
| 3bede583bf | |||
| 40f5578f85 |
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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
32
src/playwright/actions.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user