fix: uiSchemaTemplates:list 403

This commit is contained in:
chenos 2023-10-22 13:32:52 +08:00
parent 4eb6027189
commit f51c06e7b8

View File

@ -2,6 +2,7 @@ import { ISchema, useFieldSchema } from '@formily/react';
import { uid } from '@formily/shared';
import { cloneDeep } from 'lodash';
import React, { ReactNode, createContext, useContext, useMemo } from 'react';
import { useLocation } from 'react-router-dom';
import { useAPIClient, useRequest } from '../api-client';
import { Plugin } from '../application/Plugin';
import { useAppSpin } from '../application/hooks/useAppSpin';
@ -114,7 +115,7 @@ export const useSchemaTemplateManager = () => {
};
};
export const RemoteSchemaTemplateManagerProvider: React.FC<{ children?: ReactNode }> = (props) => {
const Internal = (props) => {
const api = useAPIClient();
const { render } = useAppSpin();
const options = {
@ -125,6 +126,7 @@ export const RemoteSchemaTemplateManagerProvider: React.FC<{ children?: ReactNod
paginate: false,
},
};
const service = useRequest<{
data: any[];
}>(options);
@ -144,6 +146,14 @@ export const RemoteSchemaTemplateManagerProvider: React.FC<{ children?: ReactNod
);
};
export const RemoteSchemaTemplateManagerProvider: React.FC<{ children?: ReactNode }> = (props) => {
const location = useLocation();
if (location.pathname.startsWith('/admin')) {
return <Internal {...props} />;
}
return <>{props.children}</>;
};
export class RemoteSchemaTemplateManagerPlugin extends Plugin {
async load() {
this.addRoutes();