2020-11-11 15:23:39 +08:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
// import { request } from 'umi';
|
|
|
|
import { TemplateLoader } from './TemplateLoader';
|
|
|
|
import { useRequest, request } from '@nocobase/client';
|
|
|
|
import templates from '@/templates';
|
2020-11-13 22:01:14 +08:00
|
|
|
import api from '@/api-client';
|
2020-11-11 15:23:39 +08:00
|
|
|
|
|
|
|
export function PageLoader(props: any) {
|
|
|
|
const { path } = props.match.params;
|
2020-11-13 22:01:14 +08:00
|
|
|
const { data = {}, error, loading, run } = useRequest(() => api.resource('pages').getRoutes());
|
2020-11-11 15:23:39 +08:00
|
|
|
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;
|