mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 01:17:43 +00:00
perf(SystemSettingsProvider): remove loading
This commit is contained in:
parent
667b967339
commit
7f6f133223
@ -460,6 +460,14 @@ export const InternalAdminLayout = () => {
|
|||||||
]);
|
]);
|
||||||
const fontSizeStyle = useMemo(() => ({ fontSize: token.fontSizeHeading3 }), [token.fontSizeHeading3]);
|
const fontSizeStyle = useMemo(() => ({ fontSize: token.fontSizeHeading3 }), [token.fontSizeHeading3]);
|
||||||
|
|
||||||
|
const logo = result?.data?.data?.logo?.url ? (
|
||||||
|
<img className={className2} src={result?.data?.data?.logo?.url} />
|
||||||
|
) : (
|
||||||
|
<span style={fontSizeStyle} className={className3}>
|
||||||
|
{result?.data?.data?.title}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<GlobalStyleForAdminLayout />
|
<GlobalStyleForAdminLayout />
|
||||||
@ -469,15 +477,7 @@ export const InternalAdminLayout = () => {
|
|||||||
<Layout.Header className={layoutHeaderCss}>
|
<Layout.Header className={layoutHeaderCss}>
|
||||||
<div style={style1}>
|
<div style={style1}>
|
||||||
<div style={style2}>
|
<div style={style2}>
|
||||||
<div className={className1}>
|
<div className={className1}>{result.loading ? null : logo}</div>
|
||||||
{result?.data?.data?.logo?.url ? (
|
|
||||||
<img className={className2} src={result?.data?.data?.logo?.url} />
|
|
||||||
) : (
|
|
||||||
<span style={fontSizeStyle} className={className3}>
|
|
||||||
{result?.data?.data?.title}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className={className4}>
|
<div className={className4}>
|
||||||
<SetThemeOfHeaderSubmenu>
|
<SetThemeOfHeaderSubmenu>
|
||||||
<MenuEditor sideMenuRef={sideMenuRef} />
|
<MenuEditor sideMenuRef={sideMenuRef} />
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
import { Result } from 'ahooks/es/useRequest/src/types';
|
import { Result } from 'ahooks/es/useRequest/src/types';
|
||||||
import React, { createContext, ReactNode, useContext } from 'react';
|
import React, { createContext, ReactNode, useContext } from 'react';
|
||||||
import { useRequest } from '../api-client';
|
import { useRequest } from '../api-client';
|
||||||
import { useAppSpin } from '../application/hooks/useAppSpin';
|
|
||||||
|
|
||||||
export const SystemSettingsContext = createContext<Result<any, any>>(null);
|
export const SystemSettingsContext = createContext<Result<any, any>>(null);
|
||||||
SystemSettingsContext.displayName = 'SystemSettingsContext';
|
SystemSettingsContext.displayName = 'SystemSettingsContext';
|
||||||
@ -20,13 +19,9 @@ export const useSystemSettings = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SystemSettingsProvider: React.FC<{ children?: ReactNode }> = (props) => {
|
export const SystemSettingsProvider: React.FC<{ children?: ReactNode }> = (props) => {
|
||||||
const { render } = useAppSpin();
|
|
||||||
const result = useRequest({
|
const result = useRequest({
|
||||||
url: 'systemSettings:get/1?appends=logo',
|
url: 'systemSettings:get/1?appends=logo',
|
||||||
});
|
});
|
||||||
if (result.loading) {
|
|
||||||
return render();
|
|
||||||
}
|
|
||||||
|
|
||||||
return <SystemSettingsContext.Provider value={result}>{props.children}</SystemSettingsContext.Provider>;
|
return <SystemSettingsContext.Provider value={result}>{props.children}</SystemSettingsContext.Provider>;
|
||||||
};
|
};
|
||||||
|
@ -39,7 +39,7 @@ const useSystemSettingsValues = (options) => {
|
|||||||
const result = useSystemSettings();
|
const result = useSystemSettings();
|
||||||
return useRequest(() => Promise.resolve(result.data), {
|
return useRequest(() => Promise.resolve(result.data), {
|
||||||
...options,
|
...options,
|
||||||
refreshDeps: [visible],
|
refreshDeps: [visible, result.data],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user