From 3a56432e3f03e4eaafc9fcb8b9028521145fbe6c Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 11 Jun 2026 14:47:00 +0800 Subject: [PATCH] feat: allow nested namespace (#22243) --- lib/api/index.ts | 3 +- lib/api/namespace.test.ts | 25 ++ lib/api/namespace/one.ts | 38 +- lib/registry.test.ts | 69 ++++ lib/registry.ts | 57 ++- lib/routes/cbirc/index.ts | 133 ------- lib/routes/gov/ah/kjt.ts | 36 +- lib/routes/gov/beijing/bjedu/gh.ts | 9 +- lib/routes/gov/beijing/bphc/index.ts | 24 +- lib/routes/gov/beijing/jw/tzgg.ts | 2 +- lib/routes/gov/beijing/kw/index.ts | 14 +- .../{shenzhen/szlh => beijing}/namespace.ts | 4 +- lib/routes/gov/caac/cjwt.tsx | 4 +- lib/routes/gov/caac/namespace.ts | 8 + lib/routes/gov/cac/index.ts | 26 +- lib/routes/gov/cac/namespace.ts | 8 + lib/routes/gov/cbirc/index.ts | 371 ------------------ lib/routes/gov/ccdi/index.ts | 31 +- lib/routes/gov/ccdi/namespace.ts | 8 + lib/routes/gov/chinamine-safety/namespace.ts | 8 + lib/routes/gov/chinamine-safety/xw.ts | 48 ++- lib/routes/gov/chinamine-safety/zfxxgk.ts | 201 +++++++++- lib/routes/gov/chinatax/latest.ts | 2 +- lib/routes/gov/chinatax/namespace.ts | 8 + lib/routes/gov/chongqing/gzw.ts | 6 +- lib/routes/gov/chongqing/namespace.ts | 8 + lib/routes/gov/chongqing/rsks.ts | 4 +- lib/routes/gov/chongqing/sydwgkzp.ts | 4 +- lib/routes/gov/cmse/fxrw-category.ts | 29 ++ lib/routes/gov/cmse/fxrw.ts | 2 +- lib/routes/gov/cmse/gfgg.ts | 16 + lib/routes/gov/cmse/gjhz.ts | 16 + lib/routes/gov/cmse/hqsy.ts | 22 ++ lib/routes/gov/cmse/index.ts | 10 +- lib/routes/gov/cmse/kjkx.ts | 22 ++ lib/routes/gov/cmse/kpjy.ts | 22 ++ lib/routes/gov/cmse/namespace.ts | 8 + lib/routes/gov/cmse/xwzx-yzjz.ts | 16 + lib/routes/gov/cmse/xwzx-zhxw.ts | 16 + lib/routes/gov/cmse/ztbd.ts | 22 ++ lib/routes/gov/cn/news/index.ts | 2 +- lib/routes/gov/cnnic/index.ts | 41 +- lib/routes/gov/cnnic/namespace.ts | 8 + lib/routes/gov/csrc/auditstatus.ts | 2 +- lib/routes/gov/csrc/csrc.ts | 128 +++--- lib/routes/gov/csrc/namespace.ts | 8 + lib/routes/gov/csrc/news.tsx | 19 +- lib/routes/gov/customs/list.ts | 4 +- lib/routes/gov/dianbai/dianbai.ts | 17 +- lib/routes/gov/dianbai/namespace.ts | 8 + lib/routes/gov/forestry/gjlckjdjt.ts | 2 +- lib/routes/gov/forestry/namespace.ts | 8 + lib/routes/gov/gaozhou/gaozhou.ts | 17 +- lib/routes/gov/gaozhou/namespace.ts | 8 + lib/routes/gov/guizhou/jyt.ts | 6 +- lib/routes/gov/gz/index.ts | 12 +- lib/routes/gov/gz/namespace.ts | 8 + lib/routes/gov/gz/xw.ts | 20 + lib/routes/gov/gz/zwgk.ts | 21 + lib/routes/gov/hainan/iitb/tzgg.ts | 2 +- lib/routes/gov/hangzhou/zwfw.tsx | 2 +- lib/routes/gov/hebei/czt.ts | 2 +- lib/routes/gov/hebei/namespace.ts | 8 + lib/routes/gov/huazhou/huazhou.ts | 17 +- lib/routes/gov/huazhou/namespace.ts | 8 + lib/routes/gov/huizhou/namespace.ts | 8 + lib/routes/gov/huizhou/zwgk/index.ts | 22 +- lib/routes/gov/hunan/changsha/major-email.ts | 8 +- lib/routes/gov/hunan/namespace.ts | 8 + lib/routes/gov/immiau/namespace.ts | 8 + lib/routes/gov/immiau/news.ts | 2 +- lib/routes/gov/jgjcndrc/index.ts | 2 +- lib/routes/gov/jgjcndrc/namespace.ts | 8 + lib/routes/gov/jiangsu/namespace.ts | 8 + lib/routes/gov/jiangsu/wlt/index.tsx | 6 +- .../healthcommission/medical-exam-notice.ts | 2 +- lib/routes/gov/jinan/namespace.ts | 8 + lib/routes/gov/lswz/index.ts | 56 +-- lib/routes/gov/lswz/namespace.ts | 8 + lib/routes/gov/maoming/maoming.ts | 19 +- lib/routes/gov/maoming/namespace.ts | 8 + lib/routes/gov/maonan/maonan.ts | 41 +- lib/routes/gov/maonan/namespace.ts | 8 + lib/routes/gov/mee/namespace.ts | 8 + lib/routes/gov/mee/nnsa.ts | 42 +- lib/routes/gov/mee/ywdt.ts | 4 +- lib/routes/gov/mem/sgcc.ts | 4 +- lib/routes/gov/mem/zfxxgkpt.ts | 4 +- lib/routes/gov/mfa/namespace.ts | 8 + lib/routes/gov/mfa/wjdt.ts | 4 +- lib/routes/gov/mgs/mgs.ts | 17 +- lib/routes/gov/mgs/namespace.ts | 8 + lib/routes/gov/miit/namespace.ts | 8 + lib/routes/gov/miit/wjfb.ts | 2 +- lib/routes/gov/miit/wjgs.ts | 2 +- lib/routes/gov/miit/yjzj.ts | 2 +- lib/routes/gov/miit/zcjd.ts | 2 +- lib/routes/gov/miit/zcwj.ts | 2 +- lib/routes/gov/mmht/mmht.ts | 17 +- lib/routes/gov/mmht/namespace.ts | 8 + lib/routes/gov/moa/gjs.ts | 14 +- lib/routes/gov/moa/moa.ts | 6 +- lib/routes/gov/moa/namespace.ts | 8 + lib/routes/gov/moa/szcpxx.ts | 6 +- lib/routes/gov/moa/zdscxx.ts | 16 +- lib/routes/gov/moe/moe.ts | 2 +- lib/routes/gov/moe/namespace.ts | 8 + lib/routes/gov/moe/s78.ts | 2 +- lib/routes/gov/mof/bond.ts | 2 +- lib/routes/gov/mof/gss.ts | 4 +- lib/routes/gov/mof/namespace.ts | 8 + lib/routes/gov/mofcom/article.ts | 12 +- lib/routes/gov/mofcom/namespace.ts | 8 + lib/routes/gov/moj/aac/news.ts | 2 +- lib/routes/gov/moj/lfyjzj.ts | 2 +- lib/routes/gov/moj/namespace.ts | 8 + lib/routes/gov/mot/index.ts | 10 +- lib/routes/gov/mot/namespace.ts | 8 + lib/routes/gov/ndrc/fggz.ts | 182 ++++----- lib/routes/gov/ndrc/xwdt.ts | 2 +- lib/routes/gov/ndrc/zfxxgk.ts | 7 +- lib/routes/gov/nea/bureau.ts | 4 +- lib/routes/gov/nfra/index.ts | 362 +++++++++++++++++ lib/routes/gov/nfra/namespace.ts | 8 + lib/routes/gov/nifdc/index.ts | 21 +- lib/routes/gov/nifdc/namespace.ts | 8 + lib/routes/gov/nmpa/generic.ts | 23 +- lib/routes/gov/nmpa/namespace.ts | 8 + lib/routes/gov/nopss/index.ts | 33 +- lib/routes/gov/nopss/namespace.ts | 8 + lib/routes/gov/npc/index.ts | 2 +- lib/routes/gov/npc/namespace.ts | 8 + lib/routes/gov/nrta/dsj.ts | 2 +- lib/routes/gov/nrta/namespace.ts | 8 + lib/routes/gov/nrta/news.ts | 2 +- lib/routes/gov/nsfc/index.ts | 47 ++- lib/routes/gov/nsfc/namespace.ts | 8 + lib/routes/gov/pbc/goutongjiaoliu.ts | 2 +- lib/routes/gov/pbc/gzlw.ts | 2 +- lib/routes/gov/pbc/trade-announcement.ts | 2 +- lib/routes/gov/pbc/zcyj.ts | 5 +- lib/routes/gov/pudong/namespace.ts | 8 + lib/routes/gov/pudong/zwgk.ts | 6 +- lib/routes/gov/safe/business.ts | 2 +- lib/routes/gov/safe/complaint.ts | 2 +- lib/routes/gov/safe/namespace.ts | 8 + lib/routes/gov/samr/namespace.ts | 8 + lib/routes/gov/samr/xgzlyhd.tsx | 2 +- lib/routes/gov/sasac/generic.ts | 23 +- lib/routes/gov/sasac/namespace.ts | 8 + lib/routes/gov/sdb/namespace.ts | 8 + lib/routes/gov/sdb/sdb.ts | 17 +- lib/routes/gov/sh/fgw/index.tsx | 8 +- lib/routes/gov/sh/rsj/ksxm.tsx | 4 +- lib/routes/gov/sh/wgj/wgj.tsx | 6 +- lib/routes/gov/sh/wsjkw/yqtb/index.ts | 4 +- lib/routes/gov/sh/yjj/index.ts | 26 +- lib/routes/gov/shaanxi/kjt.ts | 2 +- lib/routes/gov/shaanxi/namespace.ts | 8 + lib/routes/gov/shenzhen/hrss/szksy/index.ts | 4 +- lib/routes/gov/shenzhen/namespace.ts | 8 + lib/routes/gov/shenzhen/szlh/index.ts | 4 +- lib/routes/gov/shenzhen/xxgk/zfxxgj.ts | 4 +- lib/routes/gov/shenzhen/zjj/index.ts | 4 +- lib/routes/gov/shenzhen/zzb/index.ts | 2 +- .../gov/sichuan/deyang/govpublicinfo.tsx | 2 +- lib/routes/gov/sichuan/deyang/mztoday.tsx | 4 +- lib/routes/gov/sichuan/namespace.ts | 8 + lib/routes/gov/stats/index.tsx | 12 +- lib/routes/gov/stats/namespace.ts | 8 + lib/routes/gov/suzhou/doc.ts | 2 +- lib/routes/gov/suzhou/fg.ts | 20 +- lib/routes/gov/suzhou/namespace.ts | 8 + lib/routes/gov/suzhou/news.ts | 2 +- lib/routes/gov/taiyuan/namespace.ts | 8 + lib/routes/gov/taiyuan/rsj.ts | 4 +- lib/routes/gov/tianjin/namespace.ts | 8 + lib/routes/gov/tianjin/tjftz.ts | 4 +- lib/routes/gov/tianjin/tjrcgzw.ts | 6 +- lib/routes/gov/wuhan/namespace.ts | 8 + lib/routes/gov/wuhan/whyw.ts | 4 +- lib/routes/gov/xinyi/namespace.ts | 8 + lib/routes/gov/xinyi/xinyi.ts | 17 +- lib/routes/gov/xuzhou/hrss.ts | 4 +- lib/routes/gov/xuzhou/namespace.ts | 8 + lib/routes/gov/zhejiang/gwy.ts | 4 +- lib/routes/gov/zhejiang/namespace.ts | 8 + lib/routes/gov/zhengce/govall.ts | 4 +- lib/routes/gov/zhengce/index.ts | 20 +- lib/routes/gov/zhengce/namespace.ts | 8 + lib/routes/gov/zhengce/wenjian.ts | 4 +- lib/routes/gov/zhengce/zhengceku.ts | 4 +- lib/routes/gov/zhengce/zuixin.ts | 18 + lib/routes/gov/zj/namespace.ts | 8 + lib/routes/gov/zj/ningbogzw-notice.ts | 4 +- lib/routes/gov/zj/ningborsjnotice.ts | 4 +- lib/routes/gov/zj/search.ts | 6 +- lib/routes/{cbirc => tqyb}/namespace.ts | 5 +- .../{gov/guangdong => }/tqyb/sncsyjxh.tsx | 4 +- lib/routes/{gov/guangdong => }/tqyb/tfxtq.tsx | 4 +- 200 files changed, 2344 insertions(+), 1072 deletions(-) delete mode 100644 lib/routes/cbirc/index.ts rename lib/routes/gov/{shenzhen/szlh => beijing}/namespace.ts (65%) create mode 100644 lib/routes/gov/caac/namespace.ts create mode 100644 lib/routes/gov/cac/namespace.ts delete mode 100644 lib/routes/gov/cbirc/index.ts create mode 100644 lib/routes/gov/ccdi/namespace.ts create mode 100644 lib/routes/gov/chinamine-safety/namespace.ts create mode 100644 lib/routes/gov/chinatax/namespace.ts create mode 100644 lib/routes/gov/chongqing/namespace.ts create mode 100644 lib/routes/gov/cmse/fxrw-category.ts create mode 100644 lib/routes/gov/cmse/gfgg.ts create mode 100644 lib/routes/gov/cmse/gjhz.ts create mode 100644 lib/routes/gov/cmse/hqsy.ts create mode 100644 lib/routes/gov/cmse/kjkx.ts create mode 100644 lib/routes/gov/cmse/kpjy.ts create mode 100644 lib/routes/gov/cmse/namespace.ts create mode 100644 lib/routes/gov/cmse/xwzx-yzjz.ts create mode 100644 lib/routes/gov/cmse/xwzx-zhxw.ts create mode 100644 lib/routes/gov/cmse/ztbd.ts create mode 100644 lib/routes/gov/cnnic/namespace.ts create mode 100644 lib/routes/gov/csrc/namespace.ts create mode 100644 lib/routes/gov/dianbai/namespace.ts create mode 100644 lib/routes/gov/forestry/namespace.ts create mode 100644 lib/routes/gov/gaozhou/namespace.ts create mode 100644 lib/routes/gov/gz/namespace.ts create mode 100644 lib/routes/gov/gz/xw.ts create mode 100644 lib/routes/gov/gz/zwgk.ts create mode 100644 lib/routes/gov/hebei/namespace.ts create mode 100644 lib/routes/gov/huazhou/namespace.ts create mode 100644 lib/routes/gov/huizhou/namespace.ts create mode 100644 lib/routes/gov/hunan/namespace.ts create mode 100644 lib/routes/gov/immiau/namespace.ts create mode 100644 lib/routes/gov/jgjcndrc/namespace.ts create mode 100644 lib/routes/gov/jiangsu/namespace.ts create mode 100644 lib/routes/gov/jinan/namespace.ts create mode 100644 lib/routes/gov/lswz/namespace.ts create mode 100644 lib/routes/gov/maoming/namespace.ts create mode 100644 lib/routes/gov/maonan/namespace.ts create mode 100644 lib/routes/gov/mee/namespace.ts create mode 100644 lib/routes/gov/mfa/namespace.ts create mode 100644 lib/routes/gov/mgs/namespace.ts create mode 100644 lib/routes/gov/miit/namespace.ts create mode 100644 lib/routes/gov/mmht/namespace.ts create mode 100644 lib/routes/gov/moa/namespace.ts create mode 100644 lib/routes/gov/moe/namespace.ts create mode 100644 lib/routes/gov/mof/namespace.ts create mode 100644 lib/routes/gov/mofcom/namespace.ts create mode 100644 lib/routes/gov/moj/namespace.ts create mode 100644 lib/routes/gov/mot/namespace.ts create mode 100644 lib/routes/gov/nfra/index.ts create mode 100644 lib/routes/gov/nfra/namespace.ts create mode 100644 lib/routes/gov/nifdc/namespace.ts create mode 100644 lib/routes/gov/nmpa/namespace.ts create mode 100644 lib/routes/gov/nopss/namespace.ts create mode 100644 lib/routes/gov/npc/namespace.ts create mode 100644 lib/routes/gov/nrta/namespace.ts create mode 100644 lib/routes/gov/nsfc/namespace.ts create mode 100644 lib/routes/gov/pudong/namespace.ts create mode 100644 lib/routes/gov/safe/namespace.ts create mode 100644 lib/routes/gov/samr/namespace.ts create mode 100644 lib/routes/gov/sasac/namespace.ts create mode 100644 lib/routes/gov/sdb/namespace.ts create mode 100644 lib/routes/gov/shaanxi/namespace.ts create mode 100644 lib/routes/gov/shenzhen/namespace.ts create mode 100644 lib/routes/gov/sichuan/namespace.ts create mode 100644 lib/routes/gov/stats/namespace.ts create mode 100644 lib/routes/gov/suzhou/namespace.ts create mode 100644 lib/routes/gov/taiyuan/namespace.ts create mode 100644 lib/routes/gov/tianjin/namespace.ts create mode 100644 lib/routes/gov/wuhan/namespace.ts create mode 100644 lib/routes/gov/xinyi/namespace.ts create mode 100644 lib/routes/gov/xuzhou/namespace.ts create mode 100644 lib/routes/gov/zhejiang/namespace.ts create mode 100644 lib/routes/gov/zhengce/namespace.ts create mode 100644 lib/routes/gov/zhengce/zuixin.ts create mode 100644 lib/routes/gov/zj/namespace.ts rename lib/routes/{cbirc => tqyb}/namespace.ts (55%) rename lib/routes/{gov/guangdong => }/tqyb/sncsyjxh.tsx (96%) rename lib/routes/{gov/guangdong => }/tqyb/tfxtq.tsx (94%) diff --git a/lib/api/index.ts b/lib/api/index.ts index 76ba26e49..9ff609b4b 100644 --- a/lib/api/index.ts +++ b/lib/api/index.ts @@ -5,7 +5,7 @@ import { Scalar } from '@scalar/hono-api-reference'; import { handler as categoryOneHandler, route as categoryOneRoute } from '@/api/category/one'; import { handler as followConfigHandler, route as followConfigRoute } from '@/api/follow/config'; import { handler as namespaceAllHandler, route as namespaceAllRoute } from '@/api/namespace/all'; -import { handler as namespaceOneHandler, route as namespaceOneRoute } from '@/api/namespace/one'; +import { handler as namespaceOneHandler, route as namespaceOneRoute, routeNested as namespaceOneNestedRoute } from '@/api/namespace/one'; import { handler as radarRulesAllHandler, route as radarRulesAllRoute } from '@/api/radar/rules/all'; import { handler as radarRulesOneHandler, route as radarRulesOneRoute } from '@/api/radar/rules/one'; import { handler as routeStatusHandler, route as routeStatusRoute } from '@/api/route/status'; @@ -14,6 +14,7 @@ const app = new OpenAPIHono(); app.openapi(namespaceAllRoute, namespaceAllHandler); app.openapi(namespaceOneRoute, namespaceOneHandler); +app.openapi(namespaceOneNestedRoute, namespaceOneHandler); app.openapi(radarRulesAllRoute, radarRulesAllHandler); app.openapi(radarRulesOneRoute, radarRulesOneHandler); app.openapi(categoryOneRoute, categoryOneHandler); diff --git a/lib/api/namespace.test.ts b/lib/api/namespace.test.ts index 960e87e1f..2a0f91900 100644 --- a/lib/api/namespace.test.ts +++ b/lib/api/namespace.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; +import api from '@/api'; import { handler as allHandler } from '@/api/namespace/all'; import { handler as oneHandler } from '@/api/namespace/one'; import { namespaces } from '@/registry'; @@ -13,6 +14,8 @@ const createCtx = (param: Record = {}) => }) as any; describe('api/namespace', () => { + const nestedKey = Object.keys(namespaces).find((key) => key.includes('/')) as string; + it('returns all namespaces', () => { const result = allHandler(createCtx()); expect(result).toBe(namespaces); @@ -22,4 +25,26 @@ describe('api/namespace', () => { const result = oneHandler(createCtx({ namespace: 'test' })); expect(result).toBe(namespaces.test); }); + + it('returns a nested namespace', () => { + expect(nestedKey).toBeDefined(); + const [namespace, sub] = nestedKey.split('/'); + const result = oneHandler(createCtx({ namespace, sub })); + expect(result).toBe(namespaces[nestedKey]); + }); + + it('serves a single namespace over HTTP', async () => { + expect(namespaces.github).toBeDefined(); + const response = await api.request('/namespace/github'); + expect(response.status).toBe(200); + expect(await response.json()).toEqual(namespaces.github); + }); + + it('serves a nested namespace over HTTP', async () => { + expect(nestedKey).toBeDefined(); + const response = await api.request(`/namespace/${nestedKey}`); + expect(response.status).toBe(200); + expect(await response.json()).toEqual(namespaces[nestedKey]); + }); + }); diff --git a/lib/api/namespace/one.ts b/lib/api/namespace/one.ts index d447e5805..9c9252a97 100644 --- a/lib/api/namespace/one.ts +++ b/lib/api/namespace/one.ts @@ -3,15 +3,18 @@ import { createRoute, z } from '@hono/zod-openapi'; import { namespaces } from '@/registry'; -const ParamsSchema = z.object({ - namespace: z.string().openapi({ +const pathParam = (name: string, example: string) => + z.string().openapi({ param: { - name: 'namespace', + name, in: 'path', }, - example: 'github', - }), -}); + example, + }); + +const nestedExample = Object.keys(namespaces) + .find((key) => key.includes('/')) + ?.split('/') ?? ['namespace', 'sub']; const route = createRoute({ method: 'get', @@ -19,7 +22,7 @@ const route = createRoute({ description: 'Information about a namespace', tags: ['Namespace'], request: { - params: ParamsSchema, + params: z.object({ namespace: pathParam('namespace', 'github') }), }, responses: { 200: { @@ -28,9 +31,24 @@ const route = createRoute({ }, }); +const routeNested = createRoute({ + method: 'get', + path: '/namespace/{namespace}/{sub}', + description: `Information about a nested namespace (e.g. ${nestedExample.join('/')})`, + tags: ['Namespace'], + request: { + params: z.object({ namespace: pathParam('namespace', nestedExample[0]), sub: pathParam('sub', nestedExample[1]) }), + }, + responses: { + 200: { + description: 'Namespace registry data for a nested namespace', + }, + }, +}); + const handler: RouteHandler = (ctx) => { - const { namespace } = ctx.req.valid('param'); - return ctx.json(namespaces[namespace]); + const { namespace, sub } = ctx.req.valid('param') as { namespace: string; sub?: string }; + return ctx.json(namespaces[[namespace, sub].filter(Boolean).join('/')]); }; -export { handler, route }; +export { handler, route, routeNested }; diff --git a/lib/registry.test.ts b/lib/registry.test.ts index dfbdde572..27d691911 100644 --- a/lib/registry.test.ts +++ b/lib/registry.test.ts @@ -2,6 +2,8 @@ import { describe, expect, it, vi } from 'vitest'; import app from '@/app'; import { config } from '@/config'; +import registryApp, { collectNamespaceRoots, namespaces, resolveModuleNamespace, sortRoutes } from '@/registry'; +import type { Route } from '@/types'; describe('registry', () => { // root @@ -68,3 +70,70 @@ describe('registry', () => { expect(namespaces['2048']).toBeDefined(); }); }); + +describe('namespace-resolution', () => { + const keys = [ + '/github/namespace.ts', + '/github/issue.ts', + '/example/sub/namespace.ts', + '/example/sub/news.ts', + '/example/flat/typical.ts', + '/example/nested/namespace.ts', + '/example/nested/zzb.ts', + '/example/nested/deep/namespace.ts', + '/example/nested/deep/zwfw.ts', + ]; + const roots = collectNamespaceRoots(keys); + + it('collects directories containing namespace.ts', () => { + expect(roots).toEqual(new Set(['github', 'example/sub', 'example/nested', 'example/nested/deep'])); + }); + + it('resolves a flat module to its top directory', () => { + expect(resolveModuleNamespace('/github/issue.ts', roots)).toEqual({ namespace: 'github', location: 'issue.ts' }); + }); + + it('resolves a nested module to its namespace root', () => { + expect(resolveModuleNamespace('/example/sub/news.ts', roots)).toEqual({ namespace: 'example/sub', location: 'news.ts' }); + }); + + it('prefers the deepest matching root', () => { + expect(resolveModuleNamespace('/example/nested/deep/zwfw.ts', roots)).toEqual({ namespace: 'example/nested/deep', location: 'zwfw.ts' }); + expect(resolveModuleNamespace('/example/nested/zzb.ts', roots)).toEqual({ namespace: 'example/nested', location: 'zzb.ts' }); + }); + + it('falls back to the first segment when no root matches', () => { + expect(resolveModuleNamespace('/example/flat/typical.ts', roots)).toEqual({ namespace: 'example', location: 'flat/typical.ts' }); + }); + + it('resolves namespace.ts itself to its own root', () => { + expect(resolveModuleNamespace('/example/sub/namespace.ts', roots)).toEqual({ namespace: 'example/sub', location: 'namespace.ts' }); + }); +}); + +describe('nested namespace mounting', () => { + it('registers deeper namespaces before shallower ones', () => { + const keys = Object.keys(namespaces).filter((key) => Object.keys(namespaces[key].routes ?? {}).length > 0); + const byDepth = keys.toSorted((a, b) => b.split('/').length - a.split('/').length); + const deep = byDepth[0]; + const shallow = byDepth.at(-1) as string; + expect(deep.split('/').length).toBeGreaterThan(shallow.split('/').length); + + const paths = registryApp.routes.map((r) => r.path); + const deepIndex = paths.indexOf(`/${deep}${Object.keys(namespaces[deep].routes)[0]}`); + const shallowIndex = paths.indexOf(`/${shallow}${Object.keys(namespaces[shallow].routes)[0]}`); + expect(deepIndex).toBeGreaterThanOrEqual(0); + expect(shallowIndex).toBeGreaterThanOrEqual(0); + expect(deepIndex).toBeLessThan(shallowIndex); + }); + + it('sorts regex-constrained params before plain params', () => { + const stub = {} as Route & { location: string }; + const sorted = sortRoutes({ + '/:category?': stub, + '/:id{[0-9]+}': stub, + '/static': stub, + }); + expect(sorted.map(([path]) => path)).toEqual(['/static', '/:id{[0-9]+}', '/:category?']); + }); +}); diff --git a/lib/registry.ts b/lib/registry.ts index e07ca28d3..07b3c98e7 100644 --- a/lib/registry.ts +++ b/lib/registry.ts @@ -17,6 +17,38 @@ import logger from '@/utils/logger'; const __dirname = import.meta.dirname; +const SEPARATOR = /[/\\]/; + +/** + * A directory under lib/routes that contains a `namespace.ts` is a "namespace root". Roots are keyed by their path + * relative to lib/routes, joined with `/` (e.g. `gov/cn`). + */ +export function collectNamespaceRoots(moduleKeys: string[]): Set { + const roots = new Set(); + for (const key of moduleKeys) { + const segments = key.split(SEPARATOR).filter(Boolean); + if (segments.at(-1) === 'namespace.ts') { + roots.add(segments.slice(0, -1).join('/')); + } + } + return roots; +} + +/** + * A module belongs to its longest matching namespace root; modules with no matching root fall back to their first + * path segment (flat namespaces). `location` is the module path relative to the resolved namespace root. + */ +export function resolveModuleNamespace(moduleKey: string, roots: Set): { namespace: string; location: string } { + const segments = moduleKey.split(SEPARATOR).filter(Boolean); + for (let i = segments.length - 1; i >= 1; i--) { + const candidate = segments.slice(0, i).join('/'); + if (roots.has(candidate)) { + return { namespace: candidate, location: segments.slice(i).join('/') }; + } + } + return { namespace: segments[0], location: segments.slice(1).join('/') }; +} + function isSafeRoutes(routes: RoutesType): boolean { return Object.values(routes).every((route: Route) => !route.features?.nsfw); } @@ -84,6 +116,7 @@ if (config.feature.disable_nsfw) { } if (Object.keys(modules).length) { + const namespaceRoots = collectNamespaceRoots(Object.keys(modules)); for (const module in modules) { const content = modules[module] as | { @@ -95,7 +128,7 @@ if (Object.keys(modules).length) { | { apiRoute: APIRoute; }; - const namespace = module.split(/[/\\]/, 2)[1]; + const { namespace, location } = resolveModuleNamespace(module, namespaceRoots); if ('namespace' in content) { namespaces[namespace] = Object.assign( { @@ -117,13 +150,13 @@ if (Object.keys(modules).length) { for (const path of content.route.path) { namespaces[namespace].routes[path] = { ...content.route, - location: module.split(/[/\\]/).slice(2).join('/'), + location, }; } } else { namespaces[namespace].routes[content.route.path] = { ...content.route, - location: module.split(/[/\\]/).slice(2).join('/'), + location, }; } } else if ('apiRoute' in content) { @@ -138,13 +171,13 @@ if (Object.keys(modules).length) { for (const path of content.apiRoute.path) { namespaces[namespace].apiRoutes[path] = { ...content.apiRoute, - location: module.split(/[/\\]/).slice(2).join('/'), + location, }; } } else { namespaces[namespace].apiRoutes[content.apiRoute.path] = { ...content.apiRoute, - location: module.split(/[/\\]/).slice(2).join('/'), + location, }; } } @@ -154,7 +187,7 @@ if (Object.keys(modules).length) { export { namespaces }; const app = new Hono(); -const sortRoutes = ( +export const sortRoutes = ( routes: Record< string, Route & { @@ -178,12 +211,20 @@ const sortRoutes = ( if (segmentA.startsWith(':') !== segmentB.startsWith(':')) { return segmentA.startsWith(':') ? 1 : -1; } + + // Regex-constrained parameters have priority over plain parameters + if (segmentA.startsWith(':') && segmentA.includes('{') !== segmentB.includes('{')) { + return segmentA.includes('{') ? -1 : 1; + } } return 0; }); -for (const namespace in namespaces) { +// Deeper namespaces register first so a parent's param routes cannot shadow them +const namespacesByDepth = Object.keys(namespaces).toSorted((a, b) => b.split('/').length - a.split('/').length); + +for (const namespace of namespacesByDepth) { const subApp = app.basePath(`/${namespace}`); const namespaceData = namespaces[namespace]; @@ -217,7 +258,7 @@ for (const namespace in namespaces) { } } -for (const namespace in namespaces) { +for (const namespace of namespacesByDepth) { const subApp = app.basePath(`/api/${namespace}`); const namespaceData = namespaces[namespace]; diff --git a/lib/routes/cbirc/index.ts b/lib/routes/cbirc/index.ts deleted file mode 100644 index 1f6d8e3bd..000000000 --- a/lib/routes/cbirc/index.ts +++ /dev/null @@ -1,133 +0,0 @@ -import type { Route } from '@/types'; -import cache from '@/utils/cache'; -import got from '@/utils/got'; - -const categories = { - jgdt: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '监管动态', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=915,pageIndex=1,pageSize=18.json', - title: '监管动态', - }, - ggtz: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '公告通知', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=925,pageIndex=1,pageSize=18.json', - title: '公告通知', - }, - zcfg: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '政策法规', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=926,pageIndex=1,pageSize=18.json', - title: '政策法规', - }, - zcjd: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '政策解读', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=916,pageIndex=1,pageSize=18.json', - title: '政策解读', - }, - zqyj: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '征求意见', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=951,pageIndex=1,pageSize=18.json', - title: '征求意见', - }, - xzxk: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '行政许可', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=930,pageIndex=1,pageSize=18.json', - title: '行政许可', - }, - xzcf: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '行政处罚', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=931,pageIndex=1,pageSize=18.json', - title: '行政处罚', - }, - xzjgcs: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '行政监管措施', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=932,pageIndex=1,pageSize=18.json', - title: '行政监管措施', - }, - gzlw: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '工作论文', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=934,pageIndex=1,pageSize=18.json', - title: '工作论文', - }, - jrzgyj: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '金融监管研究', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=935,pageIndex=1,pageSize=18.json', - title: '金融监管研究', - }, - tjxx: { - baseUrl: 'http://www.cbirc.gov.cn', - description: '统计信息', - link: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=954,pageIndex=1,pageSize=18.json', - title: '统计信息', - }, -}; - -async function getContent(item) { - const response = await got({ - method: 'get', - url: 'http://www.cbirc.gov.cn/cn/static/data/DocInfo/SelectByDocId/data_docId=' + item.docId + '.json', - }); - return response.data.data.docClob; -} - -export const route: Route = { - path: '/:category?', - radar: [ - { - source: ['cbirc.gov.cn/:category', 'cbirc.gov.cn/'], - }, - ], - name: 'Unknown', - maintainers: ['JkCheung'], - handler, -}; - -async function handler(ctx) { - const category = ctx.req.param('category') ?? 'ggtz'; - const cat = categories[category]; - - // 请求集合 - const response = await cache.tryGet(cat.link, async () => { - const resp = await got({ - method: 'get', - url: cat.link, - headers: { - Referer: 'http://www.cbirc.gov.cn', - }, - }); - return resp.data; - }); - - // 遍历数据集合 - const dataLs = await Promise.all( - response.data.rows.map(async (item) => { - const content = await getContent(item); - return { - title: item.docTitle, - // 文章正文 - description: content, - // 文章发布时间 - pubDate: item.publishDate, - // 文章链接 - link: `http://www.cbirc.gov.cn/cn/view/pages/ItemDetail.html?docId=${item.docId}&itemId=925&generaltype=0`, - }; - }) - ); - - return { - title: `中国银保监会-${cat.title}`, - link: cat.link, - description: `中国银保监会-${cat.title}`, - item: dataLs, - language: 'zh-CN', - }; -} diff --git a/lib/routes/gov/ah/kjt.ts b/lib/routes/gov/ah/kjt.ts index 5e816a91c..49df0e9e9 100644 --- a/lib/routes/gov/ah/kjt.ts +++ b/lib/routes/gov/ah/kjt.ts @@ -87,8 +87,8 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: '/ah/kjt/:category{.+}?', - name: '安徽省科学技术厅', + path: '/kjt/:category{.+}?', + name: '科学技术厅', url: 'kjt.ah.gov.cn', maintainers: ['nczitzk'], handler, @@ -146,82 +146,82 @@ export const route: Route = { { title: '科技资讯 - 通知公告', source: ['kjt.ah.gov.cn/kjzx/tzgg/index.html'], - target: '/ah/kjt/kjzx/tzgg', + target: '/kjt/kjzx/tzgg', }, { title: '科技资讯 - 工作动态', source: ['kjt.ah.gov.cn/kjzx/gzdt/index.html'], - target: '/ah/kjt/kjzx/gzdt', + target: '/kjt/kjzx/gzdt', }, { title: '科技资讯 - 基层科技', source: ['kjt.ah.gov.cn/kjzx/jckj/index.html'], - target: '/ah/kjt/kjzx/jckj', + target: '/kjt/kjzx/jckj', }, { title: '科技资讯 - 媒体聚焦', source: ['kjt.ah.gov.cn/kjzx/mtjj/index.html'], - target: '/ah/kjt/kjzx/mtjj', + target: '/kjt/kjzx/mtjj', }, { title: '科技资讯 - 重要转载', source: ['kjt.ah.gov.cn/kjzx/zyzz/index.html'], - target: '/ah/kjt/kjzx/zyzz', + target: '/kjt/kjzx/zyzz', }, { title: '科技资讯 - 图片视频', source: ['kjt.ah.gov.cn/kjzx/tpsp/index.html'], - target: '/ah/kjt/kjzx/tpsp', + target: '/kjt/kjzx/tpsp', }, { title: '科技统计 - 技术市场交易', source: ['kjt.ah.gov.cn/kjzy/kjtj/jsscjy/index.html'], - target: '/ah/kjt/kjzy/kjtj/jsscjy', + target: '/kjt/kjzy/kjtj/jsscjy', }, { title: '科技统计 - 科技成果公报', source: ['kjt.ah.gov.cn/kjzy/kjtj/kjcggb/index.html'], - target: '/ah/kjt/kjzy/kjtj/kjcggb', + target: '/kjt/kjzy/kjtj/kjcggb', }, { title: '科技统计 - 孵化载体发展', source: ['kjt.ah.gov.cn/kjzy/kjtj/cyfhfz/index.html'], - target: '/ah/kjt/kjzy/kjtj/cyfhfz', + target: '/kjt/kjzy/kjtj/cyfhfz', }, { title: '科技数据 - 创新企业', source: ['kjt.ah.gov.cn/kjzy/kjsj/cxqy/index.html'], - target: '/ah/kjt/kjzy/kjsj/cxqy', + target: '/kjt/kjzy/kjsj/cxqy', }, { title: '科技数据 - 创新项目', source: ['kjt.ah.gov.cn/kjzy/kjsj/cxxm/index.html'], - target: '/ah/kjt/kjzy/kjsj/cxxm', + target: '/kjt/kjzy/kjsj/cxxm', }, { title: '科技数据 - 创新成果', source: ['kjt.ah.gov.cn/kjzy/kjsj/cxcg/index.html'], - target: '/ah/kjt/kjzy/kjsj/cxcg', + target: '/kjt/kjzy/kjsj/cxcg', }, { title: '科技数据 - 转化基金入库项目', source: ['kjt.ah.gov.cn/kjzy/kjsj/zhjjrkxm/index.html'], - target: '/ah/kjt/kjzy/kjsj/zhjjrkxm', + target: '/kjt/kjzy/kjsj/zhjjrkxm', }, { title: '科技数据 - 创新平台', source: ['kjt.ah.gov.cn/kjzy/kjsj/cxpt/index.html'], - target: '/ah/kjt/kjzy/kjsj/cxpt', + target: '/kjt/kjzy/kjsj/cxpt', }, { title: '科技数据 - 创新园区', source: ['kjt.ah.gov.cn/kjzy/kjsj/cxyq/index.html'], - target: '/ah/kjt/kjzy/kjsj/cxyq', + target: '/kjt/kjzy/kjsj/cxyq', }, { title: '科技数据 - 创新许可', source: ['kjt.ah.gov.cn/kjzy/kjsj/cxxk/index.html'], - target: '/ah/kjt/kjzy/kjsj/cxxk', + target: '/kjt/kjzy/kjsj/cxxk', }, ], }; diff --git a/lib/routes/gov/beijing/bjedu/gh.ts b/lib/routes/gov/beijing/bjedu/gh.ts index 3b7ec61d7..9ef7e6970 100644 --- a/lib/routes/gov/beijing/bjedu/gh.ts +++ b/lib/routes/gov/beijing/bjedu/gh.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/beijing/bjedu/gh/:urlPath?', + path: '/bjedu/gh/:urlPath?', categories: ['government'], example: '/gov/beijing/bjedu/gh', parameters: { urlPath: '路径,默认为 `zxtzgg`' }, @@ -22,10 +22,10 @@ export const route: Route = { radar: [ { source: ['gh.bjedu.gov.cn/ghsite/:urlPath/index.html', 'gh.bjedu.gov.cn/ghsite/:urlPath'], - target: '/beijing/bjedu/gh/:urlPath', + target: '/bjedu/gh/:urlPath', }, ], - name: '通用', + name: '教育委员会 - 通用', maintainers: ['TonyRL'], handler, description: `::: tip @@ -39,7 +39,8 @@ async function handler(ctx) { const baseUrl = 'https://gh.bjedu.cn'; const { urlPath = 'zxtzgg' } = ctx.req.param(); - const { data: response, url: link } = await got(`${baseUrl}/ghsite/${urlPath}/index.html`); + const currentUrl = `${baseUrl}/ghsite/${urlPath}/index.html`; + const { data: response, url: link = currentUrl } = await got(currentUrl); const $ = load(response); const list = $('.content li a') diff --git a/lib/routes/gov/beijing/bphc/index.ts b/lib/routes/gov/beijing/bphc/index.ts index 320711d55..f0f717127 100644 --- a/lib/routes/gov/beijing/bphc/index.ts +++ b/lib/routes/gov/beijing/bphc/index.ts @@ -1,6 +1,5 @@ import type { Route } from '@/types'; import cache from '@/utils/cache'; -import { getSubPath } from '@/utils/common-utils'; import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; @@ -8,32 +7,35 @@ import timezone from '@/utils/timezone'; const mapping = { '/project': { title: '项目介绍', - list: '/front/index/project/page', + list: '/front/index/project/page?size=10¤t=1&simpleName=&areaId=', detail: '/front/index/project', link: '/#/communityDetail?id=', }, '/announcement': { title: '通知公告', - list: '/front/announcement/page', - detail: '/front/announcement/', + list: '/front/announcement/page?current=1&size=10', + detail: '/front/announcement', link: '/#/announcementList/detail?id=', }, }; export const route: Route = { - path: '/beijing/bphc/*', - name: 'Unknown', - maintainers: [], + path: '/bphc/:caty', + name: '保障房中心 - 共有产权住房租赁服务平台', + example: '/gov/beijing/bphc/announcement', + parameters: { caty: '类别' }, + maintainers: ['bigfei'], handler, + description: `| 通知公告 | 项目介绍 | +| :----------: | :------: | +| announcement | project |`, }; async function handler(ctx) { const rootUrl = 'https://gycpt.bphc.com.cn'; - const defaultPath = 'announcement'; - const pathname = getSubPath(ctx).replaceAll(/(^\/beijing\/bphc|\/$)/g, ''); - const key = pathname === '' ? defaultPath : pathname.endsWith('/') ? pathname.slice(0, -1) : pathname; - const obj = mapping[key]; + const { caty = 'announcement' } = ctx.req.param(); + const obj = mapping[`/${caty}`]; const currentUrl = `${rootUrl}${obj.list}`; const listResp = await ofetch(currentUrl); diff --git a/lib/routes/gov/beijing/jw/tzgg.ts b/lib/routes/gov/beijing/jw/tzgg.ts index dfd3053b6..754c36532 100644 --- a/lib/routes/gov/beijing/jw/tzgg.ts +++ b/lib/routes/gov/beijing/jw/tzgg.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/beijing/jw/tzgg', + path: '/jw/tzgg', categories: ['government'], example: '/gov/beijing/jw/tzgg', parameters: {}, diff --git a/lib/routes/gov/beijing/kw/index.ts b/lib/routes/gov/beijing/kw/index.ts index e1e06e6c5..09842b723 100644 --- a/lib/routes/gov/beijing/kw/index.ts +++ b/lib/routes/gov/beijing/kw/index.ts @@ -8,10 +8,20 @@ import { parseDate } from '@/utils/parse-date'; const rootUrl = 'http://kw.beijing.gov.cn'; export const route: Route = { - path: '/beijing/kw/:channel', - name: 'Unknown', + path: '/kw/:channel', + name: '北京市科学技术委员会、中关村科技园区管理委员会', + example: '/gov/beijing/kw/col736', + parameters: { channel: '频道' }, + radar: [ + { + source: ['kw.beijing.gov.cn/col/:channel/index.html'], + }, + ], maintainers: ['Fatpandac'], handler, + description: `频道参数可在官网获取,如: + +\`http://kw.beijing.gov.cn/col/col736/index.html\` 对应 \`/gov/beijing/kw/col736\``, }; async function handler(ctx) { diff --git a/lib/routes/gov/shenzhen/szlh/namespace.ts b/lib/routes/gov/beijing/namespace.ts similarity index 65% rename from lib/routes/gov/shenzhen/szlh/namespace.ts rename to lib/routes/gov/beijing/namespace.ts index 4fd24412f..a731e7fd5 100644 --- a/lib/routes/gov/shenzhen/szlh/namespace.ts +++ b/lib/routes/gov/beijing/namespace.ts @@ -1,8 +1,8 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { - name: '深圳市罗湖区人民政府', - url: 'www.szlh.gov.cn', + name: '北京市人民政府', + url: 'www.beijing.gov.cn', categories: ['government'], lang: 'zh-CN', }; diff --git a/lib/routes/gov/caac/cjwt.tsx b/lib/routes/gov/caac/cjwt.tsx index f06636429..7b384bf11 100644 --- a/lib/routes/gov/caac/cjwt.tsx +++ b/lib/routes/gov/caac/cjwt.tsx @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/caac/cjwt/:category?', + path: '/cjwt/:category?', categories: ['government'], example: '/gov/caac/cjwt', parameters: { category: '分类,见下表,默认为全部' }, @@ -22,7 +22,7 @@ export const route: Route = { radar: [ { source: ['caac.gov.cn/HDJL/'], - target: '/caac/cjwt', + target: '/cjwt', }, ], name: '公众留言', diff --git a/lib/routes/gov/caac/namespace.ts b/lib/routes/gov/caac/namespace.ts new file mode 100644 index 000000000..03ddf5738 --- /dev/null +++ b/lib/routes/gov/caac/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中国民用航空局', + url: 'www.caac.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/cac/index.ts b/lib/routes/gov/cac/index.ts index 5ce00fb02..a86a4c596 100644 --- a/lib/routes/gov/cac/index.ts +++ b/lib/routes/gov/cac/index.ts @@ -8,18 +8,28 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/cac/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/cac/wxzw/xxh', + parameters: { path: '路径,比如xxh表示信息化' }, + maintainers: ['drgnchan'], handler, + description: `::: tip + +路径填写对应页面 URL 中间部分。例如: + +首页 > 网信政务 > 网信发布: +此时,path 参数为:/wxzw/wxfb + +:::`, }; async function handler(ctx) { - const path = ctx.params[0]; - const host = 'http://www.cac.gov.cn'; + const path = `/${ctx.req.param('path')}`; + const host = 'https://www.cac.gov.cn'; const homepage = `${host}/index.htm`; - // 在首页查找出所有的目录完整路径,比如http://www.cac.gov.cn/xxh/A0906index_1.htm - // xxh --> {"path": "/xxh", "completeUrl": "http://www.cac.gov.cn/xxh/A0906index_1.htm"} + // 在首页查找出所有的目录完整路径,比如https://www.cac.gov.cn/wxzw/xxh/A093706index_1.htm + // xxh --> {"path": "/xxh", "completeUrl": "https://www.cac.gov.cn/wxzw/xxh/A093706index_1.htm"} const pathList = await cache.tryGet( 'gov:cac:pathList', async () => { @@ -48,7 +58,7 @@ async function handler(ctx) { false ); - const completeUrl = pathList.find((item) => item && item.path === path).completeUrl; + const completeUrl = pathList.find((item) => item && item.path === path)?.completeUrl; const { data: channelResponse } = await got(completeUrl); const $1 = load(channelResponse); const items = $1('div#loadingInfoPage li') diff --git a/lib/routes/gov/cac/namespace.ts b/lib/routes/gov/cac/namespace.ts new file mode 100644 index 000000000..5e34b47f5 --- /dev/null +++ b/lib/routes/gov/cac/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家互联网信息办公室', + url: 'www.cac.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/cbirc/index.ts b/lib/routes/gov/cbirc/index.ts deleted file mode 100644 index a58d9bde7..000000000 --- a/lib/routes/gov/cbirc/index.ts +++ /dev/null @@ -1,371 +0,0 @@ -import { load } from 'cheerio'; - -import type { Route } from '@/types'; -import cache from '@/utils/cache'; -import ofetch from '@/utils/ofetch'; -import { parseDate } from '@/utils/parse-date'; -import timezone from '@/utils/timezone'; - -export const handler = async (ctx) => { - const { id = '915' } = ctx.req.param(); - const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 18; - - const rootUrl = 'https://www.nfra.gov.cn'; - const apiUrl = new URL(`cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=${id},pageIndex=1,pageSize=18.json`, rootUrl).href; - const apiBreadUrl = new URL(`cn/static/data/item/getItemBread/data_itemId=${id}.json`, rootUrl).href; - - const breadResponse = await ofetch(apiBreadUrl); - - const item = breadResponse.data.find((b) => String(b.itemId) === id); - - const currentUrl = new URL(`cn/view/pages/ItemList.html?itemPId=${item.itemPid}&itemId=${id}&itemUrl=ItemListRightList.html`, rootUrl).href; - - const response = await ofetch(apiUrl); - - let items = response.data.rows.slice(0, limit).map((item) => { - const title = item.docTitle; - const description = item.docSubtitle; - const guid = item.docId; - - return { - title, - description, - pubDate: timezone(parseDate(item.publishDate), +8), - link: new URL(`cn/view/pages/ItemDetail.html?docId=${guid}`, rootUrl).href, - guid, - id: guid, - content: { - html: description, - text: description, - }, - enclosure_url: new URL(item.pdfFileUrl, rootUrl).href, - enclosure_type: 'application/pdf', - enclosure_title: title, - }; - }); - - items = await Promise.all( - items.map((item) => - cache.tryGet(item.link, async () => { - const apiDocUrl = new URL(`cn/static/data/DocInfo/SelectByDocId/data_docId=${item.guid}.json`, rootUrl).href; - - const detailResponse = await ofetch(apiDocUrl); - - const data = detailResponse.data; - - const $$ = load(data.docClob); - - const title = data.docTitle; - const description = $$('div.Section0').html(); - - item.title = title; - item.description = description; - item.pubDate = timezone(parseDate(data.publishDate), +8); - item.category = data.listTwoItem?.[0]?.ItemLvs.map((c) => c.itemName); - item.author = data.docSource; - item.guid = `cbirc-${item.guid}`; - item.id = item.guid; - item.content = { - html: description, - text: $$('div.Section0').text(), - }; - item.updated = parseDate(data.docEditdate); - item.language = $$('html').prop('lang') || ''; - - return item; - }) - ) - ); - - const currentResponse = await ofetch(currentUrl); - - const $ = load(currentResponse); - - $('a.lyxd').remove(); - - const language = $('html').prop('lang') || ''; - - const imageSrc = $('div.header-left img').prop('src'); - const image = imageSrc ? new URL(imageSrc, rootUrl).href : ''; - - return { - title: `${$('title').text()} - ${item.itemName}`, - description: item.desc, - link: currentUrl, - item: items, - allowEmpty: true, - image, - author: item.type, - language, - }; -}; - -export const route: Route = { - path: '/cbirc/:id?', - name: '分类', - url: 'www.cbirc.gov.cn', - maintainers: ['nczitzk'], - handler, - example: '/gov/cbirc/:id?', - parameters: { category: '分类,默认为监管动态,即 915,可在对应分类页 URL 中找到' }, - description: `::: tip -若订阅 [监管动态](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemId=915\\&itemUrl=ItemListRightList.html),网址为 \`https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemId=915&itemUrl=ItemListRightList.html\`。截取 \`itemId\` 的值 \`915\` 作为参数填入,此时路由为 [\`/gov/cbirc/915\`](https://rsshub.app/gov/cbirc/915)。 -::: - -#### [首页](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=899\\&itemId=971\\&itemUrl=ItemListRightMore.html) - -| [弹出公告](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=971\\&itemId=972\\&itemUrl=sss) | [法律声明](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=971\\&itemId=4128\\&itemUrl=ItemListRightArticle.html) | -| ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| [972](https://rsshub.app/gov/cbirc/972) | [4128](https://rsshub.app/gov/cbirc/4128) | - -#### [机构概况](https://www.cbirc.gov.cn/cn/view/pages/jigougaikuang/jigougaikuang.html) - -| [主要职责](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=901\\&itemUrl=ItemListRightArticle.html) | [总局领导](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=902\\&itemUrl=jigougaikuang/huilingdao.html) | [内设机构](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=911\\&itemUrl=jigougaikuang/neishejigou.html) | [直属行政机构](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=4243\\&itemUrl=jigougaikuang/zhishuxingzhengjigou.html) | [派出机构](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=912\\&itemUrl=jigougaikuang/paichujigou.html) | -| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| [901](https://rsshub.app/gov/cbirc/901) | [902](https://rsshub.app/gov/cbirc/902) | [911](https://rsshub.app/gov/cbirc/911) | [4243](https://rsshub.app/gov/cbirc/4243) | [912](https://rsshub.app/gov/cbirc/912) | - -| [联系方式](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=913\\&itemUrl=jigougaikuang/lianxifangshi.html) | -| ---------------------------------------------------------------------------------------------------------------------------------- | -| [913](https://rsshub.app/gov/cbirc/913) | - -#### [新闻资讯](https://www.cbirc.gov.cn/cn/view/pages/xinwenzixun/xinwenzixun.html) - -| [监管动态](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=915\\&itemUrl=ItemListRightList.html) | [政策解读](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=916\\&itemUrl=ItemListRightMore.html) | [领导活动及讲话](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=919\\&itemUrl=ItemListRightList.html) | [新闻发布会及访谈](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=920\\&itemUrl=xinwenzixun/xinwenfabu.html) | [新闻发言人](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=921\\&itemUrl=xinwenzixun/xinwenfayan.html) | -| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| [915](https://rsshub.app/gov/cbirc/915) | [916](https://rsshub.app/gov/cbirc/916) | [919](https://rsshub.app/gov/cbirc/919) | [920](https://rsshub.app/gov/cbirc/920) | [921](https://rsshub.app/gov/cbirc/921) | - -#### [政务信息](https://www.cbirc.gov.cn/cn/view/pages/zhengwuxinxi/zhengwuxinxi.html) - -| [政府信息公开](https://www.cbirc.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html) | [公告通知](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=925\\&itemUrl=ItemListRightList.html) | [政策法规](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=926\\&itemUrl=ItemListRightMore.html) | [行政许可](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=930\\&itemUrl=zhengwuxinxi/xingzhengxuke.html) | [行政处罚](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=931\\&itemUrl=zhengwuxinxi/xingzhengchufa.html) | -| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| [924](https://rsshub.app/gov/cbirc/924) | [925](https://rsshub.app/gov/cbirc/925) | [926](https://rsshub.app/gov/cbirc/926) | [930](https://rsshub.app/gov/cbirc/930) | [931](https://rsshub.app/gov/cbirc/931) | - -| [行政监管措施](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=932\\&itemUrl=ItemListRightList.html) | [人事信息](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=933\\&itemUrl=ItemListRightList.html) | -| ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| [932](https://rsshub.app/gov/cbirc/932) | [933](https://rsshub.app/gov/cbirc/933) | - -#### [在线服务](https://www.cbirc.gov.cn/cn/view/pages/zaixianfuwu/zaixianfuwu.html) - -| [行政许可办事服务指南](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=937\\&itemId=938\\&itemUrl=zaixianfuwu/banshifuwu.html) | [查询服务](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=937\\&itemId=939\\&itemUrl=zaixianfuwu/chaxunfuwu.html) | -| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| [938](https://rsshub.app/gov/cbirc/938) | [939](https://rsshub.app/gov/cbirc/939) | - -#### [互动交流](https://www.cbirc.gov.cn/cn/view/pages/hudongjiaoliu/hudongjiaoliu.html) - -| [政务咨询](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=945\\&itemId=946\\&itemUrl=tosubmenu:hudongjiaoliu/woyaozixun.html) | [征集调查](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=945\\&itemId=950\\&itemUrl=ItemListRightMore.html) | [国务院办公厅开通 "国家政务服务投诉与建议" 小程序](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=945\\&itemId=952\\&itemUrl=http://www.gov.cn/xinwen/2018-09/20/content_5323786.htm) | -| ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [946](https://rsshub.app/gov/cbirc/946) | [950](https://rsshub.app/gov/cbirc/950) | [952](https://rsshub.app/gov/cbirc/952) | - -#### [统计数据](https://www.cbirc.gov.cn/cn/view/pages/tongjishuju/tongjishuju.html) - -| [统计信息](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=953\\&itemId=954\\&itemUrl=ItemListRightList.html) | [数据图表](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=953\\&itemId=955\\&itemUrl=tosubmenu:tongjishuju/zongzichan.html) | -| ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- | -| [954](https://rsshub.app/gov/cbirc/954) | [955](https://rsshub.app/gov/cbirc/955) | - -#### [专题专栏](https://www.cbirc.gov.cn/cn/view/pages/zhuantizhuanlan/zhuantizhuanlan.html) - -| [推进普惠金融高质量发展](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4234\\&itemUrl=ItemListRightMore.html) | [防范和处置非法集资](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=963\\&itemUrl=ItemListRightMore.html) | [消费者保护](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4097\\&itemUrl=ItemListRightMore.html) | [法治宣传](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4106\\&itemUrl=ItemListRightMore.html) | [政府网站年度报表](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=970\\&itemUrl=ItemListRightList.html) | -| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| [4234](https://rsshub.app/gov/cbirc/4234) | [963](https://rsshub.app/gov/cbirc/963) | [4097](https://rsshub.app/gov/cbirc/4097) | [4106](https://rsshub.app/gov/cbirc/4106) | [970](https://rsshub.app/gov/cbirc/970) | - -| [服务民营企业](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4171\\&itemUrl=ItemListRightList.html) | [服务制造业发展](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4217\\&itemUrl=ItemListRightList.html) | [学习贯彻习近平新时代中国特色社会主义思想主题教育](https://www.cbirc.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4229\\&itemUrl=ItemListRightMore.html) | -| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [4171](https://rsshub.app/gov/cbirc/4171) | [4217](https://rsshub.app/gov/cbirc/4217) | [4229](https://rsshub.app/gov/cbirc/4229) |`, - categories: ['government'], - - features: { - requireConfig: false, - requirePuppeteer: false, - antiCrawler: false, - supportRadar: true, - supportBT: false, - supportPodcast: false, - supportScihub: false, - }, - radar: [ - { - source: ['www.cbirc.gov.cn/:id?'], - target: (_, url) => { - const urlObj = new URL(url.toString()); - const id = urlObj.searchParams.get('itemId'); - - return `/gov/cbirc${id ? `/${id}` : ''}`; - }, - }, - { - title: '首页 - 弹出公告', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/972', - }, - { - title: '首页 - 法律声明', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4128', - }, - { - title: '机构概况 - 主要职责', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/901', - }, - { - title: '机构概况 - 总局领导', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/902', - }, - { - title: '机构概况 - 内设机构', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/911', - }, - { - title: '机构概况 - 直属行政机构', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4243', - }, - { - title: '机构概况 - 派出机构', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/912', - }, - { - title: '机构概况 - 联系方式', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/913', - }, - { - title: '新闻资讯 - 监管动态', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/915', - }, - { - title: '新闻资讯 - 政策解读', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/916', - }, - { - title: '新闻资讯 - 领导活动及讲话', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/919', - }, - { - title: '新闻资讯 - 新闻发布会及访谈', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/920', - }, - { - title: '新闻资讯 - 新闻发言人', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/921', - }, - { - title: '政务信息 - 政府信息公开', - source: ['www.cbirc.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html'], - target: '/cbirc/924', - }, - { - title: '政务信息 - 公告通知', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/925', - }, - { - title: '政务信息 - 政策法规', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/926', - }, - { - title: '政务信息 - 行政许可', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/930', - }, - { - title: '政务信息 - 行政处罚', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/931', - }, - { - title: '政务信息 - 行政监管措施', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/932', - }, - { - title: '政务信息 - 人事信息', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/933', - }, - { - title: '在线服务 - 行政许可办事服务指南', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/938', - }, - { - title: '在线服务 - 查询服务', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/939', - }, - { - title: '互动交流 - 政务咨询', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/946', - }, - { - title: '互动交流 - 征集调查', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/950', - }, - { - title: '互动交流 - 国务院办公厅开通"国家政务服务投诉与建议"小程序', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/952', - }, - { - title: '统计数据 - 统计信息', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/954', - }, - { - title: '统计数据 - 数据图表', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/955', - }, - { - title: '专题专栏 - 推进普惠金融高质量发展', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4234', - }, - { - title: '专题专栏 - 防范和处置非法集资', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/963', - }, - { - title: '专题专栏 - 消费者保护', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4097', - }, - { - title: '专题专栏 - 法治宣传', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4106', - }, - { - title: '专题专栏 - 政府网站年度报表', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/970', - }, - { - title: '专题专栏 - 服务民营企业', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4171', - }, - { - title: '专题专栏 - 服务制造业发展', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4217', - }, - { - title: '专题专栏 - 学习贯彻习近平新时代中国特色社会主义思想主题教育', - source: ['www.cbirc.gov.cn/cn/view/pages/ItemList.html'], - target: '/cbirc/4229', - }, - ], -}; diff --git a/lib/routes/gov/ccdi/index.ts b/lib/routes/gov/ccdi/index.ts index 9c1f5d7d8..11e496e4c 100644 --- a/lib/routes/gov/ccdi/index.ts +++ b/lib/routes/gov/ccdi/index.ts @@ -1,20 +1,35 @@ import type { Route } from '@/types'; -import { getSubPath } from '@/utils/common-utils'; import { parseArticle, parseNewsList, rootUrl } from './utils'; export const route: Route = { - path: '/ccdi/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}?', + name: '要闻', + example: '/gov/ccdi/yaowenn', + parameters: { path: '路径,默认为 要闻' }, + radar: [ + { + source: ['www.ccdi.gov.cn/*path'], + target: '/:path', + }, + ], + features: { + antiCrawler: true, + }, + maintainers: ['bigfei'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`http://www.ccdi.gov.cn/\` 后的字段。下面是一个例子。 + +若订阅 [审查调查 > 中管干部 > 执纪审查](https://www.ccdi.gov.cn/scdcn/zggb/zjsc/) 则将对应页面 URL 中 \`http://www.ccdi.gov.cn/\` 后的字段 \`scdcn/zggb/zjsc\` 作为路径填入。此时路由为 [\`/gov/ccdi/scdcn/zggb/zjsc\`](https://rsshub.app/gov/ccdi/scdcn/zggb/zjsc) + +:::`, }; async function handler(ctx) { - const defaultPath = '/yaowenn/'; - - let pathname = getSubPath(ctx).replaceAll(/(^\/ccdi|\/$)/g, ''); - pathname = pathname === '' ? defaultPath : pathname.endsWith('/') ? pathname : pathname + '/'; + const { path = 'yaowenn' } = ctx.req.param(); + const pathname = `/${path}${path.endsWith('/') ? '' : '/'}`; const currentUrl = `${rootUrl}${pathname}`; const { list, title } = await parseNewsList(currentUrl, '.list_news_dl2 li', ctx); diff --git a/lib/routes/gov/ccdi/namespace.ts b/lib/routes/gov/ccdi/namespace.ts new file mode 100644 index 000000000..7a5af7def --- /dev/null +++ b/lib/routes/gov/ccdi/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中央纪委国家监委', + url: 'www.ccdi.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/chinamine-safety/namespace.ts b/lib/routes/gov/chinamine-safety/namespace.ts new file mode 100644 index 000000000..20673afe9 --- /dev/null +++ b/lib/routes/gov/chinamine-safety/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家矿山安全监察局', + url: 'www.chinamine-safety.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/chinamine-safety/xw.ts b/lib/routes/gov/chinamine-safety/xw.ts index becd3ff8c..fc856f667 100644 --- a/lib/routes/gov/chinamine-safety/xw.ts +++ b/lib/routes/gov/chinamine-safety/xw.ts @@ -9,10 +9,52 @@ import timezone from '@/utils/timezone'; import { fetchData, processItems, rootUrl } from './util'; export const route: Route = { - path: '/chinamine-safety/xw/:category{.+}?', - name: 'Unknown', - maintainers: [], + path: '/xw/:category{.+}?', + name: '新闻', + example: '/gov/chinamine-safety/xw', + parameters: { category: '分类,见下表,默认为应急管理部要闻' }, + radar: [ + { + title: '应急管理部要闻', + source: ['www.chinamine-safety.gov.cn/xw/yjglbyw/'], + target: '/xw/yjglbyw', + }, + { + title: '国家矿山安监局要闻', + source: ['www.chinamine-safety.gov.cn/xw/mkaqjcxw/'], + target: '/xw/mkaqjcxw', + }, + { + title: '地方信息', + source: ['www.chinamine-safety.gov.cn/xw/dfdt/'], + target: '/xw/dfdt', + }, + { + title: '党建专栏', + source: ['www.chinamine-safety.gov.cn/xw/djzl/'], + target: '/xw/djzl', + }, + { + title: '经验交流', + source: ['www.chinamine-safety.gov.cn/xw/jyjl/'], + target: '/xw/jyjl', + }, + { + title: '新闻发布会', + source: ['www.chinamine-safety.gov.cn/xw/xwfbh/'], + target: '/xw/xwfbh', + }, + ], + maintainers: ['nczitzk'], handler, + description: `| 分类 | id | +| ------------------ | -------- | +| 应急管理部要闻 | yjglbyw | +| 国家矿山安监局要闻 | mkaqjcxw | +| 地方信息 | dfdt | +| 党建专栏 | djzl | +| 经验交流 | jyjl | +| 新闻发布会 | xwfbh |`, }; async function handler(ctx) { diff --git a/lib/routes/gov/chinamine-safety/zfxxgk.ts b/lib/routes/gov/chinamine-safety/zfxxgk.ts index 2b1fdf3c7..c0b0a96b3 100644 --- a/lib/routes/gov/chinamine-safety/zfxxgk.ts +++ b/lib/routes/gov/chinamine-safety/zfxxgk.ts @@ -8,10 +8,205 @@ import { parseDate } from '@/utils/parse-date'; import { fetchData, processItems, rootUrl } from './util'; export const route: Route = { - path: '/chinamine-safety/zfxxgk/:category{.+}?', - name: 'Unknown', - maintainers: [], + path: '/zfxxgk/:category{.+}?', + name: '政府信息公开', + example: '/gov/chinamine-safety/zfxxgk', + parameters: { category: '分类,见下表,默认为法定主动公开内容 > 通知公告' }, + radar: [ + { + title: '政府信息公开指南', + source: ['www.chinamine-safety.gov.cn/zfxxgk/zfxxgkzn'], + target: '/zfxxgk/zfxxgkzn', + }, + { + title: '政府信息公开制度', + source: ['www.chinamine-safety.gov.cn/zfxxgk/zfxxgkzd'], + target: '/zfxxgk/zfxxgkzd', + }, + { + title: '通知公告', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/tzgg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/tzgg', + }, + { + title: '征求意见', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zqyj_01', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zqyj_01', + }, + { + title: '政策法规', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zcfg', + }, + { + title: '规划计划', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/ghjh', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/ghjh', + }, + { + title: '政策解读', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcjd', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zcjd', + }, + { + title: '安全许可', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/anqxk', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/anqxk', + }, + { + title: '事故查处', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/sgcc', + }, + { + title: '人事信息', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/rsxx', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/rsxx', + }, + { + title: '财务信息', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/cwxx', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/cwxx', + }, + { + title: '建议提案办理', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/jytabl_4823', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/jytabl_4823', + }, + { + title: '政策法规 - 法律', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/fl_01', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zcfg/fl_01', + }, + { + title: '政策法规 - 行政法规', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/xzfg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zcfg/xzfg', + }, + { + title: '政策法规 - 部门规章', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/bmgz_01', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zcfg/bmgz_01', + }, + { + title: '政策法规 - 部门规章煤矿安监', + source: [ + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/bmgz_01/mkanj', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/bmgz_01', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr', + ], + target: '/zfxxgk/fdzdgknr/zcfg/bmgz_01/mkanj', + }, + { + title: '政策法规 - 部门规章非煤矿山', + source: [ + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/bmgz_01/fmks', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/bmgz_01', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr', + ], + target: '/zfxxgk/fdzdgknr/zcfg/bmgz_01/fmks', + }, + { + title: '政策法规 - 行业标准', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/hybz_01', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/zcfg/hybz_01', + }, + { + title: '政策法规 - 行业标准煤矿安监', + source: [ + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/hybz_01/mkanj', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/hybz_01', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr', + ], + target: '/zfxxgk/fdzdgknr/zcfg/hybz_01/mkanj', + }, + { + title: '政策法规 - 行业标准非煤矿山', + source: [ + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/hybz_01/fmks', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg/hybz_01', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/zcfg', + 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr', + ], + target: '/zfxxgk/fdzdgknr/zcfg/hybz_01/fmks', + }, + { + title: '事故查处 - 事故通报', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc/sgtb', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/sgcc/sgtb', + }, + { + title: '事故查处 - 事故督办', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc/sgdb', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/sgcc/sgdb', + }, + { + title: '事故查处 - 事故调查报告', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc/sgbg', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/sgcc/sgbg', + }, + { + title: '事故查处 - 事故案例', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc/sgalks', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/sgcc/sgalks', + }, + { + title: '事故查处 - 事故警示教育片', + source: ['www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc/sgjsjy', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr/sgcc', 'www.chinamine-safety.gov.cn/zfxxgk/fdzdgknr'], + target: '/zfxxgk/fdzdgknr/sgcc/sgjsjy', + }, + ], + maintainers: ['nczitzk'], handler, + description: `| 政府信息公开指南 | 政府信息公开制度 | +| ---------------- | ---------------- | +| zfxxgkzn | zfxxgkzd | + +
+更多分类 + +#### 法定主动公开内容 + +| 分类 | id | +| ------------ | --------------------- | +| 通知公告 | fdzdgknr/tzgg | +| 征求意见 | fdzdgknr/zqyj\\_01 | +| 政策法规 | fdzdgknr/zcfg | +| 规划计划 | fdzdgknr/ghjh | +| 政策解读 | fdzdgknr/zcjd | +| 安全许可 | fdzdgknr/anqxk | +| 事故查处 | fdzdgknr/sgcc | +| 人事信息 | fdzdgknr/rsxx | +| 财务信息 | fdzdgknr/cwxx | +| 建议提案办理 | fdzdgknr/jytabl\\_4823 | + +#### 法定主动公开内容 > 政策法规 + +| 分类 | id | +| ---------------- | ---------------------------- | +| 法律 | fdzdgknr/zcfg/fl\\_01 | +| 行政法规 | fdzdgknr/zcfg/xzfg | +| 部门规章 | fdzdgknr/zcfg/bmgz\\_01 | +| 部门规章煤矿安监 | fdzdgknr/zcfg/bmgz\\_01/mkanj | +| 部门规章非煤矿山 | fdzdgknr/zcfg/bmgz\\_01/fmks | +| 行业标准 | fdzdgknr/zcfg/hybz\\_01 | +| 行业标准煤矿安监 | fdzdgknr/zcfg/hybz\\_01/mkanj | +| 行业标准非煤矿山 | fdzdgknr/zcfg/hybz\\_01/fmks | + +#### 法定主动公开内容 > 事故查处 + +| 分类 | id | +| -------------- | -------------------- | +| 事故通报 | fdzdgknr/sgcc/sgtb | +| 事故督办 | fdzdgknr/sgcc/sgdb | +| 事故调查报告 | fdzdgknr/sgcc/sgbg | +| 事故案例 | fdzdgknr/sgcc/sgalks | +| 事故警示教育片 | fdzdgknr/sgcc/sgjsjy | + +
`, }; async function handler(ctx) { diff --git a/lib/routes/gov/chinatax/latest.ts b/lib/routes/gov/chinatax/latest.ts index 57c4ae2ca..ae7c42517 100644 --- a/lib/routes/gov/chinatax/latest.ts +++ b/lib/routes/gov/chinatax/latest.ts @@ -5,7 +5,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; export const route: Route = { - path: '/chinatax/latest', + path: '/latest', categories: ['government'], example: '/gov/chinatax/latest', parameters: {}, diff --git a/lib/routes/gov/chinatax/namespace.ts b/lib/routes/gov/chinatax/namespace.ts new file mode 100644 index 000000000..6782b7d00 --- /dev/null +++ b/lib/routes/gov/chinatax/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家税务总局', + url: 'www.chinatax.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/chongqing/gzw.ts b/lib/routes/gov/chongqing/gzw.ts index 95d6b9d54..c3072a6ba 100644 --- a/lib/routes/gov/chongqing/gzw.ts +++ b/lib/routes/gov/chongqing/gzw.ts @@ -7,18 +7,18 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/chongqing/gzw/:category{.+}?', + path: '/gzw/:category{.+}?', parameters: { category: '分类,见下表,默认为通知公告', }, - name: '重庆市人民政府 国有资产监督管理委员会', + name: '国有资产监督管理委员会', url: 'gzw.cq.gov.cn', maintainers: ['nczitzk'], handler, radar: [ { source: 'gzw.cq.gov.cn/*category', - target: '/chongqing/gzw/*category', + target: '/gzw/*category', }, ], description: `| 通知公告 | 国企资讯 | 国企简介 | 国企招聘 | diff --git a/lib/routes/gov/chongqing/namespace.ts b/lib/routes/gov/chongqing/namespace.ts new file mode 100644 index 000000000..dee7badc0 --- /dev/null +++ b/lib/routes/gov/chongqing/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '重庆市人民政府', + url: 'www.cq.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/chongqing/rsks.ts b/lib/routes/gov/chongqing/rsks.ts index 05934b386..6c2d76b66 100644 --- a/lib/routes/gov/chongqing/rsks.ts +++ b/lib/routes/gov/chongqing/rsks.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; const rsksUrl = 'https://rlsbj.cq.gov.cn/ywzl/rsks/tzgg_109374/'; export const route: Route = { - path: '/chongqing/rsks', + path: '/rsks', categories: ['government'], example: '/gov/chongqing/rsks', radar: [ @@ -15,7 +15,7 @@ export const route: Route = { source: ['rlsbj.cq.gov.cn/'], }, ], - name: '重庆市人民政府 人力社保局 - 人事考试通知', + name: '人力社保局 - 人事考试通知', maintainers: ['Mai19930513'], handler, url: 'rlsbj.cq.gov.cn/', diff --git a/lib/routes/gov/chongqing/sydwgkzp.ts b/lib/routes/gov/chongqing/sydwgkzp.ts index f4fa8e800..07cb7fc50 100644 --- a/lib/routes/gov/chongqing/sydwgkzp.ts +++ b/lib/routes/gov/chongqing/sydwgkzp.ts @@ -7,7 +7,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/chongqing/sydwgkzp/:year?', + path: '/sydwgkzp/:year?', url: 'rlsbj.cq.gov.cn/', categories: ['government'], example: '/gov/chongqing/sydwgkzp', @@ -19,7 +19,7 @@ export const route: Route = { source: ['rlsbj.cq.gov.cn/'], }, ], - name: '重庆市人民政府 人力社保局 - 事业单位公开招聘', + name: '人力社保局 - 事业单位公开招聘', maintainers: ['MajexH'], handler, }; diff --git a/lib/routes/gov/cmse/fxrw-category.ts b/lib/routes/gov/cmse/fxrw-category.ts new file mode 100644 index 000000000..69eb32bcc --- /dev/null +++ b/lib/routes/gov/cmse/fxrw-category.ts @@ -0,0 +1,29 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/fxrw/:id/:category', + name: '任务动态', + example: '/gov/cmse/fxrw/wtfx/rwdt', + parameters: { + id: '任务 id,可在对应任务页 URL 中找到', + category: '分类 id,见下表,可在对应任务页 URL 中找到', + }, + description: `::: tip + +下表分类可能并不完整。请查看各飞行任务详情页获得完整分类。 + +::: + +| 任务动态 | 综合新闻 | 视频 | 图片新闻 | 媒体聚焦 | +| -------- | -------- | ---- | -------- | -------- | +| rwdt | zhxw | sp | tpxw | mtjj |`, + radar: [ + { + source: ['www.cmse.gov.cn/fxrw/:id/:category'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/fxrw.ts b/lib/routes/gov/cmse/fxrw.ts index b1b6be4fb..cd8005706 100644 --- a/lib/routes/gov/cmse/fxrw.ts +++ b/lib/routes/gov/cmse/fxrw.ts @@ -8,7 +8,7 @@ import timezone from '@/utils/timezone'; import { renderDescription } from './templates/description'; export const route: Route = { - path: '/cmse/fxrw', + path: '/fxrw', categories: ['government'], example: '/gov/cmse/fxrw', parameters: {}, diff --git a/lib/routes/gov/cmse/gfgg.ts b/lib/routes/gov/cmse/gfgg.ts new file mode 100644 index 000000000..48a1f73f8 --- /dev/null +++ b/lib/routes/gov/cmse/gfgg.ts @@ -0,0 +1,16 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/gfgg', + name: '官方公告', + example: '/gov/cmse/gfgg', + radar: [ + { + source: ['www.cmse.gov.cn/gfgg'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/gjhz.ts b/lib/routes/gov/cmse/gjhz.ts new file mode 100644 index 000000000..dfbd31965 --- /dev/null +++ b/lib/routes/gov/cmse/gjhz.ts @@ -0,0 +1,16 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/gjhz', + name: '国际合作', + example: '/gov/cmse/gjhz', + radar: [ + { + source: ['www.cmse.gov.cn/gjhz'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/hqsy.ts b/lib/routes/gov/cmse/hqsy.ts new file mode 100644 index 000000000..1324e345b --- /dev/null +++ b/lib/routes/gov/cmse/hqsy.ts @@ -0,0 +1,22 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/hqsy/:id', + name: '环球视野', + example: '/gov/cmse/hqsy/zxdta', + parameters: { + id: '分类 id,见下表,可在对应分类页 URL 中找到', + }, + description: `| 最新动态 | 美国 | 俄罗斯 | 欧洲 | 日本 | 印度 | 领域动态 | +| -------- | ---- | ------ | ---- | ---- | ---- | -------- | +| zxdta | mg | els | oz | rb | yd | lydt |`, + radar: [ + { + source: ['www.cmse.gov.cn/hqsy/:id'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/index.ts b/lib/routes/gov/cmse/index.ts index f5f88c050..9e7079017 100644 --- a/lib/routes/gov/cmse/index.ts +++ b/lib/routes/gov/cmse/index.ts @@ -1,6 +1,5 @@ import { load } from 'cheerio'; -import type { Route } from '@/types'; import cache from '@/utils/cache'; import { getSubPath } from '@/utils/common-utils'; import got from '@/utils/got'; @@ -9,14 +8,7 @@ import timezone from '@/utils/timezone'; import { renderDescription } from './templates/description'; -export const route: Route = { - path: '/cmse/*', - name: 'Unknown', - maintainers: [], - handler, -}; - -async function handler(ctx) { +export async function handler(ctx) { const path = getSubPath(ctx).replaceAll(/(^\/cmse|\/$)/g, ''); const rootUrl = 'http://www.cmse.gov.cn'; diff --git a/lib/routes/gov/cmse/kjkx.ts b/lib/routes/gov/cmse/kjkx.ts new file mode 100644 index 000000000..a3f719922 --- /dev/null +++ b/lib/routes/gov/cmse/kjkx.ts @@ -0,0 +1,22 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/kjkx/:id', + name: '空间科学', + example: '/gov/cmse/kjkx/kjkxyjyyy', + parameters: { + id: '分类 id,见下表,可在对应分类页 URL 中找到', + }, + description: `| 空间科学研究与应用 | 航天技术试验 | 航天医学实验 | +| ------------------ | ------------ | ------------ | +| kjkxyjyyy | htjssy | htyxsy |`, + radar: [ + { + source: ['www.cmse.gov.cn/kjkx/:id'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/kpjy.ts b/lib/routes/gov/cmse/kpjy.ts new file mode 100644 index 000000000..52f35885a --- /dev/null +++ b/lib/routes/gov/cmse/kpjy.ts @@ -0,0 +1,22 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/kpjy/:id', + name: '科普教育', + example: '/gov/cmse/kpjy/kphd', + parameters: { + id: '分类 id,见下表,可在对应分类页 URL 中找到', + }, + description: `| 科普活动 | 太空课堂 | 航天知识 | +| -------- | -------- | -------- | +| kphd | tkkt | ttzs |`, + radar: [ + { + source: ['www.cmse.gov.cn/kpjy/:id'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/namespace.ts b/lib/routes/gov/cmse/namespace.ts new file mode 100644 index 000000000..f796c6543 --- /dev/null +++ b/lib/routes/gov/cmse/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中国载人航天工程', + url: 'www.cmse.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/cmse/xwzx-yzjz.ts b/lib/routes/gov/cmse/xwzx-yzjz.ts new file mode 100644 index 000000000..b91772113 --- /dev/null +++ b/lib/routes/gov/cmse/xwzx-yzjz.ts @@ -0,0 +1,16 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/xwzx/yzjz', + name: '研制进展', + example: '/gov/cmse/xwzx/yzjz', + radar: [ + { + source: ['www.cmse.gov.cn/xwzx/yzjz'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/xwzx-zhxw.ts b/lib/routes/gov/cmse/xwzx-zhxw.ts new file mode 100644 index 000000000..0c05d1987 --- /dev/null +++ b/lib/routes/gov/cmse/xwzx-zhxw.ts @@ -0,0 +1,16 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/xwzx/zhxw', + name: '综合新闻', + example: '/gov/cmse/xwzx/zhxw', + radar: [ + { + source: ['www.cmse.gov.cn/xwzx/zhxw'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cmse/ztbd.ts b/lib/routes/gov/cmse/ztbd.ts new file mode 100644 index 000000000..f891f78d5 --- /dev/null +++ b/lib/routes/gov/cmse/ztbd.ts @@ -0,0 +1,22 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/ztbd/:id', + name: '专题报道', + example: '/gov/cmse/ztbd/xwfbh', + parameters: { + id: '分类 id,见下表,可在对应分类页 URL 中找到', + }, + description: `| 新闻发布会 | 学术大会 | 标准 | 新闻专题 | +| ---------- | -------- | ---- | -------- | +| xwfdh | xsdh | bz | xwzt |`, + radar: [ + { + source: ['www.cmse.gov.cn/ztbd/:id'], + }, + ], + maintainers: ['nczitzk'], + handler, +}; diff --git a/lib/routes/gov/cn/news/index.ts b/lib/routes/gov/cn/news/index.ts index 3fa9e6252..3e34a6b63 100644 --- a/lib/routes/gov/cn/news/index.ts +++ b/lib/routes/gov/cn/news/index.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/cn/news/:uid', + path: '/news/:uid', categories: ['government'], example: '/gov/cn/news/bm', parameters: { uid: '分类名' }, diff --git a/lib/routes/gov/cnnic/index.ts b/lib/routes/gov/cnnic/index.ts index 9f66c6f4a..0c2f3e9e4 100644 --- a/lib/routes/gov/cnnic/index.ts +++ b/lib/routes/gov/cnnic/index.ts @@ -2,23 +2,37 @@ import { load } from 'cheerio'; import type { Route } from '@/types'; import cache from '@/utils/cache'; -import { getSubPath } from '@/utils/common-utils'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/cnnic/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}?', + name: '新闻中心', + example: '/gov/cnnic/11/39', + parameters: { path: '路径,默认为通知公告' }, + radar: [ + { + source: ['www.cnnic.net.cn/*path'], + target: '/:path', + }, + ], + maintainers: ['nczitzk'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`https://www.cnnic.net.cn/\` 后的字段。下面是一个例子。 + +若订阅 [通知公告](https://www.cnnic.net.cn/11/39/index.html) 则将对应页面 URL 中 \`https://www.cnnic.net.cn/\` 后的字段 \`11/39\` 作为路径填入。此时路由为 [\`/gov/cnnic/11/39\`](https://rsshub.app/gov/cnnic/11/39) + +:::`, }; async function handler(ctx) { - const path = getSubPath(ctx).replaceAll(/^\/cnnic/g, ''); + const { path = '11/39' } = ctx.req.param(); - const rootUrl = 'http://www.cnnic.net.cn'; - const currentUrl = `${rootUrl}${path === '/' ? '/gywm/xwzx/rdxw/20172017_7086/' : `${path}/`}`; + const rootUrl = 'https://www.cnnic.net.cn'; + const currentUrl = `${rootUrl}/${path.endsWith('.html') ? path : `${path.replace(/\/$/, '')}/index.html`}`; const response = await got({ method: 'get', @@ -27,15 +41,18 @@ async function handler(ctx) { const $ = load(response.data); - let items = $('.link a') + let items = $('.p_news-box li') .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 12) .toArray() .map((item) => { item = $(item); + const link = item.find('a'); + return { - title: item.text(), - link: new URL(item.attr('href'), currentUrl).href, + title: link.text(), + link: new URL(link.attr('href'), currentUrl).href, + pubDate: parseDate(item.contents().last().text().trim()), }; }); @@ -49,8 +66,8 @@ async function handler(ctx) { const content = load(detailResponse.data); - item.description = content('.TRS_Editor').html(); - item.pubDate = timezone(parseDate(content('.info .text span').first().text(), 'YYYY年MM月DD日 HH:mm'), +8); + item.description = content('.content-text .inner-text').html(); + item.pubDate = timezone(parseDate(content('.from-date .time').text(), 'YYYY年MM月DD日HH:mm'), +8); return item; }) diff --git a/lib/routes/gov/cnnic/namespace.ts b/lib/routes/gov/cnnic/namespace.ts new file mode 100644 index 000000000..aadbe131f --- /dev/null +++ b/lib/routes/gov/cnnic/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中国互联网络信息中心', + url: 'www.cnnic.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/csrc/auditstatus.ts b/lib/routes/gov/csrc/auditstatus.ts index 8a0161547..51dba1e82 100644 --- a/lib/routes/gov/csrc/auditstatus.ts +++ b/lib/routes/gov/csrc/auditstatus.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/csrc/auditstatus/:apply_id', + path: '/auditstatus/:apply_id', categories: ['government'], example: '/gov/csrc/auditstatus/9ce91cf2d750ee62de27fbbcb05fa483', parameters: { apply_id: '事项类别id,`https://neris.csrc.gov.cn/alappl/home/xkDetail` 列表中各地址的 appMatrCde 参数' }, diff --git a/lib/routes/gov/csrc/csrc.ts b/lib/routes/gov/csrc/csrc.ts index acfa3acb6..17ac21d8a 100644 --- a/lib/routes/gov/csrc/csrc.ts +++ b/lib/routes/gov/csrc/csrc.ts @@ -78,7 +78,7 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: '/csrc/zfxxgk_zdgk/:id?', + path: '/zfxxgk_zdgk/:id?', name: '政府信息公开', url: 'www.csrc.gov.cn', maintainers: ['nczitzk'], @@ -224,317 +224,317 @@ export const route: Route = { { title: '主动公开目录 - 按主题查看', source: ['www.csrc.gov.cn/csrc/c101793/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101793', + target: '/zfxxgk_zdgk/c101793', }, { title: '主动公开目录 - 按体裁文种查看', source: ['www.csrc.gov.cn/csrc/c101951/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101951', + target: '/zfxxgk_zdgk/c101951', }, { title: '主动公开目录 - 按派出机构查看', source: ['www.csrc.gov.cn/csrc/c101985/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101985', + target: '/zfxxgk_zdgk/c101985', }, { title: '按主题查看 - 综合政务', source: ['www.csrc.gov.cn/csrc/c101794/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101794', + target: '/zfxxgk_zdgk/c101794', }, { title: '按主题查看 - 发行监管', source: ['www.csrc.gov.cn/csrc/c101801/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101801', + target: '/zfxxgk_zdgk/c101801', }, { title: '按主题查看 - 公众公司监管(含北交所)', source: ['www.csrc.gov.cn/csrc/c101828/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101828', + target: '/zfxxgk_zdgk/c101828', }, { title: '按主题查看 - 证券交易监管', source: ['www.csrc.gov.cn/csrc/c101832/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101832', + target: '/zfxxgk_zdgk/c101832', }, { title: '按主题查看 - 证券经营机构监管', source: ['www.csrc.gov.cn/csrc/c101837/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101837', + target: '/zfxxgk_zdgk/c101837', }, { title: '按主题查看 - 上市公司监管', source: ['www.csrc.gov.cn/csrc/c101863/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101863', + target: '/zfxxgk_zdgk/c101863', }, { title: '按主题查看 - 基金监管', source: ['www.csrc.gov.cn/csrc/c101876/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101876', + target: '/zfxxgk_zdgk/c101876', }, { title: '按主题查看 - 私募基金监管', source: ['www.csrc.gov.cn/csrc/c101938/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101938', + target: '/zfxxgk_zdgk/c101938', }, { title: '按主题查看 - 区域性股权市场规范发展', source: ['www.csrc.gov.cn/csrc/c106301/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c106301', + target: '/zfxxgk_zdgk/c106301', }, { title: '按主题查看 - 期货监管', source: ['www.csrc.gov.cn/csrc/c101901/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101901', + target: '/zfxxgk_zdgk/c101901', }, { title: '按主题查看 - 债券监管', source: ['www.csrc.gov.cn/csrc/c106306/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c106306', + target: '/zfxxgk_zdgk/c106306', }, { title: '按主题查看 - 行政执法', source: ['www.csrc.gov.cn/csrc/c101925/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101925', + target: '/zfxxgk_zdgk/c101925', }, { title: '按主题查看 - 行政复议', source: ['www.csrc.gov.cn/csrc/c105938/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c105938', + target: '/zfxxgk_zdgk/c105938', }, { title: '按主题查看 - 国际合作', source: ['www.csrc.gov.cn/csrc/c101931/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101931', + target: '/zfxxgk_zdgk/c101931', }, { title: '按主题查看 - 证券服务机构监管', source: ['www.csrc.gov.cn/csrc/c105939/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c105939', + target: '/zfxxgk_zdgk/c105939', }, { title: '按主题查看 - 其他', source: ['www.csrc.gov.cn/csrc/c101950/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101950', + target: '/zfxxgk_zdgk/c101950', }, { title: '按派出机构查看 - 北京', source: ['www.csrc.gov.cn/csrc/c101986/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101986', + target: '/zfxxgk_zdgk/c101986', }, { title: '按派出机构查看 - 天津', source: ['www.csrc.gov.cn/csrc/c101987/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101987', + target: '/zfxxgk_zdgk/c101987', }, { title: '按派出机构查看 - 河北', source: ['www.csrc.gov.cn/csrc/c101988/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101988', + target: '/zfxxgk_zdgk/c101988', }, { title: '按派出机构查看 - 山西', source: ['www.csrc.gov.cn/csrc/c101989/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101989', + target: '/zfxxgk_zdgk/c101989', }, { title: '按派出机构查看 - 内蒙古', source: ['www.csrc.gov.cn/csrc/c101990/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101990', + target: '/zfxxgk_zdgk/c101990', }, { title: '按派出机构查看 - 辽宁', source: ['www.csrc.gov.cn/csrc/c101991/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101991', + target: '/zfxxgk_zdgk/c101991', }, { title: '按派出机构查看 - 吉林', source: ['www.csrc.gov.cn/csrc/c101992/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101992', + target: '/zfxxgk_zdgk/c101992', }, { title: '按派出机构查看 - 黑龙江', source: ['www.csrc.gov.cn/csrc/c101993/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101993', + target: '/zfxxgk_zdgk/c101993', }, { title: '按派出机构查看 - 上海', source: ['www.csrc.gov.cn/csrc/c101994/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101994', + target: '/zfxxgk_zdgk/c101994', }, { title: '按派出机构查看 - 江苏', source: ['www.csrc.gov.cn/csrc/c101995/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101995', + target: '/zfxxgk_zdgk/c101995', }, { title: '按派出机构查看 - 浙江', source: ['www.csrc.gov.cn/csrc/c101996/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101996', + target: '/zfxxgk_zdgk/c101996', }, { title: '按派出机构查看 - 安徽', source: ['www.csrc.gov.cn/csrc/c101997/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101997', + target: '/zfxxgk_zdgk/c101997', }, { title: '按派出机构查看 - 福建', source: ['www.csrc.gov.cn/csrc/c101998/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101998', + target: '/zfxxgk_zdgk/c101998', }, { title: '按派出机构查看 - 江西', source: ['www.csrc.gov.cn/csrc/c101999/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101999', + target: '/zfxxgk_zdgk/c101999', }, { title: '按派出机构查看 - 山东', source: ['www.csrc.gov.cn/csrc/c102000/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102000', + target: '/zfxxgk_zdgk/c102000', }, { title: '按派出机构查看 - 河南', source: ['www.csrc.gov.cn/csrc/c102001/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102001', + target: '/zfxxgk_zdgk/c102001', }, { title: '按派出机构查看 - 湖北', source: ['www.csrc.gov.cn/csrc/c102002/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102002', + target: '/zfxxgk_zdgk/c102002', }, { title: '按派出机构查看 - 湖南', source: ['www.csrc.gov.cn/csrc/c102003/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102003', + target: '/zfxxgk_zdgk/c102003', }, { title: '按派出机构查看 - 广东', source: ['www.csrc.gov.cn/csrc/c102004/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102004', + target: '/zfxxgk_zdgk/c102004', }, { title: '按派出机构查看 - 广西', source: ['www.csrc.gov.cn/csrc/c102005/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102005', + target: '/zfxxgk_zdgk/c102005', }, { title: '按派出机构查看 - 海南', source: ['www.csrc.gov.cn/csrc/c102006/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102006', + target: '/zfxxgk_zdgk/c102006', }, { title: '按派出机构查看 - 重庆', source: ['www.csrc.gov.cn/csrc/c102007/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102007', + target: '/zfxxgk_zdgk/c102007', }, { title: '按派出机构查看 - 四川', source: ['www.csrc.gov.cn/csrc/c102008/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102008', + target: '/zfxxgk_zdgk/c102008', }, { title: '按派出机构查看 - 贵州', source: ['www.csrc.gov.cn/csrc/c102009/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102009', + target: '/zfxxgk_zdgk/c102009', }, { title: '按派出机构查看 - 云南', source: ['www.csrc.gov.cn/csrc/c102010/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102010', + target: '/zfxxgk_zdgk/c102010', }, { title: '按派出机构查看 - 西藏', source: ['www.csrc.gov.cn/csrc/c102011/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102011', + target: '/zfxxgk_zdgk/c102011', }, { title: '按派出机构查看 - 陕西', source: ['www.csrc.gov.cn/csrc/c102012/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102012', + target: '/zfxxgk_zdgk/c102012', }, { title: '按派出机构查看 - 甘肃', source: ['www.csrc.gov.cn/csrc/c102013/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102013', + target: '/zfxxgk_zdgk/c102013', }, { title: '按派出机构查看 - 青海', source: ['www.csrc.gov.cn/csrc/c102014/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102014', + target: '/zfxxgk_zdgk/c102014', }, { title: '按派出机构查看 - 宁夏', source: ['www.csrc.gov.cn/csrc/c102015/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102015', + target: '/zfxxgk_zdgk/c102015', }, { title: '按派出机构查看 - 新疆', source: ['www.csrc.gov.cn/csrc/c102016/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102016', + target: '/zfxxgk_zdgk/c102016', }, { title: '按派出机构查看 - 深圳', source: ['www.csrc.gov.cn/csrc/c102017/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102017', + target: '/zfxxgk_zdgk/c102017', }, { title: '按派出机构查看 - 大连', source: ['www.csrc.gov.cn/csrc/c102018/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102018', + target: '/zfxxgk_zdgk/c102018', }, { title: '按派出机构查看 - 宁波', source: ['www.csrc.gov.cn/csrc/c102019/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102019', + target: '/zfxxgk_zdgk/c102019', }, { title: '按派出机构查看 - 厦门', source: ['www.csrc.gov.cn/csrc/c102020/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102020', + target: '/zfxxgk_zdgk/c102020', }, { title: '按派出机构查看 - 青岛', source: ['www.csrc.gov.cn/csrc/c102021/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c102021', + target: '/zfxxgk_zdgk/c102021', }, { title: '按派出机构查看 - 上海专员办', source: ['www.csrc.gov.cn/csrc/c105841/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c105841', + target: '/zfxxgk_zdgk/c105841', }, { title: '按派出机构查看 - 深圳专员办', source: ['www.csrc.gov.cn/csrc/c105842/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c105842', + target: '/zfxxgk_zdgk/c105842', }, { title: '综合政务 - 组织机构', source: ['www.csrc.gov.cn/csrc/c101795/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101795', + target: '/zfxxgk_zdgk/c101795', }, { title: '综合政务 - 征求意见', source: ['www.csrc.gov.cn/csrc/c101796/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101796', + target: '/zfxxgk_zdgk/c101796', }, { title: '综合政务 - 废止规章', source: ['www.csrc.gov.cn/csrc/c101797/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101797', + target: '/zfxxgk_zdgk/c101797', }, { title: '综合政务 - 财务预算管理', source: ['www.csrc.gov.cn/csrc/c105887/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c105887', + target: '/zfxxgk_zdgk/c105887', }, { title: '综合政务 - 其他', source: ['www.csrc.gov.cn/csrc/c101799/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101799', + target: '/zfxxgk_zdgk/c101799', }, { title: '综合政务 - 全国人大建议和政协提案复文公开', source: ['www.csrc.gov.cn/csrc/c101800/zfxxgk_zdgk.shtml'], - target: '/csrc/zfxxgk_zdgk/c101800', + target: '/zfxxgk_zdgk/c101800', }, ], }; diff --git a/lib/routes/gov/csrc/namespace.ts b/lib/routes/gov/csrc/namespace.ts new file mode 100644 index 000000000..dfa046b03 --- /dev/null +++ b/lib/routes/gov/csrc/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中国证券监督管理委员会', + url: 'www.csrc.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/csrc/news.tsx b/lib/routes/gov/csrc/news.tsx index 4bded27f6..60e79eff0 100644 --- a/lib/routes/gov/csrc/news.tsx +++ b/lib/routes/gov/csrc/news.tsx @@ -8,10 +8,23 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/csrc/news/:suffix{.+}?', - name: 'Unknown', - maintainers: [], + path: '/news/:suffix{.+}?', + name: '通用', + example: '/gov/csrc/news/c101975/zfxxgk_zdgk.shtml', + parameters: { suffix: '路径,预设为 `c100028/common_xq_list.shtml`' }, + radar: [ + { + source: ['www.csrc.gov.cn/csrc/*suffix'], + target: '/news/:suffix', + }, + ], + maintainers: ['chinobing', 'LogicJake'], handler, + description: `::: tip +路径处填写对应页面 URL 中 \`http://www.csrc.gov.cn/csrc/\` 后的字段。下面是一个例子。 + +若订阅 [证监会要闻](http://www.csrc.gov.cn/csrc/c100028/common_xq_list.shtml) 则将对应页面 URL 中 \`http://www.csrc.gov.cn/csrc/\` 后的字段 \`c100028/common_xq_list.shtml\` 作为路径填入。此时路由为 [\`/gov/csrc/news/c100028/common_xq_list.shtml\`](https://rsshub.app/gov/csrc/news/c100028/common_xq_list.shtml) +:::`, }; async function handler(ctx) { diff --git a/lib/routes/gov/customs/list.ts b/lib/routes/gov/customs/list.ts index e177ce6fc..15446c0bb 100644 --- a/lib/routes/gov/customs/list.ts +++ b/lib/routes/gov/customs/list.ts @@ -10,7 +10,7 @@ import timezone from '@/utils/timezone'; import { host, playwrightGet } from './utils'; export const route: Route = { - path: '/customs/list/:gchannel?', + path: '/list/:gchannel?', categories: ['government'], example: '/gov/customs/list/paimai', parameters: { gchannel: '支持 `paimai`, `fagui` 及 `latest` 3 个频道,默认为 `paimai`' }, @@ -25,7 +25,7 @@ export const route: Route = { radar: [ { source: ['www.customs.gov.cn/'], - target: '/customs/list', + target: '/list', }, ], name: '拍卖信息 / 海关法规 / 最新文件', diff --git a/lib/routes/gov/dianbai/dianbai.ts b/lib/routes/gov/dianbai/dianbai.ts index d640188df..94cfdd19b 100644 --- a/lib/routes/gov/dianbai/dianbai.ts +++ b/lib/routes/gov/dianbai/dianbai.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/dianbai/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/dianbai/www/zwgk/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政务公开 > 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政务公开 > 政策解读](http://www.dianbai.gov.cn/zwgk/zcjd/) 则将对应页面 URL 中 \`http://www.dianbai.gov.cn/\` 的字段 \`www\` 和 \`zwgk/zcjd/\` 作为路径填入。此时路由为 [\`/gov/dianbai/www/zwgk/zcjd/\`](https://rsshub.app/gov/dianbai/www/zwgk/zcjd/) + +:::`, }; async function handler(ctx) { @@ -23,5 +32,5 @@ async function handler(ctx) { pubDate_match: '(.*)', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/dianbai/namespace.ts b/lib/routes/gov/dianbai/namespace.ts new file mode 100644 index 000000000..0e4ca16e3 --- /dev/null +++ b/lib/routes/gov/dianbai/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '茂名市电白区人民政府', + url: 'www.dianbai.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/forestry/gjlckjdjt.ts b/lib/routes/gov/forestry/gjlckjdjt.ts index 290032a59..3f29bbcb7 100644 --- a/lib/routes/gov/forestry/gjlckjdjt.ts +++ b/lib/routes/gov/forestry/gjlckjdjt.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import { renderDescription } from './templates/description'; export const route: Route = { - path: '/forestry/gjlckjdjt/:category?', + path: '/gjlckjdjt/:category?', categories: ['government'], example: '/gov/forestry/gjlckjdjt', parameters: { category: '分类,见下表,默认为全部' }, diff --git a/lib/routes/gov/forestry/namespace.ts b/lib/routes/gov/forestry/namespace.ts new file mode 100644 index 000000000..44eb7f126 --- /dev/null +++ b/lib/routes/gov/forestry/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家林业和草原局', + url: 'www.forestry.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/gaozhou/gaozhou.ts b/lib/routes/gov/gaozhou/gaozhou.ts index 8cf0731e2..e99c34e50 100644 --- a/lib/routes/gov/gaozhou/gaozhou.ts +++ b/lib/routes/gov/gaozhou/gaozhou.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/gaozhou/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/gaozhou/www/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政策解读](http://www.gaozhou.gov.cn/zcjd/) 则将对应页面 URL 中 \`http://www.gaozhou.gov.cn/\` 的字段 \`www\` 和 \`zcjd/\` 作为路径填入。此时路由为 [\`/gov/gaozhou/www/zcjd/\`](https://rsshub.app/gov/gaozhou/www/zcjd/) + +:::`, }; async function handler(ctx) { @@ -24,5 +33,5 @@ async function handler(ctx) { pubDate_match: '发布时间:(.*)', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/gaozhou/namespace.ts b/lib/routes/gov/gaozhou/namespace.ts new file mode 100644 index 000000000..96936bf0f --- /dev/null +++ b/lib/routes/gov/gaozhou/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '高州市人民政府', + url: 'www.gaozhou.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/guizhou/jyt.ts b/lib/routes/gov/guizhou/jyt.ts index 5fb2a23fb..b6ef9178d 100644 --- a/lib/routes/gov/guizhou/jyt.ts +++ b/lib/routes/gov/guizhou/jyt.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/guizhou/jyt/tzgg', + path: '/jyt/tzgg', categories: ['government'], example: '/gov/guizhou/jyt/tzgg', parameters: {}, @@ -22,10 +22,10 @@ export const route: Route = { radar: [ { source: ['jyt.guizhou.gov.cn/zwgk/tzgg/', 'jyt.guizhou.gov.cn/zwgk/tzgg/index.html'], - target: '/guizhou/jyt/tzgg', + target: '/jyt/tzgg', }, ], - name: '贵州省教育厅 - 通知公告', + name: '教育厅 - 通知公告', maintainers: ['sheetung'], handler, url: 'jyt.guizhou.gov.cn/zwgk/tzgg/', diff --git a/lib/routes/gov/gz/index.ts b/lib/routes/gov/gz/index.ts index 02f799a0f..0256df0f9 100644 --- a/lib/routes/gov/gz/index.ts +++ b/lib/routes/gov/gz/index.ts @@ -1,6 +1,5 @@ import { load } from 'cheerio'; -import type { Route } from '@/types'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -13,15 +12,8 @@ const urlMap = { zcjd: 'zcjd/zcjd', }; -export const route: Route = { - path: '/gz/:channel/:category', - name: 'Unknown', - maintainers: [], - handler, -}; - -async function handler(ctx) { - const channel = ctx.req.param('channel'); +export async function handler(ctx) { + const channel = ctx.req.param('channel') ?? ctx.req.path.split('/', 4)[3]; const category = ctx.req.param('category'); const url = `${rootUrl}/${channel}/${urlMap[category]}/`; const response = await got(url); diff --git a/lib/routes/gov/gz/namespace.ts b/lib/routes/gov/gz/namespace.ts new file mode 100644 index 000000000..196fcf230 --- /dev/null +++ b/lib/routes/gov/gz/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '广州市人民政府', + url: 'www.gz.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/gz/xw.ts b/lib/routes/gov/gz/xw.ts new file mode 100644 index 000000000..09e90e91e --- /dev/null +++ b/lib/routes/gov/gz/xw.ts @@ -0,0 +1,20 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/xw/:category', + name: '新闻', + example: '/gov/gz/xw/gzyw', + parameters: { category: '新闻分类' }, + radar: [ + { + source: ['www.gz.gov.cn/xw/:category'], + }, + ], + maintainers: ['drgnchan'], + handler, + description: `| 广州要闻 | 今日头条 | 通知公告 | +| -------- | -------- | -------- | +| gzyw | jrtt | tzgg |`, +}; diff --git a/lib/routes/gov/gz/zwgk.ts b/lib/routes/gov/gz/zwgk.ts new file mode 100644 index 000000000..b8fb5c1dc --- /dev/null +++ b/lib/routes/gov/gz/zwgk.ts @@ -0,0 +1,21 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/zwgk/:category', + name: '政务公开', + example: '/gov/gz/zwgk/zcjd', + parameters: { category: '政务话你知' }, + radar: [ + { + source: ['www.gz.gov.cn/zwgk/zcjd/zcjd'], + target: '/zwgk/zcjd', + }, + ], + maintainers: ['drgnchan'], + handler, + description: `| 文字解读 | +| -------- | +| zcjd |`, +}; diff --git a/lib/routes/gov/hainan/iitb/tzgg.ts b/lib/routes/gov/hainan/iitb/tzgg.ts index 6cb7526dd..46446751c 100644 --- a/lib/routes/gov/hainan/iitb/tzgg.ts +++ b/lib/routes/gov/hainan/iitb/tzgg.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/hainan/iitb/tzgg', + path: '/iitb/tzgg', categories: ['government'], example: '/gov/hainan/iitb/tzgg', url: 'iitb.hainan.gov.cn/iitb/tzgg/list2.shtml', diff --git a/lib/routes/gov/hangzhou/zwfw.tsx b/lib/routes/gov/hangzhou/zwfw.tsx index f5cd4cdfe..75c7e1d1a 100644 --- a/lib/routes/gov/hangzhou/zwfw.tsx +++ b/lib/routes/gov/hangzhou/zwfw.tsx @@ -190,7 +190,7 @@ const renderDescription = ({ serviceInfo, applicationInfo, resultInfo, feeInfo, ); export const route: Route = { - path: '/hangzhou/zwfw', + path: '/zwfw', categories: ['government'], example: '/gov/hangzhou/zwfw', features: { diff --git a/lib/routes/gov/hebei/czt.ts b/lib/routes/gov/hebei/czt.ts index b41485c42..ed5099d67 100644 --- a/lib/routes/gov/hebei/czt.ts +++ b/lib/routes/gov/hebei/czt.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/hebei/czt/xwdt/:category?', + path: '/czt/xwdt/:category?', categories: ['government'], example: '/gov/hebei/czt/xwdt', parameters: { category: '分类,见下表,默认为财政动态' }, diff --git a/lib/routes/gov/hebei/namespace.ts b/lib/routes/gov/hebei/namespace.ts new file mode 100644 index 000000000..b86454ce6 --- /dev/null +++ b/lib/routes/gov/hebei/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '河北省人民政府', + url: 'www.hebei.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/huazhou/huazhou.ts b/lib/routes/gov/huazhou/huazhou.ts index 3c4e28aad..1544e8998 100644 --- a/lib/routes/gov/huazhou/huazhou.ts +++ b/lib/routes/gov/huazhou/huazhou.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/huazhou/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/huazhou/www/syzl/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政策解读](http://www.huazhou.gov.cn/syzl/zcjd/) 则将对应页面 URL 中 \`http://www.huazhou.gov.cn/\` 的字段 \`www\` \`syzl/zcjd/\` 作为路径填入。此时路由为 [\`/gov/huazhou/www/syzl/zcjd/\`](https://rsshub.app/gov/huazhou/www/syzl/zcjd/) + +:::`, }; async function handler(ctx) { @@ -24,5 +33,5 @@ async function handler(ctx) { pubDate_match: '日期:(.*)', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/huazhou/namespace.ts b/lib/routes/gov/huazhou/namespace.ts new file mode 100644 index 000000000..2acede124 --- /dev/null +++ b/lib/routes/gov/huazhou/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '化州市人民政府', + url: 'www.huazhou.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/huizhou/namespace.ts b/lib/routes/gov/huizhou/namespace.ts new file mode 100644 index 000000000..e3189d3cc --- /dev/null +++ b/lib/routes/gov/huizhou/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '惠州市人民政府', + url: 'www.huizhou.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/huizhou/zwgk/index.ts b/lib/routes/gov/huizhou/zwgk/index.ts index 0a4aa08f3..69b45f760 100644 --- a/lib/routes/gov/huizhou/zwgk/index.ts +++ b/lib/routes/gov/huizhou/zwgk/index.ts @@ -9,7 +9,7 @@ import timezone from '@/utils/timezone'; const rootURL = 'http://www.huizhou.gov.cn'; export const route: Route = { - path: '/huizhou/zwgk/:category?', + path: '/zwgk/:category?', categories: ['government'], example: '/gov/huizhou/zwgk/jgdt', parameters: { category: '资讯类别,可以从网址中得到,默认为政务要闻' }, @@ -21,10 +21,26 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - name: '惠州市人民政府', + radar: [ + { + title: '政务公开 - 政务要闻', + source: ['www.huizhou.gov.cn/zwgk/hzsz/zwyw'], + target: '/zwgk/zwyw', + }, + { + title: '政务公开 - 机关动态', + source: ['www.huizhou.gov.cn/zwgk/hzsz/jgdt'], + target: '/zwgk/jgdt', + }, + { + title: '政务公开 - 县区要闻', + source: ['www.huizhou.gov.cn/zwgk/hzsz/xqyw'], + target: '/zwgk/xqyw', + }, + ], + name: '政务公开', maintainers: ['Fatpandac'], handler, - description: '#### 政务公开 {#guang-dong-sheng-ren-min-zheng-fu-hui-zhou-shi-ren-min-zheng-fu-zheng-wu-gong-kai}', }; async function handler(ctx) { diff --git a/lib/routes/gov/hunan/changsha/major-email.ts b/lib/routes/gov/hunan/changsha/major-email.ts index 926f6d07c..0bdc2ddac 100644 --- a/lib/routes/gov/hunan/changsha/major-email.ts +++ b/lib/routes/gov/hunan/changsha/major-email.ts @@ -9,7 +9,7 @@ import { parseDate } from '@/utils/parse-date'; const baseUrl = 'http://wlwz.changsha.gov.cn'; export const route: Route = { - path: '/hunan/changsha/major-email', + path: '/changsha/major-email', categories: ['government'], example: '/gov/hunan/changsha/major-email', parameters: {}, @@ -26,13 +26,11 @@ export const route: Route = { source: ['wlwz.changsha.gov.cn/webapp/cs2020/email/*'], }, ], - name: '长沙市人民政府', + name: '长沙市人民政府 市长信箱', maintainers: ['shansing'], handler, url: 'wlwz.changsha.gov.cn/webapp/cs2020/email/*', - description: `#### 市长信箱 {#hu-nan-sheng-ren-min-zheng-fu-chang-sha-shi-ren-min-zheng-fu-shi-zhang-xin-xiang} - -可能仅限中国大陆服务器访问,以实际情况为准。`, + description: '可能仅限中国大陆服务器访问,以实际情况为准。', }; async function handler() { diff --git a/lib/routes/gov/hunan/namespace.ts b/lib/routes/gov/hunan/namespace.ts new file mode 100644 index 000000000..96501e97f --- /dev/null +++ b/lib/routes/gov/hunan/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '湖南省人民政府', + url: 'www.hunan.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/immiau/namespace.ts b/lib/routes/gov/immiau/namespace.ts new file mode 100644 index 000000000..c20fd0e49 --- /dev/null +++ b/lib/routes/gov/immiau/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'Australian Department of Home Affairs', + url: 'immi.homeaffairs.gov.au', + categories: ['government'], + lang: 'en', +}; diff --git a/lib/routes/gov/immiau/news.ts b/lib/routes/gov/immiau/news.ts index 5222ab30c..f090a0c1e 100644 --- a/lib/routes/gov/immiau/news.ts +++ b/lib/routes/gov/immiau/news.ts @@ -20,7 +20,7 @@ const reqBodyByYear = (year) => ({ const getItemUrl = (id) => `https://immi.homeaffairs.gov.au/news-media/archive/article?itemId=${id}`; export const route: Route = { - path: '/immiau/news', + path: '/news', categories: ['government'], example: '/gov/immiau/news', parameters: {}, diff --git a/lib/routes/gov/jgjcndrc/index.ts b/lib/routes/gov/jgjcndrc/index.ts index 832b53f0c..0c73af31c 100644 --- a/lib/routes/gov/jgjcndrc/index.ts +++ b/lib/routes/gov/jgjcndrc/index.ts @@ -84,7 +84,7 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: '/jgjcndrc/:columnId?/:subColumnId?', + path: '/:columnId?/:subColumnId?', name: '中华人民共和国国家发展和改革委员会价格监测中心', url: 'www.jgjcndrc.org.cn', maintainers: ['nczitzk'], diff --git a/lib/routes/gov/jgjcndrc/namespace.ts b/lib/routes/gov/jgjcndrc/namespace.ts new file mode 100644 index 000000000..9dbb779ae --- /dev/null +++ b/lib/routes/gov/jgjcndrc/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家发展和改革委员会价格监测中心', + url: 'www.jgjcndrc.org.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/jiangsu/namespace.ts b/lib/routes/gov/jiangsu/namespace.ts new file mode 100644 index 000000000..a1c58b799 --- /dev/null +++ b/lib/routes/gov/jiangsu/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '江苏省人民政府', + url: 'www.jiangsu.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/jiangsu/wlt/index.tsx b/lib/routes/gov/jiangsu/wlt/index.tsx index c8d35e376..e78203428 100644 --- a/lib/routes/gov/jiangsu/wlt/index.tsx +++ b/lib/routes/gov/jiangsu/wlt/index.tsx @@ -7,7 +7,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/jiangsu/wlt/:page?', + path: '/wlt/:page?', categories: ['government'], example: '/gov/jiangsu/wlt', parameters: { page: '页数,默认第 1 页' }, @@ -22,10 +22,10 @@ export const route: Route = { radar: [ { source: ['wlt.jiangsu.gov.cn/'], - target: '/jiangsu/wlt', + target: '/wlt', }, ], - name: '江苏文旅局审批公告', + name: '文旅局审批公告', maintainers: ['GideonSenku'], handler, url: 'wlt.jiangsu.gov.cn/', diff --git a/lib/routes/gov/jinan/healthcommission/medical-exam-notice.ts b/lib/routes/gov/jinan/healthcommission/medical-exam-notice.ts index 222fd71ee..329b3b6b3 100644 --- a/lib/routes/gov/jinan/healthcommission/medical-exam-notice.ts +++ b/lib/routes/gov/jinan/healthcommission/medical-exam-notice.ts @@ -6,7 +6,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/jinan/healthcommission/medical_exam_notice', + path: '/healthcommission/medical_exam_notice', categories: ['government'], example: '/gov/jinan/healthcommission/medical_exam_notice', parameters: {}, diff --git a/lib/routes/gov/jinan/namespace.ts b/lib/routes/gov/jinan/namespace.ts new file mode 100644 index 000000000..63a3b32a4 --- /dev/null +++ b/lib/routes/gov/jinan/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '济南市人民政府', + url: 'www.jinan.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/lswz/index.ts b/lib/routes/gov/lswz/index.ts index aef530339..23a7bf5ae 100644 --- a/lib/routes/gov/lswz/index.ts +++ b/lib/routes/gov/lswz/index.ts @@ -76,8 +76,8 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: '/lswz/:category{.+}?', - name: '国家粮食和物资储备局', + path: '/:category{.+}?', + name: '通用', url: 'lswz.gov.cn', maintainers: ['nczitzk'], handler, @@ -155,132 +155,132 @@ export const route: Route = { { title: '新闻发布', source: ['www.lswz.gov.cn/html/xinwen/index.shtml'], - target: '/lswz/html/xinwen/index', + target: '/html/xinwen/index', }, { title: '党建工作', source: ['www.lswz.gov.cn/html/djgz/index.shtml'], - target: '/lswz/html/djgz/index', + target: '/html/djgz/index', }, { title: '业务频道 - 粮食调控', source: ['www.lswz.gov.cn/html/ywpd/lstk/index.shtml'], - target: '/lswz/html/ywpd/lstk/index', + target: '/html/ywpd/lstk/index', }, { title: '业务频道 - 物资储备', source: ['www.lswz.gov.cn/html/ywpd/wzcb/index.shtml'], - target: '/lswz/html/ywpd/wzcb/index', + target: '/html/ywpd/wzcb/index', }, { title: '业务频道 - 能源储备', source: ['www.lswz.gov.cn/html/ywpd/nycb/index.shtml'], - target: '/lswz/html/ywpd/nycb/index', + target: '/html/ywpd/nycb/index', }, { title: '业务频道 - 安全应急', source: ['www.lswz.gov.cn/html/ywpd/aqyj/index.shtml'], - target: '/lswz/html/ywpd/aqyj/index', + target: '/html/ywpd/aqyj/index', }, { title: '业务频道 - 法规体改', source: ['www.lswz.gov.cn/html/ywpd/fgtg/index.shtml'], - target: '/lswz/html/ywpd/fgtg/index', + target: '/html/ywpd/fgtg/index', }, { title: '业务频道 - 规划建设', source: ['www.lswz.gov.cn/html/ywpd/gjks/index.shtml'], - target: '/lswz/html/ywpd/gjks/index', + target: '/html/ywpd/gjks/index', }, { title: '业务频道 - 财务审计', source: ['www.lswz.gov.cn/html/ywpd/cwsj/index.shtml'], - target: '/lswz/html/ywpd/cwsj/index', + target: '/html/ywpd/cwsj/index', }, { title: '业务频道 - 仓储科技', source: ['www.lswz.gov.cn/html/ywpd/cckj/index.shtml'], - target: '/lswz/html/ywpd/cckj/index', + target: '/html/ywpd/cckj/index', }, { title: '业务频道 - 执法督查', source: ['www.lswz.gov.cn/html/ywpd/zfdc/index.shtml'], - target: '/lswz/html/ywpd/zfdc/index', + target: '/html/ywpd/zfdc/index', }, { title: '业务频道 - 国际交流', source: ['www.lswz.gov.cn/html/ywpd/gjjl/index.shtml'], - target: '/lswz/html/ywpd/gjjl/index', + target: '/html/ywpd/gjjl/index', }, { title: '业务频道 - 人事人才', source: ['www.lswz.gov.cn/html/ywpd/rsrc/index.shtml'], - target: '/lswz/html/ywpd/rsrc/index', + target: '/html/ywpd/rsrc/index', }, { title: '业务频道 - 标准质量', source: ['www.lswz.gov.cn/html/ywpd/bzzl/index.shtml'], - target: '/lswz/html/ywpd/bzzl/index', + target: '/html/ywpd/bzzl/index', }, { title: '业务频道 - 粮食和储备研究', source: ['www.lswz.gov.cn/html/ywpd/lshcbyj/index.shtml'], - target: '/lswz/html/ywpd/lshcbyj/index', + target: '/html/ywpd/lshcbyj/index', }, { title: '政策发布 - 文件', source: ['www.lswz.gov.cn/html/zcfb/wenjian.shtml'], - target: '/lswz/html/zcfb/wenjian', + target: '/html/zcfb/wenjian', }, { title: '政策发布 - 法律法规', source: ['www.lswz.gov.cn/html/zcfb/fggz-fg.shtml'], - target: '/lswz/html/zcfb/fggz-fg', + target: '/html/zcfb/fggz-fg', }, { title: '政策发布 - 规章', source: ['www.lswz.gov.cn/html/zcfb/fggz-gz.shtml'], - target: '/lswz/html/zcfb/fggz-gz', + target: '/html/zcfb/fggz-gz', }, { title: '通知公告 - 行政通知', source: ['www.lswz.gov.cn/html/tzgg/xztz.shtml'], - target: '/lswz/html/tzgg/xztz', + target: '/html/tzgg/xztz', }, { title: '通知公告 - 公告通告', source: ['www.lswz.gov.cn/html/tzgg/ggtg.shtml'], - target: '/lswz/html/tzgg/ggtg', + target: '/html/tzgg/ggtg', }, { title: '粮食收购 - 收购数据', source: ['www.lswz.gov.cn/html/zmhd/lysj/lssg-szym.shtml'], - target: '/lswz/html/zmhd/lysj/lssg-szym', + target: '/html/zmhd/lysj/lssg-szym', }, { title: '粮食收购 - 政策·解读', source: ['www.lswz.gov.cn/html/zmhd/lysj/lssg-gzdt.shtml'], - target: '/lswz/html/zmhd/lysj/lssg-gzdt', + target: '/html/zmhd/lysj/lssg-gzdt', }, { title: '粮食价格 - 市场监测', source: ['www.lswz.gov.cn/html/zmhd/lysj/lsjg-scjc.shtml'], - target: '/lswz/html/zmhd/lysj/lsjg-scjc', + target: '/html/zmhd/lysj/lsjg-scjc', }, { title: '粮食价格 - 市场价格', source: ['www.lswz.gov.cn/html/zmhd/lysj/lsjg-scjg.shtml'], - target: '/lswz/html/zmhd/lysj/lsjg-scjg', + target: '/html/zmhd/lysj/lsjg-scjg', }, { title: '粮食交易', source: ['www.lswz.gov.cn/html/zmhd/lysj/lsjy.shtml'], - target: '/lswz/html/zmhd/lysj/lsjy', + target: '/html/zmhd/lysj/lsjy', }, { title: '粮食质量', source: ['www.lswz.gov.cn/html/zmhd/lysj/lszl.shtml'], - target: '/lswz/html/zmhd/lysj/lszl', + target: '/html/zmhd/lysj/lszl', }, ], }; diff --git a/lib/routes/gov/lswz/namespace.ts b/lib/routes/gov/lswz/namespace.ts new file mode 100644 index 000000000..83ee58cc6 --- /dev/null +++ b/lib/routes/gov/lswz/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家粮食和物资储备局', + url: 'www.lswz.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/maoming/maoming.ts b/lib/routes/gov/maoming/maoming.ts index 84a0a4c10..17d143a39 100644 --- a/lib/routes/gov/maoming/maoming.ts +++ b/lib/routes/gov/maoming/maoming.ts @@ -4,10 +4,21 @@ import { getSubPath } from '@/utils/common-utils'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/maoming/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '门户网站', + example: '/gov/maoming/www/zwgk/zcjd/jd', + parameters: { path: '路径' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中茂名有关政府网站的域名最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [茂名市人民政府门户网站 > 政务公开 > 政策解读](http://www.maoming.gov.cn/zwgk/zcjd/jd/) 则将对应页面 URL 中 \`http://www.maoming.gov.cn/\` 的字段 \`www\` 和 \`/zwgk/zcjd/jd/\` 作为路径填入。此时路由为 [\`/gov/maoming/www/zwgk/zcjd/jd/\`](https://rsshub.app/gov/maoming/www/zwgk/zcjd/jd/) + +若订阅 [茂名市农业农村局网站 > 政务区 > 政务公开 > 通知公告](http://mmny.maoming.gov.cn/zwq/zwgk/tzgg/) 则将对应页面 URL 中 \`http://mmny.maoming.gov.cn/\` 的字段 \`mmny\` 和 \`/zwq/zwgk/tzgg/\` 作为路径填入。此时路由为 [\`/gov/maoming/mmny/zwq/zwgk/tzgg/\`](https://rsshub.app/gov/maoming/mmny/zwq/zwgk/tzgg/) + +:::`, }; async function handler(ctx) { @@ -399,5 +410,5 @@ async function handler(ctx) { pubDate_match, // pubDate_format, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/maoming/namespace.ts b/lib/routes/gov/maoming/namespace.ts new file mode 100644 index 000000000..987845c91 --- /dev/null +++ b/lib/routes/gov/maoming/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '茂名市人民政府', + url: 'www.maoming.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/maonan/maonan.ts b/lib/routes/gov/maonan/maonan.ts index 636397218..a79d1c86a 100644 --- a/lib/routes/gov/maonan/maonan.ts +++ b/lib/routes/gov/maonan/maonan.ts @@ -9,7 +9,7 @@ import timezone from '@/utils/timezone'; const host = 'http://www.maonan.gov.cn'; export const route: Route = { - path: '/maonan/:category', + path: '/:category', categories: ['government'], example: '/gov/maonan/zwgk', parameters: { category: '分类名' }, @@ -21,7 +21,44 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - name: '茂名市茂南区人民政府', + radar: [ + { + title: '政务公开', + source: ['www.maonan.gov.cn/zwgk/*path'], + target: '/zwgk', + }, + { + title: '政务新闻', + source: ['www.maonan.gov.cn/zwxw/*path'], + target: '/zwxw', + }, + { + title: '茂南动态', + source: ['www.maonan.gov.cn/zwxw/mndt/*path'], + target: '/mndt', + }, + { + title: '重大会议', + source: ['www.maonan.gov.cn/zwxw/zdhy/*path'], + target: '/zdhy', + }, + { + title: '公告公示', + source: ['www.maonan.gov.cn/zwgk/tzgg/*path'], + target: '/tzgg', + }, + { + title: '招录信息', + source: ['www.maonan.gov.cn/zwgk/zlxx/*path'], + target: '/zlxx', + }, + { + title: '政策解读', + source: ['www.maonan.gov.cn/zwgk/zcjd/*path'], + target: '/zcjd', + }, + ], + name: '通用', maintainers: ['ShuiHuo'], handler, description: `| 政务公开 | 政务新闻 | 茂南动态 | 重大会议 | 公告公示 | 招录信息 | 政策解读 | diff --git a/lib/routes/gov/maonan/namespace.ts b/lib/routes/gov/maonan/namespace.ts new file mode 100644 index 000000000..939d0099a --- /dev/null +++ b/lib/routes/gov/maonan/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '茂名市茂南区人民政府', + url: 'www.maonan.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/mee/namespace.ts b/lib/routes/gov/mee/namespace.ts new file mode 100644 index 000000000..51f74158c --- /dev/null +++ b/lib/routes/gov/mee/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国生态环境部', + url: 'www.mee.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/mee/nnsa.ts b/lib/routes/gov/mee/nnsa.ts index 68a8716ee..eadcca5f3 100644 --- a/lib/routes/gov/mee/nnsa.ts +++ b/lib/routes/gov/mee/nnsa.ts @@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise => { }; export const route: Route = { - path: '/mee/nnsa/:category{.+}?', + path: '/nnsa/:category{.+}?', name: '国家核安全局', url: 'nnsa.mee.gov.cn', maintainers: ['nczitzk'], @@ -245,102 +245,102 @@ export const route: Route = { radar: [ { source: ['nnsa.mee.gov.cn/:category'], - target: '/mee/nnsa/:category', + target: '/nnsa/:category', }, { title: '要闻动态 - 时政要闻', source: ['nnsa.mee.gov.cn/ywdt/szyw/'], - target: '/mee/nnsa/ywdt/szyw', + target: '/nnsa/ywdt/szyw', }, { title: '要闻动态 - 环境要闻', source: ['nnsa.mee.gov.cn/ywdt/hjyw/'], - target: '/mee/nnsa/ywdt/hjyw', + target: '/nnsa/ywdt/hjyw', }, { title: '要闻动态 - 监管动态', source: ['nnsa.mee.gov.cn/ywdt/gzdt/'], - target: '/mee/nnsa/ywdt/gzdt', + target: '/nnsa/ywdt/gzdt', }, { title: '要闻动态 - 行业资讯', source: ['nnsa.mee.gov.cn/ywdt/hyzx/'], - target: '/mee/nnsa/ywdt/hyzx', + target: '/nnsa/ywdt/hyzx', }, { title: '要闻动态 - 国际资讯', source: ['nnsa.mee.gov.cn/ywdt/gjzx/'], - target: '/mee/nnsa/ywdt/gjzx', + target: '/nnsa/ywdt/gjzx', }, { title: '要闻动态 - 公示公告', source: ['nnsa.mee.gov.cn/ywdt/gsqg/'], - target: '/mee/nnsa/ywdt/gsqg', + target: '/nnsa/ywdt/gsqg', }, { title: '要闻动态 - 曝光台', source: ['nnsa.mee.gov.cn/ywdt/bgt/'], - target: '/mee/nnsa/ywdt/bgt', + target: '/nnsa/ywdt/bgt', }, { title: '政策文件 - 中央有关文件', source: ['nnsa.mee.gov.cn/zcwj/zyygwj/'], - target: '/mee/nnsa/zcwj/zyygwj', + target: '/nnsa/zcwj/zyygwj', }, { title: '政策文件 - 国务院有关文件', source: ['nnsa.mee.gov.cn/zcwj/gwyygwj/'], - target: '/mee/nnsa/zcwj/gwyygwj', + target: '/nnsa/zcwj/gwyygwj', }, { title: '政策文件 - 部文件', source: ['nnsa.mee.gov.cn/zcwj/bwj/'], - target: '/mee/nnsa/zcwj/bwj', + target: '/nnsa/zcwj/bwj', }, { title: '政策文件 - 核安全局文件', source: ['nnsa.mee.gov.cn/zcwj/haqjwj/'], - target: '/mee/nnsa/zcwj/haqjwj', + target: '/nnsa/zcwj/haqjwj', }, { title: '政策文件 - 其他', source: ['nnsa.mee.gov.cn/zcwj/qt/'], - target: '/mee/nnsa/zcwj/qt', + target: '/nnsa/zcwj/qt', }, { title: '政策文件 - 解读', source: ['nnsa.mee.gov.cn/zcwj/jd/'], - target: '/mee/nnsa/zcwj/jd', + target: '/nnsa/zcwj/jd', }, { title: '业务工作 - 核动力厂和研究堆', source: ['nnsa.mee.gov.cn/ywdh/fyd/'], - target: '/mee/nnsa/ywdh/fyd', + target: '/nnsa/ywdh/fyd', }, { title: '业务工作 - 核燃料、放废', source: ['nnsa.mee.gov.cn/ywdh/hrlff/'], - target: '/mee/nnsa/ywdh/hrlff', + target: '/nnsa/ywdh/hrlff', }, { title: '业务工作 - 核技术、电磁、矿冶', source: ['nnsa.mee.gov.cn/ywdh/hjsdcky/'], - target: '/mee/nnsa/ywdh/hjsdcky', + target: '/nnsa/ywdh/hjsdcky', }, { title: '业务工作 - 监测与应急', source: ['nnsa.mee.gov.cn/ywdh/jcyj_1/'], - target: '/mee/nnsa/ywdh/jcyj_1', + target: '/nnsa/ywdh/jcyj_1', }, { title: '业务工作 - 核安全设备与人员', source: ['nnsa.mee.gov.cn/ywdh/haqsbry/'], - target: '/mee/nnsa/ywdh/haqsbry', + target: '/nnsa/ywdh/haqsbry', }, { title: '业务工作 - 国际合作', source: ['nnsa.mee.gov.cn/ywdh/gjhz/'], - target: '/mee/nnsa/ywdh/gjhz', + target: '/nnsa/ywdh/gjhz', }, ], view: ViewType.Articles, diff --git a/lib/routes/gov/mee/ywdt.ts b/lib/routes/gov/mee/ywdt.ts index b027d7648..2f91ded10 100644 --- a/lib/routes/gov/mee/ywdt.ts +++ b/lib/routes/gov/mee/ywdt.ts @@ -17,7 +17,7 @@ const columns = { }; export const route: Route = { - path: '/mee/ywdt/:category?', + path: '/ywdt/:category?', categories: ['government'], example: '/gov/mee/ywdt/hjywnews', parameters: { category: '分类名,预设 `szyw`' }, @@ -32,7 +32,7 @@ export const route: Route = { radar: [ { source: ['www.mee.gov.cn/ywdt/:category'], - target: '/mee/ywdt/:category', + target: '/ywdt/:category', }, ], name: '要闻动态', diff --git a/lib/routes/gov/mem/sgcc.ts b/lib/routes/gov/mem/sgcc.ts index b3574d486..f9a6fb430 100644 --- a/lib/routes/gov/mem/sgcc.ts +++ b/lib/routes/gov/mem/sgcc.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/mem/gk/sgcc/:category?', + path: '/gk/sgcc/:category?', categories: ['government'], example: '/gov/mem/gk/sgcc/tbzdsgdcbg', parameters: { category: '分类,见下表,默认为挂牌督办' }, @@ -21,7 +21,7 @@ export const route: Route = { radar: [ { source: ['www.mem.gov.cn/gk/sgcc/:category'], - target: '/mem/gk/sgcc/:category', + target: '/gk/sgcc/:category', }, ], name: '事故及灾害查处', diff --git a/lib/routes/gov/mem/zfxxgkpt.ts b/lib/routes/gov/mem/zfxxgkpt.ts index c25f7cce8..93fac727e 100644 --- a/lib/routes/gov/mem/zfxxgkpt.ts +++ b/lib/routes/gov/mem/zfxxgkpt.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/mem/gk/zfxxgkpt/fdzdgknr', + path: '/gk/zfxxgkpt/fdzdgknr', categories: ['government'], example: '/gov/mem/gk/zfxxgkpt/fdzdgknr', parameters: {}, @@ -21,7 +21,7 @@ export const route: Route = { radar: [ { source: ['www.mem.gov.cn/gk/zfxxgkpt/fdzdgknr'], - target: '/mem/gk/zfxxgkpt/fdzdgknr', + target: '/gk/zfxxgkpt/fdzdgknr', }, ], name: '法定主动公开内容', diff --git a/lib/routes/gov/mfa/namespace.ts b/lib/routes/gov/mfa/namespace.ts new file mode 100644 index 000000000..13aea5571 --- /dev/null +++ b/lib/routes/gov/mfa/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国外交部', + url: 'www.mfa.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/mfa/wjdt.ts b/lib/routes/gov/mfa/wjdt.ts index ee2375599..c1ac58b1d 100644 --- a/lib/routes/gov/mfa/wjdt.ts +++ b/lib/routes/gov/mfa/wjdt.ts @@ -19,8 +19,8 @@ const categories = { }; export const route: Route = { - path: ['/fmprc/:category?', '/mfa/wjdt/:category?'], - name: 'Unknown', + path: '/wjdt/:category?', + name: '外交动态', maintainers: ['nicolaszf', 'nczitzk'], handler, description: `| 分类 | category | diff --git a/lib/routes/gov/mgs/mgs.ts b/lib/routes/gov/mgs/mgs.ts index ea1c5256e..7f2e0ecf4 100644 --- a/lib/routes/gov/mgs/mgs.ts +++ b/lib/routes/gov/mgs/mgs.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/mgs/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/mgs/www/zwgk/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政务公开 > 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政务公开 > 政策解读](http://www.mgs.gov.cn/zwgk/zcjd/) 则将对应页面 URL 中 \`http://www.mgs.gov.cn/\` 的字段 \`www\` 和 \`zwgk/zcjd/\` 作为路径填入。此时路由为 [\`/gov/mgs/www/zwgk/zcjd/\`](https://rsshub.app/gov/mgs/www/zwgk/zcjd/) + +:::`, }; async function handler(ctx) { @@ -24,5 +33,5 @@ async function handler(ctx) { pubDate_match: '时间:(.*)', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/mgs/namespace.ts b/lib/routes/gov/mgs/namespace.ts new file mode 100644 index 000000000..a7457bd5c --- /dev/null +++ b/lib/routes/gov/mgs/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '广东茂名滨海新区', + url: 'www.mgs.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/miit/namespace.ts b/lib/routes/gov/miit/namespace.ts new file mode 100644 index 000000000..2f7a3325e --- /dev/null +++ b/lib/routes/gov/miit/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国工业和信息化部', + url: 'www.miit.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/miit/wjfb.ts b/lib/routes/gov/miit/wjfb.ts index f4e1b6340..0adfd792b 100644 --- a/lib/routes/gov/miit/wjfb.ts +++ b/lib/routes/gov/miit/wjfb.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; const rootUrl = 'https://www.miit.gov.cn'; export const route: Route = { - path: '/miit/wjfb/:ministry', + path: '/wjfb/:ministry', categories: ['government'], example: '/gov/miit/wjfb/ghs', parameters: { ministry: '部门缩写,可以在对应 URL 中获取' }, diff --git a/lib/routes/gov/miit/wjgs.ts b/lib/routes/gov/miit/wjgs.ts index ba9156c15..9a02fdc19 100644 --- a/lib/routes/gov/miit/wjgs.ts +++ b/lib/routes/gov/miit/wjgs.ts @@ -10,7 +10,7 @@ const baseUrl = 'https://www.miit.gov.cn'; const siteUrl = `${baseUrl}/zwgk/wjgs/index.html`; export const route: Route = { - path: '/miit/wjgs', + path: '/wjgs', categories: ['government'], example: '/gov/miit/wjgs', parameters: {}, diff --git a/lib/routes/gov/miit/yjzj.ts b/lib/routes/gov/miit/yjzj.ts index 8daf89dcd..8e1e45dfe 100644 --- a/lib/routes/gov/miit/yjzj.ts +++ b/lib/routes/gov/miit/yjzj.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; const rootUrl = 'https://www.miit.gov.cn'; export const route: Route = { - path: '/miit/yjzj', + path: '/yjzj', categories: ['government'], example: '/gov/miit/yjzj', parameters: {}, diff --git a/lib/routes/gov/miit/zcjd.ts b/lib/routes/gov/miit/zcjd.ts index 16888942d..6f4242f1e 100644 --- a/lib/routes/gov/miit/zcjd.ts +++ b/lib/routes/gov/miit/zcjd.ts @@ -10,7 +10,7 @@ const baseUrl = 'https://www.miit.gov.cn'; const siteUrl = `${baseUrl}/zwgk/zcjd/index.html`; export const route: Route = { - path: '/miit/zcjd', + path: '/zcjd', categories: ['government'], example: '/gov/miit/zcjd', parameters: {}, diff --git a/lib/routes/gov/miit/zcwj.ts b/lib/routes/gov/miit/zcwj.ts index 35a92504f..59bbc09dc 100644 --- a/lib/routes/gov/miit/zcwj.ts +++ b/lib/routes/gov/miit/zcwj.ts @@ -5,7 +5,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; export const route: Route = { - path: '/miit/zcwj', + path: '/zcwj', categories: ['government'], example: '/gov/miit/zcwj', parameters: {}, diff --git a/lib/routes/gov/mmht/mmht.ts b/lib/routes/gov/mmht/mmht.ts index 355cf25f8..251944948 100644 --- a/lib/routes/gov/mmht/mmht.ts +++ b/lib/routes/gov/mmht/mmht.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/mmht/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/mmht/www/xwzx/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政务公开 > 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政务公开 > 政策解读](http://www.mmht.gov.cn/xwzx/zcjd/) 则将对应页面 URL 中 \`http://www.mmht.gov.cn/\` 的字段 \`www\` 和 \`xwzx/zcjd/\` 作为路径填入。此时路由为 [\`/gov/mmht/www/xwzx/zcjd/\`](https://rsshub.app/gov/mmht/www/xwzx/zcjd/) + +:::`, }; async function handler(ctx) { @@ -24,5 +33,5 @@ async function handler(ctx) { pubDate_match: '发表时间:(.*)       信息来源', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/mmht/namespace.ts b/lib/routes/gov/mmht/namespace.ts new file mode 100644 index 000000000..21bc864ba --- /dev/null +++ b/lib/routes/gov/mmht/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '茂名高新技术产业开发区', + url: 'www.mmht.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/moa/gjs.ts b/lib/routes/gov/moa/gjs.ts index 96bf49481..7aaee429f 100644 --- a/lib/routes/gov/moa/gjs.ts +++ b/lib/routes/gov/moa/gjs.ts @@ -120,8 +120,8 @@ export const handler = async (ctx: Context): Promise => { }; export const route: Route = { - path: '/moa/gjs/:category{.+}?', - name: '中华人民共和国农业农村部国际合作司', + path: '/gjs/:category{.+}?', + name: '国际合作司', url: 'www.gjs.moa.gov.cn', maintainers: ['nczitzk'], handler, @@ -182,27 +182,27 @@ export const route: Route = { { title: '工作动态', source: ['www.gjs.moa.gov.cn/gzdt/'], - target: '/moa/gjs/gzdt', + target: '/gjs/gzdt', }, { title: '通知公告', source: ['www.gjs.moa.gov.cn/tzgg/'], - target: '/moa/gjs/tzgg', + target: '/gjs/tzgg', }, { title: '“一带一路”合作和农业走出去', source: ['www.gjs.moa.gov.cn/ydylhzhhnyzcq/'], - target: '/moa/gjs/ydylhzhhnyzcq', + target: '/gjs/ydylhzhhnyzcq', }, { title: '农业国际贸易监测与展望', source: ['www.gjs.moa.gov.cn/ncpmy/'], - target: '/moa/gjs/ncpmy', + target: '/gjs/ncpmy', }, { title: '多双边合作', source: ['www.gjs.moa.gov.cn/dsbhz/'], - target: '/moa/gjs/dsbhz', + target: '/gjs/dsbhz', }, ], view: ViewType.Articles, diff --git a/lib/routes/gov/moa/moa.ts b/lib/routes/gov/moa/moa.ts index 2c24d145b..5bbd191b6 100644 --- a/lib/routes/gov/moa/moa.ts +++ b/lib/routes/gov/moa/moa.ts @@ -9,17 +9,17 @@ const hostUrl = 'http://www.moa.gov.cn/'; const hostUrlObj = new URL(hostUrl); // 用于在下面判断 host export const route: Route = { - path: '/moa/suburl/:suburl{.+}', + path: '/suburl/:suburl{.+}', categories: ['government'], example: '/gov/moa/suburl/gk/zcjd/', radar: [ { source: ['moa.gov.cn/'], - target: '/moa/suburl/:suburl', + target: '/suburl/:suburl', }, ], parameters: { suburl: '下级目录,请使用最下级的目录' }, - name: '中华人民共和国农业农村部 - 新闻', + name: '新闻', maintainers: ['Origami404', 'lyqluis'], handler, url: 'moa.gov.cn/', diff --git a/lib/routes/gov/moa/namespace.ts b/lib/routes/gov/moa/namespace.ts new file mode 100644 index 000000000..f352ecafa --- /dev/null +++ b/lib/routes/gov/moa/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国农业农村部', + url: 'www.moa.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/moa/szcpxx.ts b/lib/routes/gov/moa/szcpxx.ts index 5a13c92d0..4b040b1d2 100644 --- a/lib/routes/gov/moa/szcpxx.ts +++ b/lib/routes/gov/moa/szcpxx.ts @@ -87,8 +87,8 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: '/moa/szcpxx', - name: '中华人民共和国农业农村部生猪专题重要政策', + path: '/szcpxx', + name: '生猪专题重要政策', url: 'www.moa.gov.cn', maintainers: ['nczitzk'], handler, @@ -109,7 +109,7 @@ export const route: Route = { radar: [ { source: ['www.moa.gov.cn/ztzl/szcpxx/zyzc/index.htm'], - target: '/moa/szcpxx', + target: '/szcpxx', }, ], }; diff --git a/lib/routes/gov/moa/zdscxx.ts b/lib/routes/gov/moa/zdscxx.ts index 8bd7335a7..e0bdc1ae0 100644 --- a/lib/routes/gov/moa/zdscxx.ts +++ b/lib/routes/gov/moa/zdscxx.ts @@ -101,8 +101,8 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: '/moa/zdscxx/:category{.+}?', - name: '中华人民共和国农业农村部数据', + path: '/zdscxx/:category{.+}?', + name: '数据', url: 'www.moa.gov.cn', maintainers: ['nczitzk'], handler, @@ -131,32 +131,32 @@ export const route: Route = { { title: '价格指数', source: ['zdscxx.moa.gov.cn:8080/nyb/pc/messageList.jsp'], - target: '/gov/moa/zdscxx/价格指数', + target: '/zdscxx/价格指数', }, { title: '供需形势', source: ['zdscxx.moa.gov.cn:8080/nyb/pc/messageList.jsp'], - target: '/gov/moa/zdscxx/供需形势', + target: '/zdscxx/供需形势', }, { title: '分析报告周报', source: ['zdscxx.moa.gov.cn:8080/nyb/pc/messageList.jsp'], - target: '/gov/moa/zdscxx/分析报告周报', + target: '/zdscxx/分析报告周报', }, { title: '分析报告日报', source: ['zdscxx.moa.gov.cn:8080/nyb/pc/messageList.jsp'], - target: '/gov/moa/zdscxx/分析报告日报', + target: '/zdscxx/分析报告日报', }, { title: '日历信息', source: ['zdscxx.moa.gov.cn:8080/nyb/pc/messageList.jsp'], - target: '/gov/moa/zdscxx/日历信息', + target: '/zdscxx/日历信息', }, { title: '蔬菜生产', source: ['zdscxx.moa.gov.cn:8080/nyb/pc/messageList.jsp'], - target: '/gov/moa/zdscxx/蔬菜生产', + target: '/zdscxx/蔬菜生产', }, ], }; diff --git a/lib/routes/gov/moe/moe.ts b/lib/routes/gov/moe/moe.ts index 99a15446d..4ba6e27c3 100644 --- a/lib/routes/gov/moe/moe.ts +++ b/lib/routes/gov/moe/moe.ts @@ -16,7 +16,7 @@ const typesIdMap = [ ]; export const route: Route = { - path: '/moe/:type', + path: '/:type', categories: ['government'], example: '/gov/moe/policy_anal', parameters: { type: '分类名' }, diff --git a/lib/routes/gov/moe/namespace.ts b/lib/routes/gov/moe/namespace.ts new file mode 100644 index 000000000..83975fafe --- /dev/null +++ b/lib/routes/gov/moe/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国教育部', + url: 'www.moe.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/moe/s78.ts b/lib/routes/gov/moe/s78.ts index 9968fb891..6860a4bf7 100644 --- a/lib/routes/gov/moe/s78.ts +++ b/lib/routes/gov/moe/s78.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/moe/s78/:column', + path: '/s78/:column', categories: ['government'], example: '/gov/moe/s78/A13', parameters: { column: '司局 ID,可在 URL 找到' }, diff --git a/lib/routes/gov/mof/bond.ts b/lib/routes/gov/mof/bond.ts index 6e703b03a..980f4f661 100644 --- a/lib/routes/gov/mof/bond.ts +++ b/lib/routes/gov/mof/bond.ts @@ -10,7 +10,7 @@ const domain = 'gks.mof.gov.cn'; const theme = 'guozaiguanli'; export const route: Route = { - path: '/mof/bond/:category?', + path: '/bond/:category?', categories: ['government'], example: '/gov/mof/bond', parameters: { category: '专题,见下表,默认为国债管理工作动态' }, diff --git a/lib/routes/gov/mof/gss.ts b/lib/routes/gov/mof/gss.ts index e424ad60d..c60b0954b 100644 --- a/lib/routes/gov/mof/gss.ts +++ b/lib/routes/gov/mof/gss.ts @@ -54,7 +54,7 @@ const handler = async (ctx: Context): Promise => { }; export const route: Route = { - path: '/mof/gss/:category?', + path: '/gss/:category?', categories: ['government'], example: '/gov/mof/gss', parameters: { category: '列表标签,默认为政策发布' }, @@ -77,7 +77,7 @@ export const route: Route = { radar: [ { source: ['gss.mof.gov.cn/gzdt/:category/'], - target: '/mof/gss/:category', + target: '/gss/:category', }, ], }; diff --git a/lib/routes/gov/mof/namespace.ts b/lib/routes/gov/mof/namespace.ts new file mode 100644 index 000000000..5134b02e4 --- /dev/null +++ b/lib/routes/gov/mof/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国财政部', + url: 'www.mof.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/mofcom/article.ts b/lib/routes/gov/mofcom/article.ts index d861364e4..cbda728c8 100644 --- a/lib/routes/gov/mofcom/article.ts +++ b/lib/routes/gov/mofcom/article.ts @@ -9,9 +9,11 @@ import timezone from '@/utils/timezone'; const host = 'http://www.mofcom.gov.cn'; export const route: Route = { - path: '/mofcom/article/:suffix{.+}', - name: 'Unknown', - maintainers: [], + path: '/article/:suffix{.+}', + name: '政务公开', + example: '/gov/mofcom/article/b', + parameters: { suffix: '支持形如 `http://www.mofcom.gov.cn/article/*` 的网站,传入 article 之后的后缀' }, + maintainers: ['LogicJake'], handler, }; @@ -42,7 +44,7 @@ async function handler(ctx) { }; }); - await Promise.all( + const items = await Promise.all( list.map((item) => cache.tryGet(item.link, async () => { let responses = await got(item.link); @@ -73,6 +75,6 @@ async function handler(ctx) { title: $('head > title').text(), description: $('meta[name=description]').attr('content'), link: url, - item: list, + item: items, }; } diff --git a/lib/routes/gov/mofcom/namespace.ts b/lib/routes/gov/mofcom/namespace.ts new file mode 100644 index 000000000..4096dbf5b --- /dev/null +++ b/lib/routes/gov/mofcom/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国商务部', + url: 'www.mofcom.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/moj/aac/news.ts b/lib/routes/gov/moj/aac/news.ts index e1676f5e6..a90f07107 100644 --- a/lib/routes/gov/moj/aac/news.ts +++ b/lib/routes/gov/moj/aac/news.ts @@ -9,7 +9,7 @@ import timezone from '@/utils/timezone'; const baseUrl = 'https://www.aac.moj.gov.tw'; export const route: Route = { - path: '/moj/aac/news/:type?', + path: '/aac/news/:type?', categories: ['government'], example: '/gov/moj/aac/news', parameters: { type: '資料大類,留空為全部' }, diff --git a/lib/routes/gov/moj/lfyjzj.ts b/lib/routes/gov/moj/lfyjzj.ts index d8e771a95..5fe35d1c4 100644 --- a/lib/routes/gov/moj/lfyjzj.ts +++ b/lib/routes/gov/moj/lfyjzj.ts @@ -9,7 +9,7 @@ import timezone from '@/utils/timezone'; const DOMAIN = 'www.moj.gov.cn'; export const route: Route = { - path: '/moj/lfyjzj', + path: '/lfyjzj', categories: ['government'], example: '/gov/moj/lfyjzj', parameters: {}, diff --git a/lib/routes/gov/moj/namespace.ts b/lib/routes/gov/moj/namespace.ts new file mode 100644 index 000000000..55a4f7ad3 --- /dev/null +++ b/lib/routes/gov/moj/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国司法部', + url: 'www.moj.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/mot/index.ts b/lib/routes/gov/mot/index.ts index 7c9b58aa0..a45e08f97 100644 --- a/lib/routes/gov/mot/index.ts +++ b/lib/routes/gov/mot/index.ts @@ -111,8 +111,8 @@ export const handler = async (ctx: Context): Promise => { }; export const route: Route = { - path: '/mot/:category{.+}?', - name: '中华人民共和国交通运输部', + path: '/:category{.+}?', + name: '通用', url: 'www.mot.gov.cn', maintainers: ['ladeng07', 'nczitzk'], handler, @@ -161,17 +161,17 @@ export const route: Route = { { title: '交通要闻', source: ['www.mot.gov.cn/jiaotongyaowen/'], - target: '/mot/jiaotongyaowen', + target: '/jiaotongyaowen', }, { title: '时政要闻', source: ['www.mot.gov.cn/shizhengyaowen/'], - target: '/mot/shizhengyaowen', + target: '/shizhengyaowen', }, { title: '重要会议', source: ['www.mot.gov.cn/zhongyaohuiyi/'], - target: '/mot/zhongyaohuiyi', + target: '/zhongyaohuiyi', }, ], view: ViewType.Articles, diff --git a/lib/routes/gov/mot/namespace.ts b/lib/routes/gov/mot/namespace.ts new file mode 100644 index 000000000..479b5ab2d --- /dev/null +++ b/lib/routes/gov/mot/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中华人民共和国交通运输部', + url: 'www.mot.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/ndrc/fggz.ts b/lib/routes/gov/ndrc/fggz.ts index 118edca9e..a7eccaa18 100644 --- a/lib/routes/gov/ndrc/fggz.ts +++ b/lib/routes/gov/ndrc/fggz.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/ndrc/fggz/:category{.+}?', + path: '/fggz/:category{.+}?', name: '发展改革工作', example: '/gov/ndrc/fggz', parameters: { category: '分类,见下表,默认为全部' }, @@ -198,452 +198,452 @@ export const route: Route = { { title: '机关办公 - 业务工作', source: ['ndrc.gov.cn/fggz/jgbg/ywgz'], - target: '/ndrc/fggz/jgbg/ywgz', + target: '/fggz/jgbg/ywgz', }, { title: '机关办公 - 学思践悟', source: ['ndrc.gov.cn/fggz/jgbg/xsjw'], - target: '/ndrc/fggz/jgbg/xsjw', + target: '/fggz/jgbg/xsjw', }, { title: '发改政研 - 经济数据概览', source: ['ndrc.gov.cn/fggz/fgzy/jjsjgl'], - target: '/ndrc/fggz/fgzy/jjsjgl', + target: '/fggz/fgzy/jjsjgl', }, { title: '发改政研 - 社会关切回应', source: ['ndrc.gov.cn/fggz/fgzy/shgqhy'], - target: '/ndrc/fggz/fgzy/shgqhy', + target: '/fggz/fgzy/shgqhy', }, { title: '发改政研 - 新媒体解读', source: ['ndrc.gov.cn/fggz/fgzy/xmtjd'], - target: '/ndrc/fggz/fgzy/xmtjd', + target: '/fggz/fgzy/xmtjd', }, { title: '发展战略和规划 - 国家发展战略和规划', source: ['ndrc.gov.cn/fggz/fzzlgh/gjfzgh'], - target: '/ndrc/fggz/fzzlgh/gjfzgh', + target: '/fggz/fzzlgh/gjfzgh', }, { title: '发展战略和规划 - 国家级专项规划', source: ['ndrc.gov.cn/fggz/fzzlgh/gjjzxgh'], - target: '/ndrc/fggz/fzzlgh/gjjzxgh', + target: '/fggz/fzzlgh/gjjzxgh', }, { title: '发展战略和规划 - 地方发展规划', source: ['ndrc.gov.cn/fggz/fzzlgh/dffzgh'], - target: '/ndrc/fggz/fzzlgh/dffzgh', + target: '/fggz/fzzlgh/dffzgh', }, { title: '发展战略和规划 - 发展规划工作', source: ['ndrc.gov.cn/fggz/fzzlgh/fzgggz'], - target: '/ndrc/fggz/fzzlgh/fzgggz', + target: '/fggz/fzzlgh/fzgggz', }, { title: '发改综合 - 国内经济监测', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc'], - target: '/ndrc/fggz/fgzh/gnjjjc', + target: '/fggz/fgzh/gnjjjc', }, { title: '发改综合 - 工业经济', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/gyjj'], - target: '/ndrc/fggz/fgzh/gnjjjc/gyjj', + target: '/fggz/fgzh/gnjjjc/gyjj', }, { title: '发改综合 - 投资运行', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/tzyx'], - target: '/ndrc/fggz/fgzh/gnjjjc/tzyx', + target: '/fggz/fgzh/gnjjjc/tzyx', }, { title: '发改综合 - 市场消费', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/scxf'], - target: '/ndrc/fggz/fgzh/gnjjjc/scxf', + target: '/fggz/fgzh/gnjjjc/scxf', }, { title: '发改综合 - 价格情况', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/jgqk'], - target: '/ndrc/fggz/fgzh/gnjjjc/jgqk', + target: '/fggz/fgzh/gnjjjc/jgqk', }, { title: '发改综合 - 财政收支', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/czsz'], - target: '/ndrc/fggz/fgzh/gnjjjc/czsz', + target: '/fggz/fgzh/gnjjjc/czsz', }, { title: '发改综合 - 货币金融', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/hbjr'], - target: '/ndrc/fggz/fgzh/gnjjjc/hbjr', + target: '/fggz/fgzh/gnjjjc/hbjr', }, { title: '发改综合 - 就业情况', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/jyqk'], - target: '/ndrc/fggz/fgzh/gnjjjc/jyqk', + target: '/fggz/fgzh/gnjjjc/jyqk', }, { title: '发改综合 - 地区经济', source: ['ndrc.gov.cn/fggz/fgzh/gnjjjc/dqjj'], - target: '/ndrc/fggz/fgzh/gnjjjc/dqjj', + target: '/fggz/fgzh/gnjjjc/dqjj', }, { title: '发改综合 - 国际经济监测', source: ['ndrc.gov.cn/fggz/fgzh/gjjjjc'], - target: '/ndrc/fggz/fgzh/gjjjjc', + target: '/fggz/fgzh/gjjjjc', }, { title: '发改综合 - 先行指数', source: ['ndrc.gov.cn/fggz/fgzh/gjjjjc/xxzs'], - target: '/ndrc/fggz/fgzh/gjjjjc/xxzs', + target: '/fggz/fgzh/gjjjjc/xxzs', }, { title: '发改综合 - 大宗商品市场情况', source: ['ndrc.gov.cn/fggz/fgzh/gjjjjc/dzspscqk'], - target: '/ndrc/fggz/fgzh/gjjjjc/dzspscqk', + target: '/fggz/fgzh/gjjjjc/dzspscqk', }, { title: '发改综合 - 国别分析', source: ['ndrc.gov.cn/fggz/fgzh/gjjjjc/gbfx'], - target: '/ndrc/fggz/fgzh/gjjjjc/gbfx', + target: '/fggz/fgzh/gjjjjc/gbfx', }, { title: '发改综合 - 国际组织预测和研究动态', source: ['ndrc.gov.cn/fggz/fgzh/gjzzychyjdt'], - target: '/ndrc/fggz/fgzh/gjzzychyjdt', + target: '/fggz/fgzh/gjzzychyjdt', }, { title: '发改综合 - 国际组织预测', source: ['ndrc.gov.cn/fggz/fgzh/gjzzychyjdt/gjzzyc'], - target: '/ndrc/fggz/fgzh/gjzzychyjdt/gjzzyc', + target: '/fggz/fgzh/gjzzychyjdt/gjzzyc', }, { title: '发改综合 - 国际组织研究动态', source: ['ndrc.gov.cn/fggz/fgzh/gjzzychyjdt/gjzzyjdt'], - target: '/ndrc/fggz/fgzh/gjzzychyjdt/gjzzyjdt', + target: '/fggz/fgzh/gjzzychyjdt/gjzzyjdt', }, { title: '经济运行与调节 - 宏观经济运行', source: ['ndrc.gov.cn/fggz/jjyxtj/hgjjyx'], - target: '/ndrc/fggz/jjyxtj/hgjjyx', + target: '/fggz/jjyxtj/hgjjyx', }, { title: '经济运行与调节 - 地方经济运行', source: ['ndrc.gov.cn/fggz/jjyxtj/dfjjyx'], - target: '/ndrc/fggz/jjyxtj/dfjjyx', + target: '/fggz/jjyxtj/dfjjyx', }, { title: '经济运行与调节 - 煤电油气运', source: ['ndrc.gov.cn/fggz/jjyxtj/mdyqy'], - target: '/ndrc/fggz/jjyxtj/mdyqy', + target: '/fggz/jjyxtj/mdyqy', }, { title: '经济运行与调节 - 现代物流', source: ['ndrc.gov.cn/fggz/jjyxtj/xdwl'], - target: '/ndrc/fggz/jjyxtj/xdwl', + target: '/fggz/jjyxtj/xdwl', }, { title: '经济运行与调节 - 应急管理', source: ['ndrc.gov.cn/fggz/jjyxtj/yjgl'], - target: '/ndrc/fggz/jjyxtj/yjgl', + target: '/fggz/jjyxtj/yjgl', }, { title: '体制改革 - 改革快讯', source: ['ndrc.gov.cn/fggz/tzgg/ggkx'], - target: '/ndrc/fggz/tzgg/ggkx', + target: '/fggz/tzgg/ggkx', }, { title: '体制改革 - 半月改革动态', source: ['ndrc.gov.cn/fggz/tzgg/byggdt'], - target: '/ndrc/fggz/tzgg/byggdt', + target: '/fggz/tzgg/byggdt', }, { title: '体制改革 - 地方改革经验', source: ['ndrc.gov.cn/fggz/tzgg/dfggjx'], - target: '/ndrc/fggz/tzgg/dfggjx', + target: '/fggz/tzgg/dfggjx', }, { title: '固定资产投资 - 投资法规与政策动态', source: ['ndrc.gov.cn/fggz/gdzctz/tzfg'], - target: '/ndrc/fggz/gdzctz/tzfg', + target: '/fggz/gdzctz/tzfg', }, { title: '利用外资和境外投资 - 境外投资', source: ['ndrc.gov.cn/fggz/lywzjw/jwtz'], - target: '/ndrc/fggz/lywzjw/jwtz', + target: '/fggz/lywzjw/jwtz', }, { title: '利用外资和境外投资 - 外商投资', source: ['ndrc.gov.cn/fggz/lywzjw/wstz'], - target: '/ndrc/fggz/lywzjw/wstz', + target: '/fggz/lywzjw/wstz', }, { title: '利用外资和境外投资 - 外债管理', source: ['ndrc.gov.cn/fggz/lywzjw/wzgl'], - target: '/ndrc/fggz/lywzjw/wzgl', + target: '/fggz/lywzjw/wzgl', }, { title: '利用外资和境外投资 - 政策法规', source: ['ndrc.gov.cn/fggz/lywzjw/zcfg'], - target: '/ndrc/fggz/lywzjw/zcfg', + target: '/fggz/lywzjw/zcfg', }, { title: '地区经济 - 重大战略', source: ['ndrc.gov.cn/fggz/dqjj/zdzl'], - target: '/ndrc/fggz/dqjj/zdzl', + target: '/fggz/dqjj/zdzl', }, { title: '地区经济 - 四大板块', source: ['ndrc.gov.cn/fggz/dqjj/sdbk'], - target: '/ndrc/fggz/dqjj/sdbk', + target: '/fggz/dqjj/sdbk', }, { title: '地区经济 - 国土海洋流域新区', source: ['ndrc.gov.cn/fggz/dqjj/qt'], - target: '/ndrc/fggz/dqjj/qt', + target: '/fggz/dqjj/qt', }, { title: '地区振兴 - 巩固拓展脱贫攻坚成果和欠发达地区振兴发展', source: ['ndrc.gov.cn/fggz/dqzx/tpgjypkfq'], - target: '/ndrc/fggz/dqzx/tpgjypkfq', + target: '/fggz/dqzx/tpgjypkfq', }, { title: '地区振兴 - 对口支援与合作', source: ['ndrc.gov.cn/fggz/dqzx/dkzyyhz'], - target: '/ndrc/fggz/dqzx/dkzyyhz', + target: '/fggz/dqzx/dkzyyhz', }, { title: '地区振兴 - 革命老区振兴发展', source: ['ndrc.gov.cn/fggz/dqzx/gglqzxfz'], - target: '/ndrc/fggz/dqzx/gglqzxfz', + target: '/fggz/dqzx/gglqzxfz', }, { title: '地区振兴 - 生态退化地区治理', source: ['ndrc.gov.cn/fggz/dqzx/stthdqzl'], - target: '/ndrc/fggz/dqzx/stthdqzl', + target: '/fggz/dqzx/stthdqzl', }, { title: '地区振兴 - 资源型地区转型发展', source: ['ndrc.gov.cn/fggz/dqzx/zyxdqzxfz'], - target: '/ndrc/fggz/dqzx/zyxdqzxfz', + target: '/fggz/dqzx/zyxdqzxfz', }, { title: '地区振兴 - 老工业地区振兴发展', source: ['ndrc.gov.cn/fggz/dqzx/lzydfzxfz'], - target: '/ndrc/fggz/dqzx/lzydfzxfz', + target: '/fggz/dqzx/lzydfzxfz', }, { title: '区域开放 - 信息集萃', source: ['ndrc.gov.cn/fggz/qykf/xxjc'], - target: '/ndrc/fggz/qykf/xxjc', + target: '/fggz/qykf/xxjc', }, { title: '农业农村经济 - 重点建设', source: ['ndrc.gov.cn/fggz/nyncjj/zdjs'], - target: '/ndrc/fggz/nyncjj/zdjs', + target: '/fggz/nyncjj/zdjs', }, { title: '农业农村经济 - 投资指南', source: ['ndrc.gov.cn/fggz/nyncjj/tzzn'], - target: '/ndrc/fggz/nyncjj/tzzn', + target: '/fggz/nyncjj/tzzn', }, { title: '农业农村经济 - 乡村振兴', source: ['ndrc.gov.cn/fggz/nyncjj/xczx'], - target: '/ndrc/fggz/nyncjj/xczx', + target: '/fggz/nyncjj/xczx', }, { title: '农业农村经济 - 农经信息', source: ['ndrc.gov.cn/fggz/nyncjj/njxx'], - target: '/ndrc/fggz/nyncjj/njxx', + target: '/fggz/nyncjj/njxx', }, { title: '基础设施发展 - 政策规划', source: ['ndrc.gov.cn/fggz/zcssfz/zcgh'], - target: '/ndrc/fggz/zcssfz/zcgh', + target: '/fggz/zcssfz/zcgh', }, { title: '基础设施发展 - 城轨监管', source: ['ndrc.gov.cn/fggz/zcssfz/cgjg'], - target: '/ndrc/fggz/zcssfz/cgjg', + target: '/fggz/zcssfz/cgjg', }, { title: '基础设施发展 - 重大工程', source: ['ndrc.gov.cn/fggz/zcssfz/zdgc'], - target: '/ndrc/fggz/zcssfz/zdgc', + target: '/fggz/zcssfz/zdgc', }, { title: '基础设施发展 - 问题研究', source: ['ndrc.gov.cn/fggz/zcssfz/wtyj'], - target: '/ndrc/fggz/zcssfz/wtyj', + target: '/fggz/zcssfz/wtyj', }, { title: '基础设施发展 - 行业数据', source: ['ndrc.gov.cn/fggz/zcssfz/hysj'], - target: '/ndrc/fggz/zcssfz/hysj', + target: '/fggz/zcssfz/hysj', }, { title: '基础设施发展 - 地方发展', source: ['ndrc.gov.cn/fggz/zcssfz/dffz'], - target: '/ndrc/fggz/zcssfz/dffz', + target: '/fggz/zcssfz/dffz', }, { title: '产业发展 - 制造业发展', source: ['ndrc.gov.cn/fggz/cyfz/zcyfz'], - target: '/ndrc/fggz/cyfz/zcyfz', + target: '/fggz/cyfz/zcyfz', }, { title: '产业发展 - 服务业发展', source: ['ndrc.gov.cn/fggz/cyfz/fwyfz'], - target: '/ndrc/fggz/cyfz/fwyfz', + target: '/fggz/cyfz/fwyfz', }, { title: '创新和高技术发展 - 地方进展', source: ['ndrc.gov.cn/fggz/cxhgjsfz/dfjz'], - target: '/ndrc/fggz/cxhgjsfz/dfjz', + target: '/fggz/cxhgjsfz/dfjz', }, { title: '环境与资源 - 碳达峰碳中和', source: ['ndrc.gov.cn/fggz/hjyzy/tdftzh'], - target: '/ndrc/fggz/hjyzy/tdftzh', + target: '/fggz/hjyzy/tdftzh', }, { title: '环境与资源 - 生态文明建设', source: ['ndrc.gov.cn/fggz/hjyzy/stwmjs'], - target: '/ndrc/fggz/hjyzy/stwmjs', + target: '/fggz/hjyzy/stwmjs', }, { title: '环境与资源 - 节能和能效', source: ['ndrc.gov.cn/fggz/hjyzy/jnhnx'], - target: '/ndrc/fggz/hjyzy/jnhnx', + target: '/fggz/hjyzy/jnhnx', }, { title: '环境与资源 - 资源利用和循环经济', source: ['ndrc.gov.cn/fggz/hjyzy/zyzhlyhxhjj'], - target: '/ndrc/fggz/hjyzy/zyzhlyhxhjj', + target: '/fggz/hjyzy/zyzhlyhxhjj', }, { title: '环境与资源 - 水节约与保护', source: ['ndrc.gov.cn/fggz/hjyzy/sjyybh'], - target: '/ndrc/fggz/hjyzy/sjyybh', + target: '/fggz/hjyzy/sjyybh', }, { title: '环境与资源 - 环境与保护', source: ['ndrc.gov.cn/fggz/hjyzy/hjybh'], - target: '/ndrc/fggz/hjyzy/hjybh', + target: '/fggz/hjyzy/hjybh', }, { title: '就业与收入 - 就业收入社保消费', source: ['ndrc.gov.cn/fggz/jyysr/jysrsbxf'], - target: '/ndrc/fggz/jyysr/jysrsbxf', + target: '/fggz/jyysr/jysrsbxf', }, { title: '就业与收入 - 地方经验', source: ['ndrc.gov.cn/fggz/jyysr/dfjx'], - target: '/ndrc/fggz/jyysr/dfjx', + target: '/fggz/jyysr/dfjx', }, { title: '经济贸易 - 重要商品情况', source: ['ndrc.gov.cn/fggz/jjmy/zyspqk'], - target: '/ndrc/fggz/jjmy/zyspqk', + target: '/fggz/jjmy/zyspqk', }, { title: '经济贸易 - 对外经贸及政策分析', source: ['ndrc.gov.cn/fggz/jjmy/dwjmjzcfx'], - target: '/ndrc/fggz/jjmy/dwjmjzcfx', + target: '/fggz/jjmy/dwjmjzcfx', }, { title: '经济贸易 - 流通业发展', source: ['ndrc.gov.cn/fggz/jjmy/ltyfz'], - target: '/ndrc/fggz/jjmy/ltyfz', + target: '/fggz/jjmy/ltyfz', }, { title: '财金信用 - 工作动态', source: ['ndrc.gov.cn/fggz/cjxy/gzdt03'], - target: '/ndrc/fggz/cjxy/gzdt03', + target: '/fggz/cjxy/gzdt03', }, { title: '价格管理 - 地方工作', source: ['ndrc.gov.cn/fggz/jggl/dfgz'], - target: '/ndrc/fggz/jggl/dfgz', + target: '/fggz/jggl/dfgz', }, { title: '发改法规 - 地方信息', source: ['ndrc.gov.cn/fggz/fgfg/dfxx'], - target: '/ndrc/fggz/fgfg/dfxx', + target: '/fggz/fgfg/dfxx', }, { title: '国际合作 - 世经动态', source: ['ndrc.gov.cn/fggz/gjhz/zywj'], - target: '/ndrc/fggz/gjhz/zywj', + target: '/fggz/gjhz/zywj', }, { title: '干部之家 - 系统风采', source: ['ndrc.gov.cn/fggz/gbzj/xtfc'], - target: '/ndrc/fggz/gbzj/xtfc', + target: '/fggz/gbzj/xtfc', }, { title: '干部之家 - 人才招聘', source: ['ndrc.gov.cn/fggz/gbzj/rczp'], - target: '/ndrc/fggz/gbzj/rczp', + target: '/fggz/gbzj/rczp', }, { title: '干部之家 - 委属工作', source: ['ndrc.gov.cn/fggz/gbzj/wsgz'], - target: '/ndrc/fggz/gbzj/wsgz', + target: '/fggz/gbzj/wsgz', }, { title: '干部之家 - 学习园地', source: ['ndrc.gov.cn/fggz/gbzj/xxyd'], - target: '/ndrc/fggz/gbzj/xxyd', + target: '/fggz/gbzj/xxyd', }, { title: '评估督导 - 评督动态', source: ['ndrc.gov.cn/fggz/pgdd/pddt'], - target: '/ndrc/fggz/pgdd/pddt', + target: '/fggz/pgdd/pddt', }, { title: '评估督导 - 评督经验', source: ['ndrc.gov.cn/fggz/pgdd/pdjy'], - target: '/ndrc/fggz/pgdd/pdjy', + target: '/fggz/pgdd/pdjy', }, { title: '发改党建 - 中央精神', source: ['ndrc.gov.cn/fggz/fgdj/zydj'], - target: '/ndrc/fggz/fgdj/zydj', + target: '/fggz/fgdj/zydj', }, { title: '发改党建 - 机关党建', source: ['ndrc.gov.cn/fggz/fgdj/jgdj'], - target: '/ndrc/fggz/fgdj/jgdj', + target: '/fggz/fgdj/jgdj', }, { title: '发改党建 - 委属党建', source: ['ndrc.gov.cn/fggz/fgdj/wsdj'], - target: '/ndrc/fggz/fgdj/wsdj', + target: '/fggz/fgdj/wsdj', }, { title: '发改党建 - 系统党建', source: ['ndrc.gov.cn/fggz/fgdj/xtdj'], - target: '/ndrc/fggz/fgdj/xtdj', + target: '/fggz/fgdj/xtdj', }, { title: '发改金辉 - 党建之窗', source: ['ndrc.gov.cn/fggz/fgjh/djzc'], - target: '/ndrc/fggz/fgjh/djzc', + target: '/fggz/fgjh/djzc', }, { title: '发改金辉 - 系统交流', source: ['ndrc.gov.cn/fggz/fgjh/zthd'], - target: '/ndrc/fggz/fgjh/zthd', + target: '/fggz/fgjh/zthd', }, { title: '发改金辉 - 学习园地', source: ['ndrc.gov.cn/fggz/fgjh/yxyd'], - target: '/ndrc/fggz/fgjh/yxyd', + target: '/fggz/fgjh/yxyd', }, { title: '发改金辉 - 金色夕阳', source: ['ndrc.gov.cn/fggz/fgjh/jsxy'], - target: '/ndrc/fggz/fgjh/jsxy', + target: '/fggz/fgjh/jsxy', }, ], }; diff --git a/lib/routes/gov/ndrc/xwdt.ts b/lib/routes/gov/ndrc/xwdt.ts index ddb1b5167..b4c9979e1 100644 --- a/lib/routes/gov/ndrc/xwdt.ts +++ b/lib/routes/gov/ndrc/xwdt.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/ndrc/xwdt/:category{.+}?', + path: '/xwdt/:category{.+}?', name: '新闻动态', example: '/gov/ndrc/xwdt', parameters: { category: '分类,见下表,默认为新闻发布' }, diff --git a/lib/routes/gov/ndrc/zfxxgk.ts b/lib/routes/gov/ndrc/zfxxgk.ts index 6a6f67e2e..5e270ecf0 100644 --- a/lib/routes/gov/ndrc/zfxxgk.ts +++ b/lib/routes/gov/ndrc/zfxxgk.ts @@ -77,9 +77,8 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: ['/ndrc/zfxxgk'], - // path: ['/ndrc/zfxxgk', '/ndrc/zfxxgk/iteminfo'], - name: '中华人民共和国国家发展和改革委员会政府信息公开', + path: '/zfxxgk', + name: '政府信息公开', url: 'zfxxgk.ndrc.gov.cn', maintainers: ['howfool', 'nczitzk'], handler, @@ -100,7 +99,7 @@ export const route: Route = { radar: [ { source: ['zfxxgk.ndrc.gov.cn/web/dirlist.jsp'], - target: '/ndrc/zfxxgk', + target: '/zfxxgk', }, ], }; diff --git a/lib/routes/gov/nea/bureau.ts b/lib/routes/gov/nea/bureau.ts index 258422c30..9bfb84119 100644 --- a/lib/routes/gov/nea/bureau.ts +++ b/lib/routes/gov/nea/bureau.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/nea/sjzz/:bureau', + path: '/sjzz/:bureau', categories: ['government'], example: '/gov/nea/sjzz/ghs', parameters: { @@ -42,7 +42,7 @@ export const route: Route = { radar: [ { source: ['nea.gov.cn/sjzz/:bureau/index.htm'], - target: '/nea/sjzz/:bureau', + target: '/sjzz/:bureau', }, ], name: '司工作进展', diff --git a/lib/routes/gov/nfra/index.ts b/lib/routes/gov/nfra/index.ts new file mode 100644 index 000000000..361ec87ed --- /dev/null +++ b/lib/routes/gov/nfra/index.ts @@ -0,0 +1,362 @@ +import { load } from 'cheerio'; + +import type { Route } from '@/types'; +import cache from '@/utils/cache'; +import ofetch from '@/utils/ofetch'; +import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; + +export const handler = async (ctx) => { + const { id = '915' } = ctx.req.param(); + const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 18; + + const rootUrl = 'https://www.nfra.gov.cn'; + const apiUrl = new URL(`cn/static/data/DocInfo/SelectDocByItemIdAndChild/data_itemId=${id},pageIndex=1,pageSize=18.json`, rootUrl).href; + const apiBreadUrl = new URL(`cn/static/data/item/getItemBread/data_itemId=${id}.json`, rootUrl).href; + + const breadResponse = await ofetch(apiBreadUrl); + + const item = breadResponse.data.find((b) => String(b.itemId) === id); + + const currentUrl = new URL(`cn/view/pages/ItemList.html?itemPId=${item.itemPid}&itemId=${id}&itemUrl=ItemListRightList.html`, rootUrl).href; + + const response = await ofetch(apiUrl); + + let items = response.data.rows.slice(0, limit).map((item) => { + const title = item.docTitle; + const description = item.docSubtitle; + const guid = item.docId; + + return { + title, + description, + pubDate: timezone(parseDate(item.publishDate), +8), + link: new URL(`cn/view/pages/ItemDetail.html?docId=${guid}`, rootUrl).href, + guid, + id: guid, + content: { + html: description, + text: description, + }, + enclosure_url: new URL(item.pdfFileUrl, rootUrl).href, + enclosure_type: 'application/pdf', + enclosure_title: title, + }; + }); + + items = await Promise.all( + items.map((item) => + cache.tryGet(item.link, async () => { + const apiDocUrl = new URL(`cn/static/data/DocInfo/SelectByDocId/data_docId=${item.guid}.json`, rootUrl).href; + + const detailResponse = await ofetch(apiDocUrl); + + const data = detailResponse.data; + + const $$ = load(data.docClob); + + const title = data.docTitle; + const description = $$('div.Section0').html(); + + item.title = title; + item.description = description; + item.pubDate = timezone(parseDate(data.publishDate), +8); + item.category = data.listTwoItem?.[0]?.ItemLvs.map((c) => c.itemName); + item.author = data.docSource; + item.guid = `cbirc-${item.guid}`; + item.id = item.guid; + item.content = { + html: description, + text: $$('div.Section0').text(), + }; + item.updated = parseDate(data.docEditdate); + item.language = $$('html').prop('lang') || ''; + + return item; + }) + ) + ); + + const currentResponse = await ofetch(currentUrl); + + const $ = load(currentResponse); + + $('a.lyxd').remove(); + + const language = $('html').prop('lang') || ''; + + const imageSrc = $('div.header-left img').prop('src'); + const image = imageSrc ? new URL(imageSrc, rootUrl).href : ''; + + return { + title: `${$('title').text()} - ${item.itemName}`, + description: item.desc, + link: currentUrl, + item: items, + allowEmpty: true, + image, + author: item.type, + language, + }; +}; + +export const route: Route = { + path: '/:id?', + name: '分类', + url: 'www.nfra.gov.cn', + maintainers: ['nczitzk', 'JkCheung'], + handler, + example: '/gov/nfra/915', + parameters: { id: '分类,默认为监管动态,即 915,可在对应分类页 URL 中找到' }, + description: `::: tip +若订阅 [监管动态](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemId=915\\&itemUrl=ItemListRightList.html),网址为 \`https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemId=915&itemUrl=ItemListRightList.html\`。截取 \`itemId\` 的值 \`915\` 作为参数填入,此时路由为 [\`/gov/nfra/915\`](https://rsshub.app/gov/nfra/915)。 +::: + +#### [首页](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=899\\&itemId=971\\&itemUrl=ItemListRightMore.html) + +| [弹出公告](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=971\\&itemId=972\\&itemUrl=sss) | [法律声明](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=971\\&itemId=4128\\&itemUrl=ItemListRightArticle.html) | +| ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| [972](https://rsshub.app/gov/nfra/972) | [4128](https://rsshub.app/gov/nfra/4128) | + +#### [机构概况](https://www.nfra.gov.cn/cn/view/pages/jigougaikuang/jigougaikuang.html) + +| [主要职责](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=901\\&itemUrl=ItemListRightArticle.html) | [总局领导](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=902\\&itemUrl=jigougaikuang/huilingdao.html) | [内设机构](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=911\\&itemUrl=jigougaikuang/neishejigou.html) | [直属行政机构](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=4243\\&itemUrl=jigougaikuang/zhishuxingzhengjigou.html) | [派出机构](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=912\\&itemUrl=jigougaikuang/paichujigou.html) | +| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| [901](https://rsshub.app/gov/nfra/901) | [902](https://rsshub.app/gov/nfra/902) | [911](https://rsshub.app/gov/nfra/911) | [4243](https://rsshub.app/gov/nfra/4243) | [912](https://rsshub.app/gov/nfra/912) | + +| [联系方式](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=900\\&itemId=913\\&itemUrl=jigougaikuang/lianxifangshi.html) | +| --------------------------------------------------------------------------------------------------------------------------------- | +| [913](https://rsshub.app/gov/nfra/913) | + +#### [新闻资讯](https://www.nfra.gov.cn/cn/view/pages/xinwenzixun/xinwenzixun.html) + +| [监管动态](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=915\\&itemUrl=ItemListRightList.html) | [政策解读](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=916\\&itemUrl=ItemListRightMore.html) | [领导活动及讲话](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=919\\&itemUrl=ItemListRightList.html) | [新闻发布会及访谈](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=920\\&itemUrl=xinwenzixun/xinwenfabu.html) | [新闻发言人](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=914\\&itemId=921\\&itemUrl=xinwenzixun/xinwenfayan.html) | +| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | +| [915](https://rsshub.app/gov/nfra/915) | [916](https://rsshub.app/gov/nfra/916) | [919](https://rsshub.app/gov/nfra/919) | [920](https://rsshub.app/gov/nfra/920) | [921](https://rsshub.app/gov/nfra/921) | + +#### [政务信息](https://www.nfra.gov.cn/cn/view/pages/zhengwuxinxi/zhengwuxinxi.html) + +| [政府信息公开](https://www.nfra.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html) | [公告通知](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=925\\&itemUrl=ItemListRightList.html) | [政策法规](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=926\\&itemUrl=ItemListRightMore.html) | [行政许可](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=930\\&itemUrl=zhengwuxinxi/xingzhengxuke.html) | [行政处罚](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=931\\&itemUrl=zhengwuxinxi/xingzhengchufa.html) | +| ------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | +| [924](https://rsshub.app/gov/nfra/924) | [925](https://rsshub.app/gov/nfra/925) | [926](https://rsshub.app/gov/nfra/926) | [930](https://rsshub.app/gov/nfra/930) | [931](https://rsshub.app/gov/nfra/931) | + +| [行政监管措施](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=932\\&itemUrl=ItemListRightList.html) | [人事信息](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=923\\&itemId=933\\&itemUrl=ItemListRightList.html) | +| --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | +| [932](https://rsshub.app/gov/nfra/932) | [933](https://rsshub.app/gov/nfra/933) | + +#### [在线服务](https://www.nfra.gov.cn/cn/view/pages/zaixianfuwu/zaixianfuwu.html) + +| [行政许可办事服务指南](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=937\\&itemId=938\\&itemUrl=zaixianfuwu/banshifuwu.html) | [查询服务](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=937\\&itemId=939\\&itemUrl=zaixianfuwu/chaxunfuwu.html) | +| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| [938](https://rsshub.app/gov/nfra/938) | [939](https://rsshub.app/gov/nfra/939) | + +#### [互动交流](https://www.nfra.gov.cn/cn/view/pages/hudongjiaoliu/hudongjiaoliu.html) + +| [政务咨询](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=945\\&itemId=946\\&itemUrl=tosubmenu:hudongjiaoliu/woyaozixun.html) | [征集调查](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=945\\&itemId=950\\&itemUrl=ItemListRightMore.html) | [国务院办公厅开通 "国家政务服务投诉与建议" 小程序](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=945\\&itemId=952\\&itemUrl=http://www.gov.cn/xinwen/2018-09/20/content_5323786.htm) | +| ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [946](https://rsshub.app/gov/nfra/946) | [950](https://rsshub.app/gov/nfra/950) | [952](https://rsshub.app/gov/nfra/952) | + +#### [统计数据](https://www.nfra.gov.cn/cn/view/pages/tongjishuju/tongjishuju.html) + +| [统计信息](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=953\\&itemId=954\\&itemUrl=ItemListRightList.html) | [数据图表](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=953\\&itemId=955\\&itemUrl=tosubmenu:tongjishuju/zongzichan.html) | +| ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| [954](https://rsshub.app/gov/nfra/954) | [955](https://rsshub.app/gov/nfra/955) | + +#### [专题专栏](https://www.nfra.gov.cn/cn/view/pages/zhuantizhuanlan/zhuantizhuanlan.html) + +| [推进普惠金融高质量发展](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4234\\&itemUrl=ItemListRightMore.html) | [防范和处置非法集资](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=963\\&itemUrl=ItemListRightMore.html) | [消费者保护](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4097\\&itemUrl=ItemListRightMore.html) | [法治宣传](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4106\\&itemUrl=ItemListRightMore.html) | [政府网站年度报表](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=970\\&itemUrl=ItemListRightList.html) | +| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | +| [4234](https://rsshub.app/gov/nfra/4234) | [963](https://rsshub.app/gov/nfra/963) | [4097](https://rsshub.app/gov/nfra/4097) | [4106](https://rsshub.app/gov/nfra/4106) | [970](https://rsshub.app/gov/nfra/970) | + +| [服务民营企业](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4171\\&itemUrl=ItemListRightList.html) | [服务制造业发展](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4217\\&itemUrl=ItemListRightList.html) | [学习贯彻习近平新时代中国特色社会主义思想主题教育](https://www.nfra.gov.cn/cn/view/pages/ItemList.html?itemPId=960\\&itemId=4229\\&itemUrl=ItemListRightMore.html) | +| ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [4171](https://rsshub.app/gov/nfra/4171) | [4217](https://rsshub.app/gov/nfra/4217) | [4229](https://rsshub.app/gov/nfra/4229) |`, + categories: ['government'], + + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportRadar: true, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + title: '首页 - 弹出公告', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/972', + }, + { + title: '首页 - 法律声明', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4128', + }, + { + title: '机构概况 - 主要职责', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/901', + }, + { + title: '机构概况 - 总局领导', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/902', + }, + { + title: '机构概况 - 内设机构', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/911', + }, + { + title: '机构概况 - 直属行政机构', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4243', + }, + { + title: '机构概况 - 派出机构', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/912', + }, + { + title: '机构概况 - 联系方式', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/913', + }, + { + title: '新闻资讯 - 监管动态', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/915', + }, + { + title: '新闻资讯 - 政策解读', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/916', + }, + { + title: '新闻资讯 - 领导活动及讲话', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/919', + }, + { + title: '新闻资讯 - 新闻发布会及访谈', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/920', + }, + { + title: '新闻资讯 - 新闻发言人', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/921', + }, + { + title: '政务信息 - 政府信息公开', + source: ['www.nfra.gov.cn/cn/view/pages/zhengwuxinxi/zhengfuxinxi.html'], + target: '/924', + }, + { + title: '政务信息 - 公告通知', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/925', + }, + { + title: '政务信息 - 政策法规', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/926', + }, + { + title: '政务信息 - 行政许可', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/930', + }, + { + title: '政务信息 - 行政处罚', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/931', + }, + { + title: '政务信息 - 行政监管措施', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/932', + }, + { + title: '政务信息 - 人事信息', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/933', + }, + { + title: '在线服务 - 行政许可办事服务指南', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/938', + }, + { + title: '在线服务 - 查询服务', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/939', + }, + { + title: '互动交流 - 政务咨询', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/946', + }, + { + title: '互动交流 - 征集调查', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/950', + }, + { + title: '互动交流 - 国务院办公厅开通"国家政务服务投诉与建议"小程序', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/952', + }, + { + title: '统计数据 - 统计信息', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/954', + }, + { + title: '统计数据 - 数据图表', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/955', + }, + { + title: '专题专栏 - 推进普惠金融高质量发展', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4234', + }, + { + title: '专题专栏 - 防范和处置非法集资', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/963', + }, + { + title: '专题专栏 - 消费者保护', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4097', + }, + { + title: '专题专栏 - 法治宣传', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4106', + }, + { + title: '专题专栏 - 政府网站年度报表', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/970', + }, + { + title: '专题专栏 - 服务民营企业', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4171', + }, + { + title: '专题专栏 - 服务制造业发展', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4217', + }, + { + title: '专题专栏 - 学习贯彻习近平新时代中国特色社会主义思想主题教育', + source: ['www.nfra.gov.cn/cn/view/pages/ItemList.html'], + target: '/4229', + }, + ], +}; diff --git a/lib/routes/gov/nfra/namespace.ts b/lib/routes/gov/nfra/namespace.ts new file mode 100644 index 000000000..78243bce4 --- /dev/null +++ b/lib/routes/gov/nfra/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家金融监督管理总局', + url: 'www.nfra.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/nifdc/index.ts b/lib/routes/gov/nifdc/index.ts index d3be4dbb1..5f8b0ae74 100644 --- a/lib/routes/gov/nifdc/index.ts +++ b/lib/routes/gov/nifdc/index.ts @@ -7,10 +7,25 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/nifdc/:path{.+}?', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}?', + name: '国家药品监督管理局医疗器械标准管理中心 - 通用', + example: '/gov/nifdc/bshff/ylqxbzhgl/qxggtzh', + parameters: { path: '路径,默认为公告通告' }, + radar: [ + { + source: ['www.nifdc.org.cn/nifdc/*path/index.html', 'www.nifdc.org.cn/nifdc/*path'], + target: '/:path', + }, + ], + maintainers: ['nczitzk'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`https://www.nifdc.org.cn/nifdc/\` 与 \`/index.html\` 之间的字段,下面是一个例子。 + +若订阅 [公告通告](https://www.nifdc.org.cn/nifdc/bshff/ylqxbzhgl/qxggtzh/index.html) 则将对应页面 URL 中 \`https://www.nifdc.org.cn/nifdc/\` 和 \`/index.html\` 之间的字段 \`bshff/ylqxbzhgl/qxggtzh\` 作为路径填入。此时路由为 [\`/gov/nifdc/bshff/ylqxbzhgl/qxggtzh\`](https://rsshub.app/gov/nifdc/bshff/ylqxbzhgl/qxggtzh) + +:::`, }; async function handler(ctx) { diff --git a/lib/routes/gov/nifdc/namespace.ts b/lib/routes/gov/nifdc/namespace.ts new file mode 100644 index 000000000..82a909d30 --- /dev/null +++ b/lib/routes/gov/nifdc/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '中国食品药品检定研究院', + url: 'www.nifdc.org.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/nmpa/generic.ts b/lib/routes/gov/nmpa/generic.ts index c8a6b8461..c93911e4d 100644 --- a/lib/routes/gov/nmpa/generic.ts +++ b/lib/routes/gov/nmpa/generic.ts @@ -11,14 +11,29 @@ import { finishArticleItem } from '@/utils/wechat-mp'; const baseUrl = 'https://www.nmpa.gov.cn'; export const route: Route = { - path: '/nmpa/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/nmpa/xxgk/ggtg', + parameters: { path: '路径,默认为公告通告' }, + radar: [ + { + source: ['www.nmpa.gov.cn/*path/index.html', 'www.nmpa.gov.cn/*path'], + target: '/:path', + }, + ], + maintainers: ['TonyRL'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`https://www.nmpa.gov.cn/\` 与 \`/index.html\` 之间的字段,下面是一个例子。 + +若订阅 [公告通告](https://www.nmpa.gov.cn/xxgk/ggtg/index.html) 则将对应页面 URL 中 \`https://www.nmpa.gov.cn/\` 和 \`/index.html\` 之间的字段 \`xxgk/ggtg\` 作为路径填入。此时路由为 [\`/gov/nmpa/xxgk/ggtg\`](https://rsshub.app/gov/nmpa/xxgk/ggtg) + +:::`, }; async function handler(ctx) { - const path = ctx.params[0]; + const path = ctx.req.param('path'); const url = `${baseUrl}/${path.endsWith('/') ? path.slice(0, -1) : path}/index.html`; const data = await cache.tryGet( url, diff --git a/lib/routes/gov/nmpa/namespace.ts b/lib/routes/gov/nmpa/namespace.ts new file mode 100644 index 000000000..fc7c95203 --- /dev/null +++ b/lib/routes/gov/nmpa/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家药品监督管理局', + url: 'www.nmpa.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/nopss/index.ts b/lib/routes/gov/nopss/index.ts index 99a7219d4..5f2fbe99a 100644 --- a/lib/routes/gov/nopss/index.ts +++ b/lib/routes/gov/nopss/index.ts @@ -1,33 +1,45 @@ import { load } from 'cheerio'; -import iconv from 'iconv-lite'; import type { Route } from '@/types'; import cache from '@/utils/cache'; -import { getSubPath } from '@/utils/common-utils'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/nopss/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}?', + name: '通用', + example: '/gov/nopss/GB/219469', + parameters: { path: '路径,默认为通知公告' }, + radar: [ + { + source: ['www.nopss.gov.cn/*path/index.html', 'www.nopss.gov.cn/*path'], + target: '/:path', + }, + ], + maintainers: ['nczitzk'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`http://www.nopss.gov.cn/\` 后的字段。下面是一个例子。 + +若订阅 [年度项目、青年项目和西部项目](http://www.nopss.gov.cn/GB/219469/431027) 则将对应页面 URL 中 \`http://www.nopss.gov.cn/\` 后的字段 \`GB/219469/431027\` 作为路径填入。此时路由为 [\`/gov/nopss/GB/219469/431027\`](https://rsshub.app/gov/nopss/GB/219469/431027) + +:::`, }; async function handler(ctx) { - const params = getSubPath(ctx) === '/nopss' ? '/GB/219469' : getSubPath(ctx).replace(/^\/nopss/, ''); + const { path = 'GB/219469' } = ctx.req.param(); const rootUrl = 'http://www.nopss.gov.cn'; - const currentUrl = `${rootUrl}${params}`; + const currentUrl = `${rootUrl}/${path}`; const response = await got({ method: 'get', url: currentUrl, - responseType: 'buffer', }); - const $ = load(iconv.decode(response.data, 'gbk')); + const $ = load(response.data); let items = $('.p2j_list_con .clearfix li a') .slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 40) @@ -48,10 +60,9 @@ async function handler(ctx) { const detailResponse = await got({ method: 'get', url: item.link, - responseType: 'buffer', }); - const content = load(iconv.decode(detailResponse.data, 'gbk')); + const content = load(detailResponse.data); item.description = content('.text_con').html(); diff --git a/lib/routes/gov/nopss/namespace.ts b/lib/routes/gov/nopss/namespace.ts new file mode 100644 index 000000000..f1153edba --- /dev/null +++ b/lib/routes/gov/nopss/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '全国哲学社会科学工作办公室', + url: 'www.nopss.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/npc/index.ts b/lib/routes/gov/npc/index.ts index e4fe2bd0e..2f3bdbe0b 100644 --- a/lib/routes/gov/npc/index.ts +++ b/lib/routes/gov/npc/index.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/npc/:caty', + path: '/:caty', categories: ['government'], example: '/gov/npc/c183', parameters: { caty: '分类名,支持形如 `http://www.npc.gov.cn/npc/c2/*/` 的网站,传入 npc 之后的参数' }, diff --git a/lib/routes/gov/npc/namespace.ts b/lib/routes/gov/npc/namespace.ts new file mode 100644 index 000000000..06ef96676 --- /dev/null +++ b/lib/routes/gov/npc/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '全国人民代表大会', + url: 'www.npc.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/nrta/dsj.ts b/lib/routes/gov/nrta/dsj.ts index 667178e14..b5cdecbe0 100644 --- a/lib/routes/gov/nrta/dsj.ts +++ b/lib/routes/gov/nrta/dsj.ts @@ -7,7 +7,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/nrta/dsj/:category?', + path: '/dsj/:category?', categories: ['government'], example: '/gov/nrta/dsj', parameters: { category: '分类,见下表,默认为备案公示' }, diff --git a/lib/routes/gov/nrta/namespace.ts b/lib/routes/gov/nrta/namespace.ts new file mode 100644 index 000000000..1dc9cdeb5 --- /dev/null +++ b/lib/routes/gov/nrta/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家广播电视总局', + url: 'www.nrta.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/nrta/news.ts b/lib/routes/gov/nrta/news.ts index 519f29240..a2ada9976 100644 --- a/lib/routes/gov/nrta/news.ts +++ b/lib/routes/gov/nrta/news.ts @@ -13,7 +13,7 @@ const categories = { }; export const route: Route = { - path: '/nrta/news/:category?', + path: '/news/:category?', categories: ['government'], example: '/gov/nrta/news', parameters: { category: '资讯类别,可从地址中获取,默认为总局要闻' }, diff --git a/lib/routes/gov/nsfc/index.ts b/lib/routes/gov/nsfc/index.ts index 124e308b1..304b3fd22 100644 --- a/lib/routes/gov/nsfc/index.ts +++ b/lib/routes/gov/nsfc/index.ts @@ -2,21 +2,58 @@ import { load } from 'cheerio'; import type { Route } from '@/types'; import cache from '@/utils/cache'; -import { getSubPath } from '@/utils/common-utils'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import shortcuts from './shortcuts'; export const route: Route = { - path: '/nsfc/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}?', + name: '通用', + example: '/gov/nsfc', + parameters: { path: '路径,默认为基金要闻' }, + maintainers: ['Derekmini', 'nczitzk'], handler, + description: `::: tip + +若订阅 [基金要闻 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab442),网址为 。截取 \`https://www.nsfc.gov.cn\` 到末尾的部分 \`/publish/portal0/tab442\` 作为参数,此时路由为 [\`/gov/nsfc/publish/portal0/tab442\`](https://rsshub.app/gov/nsfc/publish/portal0/tab442)。 + +当然,也可以填入路径在下表中对应的快捷方式。其中 [基金要闻 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab442) 的快捷方式为 \`tzgg\`,此时路由为 [\`/gov/nsfc/tzgg\`](https://rsshub.app/gov/nsfc/tzgg)。 + +若订阅 [管理科学部 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab1212),网址为 。截取 \`https://www.nsfc.gov.cn\` 到末尾的部分 \`/publish/portal0/tab1212\` 作为参数,此时路由为 [\`/gov/nsfc/publish/portal0/tab1212\`](https://rsshub.app/gov/nsfc/publish/portal0/tab1212)。 + +同理,也可以填入路径在下表中对应的快捷方式。其中 [管理科学部 - 通知公告](https://www.nsfc.gov.cn/publish/portal0/tab1212) 的快捷方式为 \`glkxb-tzgg\`,此时路由为 [\`/gov/nsfc/glkxb-tzgg\`](https://rsshub.app/gov/nsfc/glkxb-tzgg)。 + +::: + +基金要闻 + +| 基金要闻 | 通知公告 | 部门动态 | 科普快讯 | 资助成果 | +| -------- | -------- | -------- | -------- | -------- | +| jjyw | tzgg | bmdt | kpkx | zzcg | + +政策法规 + +| 国家自然科学基金条例 | 国家自然科学基金发展规划 | 国家自然科学基金规章制度 | 国家科学技术相关法律法规 | +| -------------------- | ------------------------ | ------------------------ | ------------------------ | +| zcfg-jjtl | zcfg-fzgh | zcfg-gzzd | zcfg-flfg | + +管理科学部 + +| 工作动态 | 通知公告 | 资助成果 | +| ---------- | ---------- | ---------- | +| glkxb-gzdt | glkxb-tzgg | glkxb-zzcg | + +国际合作局 + +| 项目指南 | 初审结果 | 批准通知 | 进程简表 | 信息公开 | +| ---------- | ---------- | ---------- | ---------- | ---------- | +| gjhzj-xmzn | gjhzj-csjg | gjhzj-pztz | gjhzj-jcjb | gjhzj-xxgk |`, }; async function handler(ctx) { - let thePath = getSubPath(ctx).replace(/^\/nsfc/, ''); + const path = ctx.req.param('path'); + let thePath = path ? `/${path}` : ''; const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30; diff --git a/lib/routes/gov/nsfc/namespace.ts b/lib/routes/gov/nsfc/namespace.ts new file mode 100644 index 000000000..071c89c4b --- /dev/null +++ b/lib/routes/gov/nsfc/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家自然科学基金委员会', + url: 'www.nsfc.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/pbc/goutongjiaoliu.ts b/lib/routes/gov/pbc/goutongjiaoliu.ts index b2e9a3cb0..73f66d8bc 100644 --- a/lib/routes/gov/pbc/goutongjiaoliu.ts +++ b/lib/routes/gov/pbc/goutongjiaoliu.ts @@ -7,7 +7,7 @@ import playwright from '@/utils/playwright'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/pbc/goutongjiaoliu', + path: '/goutongjiaoliu', categories: ['finance'], example: '/gov/pbc/goutongjiaoliu', parameters: {}, diff --git a/lib/routes/gov/pbc/gzlw.ts b/lib/routes/gov/pbc/gzlw.ts index 7d54b5c9f..760b318eb 100644 --- a/lib/routes/gov/pbc/gzlw.ts +++ b/lib/routes/gov/pbc/gzlw.ts @@ -8,7 +8,7 @@ import { processItems } from './utils'; const host = 'http://www.pbc.gov.cn'; export const route: Route = { - path: '/pbc/gzlw', + path: '/gzlw', categories: ['finance'], example: '/gov/pbc/gzlw', parameters: {}, diff --git a/lib/routes/gov/pbc/trade-announcement.ts b/lib/routes/gov/pbc/trade-announcement.ts index 8e0545686..85d835ece 100644 --- a/lib/routes/gov/pbc/trade-announcement.ts +++ b/lib/routes/gov/pbc/trade-announcement.ts @@ -7,7 +7,7 @@ import playwright from '@/utils/playwright'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/pbc/tradeAnnouncement', + path: '/tradeAnnouncement', categories: ['finance'], example: '/gov/pbc/tradeAnnouncement', parameters: {}, diff --git a/lib/routes/gov/pbc/zcyj.ts b/lib/routes/gov/pbc/zcyj.ts index 29d8fa34f..bba1a2979 100644 --- a/lib/routes/gov/pbc/zcyj.ts +++ b/lib/routes/gov/pbc/zcyj.ts @@ -10,13 +10,14 @@ import { processItems } from './utils'; const host = 'http://www.pbc.gov.cn'; export const route: Route = { - path: '/pbc/zcyj', + path: '/zcyj', + example: '/gov/pbc/zcyj', radar: [ { source: ['pbc.gov.cn/redianzhuanti/118742/4122386/4122510/index.html'], }, ], - name: 'Unknown', + name: '政策研究', maintainers: ['Fatpandac'], handler, url: 'pbc.gov.cn/redianzhuanti/118742/4122386/4122510/index.html', diff --git a/lib/routes/gov/pudong/namespace.ts b/lib/routes/gov/pudong/namespace.ts new file mode 100644 index 000000000..b4f8169df --- /dev/null +++ b/lib/routes/gov/pudong/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '上海市浦东新区人民政府', + url: 'www.pudong.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/pudong/zwgk.ts b/lib/routes/gov/pudong/zwgk.ts index ba93e5834..a08f7ef62 100644 --- a/lib/routes/gov/pudong/zwgk.ts +++ b/lib/routes/gov/pudong/zwgk.ts @@ -6,7 +6,7 @@ import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; // 解析日期的工具函数 export const route: Route = { - path: '/pudong/zwgk', + path: '/zwgk', categories: ['government'], example: '/gov/pudong/zwgk', features: { @@ -20,10 +20,10 @@ export const route: Route = { radar: [ { source: ['www.pudong.gov.cn/zwgk/zxxxgk/index.html'], - target: '/pudong/zwgk', + target: '/zwgk', }, ], - name: '政务公开-浦东新区', + name: '政务公开', maintainers: ['himingway'], handler, }; diff --git a/lib/routes/gov/safe/business.ts b/lib/routes/gov/safe/business.ts index fc54eef0d..971a29aa7 100644 --- a/lib/routes/gov/safe/business.ts +++ b/lib/routes/gov/safe/business.ts @@ -3,7 +3,7 @@ import type { Route } from '@/types'; import { processZxfkItems } from './util'; export const route: Route = { - path: '/safe/business/:site?', + path: '/business/:site?', categories: ['government'], example: '/gov/safe/business/beijing', parameters: { site: '站点,见上表,默认为 beijing' }, diff --git a/lib/routes/gov/safe/complaint.ts b/lib/routes/gov/safe/complaint.ts index c45ef580b..65631fcb0 100644 --- a/lib/routes/gov/safe/complaint.ts +++ b/lib/routes/gov/safe/complaint.ts @@ -3,7 +3,7 @@ import type { Route } from '@/types'; import { processZxfkItems } from './util'; export const route: Route = { - path: '/safe/complaint/:site?', + path: '/complaint/:site?', categories: ['government'], example: '/gov/safe/complaint/beijing', parameters: { site: '站点,见上表,默认为 beijing' }, diff --git a/lib/routes/gov/safe/namespace.ts b/lib/routes/gov/safe/namespace.ts new file mode 100644 index 000000000..ef06c6a43 --- /dev/null +++ b/lib/routes/gov/safe/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家外汇管理局', + url: 'www.safe.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/samr/namespace.ts b/lib/routes/gov/samr/namespace.ts new file mode 100644 index 000000000..047780b4d --- /dev/null +++ b/lib/routes/gov/samr/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家市场监督管理总局', + url: 'www.samr.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/samr/xgzlyhd.tsx b/lib/routes/gov/samr/xgzlyhd.tsx index 63f24b74f..793cf8509 100644 --- a/lib/routes/gov/samr/xgzlyhd.tsx +++ b/lib/routes/gov/samr/xgzlyhd.tsx @@ -36,7 +36,7 @@ const getOption = async (type, name) => { }; export const route: Route = { - path: '/samr/xgzlyhd/:category?/:department?', + path: '/xgzlyhd/:category?/:department?', categories: ['government'], example: '/gov/samr/xgzlyhd', parameters: { category: '留言类型,见下表,默认为全部', department: '回复部门,见下表,默认为全部' }, diff --git a/lib/routes/gov/sasac/generic.ts b/lib/routes/gov/sasac/generic.ts index 06a1e0117..95335bbf7 100644 --- a/lib/routes/gov/sasac/generic.ts +++ b/lib/routes/gov/sasac/generic.ts @@ -6,10 +6,25 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/sasac/:path{.+}', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/sasac/n2588030/n16436141', + parameters: { path: '路径,可在 URL 找到' }, + radar: [ + { + source: ['www.sasac.gov.cn/*path/index.html', 'www.sasac.gov.cn/*path'], + target: '/:path', + }, + ], + maintainers: ['TonyRL'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`http://www.sasac.gov.cn/\` 与 \`/index.html\` 之间的字段,下面是一个例子。 + +若订阅 [其他](http://www.sasac.gov.cn/n2588030/n16436141/index.html) 则将对应页面 URL 中 \`http://www.sasac.gov.cn/\` 和 \`/index.html\` 之间的字段 \`n2588030/n16436141\` 作为路径填入。此时路由为 [\`/gov/sasac/n2588030/n16436141\`](https://rsshub.app/gov/sasac/n2588030/n16436141) + +:::`, }; async function handler(ctx) { @@ -26,7 +41,7 @@ async function handler(ctx) { item = $(item); return { title: item.find('a').attr('title'), - link: new URL(item.find('a').attr('href'), response.url).href, + link: new URL(item.find('a').attr('href'), url).href, pubDate: parseDate(item.find('span').text().replace('[', '').replace(']', '')), }; }); diff --git a/lib/routes/gov/sasac/namespace.ts b/lib/routes/gov/sasac/namespace.ts new file mode 100644 index 000000000..cf3773cc6 --- /dev/null +++ b/lib/routes/gov/sasac/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国务院国有资产监督管理委员会', + url: 'www.sasac.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/sdb/namespace.ts b/lib/routes/gov/sdb/namespace.ts new file mode 100644 index 000000000..e25bcf2dc --- /dev/null +++ b/lib/routes/gov/sdb/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '茂名水东湾新城建设管理委员会', + url: 'www.sdb.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/sdb/sdb.ts b/lib/routes/gov/sdb/sdb.ts index 20883d6b6..496d99152 100644 --- a/lib/routes/gov/sdb/sdb.ts +++ b/lib/routes/gov/sdb/sdb.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/sdb/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/sdb/www/zwgk/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政务公开 > 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政务公开 > 政策解读](http://www.sdb.gov.cn/zwgk/zcjd/) 则将对应页面 URL 中 \`http://www.sdb.gov.cn/\` 的字段 \`www\` 和 \`zwgk/zcjd/\` 作为路径填入。此时路由为 [\`/gov/sdb/www/zwgk/zcjd/\`](https://rsshub.app/gov/sdb/www/zwgk/zcjd/) + +:::`, }; async function handler(ctx) { @@ -24,5 +33,5 @@ async function handler(ctx) { pubDate_match: '发布时间:(.*)', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/sh/fgw/index.tsx b/lib/routes/gov/sh/fgw/index.tsx index 7335f318e..2745d3b7f 100644 --- a/lib/routes/gov/sh/fgw/index.tsx +++ b/lib/routes/gov/sh/fgw/index.tsx @@ -119,8 +119,8 @@ export const handler = async (ctx) => { }; export const route: Route = { - path: ['/sh/fgw/:category{.+}?', '/shanghai/fgw/:category{.+}?'], - name: '上海市发展和改革委员会', + path: '/fgw/:category{.+}?', + name: '发展和改革委员会', url: 'fgw.sh.gov.cn', maintainers: ['nczitzk'], handler, @@ -156,12 +156,12 @@ export const route: Route = { { title: '最新信息公开', source: ['fgw.sh.gov.cn/fgw_zxxxgk/index.html'], - target: '/sh/fgw/fgw_zxxxgk', + target: '/fgw/fgw_zxxxgk', }, { title: '要闻动态', source: ['fgw.sh.gov.cn/fgw_fzggdt/index.html'], - target: '/sh/fgw/fgw_fzggdt', + target: '/fgw/fgw_fzggdt', }, ], }; diff --git a/lib/routes/gov/sh/rsj/ksxm.tsx b/lib/routes/gov/sh/rsj/ksxm.tsx index fa0e7f78d..44c90f652 100644 --- a/lib/routes/gov/sh/rsj/ksxm.tsx +++ b/lib/routes/gov/sh/rsj/ksxm.tsx @@ -21,7 +21,7 @@ const renderDescription = ({ name, type, date, registrationDeadline }) => ); export const route: Route = { - path: ['/sh/rsj/ksxm', '/shanghai/rsj/ksxm'], + path: '/rsj/ksxm', categories: ['government'], example: '/gov/sh/rsj/ksxm', parameters: {}, @@ -38,7 +38,7 @@ export const route: Route = { source: ['rsj.sh.gov.cn/'], }, ], - name: '上海市职业能力考试院 考试项目', + name: '职业能力考试院 考试项目', maintainers: ['Fatpandac'], handler, url: 'rsj.sh.gov.cn/', diff --git a/lib/routes/gov/sh/wgj/wgj.tsx b/lib/routes/gov/sh/wgj/wgj.tsx index 7309eea2a..0010cb8e7 100644 --- a/lib/routes/gov/sh/wgj/wgj.tsx +++ b/lib/routes/gov/sh/wgj/wgj.tsx @@ -7,7 +7,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: ['/sh/wgj/:page?', '/shanghai/wgj/:page?'], + path: '/wgj/:page?', categories: ['government'], example: '/gov/sh/wgj', parameters: { page: '页数,默认第 1 页' }, @@ -22,10 +22,10 @@ export const route: Route = { radar: [ { source: ['wsbs.wgj.sh.gov.cn/'], - target: '/sh/wgj', + target: '/wgj', }, ], - name: '上海市文旅局审批公告', + name: '文旅局审批公告', maintainers: ['gideonsenku'], handler, url: 'wsbs.wgj.sh.gov.cn/', diff --git a/lib/routes/gov/sh/wsjkw/yqtb/index.ts b/lib/routes/gov/sh/wsjkw/yqtb/index.ts index 4d11457e0..d6004ed5e 100644 --- a/lib/routes/gov/sh/wsjkw/yqtb/index.ts +++ b/lib/routes/gov/sh/wsjkw/yqtb/index.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: ['/sh/wsjkw/yqtb', '/shanghai/wsjkw/yqtb'], + path: '/wsjkw/yqtb', categories: ['government'], example: '/gov/sh/wsjkw/yqtb', parameters: {}, @@ -22,7 +22,7 @@ export const route: Route = { source: ['wsjkw.sh.gov.cn/'], }, ], - name: '上海卫健委 疫情通报', + name: '卫健委 疫情通报', maintainers: ['zcf0508'], handler, url: 'wsjkw.sh.gov.cn/', diff --git a/lib/routes/gov/sh/yjj/index.ts b/lib/routes/gov/sh/yjj/index.ts index 80e209605..1f9adf320 100644 --- a/lib/routes/gov/sh/yjj/index.ts +++ b/lib/routes/gov/sh/yjj/index.ts @@ -2,23 +2,37 @@ import { load } from 'cheerio'; import type { Route } from '@/types'; import cache from '@/utils/cache'; -import { getSubPath } from '@/utils/common-utils'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: ['/sh/yjj/*', '/shanghai/yjj/*'], - name: 'Unknown', - maintainers: [], + path: '/yjj/:path{.+}?', + name: '药品监督管理局', + example: '/gov/sh/yjj/zh', + parameters: { path: '路径参数' }, + radar: [ + { + source: ['yjj.sh.gov.cn/*path/index.html', 'yjj.sh.gov.cn/*path'], + target: '/yjj/:path', + }, + ], + maintainers: ['nczitzk'], handler, + description: `::: tip + +路径处填写对应页面 URL 中 \`https://yjj.sh.gov.cn/\` 与 \`/index.html\` 之间的字段,下面是一个例子。 + +若订阅 [最新信息公开 > 综合](https://yjj.sh.gov.cn/zh/index.html) 则将对应页面 URL 中 \`https://yjj.sh.gov.cn/\` 和 \`/index.html\` 之间的字段 \`zh\` 作为路径填入。此时路由为 [\`/gov/sh/yjj/zh\`](https://rsshub.app/gov/sh/yjj/zh) + +:::`, }; async function handler(ctx) { - const params = getSubPath(ctx) === '/sh/yjj' ? '/sh/yjj/zx-ylqx' : getSubPath(ctx); + const { path = 'zx-ylqx' } = ctx.req.param(); const rootUrl = 'https://yjj.sh.gov.cn'; - const currentUrl = `${rootUrl}${params.replace(/^\/sh\/yjj/, '')}/index.html`; + const currentUrl = `${rootUrl}/${path}/index.html`; const response = await got({ method: 'get', diff --git a/lib/routes/gov/shaanxi/kjt.ts b/lib/routes/gov/shaanxi/kjt.ts index 9988b1153..acad693a5 100644 --- a/lib/routes/gov/shaanxi/kjt.ts +++ b/lib/routes/gov/shaanxi/kjt.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/shaanxi/kjt/:id?', + path: '/kjt/:id?', categories: ['government'], example: '/gov/shaanxi/kjt', parameters: { id: '分类,见下表,默认为通知公告' }, diff --git a/lib/routes/gov/shaanxi/namespace.ts b/lib/routes/gov/shaanxi/namespace.ts new file mode 100644 index 000000000..4481b74fe --- /dev/null +++ b/lib/routes/gov/shaanxi/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '陕西省人民政府', + url: 'www.shaanxi.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/shenzhen/hrss/szksy/index.ts b/lib/routes/gov/shenzhen/hrss/szksy/index.ts index 2aa7aade1..67d4b7e2b 100644 --- a/lib/routes/gov/shenzhen/hrss/szksy/index.ts +++ b/lib/routes/gov/shenzhen/hrss/szksy/index.ts @@ -8,7 +8,7 @@ import timezone from '@/utils/timezone'; const rootURL = 'http://hrss.sz.gov.cn/'; export const route: Route = { - path: '/shenzhen/hrss/szksy/:caty/:page?', + path: '/hrss/szksy/:caty/:page?', categories: ['government'], example: '/gov/shenzhen/hrss/szksy/bmxx/2', parameters: { caty: '信息类别', page: '页码' }, @@ -25,7 +25,7 @@ export const route: Route = { source: ['xxgk.sz.gov.cn/cn/xxgk/zfxxgj/:caty'], }, ], - name: '深圳市考试院', + name: '考试院', maintainers: ['zlasd'], handler, url: 'hrss.sz.gov.cn/*', diff --git a/lib/routes/gov/shenzhen/namespace.ts b/lib/routes/gov/shenzhen/namespace.ts new file mode 100644 index 000000000..b4fca3e55 --- /dev/null +++ b/lib/routes/gov/shenzhen/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '深圳市人民政府', + url: 'www.sz.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/shenzhen/szlh/index.ts b/lib/routes/gov/shenzhen/szlh/index.ts index 8f83d37e8..ad9b7b993 100644 --- a/lib/routes/gov/shenzhen/szlh/index.ts +++ b/lib/routes/gov/shenzhen/szlh/index.ts @@ -14,7 +14,7 @@ const config = { }; export const route: Route = { - path: '/shenzhen/szlh/zwfw/zffw/:caty', + path: '/szlh/zwfw/zffw/:caty', categories: ['government'], example: '/gov/shenzhen/szlh/zwfw/zffw/tzgg', parameters: { caty: '信息类别' }, @@ -31,7 +31,7 @@ export const route: Route = { source: ['szlh.gov.cn/zwfw/zffw/:caty'], }, ], - name: '深圳市罗湖区人民政府', + name: '罗湖区人民政府 政务服务', maintainers: ['lonn'], handler, description: `| 通知公告 | diff --git a/lib/routes/gov/shenzhen/xxgk/zfxxgj.ts b/lib/routes/gov/shenzhen/xxgk/zfxxgj.ts index 85407af13..16db56327 100644 --- a/lib/routes/gov/shenzhen/xxgk/zfxxgj.ts +++ b/lib/routes/gov/shenzhen/xxgk/zfxxgj.ts @@ -29,7 +29,7 @@ const config = { }; export const route: Route = { - path: '/shenzhen/xxgk/zfxxgj/:caty', + path: '/xxgk/zfxxgj/:caty', categories: ['government'], example: '/gov/shenzhen/xxgk/zfxxgj/tzgg', parameters: { caty: '信息类别' }, @@ -41,7 +41,7 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - name: '深圳市人民政府', + name: '政府信息公开', maintainers: ['laoxua'], handler, description: `| 通知公告 | 政府采购 | 资金信息 | 重大项目 | diff --git a/lib/routes/gov/shenzhen/zjj/index.ts b/lib/routes/gov/shenzhen/zjj/index.ts index 8032e08d3..ff5a57498 100644 --- a/lib/routes/gov/shenzhen/zjj/index.ts +++ b/lib/routes/gov/shenzhen/zjj/index.ts @@ -14,7 +14,7 @@ const config = { }; export const route: Route = { - path: '/shenzhen/zjj/xxgk/:caty', + path: '/zjj/xxgk/:caty', categories: ['government'], example: '/gov/shenzhen/zjj/xxgk/tzgg', parameters: { caty: '信息类别' }, @@ -31,7 +31,7 @@ export const route: Route = { source: ['zjj.sz.gov.cn/xxgk/:caty'], }, ], - name: '深圳市住房和建设局', + name: '住房和建设局', maintainers: ['lonn'], handler, description: `| 通知公告 | diff --git a/lib/routes/gov/shenzhen/zzb/index.ts b/lib/routes/gov/shenzhen/zzb/index.ts index 6bb742ab2..b3c6a97cc 100644 --- a/lib/routes/gov/shenzhen/zzb/index.ts +++ b/lib/routes/gov/shenzhen/zzb/index.ts @@ -8,7 +8,7 @@ import timezone from '@/utils/timezone'; const rootURL = 'http://www.zzb.sz.gov.cn/'; export const route: Route = { - path: '/shenzhen/zzb/:caty/:page?', + path: '/zzb/:caty/:page?', categories: ['government'], example: '/gov/shenzhen/zzb/tzgg', parameters: { caty: '信息类别', page: '页码' }, diff --git a/lib/routes/gov/sichuan/deyang/govpublicinfo.tsx b/lib/routes/gov/sichuan/deyang/govpublicinfo.tsx index 144f9e409..35aa7ac3f 100644 --- a/lib/routes/gov/sichuan/deyang/govpublicinfo.tsx +++ b/lib/routes/gov/sichuan/deyang/govpublicinfo.tsx @@ -74,7 +74,7 @@ const getInfoContent = (rootUrl, item) => }); export const route: Route = { - path: '/sichuan/deyang/govpublicinfo/:countyName/:infoType?', + path: '/deyang/govpublicinfo/:countyName/:infoType?', categories: ['government'], example: '/gov/sichuan/deyang/govpublicinfo/绵竹市', parameters: { countyName: '区县名(**其他区县整改中,暂时只支持`绵竹市`**)。德阳市、绵竹市、广汉市、什邡市、中江县、罗江区、旌阳区、高新区', infoType: '信息类型。默认值:fdzdnr-“法定主动内容”' }, diff --git a/lib/routes/gov/sichuan/deyang/mztoday.tsx b/lib/routes/gov/sichuan/deyang/mztoday.tsx index c37ceb788..7d153f019 100644 --- a/lib/routes/gov/sichuan/deyang/mztoday.tsx +++ b/lib/routes/gov/sichuan/deyang/mztoday.tsx @@ -119,7 +119,7 @@ const getInfoContent = (item) => }); export const route: Route = { - path: '/sichuan/deyang/mztoday/:infoType?', + path: '/deyang/mztoday/:infoType?', categories: ['government'], example: '/gov/sichuan/deyang/mztoday/zx', parameters: { infoType: '信息栏目名称。默认最新(zx)' }, @@ -134,7 +134,7 @@ export const route: Route = { radar: [ { source: ['www.mztoday.gov.cn/*'], - target: '/sichuan/deyang/mztoday', + target: '/deyang/mztoday', }, ], name: '今日绵竹', diff --git a/lib/routes/gov/sichuan/namespace.ts b/lib/routes/gov/sichuan/namespace.ts new file mode 100644 index 000000000..0a2dce41e --- /dev/null +++ b/lib/routes/gov/sichuan/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '四川省人民政府', + url: 'www.sc.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/stats/index.tsx b/lib/routes/gov/stats/index.tsx index 091f581f3..e9636bb56 100644 --- a/lib/routes/gov/stats/index.tsx +++ b/lib/routes/gov/stats/index.tsx @@ -4,7 +4,6 @@ import { renderToString } from 'hono/jsx/dom/server'; import type { Route } from '@/types'; import cache from '@/utils/cache'; -import { getSubPath } from '@/utils/common-utils'; import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; @@ -40,18 +39,18 @@ const renderDescription = ({ description, attachments }: DescriptionProps): stri ); export const route: Route = { - path: '/stats/*', - name: '国家统计局 通用', + path: '/:path{.+}?', + name: '通用', url: 'www.stats.gov.cn', categories: ['government'], maintainers: ['bigfei', 'nczitzk', 'reply2future'], example: '/gov/stats/sj/zxfb', + parameters: { path: '路径,默认为 统计数据 > 最新发布' }, handler, radar: [ { - title: '国家统计局 通用', source: ['www.stats.gov.cn/*path'], - target: '/gov/stats/*path', + target: '/:path', }, ], description: `::: tip @@ -77,7 +76,8 @@ async function handler(ctx) { .find((s) => s.startsWith('wzws_sessionid=')) ?.split(';', 1)[0] as string; - const pathname = getSubPath(ctx) === '/stats' ? '/sj/zxfb/' : getSubPath(ctx).replace(/^\/stats(.*)/, '$1'); + const { path = 'sj/zxfb' } = ctx.req.param(); + const pathname = `/${path}`; const currentUrl = `${rootUrl}${pathname.endsWith('/') ? pathname : pathname + '/'}`; const response = await ofetch(currentUrl, { diff --git a/lib/routes/gov/stats/namespace.ts b/lib/routes/gov/stats/namespace.ts new file mode 100644 index 000000000..7988ec1a1 --- /dev/null +++ b/lib/routes/gov/stats/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国家统计局', + url: 'www.stats.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/suzhou/doc.ts b/lib/routes/gov/suzhou/doc.ts index e3f26e02e..ec6f45619 100644 --- a/lib/routes/gov/suzhou/doc.ts +++ b/lib/routes/gov/suzhou/doc.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/suzhou/doc', + path: '/doc', categories: ['government'], example: '/gov/suzhou/doc', parameters: {}, diff --git a/lib/routes/gov/suzhou/fg.ts b/lib/routes/gov/suzhou/fg.ts index 1d36dd307..c05d8459f 100644 --- a/lib/routes/gov/suzhou/fg.ts +++ b/lib/routes/gov/suzhou/fg.ts @@ -7,18 +7,30 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/suzhou/fg/:category{.+}?', - name: 'Unknown', - maintainers: [], + path: '/fg/:category{.+}?', + name: '发展和改革委员会', + example: '/gov/suzhou/fg/szfgw/ggl/nav_list', + parameters: { category: '分类,见下表,默认为通知公告' }, + radar: [ + { + source: ['fg.suzhou.gov.cn/*category'], + target: '/fg/:category', + }, + ], + maintainers: ['nczitzk'], handler, + description: `| 通知公告 | 发改要闻 | +| ------------------- | -------------------- | +| szfgw/ggl/nav\\_list | szfgw/gzdt/nav\\_list |`, }; async function handler(ctx) { const { category = 'szfgw/ggl/nav_list' } = ctx.req.param(); + const categoryPath = category.replace(/\.shtml$/, ''); const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30; const rootUrl = 'https://fg.suzhou.gov.cn'; - const currentUrl = new URL(`${category}.shtml`, rootUrl).href; + const currentUrl = new URL(`${categoryPath}.shtml`, rootUrl).href; const { data: response } = await got(currentUrl); diff --git a/lib/routes/gov/suzhou/namespace.ts b/lib/routes/gov/suzhou/namespace.ts new file mode 100644 index 000000000..5edaca589 --- /dev/null +++ b/lib/routes/gov/suzhou/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '苏州市人民政府', + url: 'www.suzhou.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/suzhou/news.ts b/lib/routes/gov/suzhou/news.ts index fe048d4dc..6b95249b7 100644 --- a/lib/routes/gov/suzhou/news.ts +++ b/lib/routes/gov/suzhou/news.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/suzhou/news/:uid', + path: '/news/:uid', categories: ['government'], example: '/gov/suzhou/news/news', parameters: { uid: '栏目名' }, diff --git a/lib/routes/gov/taiyuan/namespace.ts b/lib/routes/gov/taiyuan/namespace.ts new file mode 100644 index 000000000..32b1b1e83 --- /dev/null +++ b/lib/routes/gov/taiyuan/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '太原市人民政府', + url: 'www.taiyuan.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/taiyuan/rsj.ts b/lib/routes/gov/taiyuan/rsj.ts index bdf8bcd1a..fc3f8628b 100644 --- a/lib/routes/gov/taiyuan/rsj.ts +++ b/lib/routes/gov/taiyuan/rsj.ts @@ -8,7 +8,7 @@ import timezone from '@/utils/timezone'; const rootURL = 'http://rsj.taiyuan.gov.cn/'; export const route: Route = { - path: '/taiyuan/rsj/:caty/:page?', + path: '/rsj/:caty/:page?', categories: ['government'], example: '/gov/taiyuan/rsj/gggs', parameters: { caty: '信息类别', page: '页码' }, @@ -25,7 +25,7 @@ export const route: Route = { source: ['rsj.taiyuan.gov.cn/*'], }, ], - name: '太原市人力资源和社会保障局政府公开信息', + name: '人力资源和社会保障局政府公开信息', maintainers: ['2PoL'], handler, url: 'rsj.taiyuan.gov.cn/*', diff --git a/lib/routes/gov/tianjin/namespace.ts b/lib/routes/gov/tianjin/namespace.ts new file mode 100644 index 000000000..fc7e847ff --- /dev/null +++ b/lib/routes/gov/tianjin/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '天津市人民政府', + url: 'www.tianjin.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/tianjin/tjftz.ts b/lib/routes/gov/tianjin/tjftz.ts index 591205d42..277be7853 100644 --- a/lib/routes/gov/tianjin/tjftz.ts +++ b/lib/routes/gov/tianjin/tjftz.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/tianjin/tjftz-notice/:channelId', + path: '/tjftz-notice/:channelId', categories: ['government'], example: '/gov/tianjin/tjftz-notice/6302', parameters: { @@ -14,7 +14,7 @@ export const route: Route = { radar: [ { source: ['tjftz.gov.cn/channels/:channelId.html'], - target: '/tianjin/tjftz-notice/:channelId', + target: '/tjftz-notice/:channelId', }, ], name: '天津港保税区-公告', diff --git a/lib/routes/gov/tianjin/tjrcgzw.ts b/lib/routes/gov/tianjin/tjrcgzw.ts index 1c5911296..a729d5bb6 100644 --- a/lib/routes/gov/tianjin/tjrcgzw.ts +++ b/lib/routes/gov/tianjin/tjrcgzw.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/tianjin/tjrcgzw-notice/:cate/:subCate', + path: '/tjrcgzw-notice/:cate/:subCate', categories: ['government'], example: '/gov/tianjin/tjrcgzw-notice/rczc/sjrczc/', parameters: { @@ -14,10 +14,10 @@ export const route: Route = { radar: [ { source: ['hrss.tj.gov.cn/ztzl/ztzl1/tjrcgzw/'], - target: '/tianjin/tjrcgzw-notice/:cate/:subCate', + target: '/tjrcgzw-notice/:cate/:subCate', }, ], - name: '天津人才工作网-公告', + name: '人才工作网-公告', url: 'hrss.tj.gov.cn/ztzl/ztzl1/tjrcgzw/', maintainers: ['HaoyuLee'], async handler(ctx) { diff --git a/lib/routes/gov/wuhan/namespace.ts b/lib/routes/gov/wuhan/namespace.ts new file mode 100644 index 000000000..e07dd7c66 --- /dev/null +++ b/lib/routes/gov/wuhan/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '武汉市人民政府', + url: 'www.wuhan.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/wuhan/whyw.ts b/lib/routes/gov/wuhan/whyw.ts index 6f2f4ec94..0fa6ff9f0 100644 --- a/lib/routes/gov/wuhan/whyw.ts +++ b/lib/routes/gov/wuhan/whyw.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/wuhan/sy/whyw', + path: '/sy/whyw', categories: ['government'], example: '/gov/wuhan/sy/whyw', parameters: {}, @@ -24,7 +24,7 @@ export const route: Route = { source: ['wuhan.gov.cn/sy/whyw/', 'wuhan.gov.cn/whyw', 'wuhan.gov.cn/'], }, ], - name: '武汉要闻', + name: '要闻', maintainers: ['nczitzk'], handler, url: 'wuhan.gov.cn/sy/whyw/', diff --git a/lib/routes/gov/xinyi/namespace.ts b/lib/routes/gov/xinyi/namespace.ts new file mode 100644 index 000000000..549f13aff --- /dev/null +++ b/lib/routes/gov/xinyi/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '信宜市人民政府', + url: 'www.xinyi.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/xinyi/xinyi.ts b/lib/routes/gov/xinyi/xinyi.ts index 496b185a8..b3d6eb5c5 100644 --- a/lib/routes/gov/xinyi/xinyi.ts +++ b/lib/routes/gov/xinyi/xinyi.ts @@ -3,10 +3,19 @@ import type { Route } from '@/types'; import { gdgov } from '../general/general'; export const route: Route = { - path: '/xinyi/*', - name: 'Unknown', - maintainers: [], + path: '/:path{.+}', + name: '通用', + example: '/gov/xinyi/www/zwgk/zcjd', + parameters: { path: '路径,只填写 `www` 默认为 政务公开 > 政策解读' }, + maintainers: ['ShuiHuo'], handler, + description: `::: tip + +路径处填写对应页面 URL 中最前面的部分和域名后的字段。下面是一个例子。 + +若订阅 [政务公开 > 政策解读](http://www.xinyi.gov.cn/zwgk/zcjd/) 则将对应页面 URL 中 \`http://www.xinyi.gov.cn/\` 的字段 \`www\` 和 \`zwgk/zcjd/\` 作为路径填入。此时路由为 [\`/gov/xinyi/www/zwgk/zcjd/\`](https://rsshub.app/gov/xinyi/www/zwgk/zcjd/) + +:::`, }; async function handler(ctx) { @@ -24,5 +33,5 @@ async function handler(ctx) { pubDate_match: '发布时间:(.*)', pubDate_format: undefined, }; - await gdgov(info, ctx); + return await gdgov(info, ctx); } diff --git a/lib/routes/gov/xuzhou/hrss.ts b/lib/routes/gov/xuzhou/hrss.ts index 37d4f8ae9..4ba9339e9 100644 --- a/lib/routes/gov/xuzhou/hrss.ts +++ b/lib/routes/gov/xuzhou/hrss.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/xuzhou/hrss/:category?', + path: '/hrss/:category?', categories: ['government'], example: '/gov/xuzhou/hrss', parameters: { category: '分类,见下表,默认为通知公告' }, @@ -19,7 +19,7 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - name: '徐州市人力资源和社会保障局', + name: '人力资源和社会保障局', maintainers: ['nczitzk'], handler, description: `| 通知公告 | 要闻动态 | 县区动态 | 事业招聘 | 企业招聘 | 政声传递 | diff --git a/lib/routes/gov/xuzhou/namespace.ts b/lib/routes/gov/xuzhou/namespace.ts new file mode 100644 index 000000000..9c9184e3c --- /dev/null +++ b/lib/routes/gov/xuzhou/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '徐州市人民政府', + url: 'www.xuzhou.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/zhejiang/gwy.ts b/lib/routes/gov/zhejiang/gwy.ts index d041d1027..b9c81080d 100644 --- a/lib/routes/gov/zhejiang/gwy.ts +++ b/lib/routes/gov/zhejiang/gwy.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/zhejiang/gwy/:category?/:column?', + path: '/gwy/:category?/:column?', categories: ['government'], example: '/gov/zhejiang/gwy/1', parameters: { category: '分类,见下表,默认为全部', column: '地市专栏,见下表,默认为全部' }, @@ -21,7 +21,7 @@ export const route: Route = { radar: [ { source: ['zjks.gov.cn/zjgwy/website/init.htm', 'zjks.gov.cn/zjgwy/website/queryDetail.htm', 'zjks.gov.cn/zjgwy/website/queryMore.htm'], - target: '/zhejiang/gwy', + target: '/gwy', }, ], name: '通知', diff --git a/lib/routes/gov/zhejiang/namespace.ts b/lib/routes/gov/zhejiang/namespace.ts new file mode 100644 index 000000000..b0fb69340 --- /dev/null +++ b/lib/routes/gov/zhejiang/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '浙江公务员考试录用', + url: 'gwy.zjks.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/zhengce/govall.ts b/lib/routes/gov/zhengce/govall.ts index ca70133c1..5de5ec583 100644 --- a/lib/routes/gov/zhengce/govall.ts +++ b/lib/routes/gov/zhengce/govall.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/zhengce/govall/:advance?', + path: '/govall/:advance?', categories: ['government'], example: '/gov/zhengce/govall/orpro=555¬pro=2&search_field=title', parameters: { advance: '高级搜索选项,将作为请求参数直接添加到url后。目前已知的选项及其意义如下。' }, @@ -22,7 +22,7 @@ export const route: Route = { radar: [ { source: ['www.gov.cn/'], - target: '/zhengce/govall', + target: '/govall', }, ], name: '信息稿件', diff --git a/lib/routes/gov/zhengce/index.ts b/lib/routes/gov/zhengce/index.ts index aa9bb6262..85144e678 100644 --- a/lib/routes/gov/zhengce/index.ts +++ b/lib/routes/gov/zhengce/index.ts @@ -7,10 +7,10 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: ['/zhengce/zuixin', '/zhengce/:category{.+}?'], + path: '/:category{.+}?', categories: ['government'], - example: '/gov/zhengce/zuixin', - parameters: {}, + example: '/gov/zhengce', + parameters: { category: '分类,见下表,默认为最新' }, features: { requireConfig: false, requirePuppeteer: false, @@ -21,16 +21,20 @@ export const route: Route = { }, radar: [ { - source: ['www.gov.cn/zhengce/zuixin.htm', 'www.gov.cn/'], + source: ['www.gov.cn/zhengce/*category'], + target: '/:category', }, ], - name: '最新政策', - maintainers: ['SettingDust', 'nczitzk'], + name: '政策', + maintainers: ['nczitzk'], handler, - url: 'www.gov.cn/zhengce/zuixin.htm', + url: 'www.gov.cn/zhengce/', + description: `| 最新政策 | 政策解读 | 图解政策 | +| -------- | -------- | ----------- | +| zuixin | jiedu | jiedu/tujie |`, }; -async function handler(ctx) { +export async function handler(ctx) { const { category = 'zuixin' } = ctx.req.param(); const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20; diff --git a/lib/routes/gov/zhengce/namespace.ts b/lib/routes/gov/zhengce/namespace.ts new file mode 100644 index 000000000..8f79902b3 --- /dev/null +++ b/lib/routes/gov/zhengce/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '国务院政策文件库', + url: 'www.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/zhengce/wenjian.ts b/lib/routes/gov/zhengce/wenjian.ts index 4d3356b94..805a812c0 100644 --- a/lib/routes/gov/zhengce/wenjian.ts +++ b/lib/routes/gov/zhengce/wenjian.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; export const route: Route = { - path: '/zhengce/wenjian/:pcodeJiguan?', + path: '/wenjian/:pcodeJiguan?', categories: ['government'], example: '/gov/zhengce/wenjian', parameters: { pcodeJiguan: '文种分类。国令、国发、国函、国发明电、国办发、国办函、国办发明电、其他' }, @@ -22,7 +22,7 @@ export const route: Route = { radar: [ { source: ['www.gov.cn/'], - target: '/zhengce/wenjian', + target: '/wenjian', }, ], name: '最新文件', diff --git a/lib/routes/gov/zhengce/zhengceku.ts b/lib/routes/gov/zhengce/zhengceku.ts index 99536e601..feacba3be 100644 --- a/lib/routes/gov/zhengce/zhengceku.ts +++ b/lib/routes/gov/zhengce/zhengceku.ts @@ -2,7 +2,7 @@ import type { Route } from '@/types'; import buildData from '@/utils/common-config'; export const route: Route = { - path: '/zhengce/zhengceku/:department', + path: '/zhengceku/:department', categories: ['government'], example: '/gov/zhengce/zhengceku/bmwj', parameters: { department: '库名' }, @@ -14,7 +14,7 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - name: '国务院政策文件库', + name: '政策文件库', maintainers: ['zxx-457'], handler, }; diff --git a/lib/routes/gov/zhengce/zuixin.ts b/lib/routes/gov/zhengce/zuixin.ts new file mode 100644 index 000000000..33c613794 --- /dev/null +++ b/lib/routes/gov/zhengce/zuixin.ts @@ -0,0 +1,18 @@ +import type { Route } from '@/types'; + +import { handler } from './index'; + +export const route: Route = { + path: '/zuixin', + categories: ['government'], + example: '/gov/zhengce/zuixin', + radar: [ + { + source: ['www.gov.cn/zhengce/zuixin.htm', 'www.gov.cn/'], + }, + ], + name: '最新政策', + maintainers: ['SettingDust', 'nczitzk'], + handler, + url: 'www.gov.cn/zhengce/zuixin.htm', +}; diff --git a/lib/routes/gov/zj/namespace.ts b/lib/routes/gov/zj/namespace.ts new file mode 100644 index 000000000..9af9e05b6 --- /dev/null +++ b/lib/routes/gov/zj/namespace.ts @@ -0,0 +1,8 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: '浙江省人民政府', + url: 'www.zj.gov.cn', + categories: ['government'], + lang: 'zh-CN', +}; diff --git a/lib/routes/gov/zj/ningbogzw-notice.ts b/lib/routes/gov/zj/ningbogzw-notice.ts index 61b26a86a..3ee5452db 100644 --- a/lib/routes/gov/zj/ningbogzw-notice.ts +++ b/lib/routes/gov/zj/ningbogzw-notice.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/zj/ningbogzw-notice/:colId?', + path: '/ningbogzw-notice/:colId?', categories: ['government'], example: '/gov/zj/ningbogzw-notice/1229116730', parameters: { @@ -14,7 +14,7 @@ export const route: Route = { radar: [ { source: ['gzw.ningbo.gov.cn/col/col1229116730/index.html'], - target: '/zj/ningbogzw-notice/:colId?', + target: '/ningbogzw-notice/:colId?', }, ], name: '宁波市国资委-公告', diff --git a/lib/routes/gov/zj/ningborsjnotice.ts b/lib/routes/gov/zj/ningborsjnotice.ts index d9e06dad3..c8049103d 100644 --- a/lib/routes/gov/zj/ningborsjnotice.ts +++ b/lib/routes/gov/zj/ningborsjnotice.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/zj/ningborsjnotice/:colId?', + path: '/ningborsjnotice/:colId?', categories: ['government'], example: '/gov/zj/ningborsjnotice/1229676740', parameters: { @@ -14,7 +14,7 @@ export const route: Route = { radar: [ { source: ['rsj.ningbo.gov.cn/col/col1229676740/index.html'], - target: '/zj/ningborsjnotice/:colId?', + target: '/ningborsjnotice/:colId?', }, ], name: '宁波市人力资源和社会保障局-公告', diff --git a/lib/routes/gov/zj/search.ts b/lib/routes/gov/zj/search.ts index 32325f78b..cfc29fd43 100644 --- a/lib/routes/gov/zj/search.ts +++ b/lib/routes/gov/zj/search.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/zj/search/:websiteid?/:word/:cateid?', + path: '/search/:websiteid?/:word/:cateid?', categories: ['government'], example: '/gov/zj/search', parameters: { @@ -18,10 +18,10 @@ export const route: Route = { radar: [ { source: ['search.zj.gov.cn/jsearchfront/search.do'], - target: '/zj/search/:websiteid?/:word/:cateid?', + target: '/search/:websiteid?/:word/:cateid?', }, ], - name: '浙江省人民政府-全省政府网站统一搜索', + name: '全省政府网站统一搜索', url: 'search.zj.gov.cn/jsearchfront/search.do', maintainers: ['HaoyuLee'], description: `| 行政区域 | websiteid | diff --git a/lib/routes/cbirc/namespace.ts b/lib/routes/tqyb/namespace.ts similarity index 55% rename from lib/routes/cbirc/namespace.ts rename to lib/routes/tqyb/namespace.ts index c21982ff1..2e29d15da 100644 --- a/lib/routes/cbirc/namespace.ts +++ b/lib/routes/tqyb/namespace.ts @@ -1,7 +1,8 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { - name: '中国银行保险监督管理委员会', - url: 'cbirc.gov.cn', + name: '广东天气', + url: 'www.tqyb.com.cn', + categories: ['forecast'], lang: 'zh-CN', }; diff --git a/lib/routes/gov/guangdong/tqyb/sncsyjxh.tsx b/lib/routes/tqyb/sncsyjxh.tsx similarity index 96% rename from lib/routes/gov/guangdong/tqyb/sncsyjxh.tsx rename to lib/routes/tqyb/sncsyjxh.tsx index 8399a86e3..6796c63e4 100644 --- a/lib/routes/gov/guangdong/tqyb/sncsyjxh.tsx +++ b/lib/routes/tqyb/sncsyjxh.tsx @@ -8,9 +8,9 @@ import timezone from '@/utils/timezone'; const rootUrl = 'http://www.tqyb.com.cn'; export const route: Route = { - path: '/guangdong/tqyb/sncsyjxh', + path: '/sncsyjxh', categories: ['forecast'], - example: '/gov/guangdong/tqyb/sncsyjxh', + example: '/tqyb/sncsyjxh', parameters: {}, features: { requireConfig: false, diff --git a/lib/routes/gov/guangdong/tqyb/tfxtq.tsx b/lib/routes/tqyb/tfxtq.tsx similarity index 94% rename from lib/routes/gov/guangdong/tqyb/tfxtq.tsx rename to lib/routes/tqyb/tfxtq.tsx index a2c09e3e2..86567416b 100644 --- a/lib/routes/gov/guangdong/tqyb/tfxtq.tsx +++ b/lib/routes/tqyb/tfxtq.tsx @@ -7,9 +7,9 @@ import { parseDate } from '@/utils/parse-date'; const rootUrl = 'http://www.tqyb.com.cn'; export const route: Route = { - path: '/guangdong/tqyb/tfxtq', + path: '/tfxtq', categories: ['forecast'], - example: '/gov/guangdong/tqyb/tfxtq', + example: '/tqyb/tfxtq', parameters: {}, features: { requireConfig: false,