From 7bf7c5099bbd43f36ab34dd0cb48b603c002e655 Mon Sep 17 00:00:00 2001 From: xiongxiao Date: Thu, 19 Mar 2026 03:33:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20CNB=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=A3=80=E6=B5=8B=EF=BC=8C=E7=89=88=E6=9C=AC=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=87=B3=200.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/modules/cnb.ts | 4 ++++ src/pages/code-graph/store/index.ts | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 src/modules/cnb.ts diff --git a/package.json b/package.json index 986cd21..2df7794 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "code-graph", "private": true, - "version": "0.0.1", + "version": "0.0.2", "type": "module", "basename": "/root/code-graph", "scripts": { @@ -9,7 +9,7 @@ "build": "vite build", "preview": "vite preview", "ui": "bunx shadcn@latest add ", - "pub": "envision deploy ./dist -k code-graph -v 0.0.1 -y y -u" + "pub": "envision deploy ./dist -k code-graph -v 0.0.2 -y y -u" }, "files": [ "dist" diff --git a/src/modules/cnb.ts b/src/modules/cnb.ts new file mode 100644 index 0000000..380b277 --- /dev/null +++ b/src/modules/cnb.ts @@ -0,0 +1,4 @@ +export const isCNB = () => { + const hostname = window.location.hostname; + return hostname.endsWith('.cnb.run') || hostname.includes('localhost'); +} diff --git a/src/pages/code-graph/store/index.ts b/src/pages/code-graph/store/index.ts index ea4096a..3bdbf35 100644 --- a/src/pages/code-graph/store/index.ts +++ b/src/pages/code-graph/store/index.ts @@ -7,6 +7,7 @@ import { FileProjectData } from '../modules/tree'; import { UserInfo } from '@/pages/auth/store'; import { Result } from '@kevisual/query'; import { AssistantMessage, Part } from '@opencode-ai/sdk' +import { isCNB } from '@/modules/cnb'; export type ProjectItem = { path: string; name?: string; @@ -223,7 +224,10 @@ export const useCodeGraphStore = create()((set, get) => ({ // 可以在这里根据用户信息初始化一些数据,比如权限相关的设置等 console.log('CodeGraphStore initialized for user:', user.username); const username = user.username; - const url = username ? `/${username}/v1/dev-cnb` : API_URL; + let url = username ? `/${username}/v1/dev-cnb` : API_URL; + if (isCNB()) { + url = `/client/router`; + } set({ url }); const load = opts.load ?? true; if (load) {