From f51c06e7b8b1aae262de8489c3b5be392652e3b9 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 22 Oct 2023 13:32:52 +0800 Subject: [PATCH] fix: uiSchemaTemplates:list 403 --- .../SchemaTemplateManagerProvider.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx b/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx index 89a182e20..e8b6d7a83 100644 --- a/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx +++ b/packages/core/client/src/schema-templates/SchemaTemplateManagerProvider.tsx @@ -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 ; + } + return <>{props.children}; +}; + export class RemoteSchemaTemplateManagerPlugin extends Plugin { async load() { this.addRoutes();