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) {