fix(web): use env flag to hide graph menu at build time

This commit is contained in:
肖泽涛 2026-02-28 17:13:51 +08:00
parent 835f0786b2
commit e2060de810
4 changed files with 21 additions and 1 deletions

View File

@ -104,6 +104,10 @@ services:
context: . context: .
dockerfile: docker/web.Dockerfile dockerfile: docker/web.Dockerfile
target: production target: production
args:
VITE_API_URL: ${VITE_API_URL:-http://api:5050}
VITE_USE_RUNS_API: ${VITE_USE_RUNS_API:-false}
VITE_ENABLE_KNOWLEDGE_GRAPH: ${YUXI_ENABLE_KNOWLEDGE_GRAPH:-true}
image: yuxi-web:0.5.prod image: yuxi-web:0.5.prod
container_name: web-prod container_name: web-prod
ports: ports:
@ -116,6 +120,7 @@ services:
- NODE_ENV=production - NODE_ENV=production
- VITE_API_URL=http://api:5050 - VITE_API_URL=http://api:5050
- VITE_USE_RUNS_API=${VITE_USE_RUNS_API:-false} - VITE_USE_RUNS_API=${VITE_USE_RUNS_API:-false}
- VITE_ENABLE_KNOWLEDGE_GRAPH=${YUXI_ENABLE_KNOWLEDGE_GRAPH:-true}
command: nginx -g "daemon off;" command: nginx -g "daemon off;"
restart: unless-stopped restart: unless-stopped

View File

@ -141,6 +141,7 @@ services:
- NODE_ENV=development - NODE_ENV=development
- VITE_API_URL=http://api:5050 - VITE_API_URL=http://api:5050
- VITE_USE_RUNS_API=${VITE_USE_RUNS_API:-false} - VITE_USE_RUNS_API=${VITE_USE_RUNS_API:-false}
- VITE_ENABLE_KNOWLEDGE_GRAPH=${YUXI_ENABLE_KNOWLEDGE_GRAPH:-true}
command: pnpm run server command: pnpm run server
restart: unless-stopped restart: unless-stopped

View File

@ -28,6 +28,14 @@ WORKDIR /app
# 安装 pnpm # 安装 pnpm
RUN npm install -g pnpm@latest RUN npm install -g pnpm@latest
# 构建阶段注入前端环境变量Vite 在 build 时读取)
ARG VITE_API_URL=http://api:5050
ARG VITE_USE_RUNS_API=false
ARG VITE_ENABLE_KNOWLEDGE_GRAPH=true
ENV VITE_API_URL=${VITE_API_URL}
ENV VITE_USE_RUNS_API=${VITE_USE_RUNS_API}
ENV VITE_ENABLE_KNOWLEDGE_GRAPH=${VITE_ENABLE_KNOWLEDGE_GRAPH}
# 复制依赖文件 # 复制依赖文件
COPY ./web/package*.json ./ COPY ./web/package*.json ./
COPY ./web/pnpm-lock.yaml* ./ COPY ./web/pnpm-lock.yaml* ./

View File

@ -37,6 +37,11 @@ const showDebugModal = ref(false)
// Add state for settings modal // Add state for settings modal
const showSettingsModal = ref(false) const showSettingsModal = ref(false)
const graphMenuVisible = computed(() => {
const value = String(import.meta.env.VITE_ENABLE_KNOWLEDGE_GRAPH ?? 'true').toLowerCase()
return value === 'true'
})
// Provide settings modal methods to child components // Provide settings modal methods to child components
const openSettingsModal = () => { const openSettingsModal = () => {
showSettingsModal.value = true showSettingsModal.value = true
@ -100,7 +105,8 @@ const mainList = computed(() => {
name: '图谱', name: '图谱',
path: '/graph', path: '/graph',
icon: Waypoints, icon: Waypoints,
activeIcon: Waypoints activeIcon: Waypoints,
hidden: !graphMenuVisible.value
}, },
{ {
name: '知识库', name: '知识库',