mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-05 05:38:23 +08:00
fix(client): add RemoteDocumentTitleProvider
This commit is contained in:
parent
17b6daf41e
commit
d1afb15a7a
@ -13,11 +13,11 @@ import {
|
|||||||
CollectionManagerShortcut,
|
CollectionManagerShortcut,
|
||||||
compose,
|
compose,
|
||||||
DesignableSwitch,
|
DesignableSwitch,
|
||||||
DocumentTitleProvider,
|
|
||||||
FileStorageShortcut,
|
FileStorageShortcut,
|
||||||
i18n,
|
i18n,
|
||||||
MenuItemInitializers,
|
MenuItemInitializers,
|
||||||
PluginManagerProvider,
|
PluginManagerProvider,
|
||||||
|
RemoteDocumentTitleProvider,
|
||||||
RemoteRouteSwitchProvider,
|
RemoteRouteSwitchProvider,
|
||||||
// RemoteCollectionManagerProvider,
|
// RemoteCollectionManagerProvider,
|
||||||
RouteSchemaComponent,
|
RouteSchemaComponent,
|
||||||
@ -47,7 +47,7 @@ apiClient.axios.interceptors.response.use(
|
|||||||
(error) => {
|
(error) => {
|
||||||
const redirectTo = error?.response?.data?.redirectTo;
|
const redirectTo = error?.response?.data?.redirectTo;
|
||||||
if (redirectTo) {
|
if (redirectTo) {
|
||||||
return window.location.href = redirectTo;
|
return (window.location.href = redirectTo);
|
||||||
}
|
}
|
||||||
notification.error({
|
notification.error({
|
||||||
message: error?.response?.data?.errors?.map?.((error: any) => {
|
message: error?.response?.data?.errors?.map?.((error: any) => {
|
||||||
@ -109,7 +109,7 @@ const providers = [
|
|||||||
ACLProvider,
|
ACLProvider,
|
||||||
ChinaRegionProvider,
|
ChinaRegionProvider,
|
||||||
WorkflowRouteProvider,
|
WorkflowRouteProvider,
|
||||||
[DocumentTitleProvider, { addonAfter: 'NocoBase' }],
|
RemoteDocumentTitleProvider,
|
||||||
];
|
];
|
||||||
|
|
||||||
const App = compose(...providers)(() => {
|
const App = compose(...providers)(() => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
||||||
import { Helmet } from 'react-helmet';
|
import { Helmet } from 'react-helmet';
|
||||||
|
import { useSystemSettings } from '../system-settings';
|
||||||
|
|
||||||
interface DocumentTitleContextProps {
|
interface DocumentTitleContextProps {
|
||||||
title?: any;
|
title?: any;
|
||||||
@ -32,6 +33,15 @@ export const DocumentTitleProvider: React.FC<{ addonBefore?: string; addonAfter?
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const RemoteDocumentTitleProvider: React.FC = (props) => {
|
||||||
|
const ctx = useSystemSettings();
|
||||||
|
return (
|
||||||
|
<DocumentTitleProvider addonAfter={ctx?.data?.data?.title}>
|
||||||
|
{props.children}
|
||||||
|
</DocumentTitleProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const useDocumentTitle = () => {
|
export const useDocumentTitle = () => {
|
||||||
return useContext(DocumentTitleContext);
|
return useContext(DocumentTitleContext);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user