fix: content loading

This commit is contained in:
chenos 2022-04-24 12:39:23 +08:00
parent 8acba12025
commit d32261bb88
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import { Spin } from 'antd';
import React from 'react';
import React, { useState } from 'react';
import { useAPIClient, useRequest } from '../api-client';
import { CollectionManagerSchemaComponentProvider } from './CollectionManagerSchemaComponentProvider';
import { CollectionManagerContext } from './context';
@ -28,6 +28,7 @@ export const CollectionManagerProvider: React.FC<CollectionManagerOptions> = (pr
export const RemoteCollectionManagerProvider = (props: any) => {
const api = useAPIClient();
const [contentLoading, setContentLoading] = useState(false);
const options = {
resource: 'collections',
action: 'list',
@ -46,11 +47,13 @@ export const RemoteCollectionManagerProvider = (props: any) => {
}
return (
<CollectionManagerProvider
service={service}
service={{...service, contentLoading, setContentLoading}}
collections={service?.data?.data}
refreshCM={async () => {
setContentLoading(true);
const { data } = await api.request(options);
service.mutate(data);
setContentLoading(false);
}}
{...props}
/>

View File

@ -1,9 +1,10 @@
import { css } from '@emotion/css';
import { Layout } from 'antd';
import { Layout, Spin } from 'antd';
import React, { useRef, useState } from 'react';
import { useHistory, useRouteMatch } from 'react-router-dom';
import {
ACLAllowConfigure, ACLRolesCheckProvider,
ACLAllowConfigure,
ACLRolesCheckProvider,
CurrentUser,
CurrentUserProvider,
findByUid,
@ -17,6 +18,7 @@ import {
useRoute,
useSystemSettings
} from '../../../';
import { useCollectionManager } from '../../../collection-manager';
import { PoweredBy } from '../../../powered-by';
const filterByACL = (schema, options) => {
@ -56,6 +58,7 @@ const InternalAdminLayout = (props: any) => {
};
const [hidden, setHidden] = useState(false);
const result = useSystemSettings();
const { service } = useCollectionManager();
return (
<Layout>
<Layout.Header
@ -156,7 +159,7 @@ const InternalAdminLayout = (props: any) => {
}
`}
>
{props.children}
{service.contentLoading ? <Spin /> : props.children}
<Layout.Footer>
<PoweredBy />
</Layout.Footer>