feat: 添加 CNB 环境检测,版本更新至 0.0.2

This commit is contained in:
xiongxiao
2026-03-19 03:33:52 +08:00
committed by cnb
parent 155a126c6e
commit 7bf7c5099b
3 changed files with 11 additions and 3 deletions

View File

@@ -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"

4
src/modules/cnb.ts Normal file
View File

@@ -0,0 +1,4 @@
export const isCNB = () => {
const hostname = window.location.hostname;
return hostname.endsWith('.cnb.run') || hostname.includes('localhost');
}

View File

@@ -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<State>()((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) {