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