From 9400ccf2292ce7c252b1a6fbf9690d88a2308c87 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sun, 15 Feb 2026 20:08:22 +0800 Subject: [PATCH] temp --- query/query-proxy/proxy.ts | 23 ++++++++++++++--------- query/query-proxy/router-api-proxy.ts | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/query/query-proxy/proxy.ts b/query/query-proxy/proxy.ts index f1cc0bb..c4b3dce 100644 --- a/query/query-proxy/proxy.ts +++ b/query/query-proxy/proxy.ts @@ -62,7 +62,7 @@ export type RouterViewWorker = { } & RouteViewBase; /** - * 去掉不需要保存都服务器的数据 + * 去掉不需要保存的服务器的数据 * @param item * @returns */ @@ -100,6 +100,9 @@ export type RouterViewQuery = { query: string, title: string } +/** + * 后端存储结构 + */ export type RouterViewData = { data: { items: RouterViewItem[]; } views: RouterViewQuery[]; @@ -121,7 +124,7 @@ export class QueryProxy { this.initRouterViewQuery(); this.emitter = new EventEmitter(); } - getDefulatToken() { + private getDefulatToken() { try { if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') { return localStorage.getItem('token') || undefined; @@ -139,7 +142,7 @@ export class QueryProxy { }); } - initRouterView(item: RouterViewItem) { + private initRouterView(item: RouterViewItem) { if (item.type === 'api' && item.api?.url) { const url = item.api.url; if (item?.api?.query) return item; @@ -253,6 +256,7 @@ export class QueryProxy { console.debug(`注册路由: [${r.path}] ${r?.key}`, 'Context'); let metadata = r.metadata || {}; metadata.viewItem = item; + metadata.source = 'query-proxy-context'; this.router.route({ path: r.path, key: r.key || '', @@ -268,7 +272,7 @@ export class QueryProxy { generateId() { return 'route_' + Math.random().toString(36).substring(2, 9); } - async callWorker(msg: any, viewItem: RouterViewWorker['worker']): Promise { + private async callWorker(msg: any, viewItem: RouterViewWorker['worker']): Promise { const that = this; const requestId = this.generateId(); const worker = viewItem?.worker; @@ -296,7 +300,7 @@ export class QueryProxy { }); }); } - async initWorker(item?: RouterViewWorker, initRoutes: boolean = true) { + private async initWorker(item?: RouterViewWorker, initRoutes: boolean = true) { const that = this; if (!item?.worker?.url) { console.warn('Worker URL not provided'); @@ -347,6 +351,7 @@ export class QueryProxy { console.debug(`注册路由: [${r.path}] ${r?.key}`, 'API'); let metadata = r.metadata || {}; metadata.viewItem = item; + metadata.source = 'query-proxy-worker'; this.router.route({ path: r.path, key: r.key || '', @@ -364,7 +369,7 @@ export class QueryProxy { } } } - async initPage(item?: RouteViewPage) { + private async initPage(item?: RouteViewPage) { if (!item?.page?.url) { console.warn('Page地址未提供'); return; @@ -381,7 +386,7 @@ export class QueryProxy { return; } } - getQueryByViewId(viewId: string): string | undefined { + private getQueryByViewId(viewId: string): string | undefined { const view = this.views.find(v => v.id === viewId); if (view) { return view.query; @@ -465,7 +470,7 @@ export class QueryProxy { item.response = res; return item; } - item.response = { code: 500, message: '无法处理的路由类型' }; + item.response = { code: 500, message: '无法处理的路由类型', data: item }; return item; } } @@ -477,4 +482,4 @@ export type RouterItem = { description?: string; middleware?: string[]; metadata?: Record; -} \ No newline at end of file +} diff --git a/query/query-proxy/router-api-proxy.ts b/query/query-proxy/router-api-proxy.ts index 0e5e345..0820023 100644 --- a/query/query-proxy/router-api-proxy.ts +++ b/query/query-proxy/router-api-proxy.ts @@ -38,6 +38,7 @@ export const initApi = async (opts: { let metadata = r.metadata || {}; metadata.viewItem = item; metadata.url = query.url; + metadata.source = 'query-proxy-api'; router.route({ path: r.path, key: r.key || '',