fix: load collections history only admin pages
This commit is contained in:
parent
d062c8fd99
commit
2cba502f60
@ -1,5 +1,6 @@
|
|||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
import React, { createContext, useContext, useEffect, useState } from 'react';
|
import React, { createContext, useContext, useEffect } from 'react';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
import { APIClientContext, useRequest } from '../api-client';
|
import { APIClientContext, useRequest } from '../api-client';
|
||||||
|
|
||||||
export interface CollectionHistoryContextValue {
|
export interface CollectionHistoryContextValue {
|
||||||
@ -28,7 +29,21 @@ export const CollectionHistoryProvider: React.FC = (props) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const service = useRequest(options);
|
const location = useLocation();
|
||||||
|
|
||||||
|
// console.log('location', location);
|
||||||
|
|
||||||
|
const service = useRequest(options, {
|
||||||
|
manual: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const isAdminPage = location.pathname.startsWith('/admin');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isAdminPage) {
|
||||||
|
service.run();
|
||||||
|
}
|
||||||
|
}, [isAdminPage]);
|
||||||
|
|
||||||
// 刷新 collecionHistory
|
// 刷新 collecionHistory
|
||||||
const refreshCH = async () => {
|
const refreshCH = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user