feat: 添加 CNB 环境检测,版本更新至 0.0.2
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "code-graph",
|
"name": "code-graph",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"basename": "/root/code-graph",
|
"basename": "/root/code-graph",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"ui": "bunx shadcn@latest add ",
|
"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": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
|
|||||||
4
src/modules/cnb.ts
Normal file
4
src/modules/cnb.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const isCNB = () => {
|
||||||
|
const hostname = window.location.hostname;
|
||||||
|
return hostname.endsWith('.cnb.run') || hostname.includes('localhost');
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import { FileProjectData } from '../modules/tree';
|
|||||||
import { UserInfo } from '@/pages/auth/store';
|
import { UserInfo } from '@/pages/auth/store';
|
||||||
import { Result } from '@kevisual/query';
|
import { Result } from '@kevisual/query';
|
||||||
import { AssistantMessage, Part } from '@opencode-ai/sdk'
|
import { AssistantMessage, Part } from '@opencode-ai/sdk'
|
||||||
|
import { isCNB } from '@/modules/cnb';
|
||||||
export type ProjectItem = {
|
export type ProjectItem = {
|
||||||
path: string;
|
path: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -223,7 +224,10 @@ export const useCodeGraphStore = create<State>()((set, get) => ({
|
|||||||
// 可以在这里根据用户信息初始化一些数据,比如权限相关的设置等
|
// 可以在这里根据用户信息初始化一些数据,比如权限相关的设置等
|
||||||
console.log('CodeGraphStore initialized for user:', user.username);
|
console.log('CodeGraphStore initialized for user:', user.username);
|
||||||
const username = 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 });
|
set({ url });
|
||||||
const load = opts.load ?? true;
|
const load = opts.load ?? true;
|
||||||
if (load) {
|
if (load) {
|
||||||
|
|||||||
Reference in New Issue
Block a user