Skip to content

Commit

Permalink
fix: Fixed the issue where the export mode would try to request backe…
Browse files Browse the repository at this point in the history
…nd data
  • Loading branch information
Amery2010 committed Jan 3, 2025
1 parent 0341d15 commit ec4f4c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion components/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ function Setting({ open, hiddenTalkPanel, onClose }: SettingProps) {
useLayoutEffect(() => {
if (buildMode === 'export') {
setHiddenPasswordInput(true)
} else if (open && !cachedModelList) {
}
if (open && !cachedModelList) {
const { update } = useModelStore.getState()
const { apiKey, apiProxy, password } = useSettingStore.getState()
if (apiKey || !isProtected) {
Expand Down
18 changes: 11 additions & 7 deletions components/StoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
import { useLayoutEffect } from 'react'
import { useEnvStore } from '@/store/setting'

const NEXT_PUBLIC_BUILD_MODE = process.env.NEXT_PUBLIC_BUILD_MODE || 'default'

interface Props {
children: React.ReactNode
}

function StoreProvider({ children }: Props) {
useLayoutEffect(() => {
const { update } = useEnvStore.getState()
fetch('/api/env')
.then(async (response) => {
const env = await response.json()
update(env)
})
.catch(console.error)
if (NEXT_PUBLIC_BUILD_MODE !== 'export') {
const { update } = useEnvStore.getState()
fetch('/api/env')
.then(async (response) => {
const env = await response.json()
update(env)
})
.catch(console.error)
}
}, [])

return children
Expand Down
2 changes: 1 addition & 1 deletion store/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ export const useEnvStore = create<EnvStore>((set) => ({
modelList: '',
uploadLimit: 0,
buildMode: '',
isProtected: false,
isProtected: true,
update: (values) => set(values),
}))

0 comments on commit ec4f4c3

Please sign in to comment.