From 9067be12934c97e273fe830a16be74047987fe0f Mon Sep 17 00:00:00 2001 From: xiongxiao Date: Mon, 29 Dec 2025 03:36:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20package.json=20=E5=92=8C?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=E8=B7=AF=E7=94=B1=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=92=8C=E5=85=83=E6=95=B0=E6=8D=AE=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=8A=9F=E8=83=BD=E5=92=8C=E5=8F=AF=E8=AF=BB?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/routes/browser/page.ts | 6 +++- src/routes/browser/pane-manager.ts | 5 +++- src/routes/good/index.ts | 48 ++++++++++++++++++++++++++++++ src/routes/index.ts | 1 + src/routes/xhs/search-notes.ts | 16 +++++++--- 6 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 src/routes/good/index.ts diff --git a/package.json b/package.json index e8942ea..a9277b8 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,11 @@ "build": "bun run bun.config.ts", "browser": "pm2 start start-browser.js --name browser-helper", "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": "pnpm approve-builds", "init:db": "npx drizzle-kit push", "studio": "npx drizzle-kit studio", - "pm2": "pm2 start dist/app.js --name /root/browser-helper", "drizzle:migrate": "npx drizzle-kit migrate", "drizzle:push": "npx drizzle-kit push" }, diff --git a/src/routes/browser/page.ts b/src/routes/browser/page.ts index fb271f9..e73d20c 100644 --- a/src/routes/browser/page.ts +++ b/src/routes/browser/page.ts @@ -4,7 +4,11 @@ import { app, core } from "../../app.ts"; app.route({ path: 'page', key: 'go', - middleware: ['auth'] + middleware: ['auth'], + description: '导航到指定页面。参数:url (string, 必需) - 目标 URL 地址', + metadata: { + tags: ['浏览器操作'], + } }).define(async (ctx) => { const url = ctx.query?.url as string; if (!url) { diff --git a/src/routes/browser/pane-manager.ts b/src/routes/browser/pane-manager.ts index e1f9f3e..7f424a9 100644 --- a/src/routes/browser/pane-manager.ts +++ b/src/routes/browser/pane-manager.ts @@ -38,7 +38,10 @@ app.route({ path: 'window', key: 'manager', description: desc, - middleware: ['auth'] + middleware: ['auth'], + metadata: { + tags: ['浏览器操作', '窗口管理'], + } }).define(async (ctx) => { const bounds = ctx.query as Bounds || {}; const { left, top, width, height, windowState } = bounds; diff --git a/src/routes/good/index.ts b/src/routes/good/index.ts new file mode 100644 index 0000000..faca073 --- /dev/null +++ b/src/routes/good/index.ts @@ -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); \ No newline at end of file diff --git a/src/routes/index.ts b/src/routes/index.ts index 2dd0872..5850b50 100644 --- a/src/routes/index.ts +++ b/src/routes/index.ts @@ -1,2 +1,3 @@ import './browser/index.ts'; import './xhs/index.ts'; +import './good/index.ts'; \ No newline at end of file diff --git a/src/routes/xhs/search-notes.ts b/src/routes/xhs/search-notes.ts index 32c408f..cced1a6 100644 --- a/src/routes/xhs/search-notes.ts +++ b/src/routes/xhs/search-notes.ts @@ -120,7 +120,11 @@ app.route({ path: 'xhs', key: 'search-notes', description: searchNoteDesc, - middleware: ['auth'] + middleware: ['auth'], + metadata: { + tags: ['小红书', '搜索', '笔记'], + icon: 'search', + } }).define( async (ctx) => { const query = ctx.query!; @@ -153,21 +157,25 @@ app.route({ path: 'xhs', key: 'save-search-notes', description: '保存搜索笔记结果', - middleware: ['auth'] + middleware: ['auth'], + metadata: { + tags: ['小红书', '搜索', '保存'], + icon: 'save', + } }).define(async (ctx) => { const data = ctx.query!.data as XHS.SearchNote[]; try { const getNoteUrl = (note: XHS.SearchNote) => { const id = note.id; 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 user = note.note_card?.user; const id = user?.user_id; const secToken = user?.xsec_token; 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 `` }