20 lines
532 B
TypeScript
20 lines
532 B
TypeScript
import { app, core } from "../../app.ts";
|
||
|
||
|
||
app.route({
|
||
path: 'page',
|
||
key: 'go',
|
||
middleware: ['auth'],
|
||
description: '导航到指定页面。参数:url (string, 必需) - 目标 URL 地址',
|
||
metadata: {
|
||
tags: ['浏览器操作', '核心功能'],
|
||
}
|
||
}).define(async (ctx) => {
|
||
const url = ctx.query?.url as string;
|
||
if (!url) {
|
||
ctx.throw!(400, '缺少 url 参数');
|
||
}
|
||
const page = await core.getPage();
|
||
await page.goto(url);
|
||
ctx.body = { success: true, message: `已导航到 ${url}` };
|
||
}).addTo(app); |