Skip to content

Commit e3f6a96

Browse files
authored
Merge pull request #5 from hopeu/master
搜索和重置的时候跳到第一页
2 parents ce8b177 + 84085cc commit e3f6a96

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

src/app.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ResponseError } from 'umi-request';
55
import { queryQuarkInfo, queryQuarkLayout, queryQuarkMenus, queryAccountInfo } from '@/services/quark';
66
import defaultSettings from '../config/defaultSettings';
77
import logo from './assets/logo.png';
8+
import {Response} from "express";
89

910
export async function getInitialState(): Promise<{
1011
accountInfo?: API.AccountInfo;
@@ -118,6 +119,17 @@ const errorHandler = (error: ResponseError) => {
118119

119120
export const request: RequestConfig = {
120121
errorHandler: errorHandler,
122+
responseInterceptors: [
123+
(response, options) => {
124+
if(response.status == 208){ //跳转新的url
125+
const locationUrl = response.headers.get('Location');
126+
if(locationUrl){
127+
window.open(locationUrl, response.headers.get('Target') || '_blank');
128+
}
129+
}
130+
return response;
131+
}
132+
],
121133
// 请求拦截器
122134
requestInterceptors: [
123135
(url: string, options) => {

src/pages/Quark/components/DrawerForm.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const DrawerForm: React.FC<any> = (props:any) => {
3939
});
4040

4141
const [visible, setVisible] = useState(false);
42+
const [loading, setLoading] = useState(false);
4243

4344
const getComponent = async () => {
4445
const result = await get({
@@ -55,7 +56,7 @@ const DrawerForm: React.FC<any> = (props:any) => {
5556
}
5657
}
5758
});
58-
59+
5960
form.setFieldsValue(initialValues);
6061
setVisible(true);
6162
}
@@ -68,7 +69,7 @@ const DrawerForm: React.FC<any> = (props:any) => {
6869
if(data.hasOwnProperty('content')) {
6970
return findFormComponent(data.content);
7071
}
71-
72+
7273
let conmpontent = [];
7374

7475
if(data.hasOwnProperty(0)) {
@@ -120,16 +121,20 @@ const DrawerForm: React.FC<any> = (props:any) => {
120121
if(formComponent.disabledSubmitButton === true) {
121122
return null;
122123
}
123-
124+
124125
return (
125126
<Space>
126127
<Button onClick={()=>setVisible(false)}>
127128
取消
128129
</Button>
129130
<Button
131+
loading={loading}
130132
onClick={() => {
131133
form.validateFields().then((values:any) => {
132-
onFinish(values);
134+
setLoading(true);
135+
onFinish(values).finally(() => {
136+
setLoading(false);
137+
});
133138
}).catch((info:any) => {
134139
console.log('Validate Failed:', info);
135140
});
@@ -204,4 +209,4 @@ const DrawerForm: React.FC<any> = (props:any) => {
204209
);
205210
}
206211

207-
export default DrawerForm;
212+
export default DrawerForm;

src/pages/Quark/components/QueryFilter.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const QueryFilter: React.FC<Action> = (props) => {
3131
let query = {};
3232

3333
query['api'] = history.location.query.api;
34-
query['page'] = history.location.query.page;
3534
query['pageSize'] = history.location.query.pageSize;
3635

3736
query['search'] = values;
@@ -47,8 +46,11 @@ const QueryFilter: React.FC<Action> = (props) => {
4746
query['random'] = Math.random();
4847

4948
history.push({ pathname: history.location.pathname, query: query });
50-
49+
50+
51+
5152
if (props.current) {
53+
props.current.pageInfo.current = 1;
5254
props.current.reload();
5355
}
5456
};
@@ -57,7 +59,6 @@ const QueryFilter: React.FC<Action> = (props) => {
5759
let query = {};
5860

5961
query['api'] = history.location.query.api;
60-
query['page'] = history.location.query.page;
6162
query['pageSize'] = history.location.query.pageSize;
6263

6364
if(history.location.query.sorter) {
@@ -71,9 +72,12 @@ const QueryFilter: React.FC<Action> = (props) => {
7172
// hack random
7273
query['random'] = Math.random();
7374

75+
console.log(JSON.stringify(query));
76+
console.log('on_reset');
7477
history.push({ pathname: history.location.pathname, query: query });
7578

7679
if (props.current) {
80+
props.current.pageInfo.current = 1;
7781
props.current.reload();
7882
}
7983
};

0 commit comments

Comments
 (0)