diff --git a/packages/plugin-pages/package.json b/packages/plugin-pages/package.json index f84dfed38..574e48114 100644 --- a/packages/plugin-pages/package.json +++ b/packages/plugin-pages/package.json @@ -5,11 +5,9 @@ "license": "MIT", "dependencies": { "@nocobase/actions": "^0.4.0-alpha.0", - "@nocobase/client": "^0.4.0-alpha.0", "@nocobase/database": "^0.4.0-alpha.0", "@nocobase/resourcer": "^0.4.0-alpha.0", "@nocobase/server": "^0.4.0-alpha.0", - "crypto-random-string": "^3.3.1", - "react": "16.14.0" + "crypto-random-string": "^3.3.1" } } diff --git a/packages/plugin-pages/src/components/collection-loader.tsx b/packages/plugin-pages/src/components/collection-loader.tsx deleted file mode 100644 index 813b5ec82..000000000 --- a/packages/plugin-pages/src/components/collection-loader.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; - -export function CollectionLoader(props: any) { - return ( -
- Collection Loader -
- ) -} diff --git a/packages/plugin-pages/src/components/index.tsx b/packages/plugin-pages/src/components/index.tsx deleted file mode 100644 index d5ed21bbd..000000000 --- a/packages/plugin-pages/src/components/index.tsx +++ /dev/null @@ -1,4 +0,0 @@ -export { PageLoader } from './page-loader'; -export { TemplateLoader } from './template-loader'; -export { CollectionLoader } from './collection-loader'; -export { PageLoader as default } from './page-loader'; diff --git a/packages/plugin-pages/src/components/page-loader.tsx b/packages/plugin-pages/src/components/page-loader.tsx deleted file mode 100644 index fa0332494..000000000 --- a/packages/plugin-pages/src/components/page-loader.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React, { useState } from 'react'; -import { TemplateLoader } from './template-loader'; -import { useRequest, request } from '@nocobase/client'; - -export function PageLoader(props: any) { - const { path } = props.match.params; - const { data = {}, error, loading, run } = useRequest(() => request('/routes')); - const [first, setFirst] = useState(true); - // @ts-ignore - window.routesReload = async () => { - setFirst(false); - await run(); - }; - // const routes = pages2routes(data); - console.log(data); - return ( - - ); -} diff --git a/packages/plugin-pages/src/components/template-loader.tsx b/packages/plugin-pages/src/components/template-loader.tsx deleted file mode 100644 index 6f1466102..000000000 --- a/packages/plugin-pages/src/components/template-loader.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; -import get from 'lodash/get'; -import { Spin, Redirect } from '@nocobase/client'; - -function getRoutes(path: string, pages: any) { - const keys = path.split('/'); - const routes: Array = []; - while(keys.length) { - const uri = keys.join('/'); - if (pages[uri]) { - routes.push({...pages[uri], path: uri}); - } - keys.pop(); - } - if (path && pages['/']) { - routes.push({...pages['/'], path: '/'}); - } - return routes; -} - -export function TemplateLoader(props: any) { - const { loading, pathname, pages } = props; - if (loading) { - return ; - } - const redirect = get(pages, [pathname, 'redirect']); - if (redirect) { - return - } - const routes = getRoutes(pathname, pages); - let component: any; - console.log(...routes); - const len = routes.length; - const componentProps = {...props}; - while(routes.length) { - const route = routes.shift(); - console.log(route.template); - const Component = require(route.template).default; - if (route.type === 'collection') { - componentProps.match.params['collection'] = route.collection; - } - if (len === routes.length+1) { - componentProps['lastPage'] = route; - } - componentProps['page'] = route; - component = {component}; - if (route.inherit === false) { - break; - } - } - return component; -}