Files
browser-helper/src/routes/browser/page.ts

20 lines
532 B
TypeScript
Raw 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.
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);