From 2d7375e32d3a0ce44f43f0abc95e8babaa0b650d Mon Sep 17 00:00:00 2001 From: abearxiong Date: Tue, 3 Feb 2026 02:54:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E8=87=B3?= =?UTF-8?q?=200.0.44=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BB=8E=20JSON=20Schema?= =?UTF-8?q?=20=E8=BD=AC=E6=8D=A2=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- query/query-proxy/proxy.ts | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 060fc5c..ae37d3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/api", - "version": "0.0.43", + "version": "0.0.44", "description": "", "main": "mod.ts", "scripts": { diff --git a/query/query-proxy/proxy.ts b/query/query-proxy/proxy.ts index cf884d3..9c0cf7a 100644 --- a/query/query-proxy/proxy.ts +++ b/query/query-proxy/proxy.ts @@ -1,5 +1,5 @@ import { QueryClient as Query, Result } from '@kevisual/query'; -import { QueryRouterServer, type App, type Route } from '@kevisual/router/browser'; +import { QueryRouterServer, type App, type Route, fromJSONSchema, toJSONSchema } from '@kevisual/router/browser'; import { filter } from '@kevisual/js-filter' import { EventEmitter } from 'eventemitter3'; import { initApi } from './router-api-proxy.ts'; @@ -190,6 +190,7 @@ export class QueryProxy { /** * 初始化路由 + * main * @returns */ async init() { @@ -246,6 +247,8 @@ export class QueryProxy { return } const routes = router.getList(); + // TODO: args + // const args = fromJSONSchema(r); for (const r of routes) { console.debug(`注册路由: [${r.path}] ${r?.key}`, 'Context'); let metadata = r.metadata || {}; @@ -378,6 +381,13 @@ export class QueryProxy { return; } } + getQueryByViewId(viewId: string): string | undefined { + const view = this.views.find(v => v.id === viewId); + if (view) { + return view.query; + } + return undefined; + } /** * 列出路由 * @param filter @@ -386,14 +396,10 @@ export class QueryProxy { */ async listRoutes(filterFn?: (item: Route) => boolean, opts?: { viewId?: string, query?: string }) { let query = opts?.query; - if (opts?.viewId) { - const view = this.views.find(v => v.id === opts.viewId); - if (view) { - query = view.query; - } - } if (opts?.query) { - query = opts.query; + if (opts?.viewId && !query) { + query = this.getQueryByViewId(opts.viewId); } + const routes = this.router.routes.filter(filterFn || (() => true)); if (query) { if (query.toLocaleUpperCase().startsWith('WHERE')) {