tachybase_todo/packages/app/src/components/pages/PageLoader.tsx
chenos 9daae13c68
feat: improve plugins (#14)
* feat: delete defined resources

* feat: api client

* feat: view fields & tab field options & page info...

* fix: view type
2020-11-13 22:01:14 +08:00

29 lines
792 B
TypeScript

import React, { useState } from 'react';
// import { request } from 'umi';
import { TemplateLoader } from './TemplateLoader';
import { useRequest, request } from '@nocobase/client';
import templates from '@/templates';
import api from '@/api-client';
export function PageLoader(props: any) {
const { path } = props.match.params;
const { data = {}, error, loading, run } = useRequest(() => api.resource('pages').getRoutes());
const [first, setFirst] = useState(true);
(window as any).routesReload = async () => {
setFirst(false);
await run();
};
console.log(data);
return (
<TemplateLoader
{...props}
templates={templates}
loading={loading && first}
pages={data.data||{}}
pathname={`/${path}`}
/>
);
}
export default PageLoader;