更新 package.json 和多个路由,添加描述和元数据,增强功能和可读性

This commit is contained in:
2025-12-29 03:36:25 +08:00
parent 64ba53f73c
commit 9067be1293
6 changed files with 71 additions and 7 deletions

View File

@@ -19,11 +19,11 @@
"build": "bun run bun.config.ts", "build": "bun run bun.config.ts",
"browser": "pm2 start start-browser.js --name browser-helper", "browser": "pm2 start start-browser.js --name browser-helper",
"cmd": "tsx src/test/cmd.ts ", "cmd": "tsx src/test/cmd.ts ",
"pm2": "pm2 start dist/app.js --name /root/browser-helper",
"init": "pnpm run init:pnpm && pnpm run init:db && pnpm run init:browser", "init": "pnpm run init:pnpm && pnpm run init:db && pnpm run init:browser",
"init:pnpm": "pnpm approve-builds", "init:pnpm": "pnpm approve-builds",
"init:db": "npx drizzle-kit push", "init:db": "npx drizzle-kit push",
"studio": "npx drizzle-kit studio", "studio": "npx drizzle-kit studio",
"pm2": "pm2 start dist/app.js --name /root/browser-helper",
"drizzle:migrate": "npx drizzle-kit migrate", "drizzle:migrate": "npx drizzle-kit migrate",
"drizzle:push": "npx drizzle-kit push" "drizzle:push": "npx drizzle-kit push"
}, },

View File

@@ -4,7 +4,11 @@ import { app, core } from "../../app.ts";
app.route({ app.route({
path: 'page', path: 'page',
key: 'go', key: 'go',
middleware: ['auth'] middleware: ['auth'],
description: '导航到指定页面。参数url (string, 必需) - 目标 URL 地址',
metadata: {
tags: ['浏览器操作'],
}
}).define(async (ctx) => { }).define(async (ctx) => {
const url = ctx.query?.url as string; const url = ctx.query?.url as string;
if (!url) { if (!url) {

View File

@@ -38,7 +38,10 @@ app.route({
path: 'window', path: 'window',
key: 'manager', key: 'manager',
description: desc, description: desc,
middleware: ['auth'] middleware: ['auth'],
metadata: {
tags: ['浏览器操作', '窗口管理'],
}
}).define(async (ctx) => { }).define(async (ctx) => {
const bounds = ctx.query as Bounds || {}; const bounds = ctx.query as Bounds || {};
const { left, top, width, height, windowState } = bounds; const { left, top, width, height, windowState } = bounds;

48
src/routes/good/index.ts Normal file
View File

@@ -0,0 +1,48 @@
import { app, core, db } from '../../app.ts';
app.route({
path: 'good',
key: 'searchInfo',
description: '搜索小红书今日热门信息差内容。支持自定义关键词参数keyword字符串可选默认搜索"信息差"',
middleware: ['auth'],
metadata: {
tags: ['小红书', '信息差', '热门'],
icon: 'search',
}
}).define(async (ctx) => {
const keyword = ctx.query?.keyword as string || '信息差';
const res = await app.run({
path: 'xhs',
key: 'search-notes',
payload: {
keyword: keyword,
scrollTimes: 5,
token: ctx.query?.token as string,
}
})
ctx.forward(res)
}).addTo(app);
app.route({
path: 'good',
key: 'searchWork',
description: '搜索小红书今日工作机会与招聘信息。支持自定义关键词搜索,默认搜索"工作 杭州"',
middleware: ['auth'],
metadata: {
tags: ['小红书', '工作', '招聘'],
icon: 'search',
}
}).define(async (ctx) => {
const keyword = ctx.query?.keyword as string || '工作 杭州';
const res = await app.run({
path: 'xhs',
key: 'search-notes',
payload: {
keyword: keyword,
scrollTimes: 5,
token: ctx.query?.token as string,
}
})
ctx.forward(res)
}).addTo(app);

View File

@@ -1,2 +1,3 @@
import './browser/index.ts'; import './browser/index.ts';
import './xhs/index.ts'; import './xhs/index.ts';
import './good/index.ts';

View File

@@ -120,7 +120,11 @@ app.route({
path: 'xhs', path: 'xhs',
key: 'search-notes', key: 'search-notes',
description: searchNoteDesc, description: searchNoteDesc,
middleware: ['auth'] middleware: ['auth'],
metadata: {
tags: ['小红书', '搜索', '笔记'],
icon: 'search',
}
}).define( }).define(
async (ctx) => { async (ctx) => {
const query = ctx.query!; const query = ctx.query!;
@@ -153,21 +157,25 @@ app.route({
path: 'xhs', path: 'xhs',
key: 'save-search-notes', key: 'save-search-notes',
description: '保存搜索笔记结果', description: '保存搜索笔记结果',
middleware: ['auth'] middleware: ['auth'],
metadata: {
tags: ['小红书', '搜索', '保存'],
icon: 'save',
}
}).define(async (ctx) => { }).define(async (ctx) => {
const data = ctx.query!.data as XHS.SearchNote[]; const data = ctx.query!.data as XHS.SearchNote[];
try { try {
const getNoteUrl = (note: XHS.SearchNote) => { const getNoteUrl = (note: XHS.SearchNote) => {
const id = note.id; const id = note.id;
const secToken = note.xsec_token; const secToken = note.xsec_token;
return `https://www.xiaohongshu.com/explore/${id}?xsec_token=${secToken}&xsec_source=pc_feed` return `https://www.xiaohongshu.com/explore/${id}?xsec_token=${secToken}`
} }
const getUserUrl = (note: XHS.SearchNote) => { const getUserUrl = (note: XHS.SearchNote) => {
const user = note.note_card?.user; const user = note.note_card?.user;
const id = user?.user_id; const id = user?.user_id;
const secToken = user?.xsec_token; const secToken = user?.xsec_token;
if (user) { if (user) {
return `https://www.xiaohongshu.com/user/profile/${id}?xsec_token=${secToken}&xsec_source=pc_note` return `https://www.xiaohongshu.com/user/profile/${id}?xsec_token=${secToken}`
} }
return `` return ``
} }