From 73d0fb97308dc5b13ac1cb26e0e8b2464b817985 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sat, 28 Feb 2026 04:33:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96=E8=AE=BF=E9=97=AE=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/module/assistant/config/index.ts | 25 ++++++++++++++++--- assistant/src/routes/config/index.ts | 8 ++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/assistant/src/module/assistant/config/index.ts b/assistant/src/module/assistant/config/index.ts index 0139bb3..900c187 100644 --- a/assistant/src/module/assistant/config/index.ts +++ b/assistant/src/module/assistant/config/index.ts @@ -381,13 +381,22 @@ export class AssistantConfig { protected getDefaultInitAssistantConfig() { const id = randomId(); const isCNB = !!useKey('CNB'); + let kevisualUrl = 'https://kevisual.cn'; + if (isCNB) { + const uri = getCNBUrl(); + if (uri) { + kevisualUrl = uri; + } else { + kevisualUrl = 'http://kevisual.cn'; + } + } return { app: { - url: 'https://kevisual.cn', + url: kevisualUrl, id, }, description: '助手配置文件', - docs: "https://kevisual.cn/root/cli/docs/", + docs: `${kevisualUrl}/root/cli/docs/`, home: isCNB ? '/root/cli-center' : '/root/home', proxy: [], share: { @@ -413,4 +422,14 @@ export const parseIfJson = (content: string) => { export * from './args.ts'; -const randomId = () => Math.random().toString(36).substring(2, 8); \ No newline at end of file +const randomId = () => Math.random().toString(36).substring(2, 8); + +export const getCNBUrl = () => { + const isCNB = !!useKey('CNB'); + const uri = useKey('CNB_VSCODE_PROXY_URI') as string; + if (!isCNB) return null + if (uri) { + return uri.replace('{{port}}', '51515'); + } + return null +} \ No newline at end of file diff --git a/assistant/src/routes/config/index.ts b/assistant/src/routes/config/index.ts index 5cf0dea..2f07a1b 100644 --- a/assistant/src/routes/config/index.ts +++ b/assistant/src/routes/config/index.ts @@ -1,5 +1,7 @@ import { app, assistantConfig } from '@/app.ts'; import { reload } from '../../module/reload-server.ts'; +import { useKey } from '@kevisual/context'; +import { getCNBUrl } from '@/lib.ts'; app .route({ @@ -29,13 +31,15 @@ app app.route({ path: 'config', key: 'getId', - description: '获取appId', + description: '获取appId和访问地址', }).define(async (ctx) => { const config = assistantConfig.getCacheAssistantConfig(); const appId = config?.app?.id || null; + let kevisualUrl = getCNBUrl() || 'https://kevisual.cn'; ctx.body = { id: appId, + url: kevisualUrl, } -}).addTo(app); \ No newline at end of file +}).addTo(app);