mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 01:36:27 +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 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 (
|
||||
<Layout>
|
||||
<GlobalStyleForAdminLayout />
|
||||
@ -469,15 +477,7 @@ export const InternalAdminLayout = () => {
|
||||
<Layout.Header className={layoutHeaderCss}>
|
||||
<div style={style1}>
|
||||
<div style={style2}>
|
||||
<div className={className1}>
|
||||
{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={className1}>{result.loading ? null : logo}</div>
|
||||
<div className={className4}>
|
||||
<SetThemeOfHeaderSubmenu>
|
||||
<MenuEditor sideMenuRef={sideMenuRef} />
|
||||
|
@ -10,7 +10,6 @@
|
||||
import { Result } from 'ahooks/es/useRequest/src/types';
|
||||
import React, { createContext, ReactNode, useContext } from 'react';
|
||||
import { useRequest } from '../api-client';
|
||||
import { useAppSpin } from '../application/hooks/useAppSpin';
|
||||
|
||||
export const SystemSettingsContext = createContext<Result<any, any>>(null);
|
||||
SystemSettingsContext.displayName = 'SystemSettingsContext';
|
||||
@ -20,13 +19,9 @@ export const useSystemSettings = () => {
|
||||
};
|
||||
|
||||
export const SystemSettingsProvider: React.FC<{ children?: ReactNode }> = (props) => {
|
||||
const { render } = useAppSpin();
|
||||
const result = useRequest({
|
||||
url: 'systemSettings:get/1?appends=logo',
|
||||
});
|
||||
if (result.loading) {
|
||||
return render();
|
||||
}
|
||||
|
||||
return <SystemSettingsContext.Provider value={result}>{props.children}</SystemSettingsContext.Provider>;
|
||||
};
|
||||
|
@ -39,7 +39,7 @@ const useSystemSettingsValues = (options) => {
|
||||
const result = useSystemSettings();
|
||||
return useRequest(() => Promise.resolve(result.data), {
|
||||
...options,
|
||||
refreshDeps: [visible],
|
||||
refreshDeps: [visible, result.data],
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user