Commit 52c97ca6 by weiw

fix:同步内外网代码

parent b918f01c
...@@ -8,12 +8,15 @@ import { AuthProvider } from './auth/AuthContext' ...@@ -8,12 +8,15 @@ import { AuthProvider } from './auth/AuthContext'
import ToastWrapper from './components/ToastWrapper/ToastWrapper' import ToastWrapper from './components/ToastWrapper/ToastWrapper'
import { store } from './store' import { store } from './store'
const viteOutputObj = import.meta.env.VITE_OUTPUT_OBJ || 'open'
const basename = viteOutputObj === 'inner' ? '/sdream-fe' : '/sdream-ai'
const App: React.FC = () => { const App: React.FC = () => {
return ( return (
<Provider store={store}> <Provider store={store}>
<ToastWrapper> <ToastWrapper>
<AuthProvider> <AuthProvider>
<Router basename="/sdream-ai"> <Router basename={basename}>
<MainLayout> <MainLayout>
<AppRoutes /> <AppRoutes />
</MainLayout> </MainLayout>
......
...@@ -93,7 +93,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => { ...@@ -93,7 +93,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
// eslint-disable-next-line react-refresh/only-export-components // eslint-disable-next-line react-refresh/only-export-components
export function useAuth(): AuthContextType { export function useAuth(): AuthContextType {
const context = useContext(AuthContext) const context = useContext(AuthContext)
if (context === undefined) { if (context === null) {
throw new Error('useAuth must be used within an AuthProvider') throw new Error('useAuth must be used within an AuthProvider')
} }
return context return context
......
...@@ -81,7 +81,7 @@ export function deepMerge<T extends object = object, S extends object = T>(targe ...@@ -81,7 +81,7 @@ export function deepMerge<T extends object = object, S extends object = T>(targe
return target as any return target as any
const source = sources.shift() const source = sources.shift()
if (source === undefined) if (source === null)
return target as any return target as any
if (isMergableObject(target) && isMergableObject(source)) { if (isMergableObject(target) && isMergableObject(source)) {
...@@ -131,7 +131,7 @@ export function deepMergeWithArray<T extends object = object, S extends object = ...@@ -131,7 +131,7 @@ export function deepMergeWithArray<T extends object = object, S extends object =
return target as any return target as any
const source = sources.shift() const source = sources.shift()
if (source === undefined) if (source === null)
return target as any return target as any
if (Array.isArray(target) && Array.isArray(source)) if (Array.isArray(target) && Array.isArray(source))
...@@ -198,7 +198,7 @@ export function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[ ...@@ -198,7 +198,7 @@ export function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[
*/ */
export function clearUndefined<T extends object>(obj: T): T { export function clearUndefined<T extends object>(obj: T): T {
// @ts-expect-error // @ts-expect-error
Object.keys(obj).forEach((key: string) => (obj[key] === undefined ? delete obj[key] : {})) Object.keys(obj).forEach((key: string) => (obj[key] === null ? delete obj[key] : {}))
return obj return obj
} }
......
...@@ -130,7 +130,7 @@ export function unindent(str: TemplateStringsArray | string) { ...@@ -130,7 +130,7 @@ export function unindent(str: TemplateStringsArray | string) {
if (whitespaceLines[idx]) if (whitespaceLines[idx])
return min return min
const indent = line.match(/^\s*/)?.[0].length const indent = line.match(/^\s*/)?.[0].length
return indent === undefined ? min : Math.min(min, indent) return indent === null ? min : Math.min(min, indent)
}, Number.POSITIVE_INFINITY) }, Number.POSITIVE_INFINITY)
let emptyLinesHead = 0 let emptyLinesHead = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment