mirror of
				https://github.com/whyour/qinglong.git
				synced 2025-10-30 00:06:09 +08:00 
			
		
		
		
	修复定时任务查询不存在的订阅报错
This commit is contained in:
		
							parent
							
								
									035f0eb9e3
								
							
						
					
					
						commit
						a45efbd69b
					
				|  | @ -57,6 +57,7 @@ import { useVT } from 'virtualizedtableforantd4'; | ||||||
| import { ICrontab, OperationName, OperationPath, CrontabStatus } from './type'; | import { ICrontab, OperationName, OperationPath, CrontabStatus } from './type'; | ||||||
| import Name from '@/components/name'; | import Name from '@/components/name'; | ||||||
| import dayjs from 'dayjs'; | import dayjs from 'dayjs'; | ||||||
|  | import { noop } from 'lodash'; | ||||||
| 
 | 
 | ||||||
| const { Text, Paragraph, Link } = Typography; | const { Text, Paragraph, Link } = Typography; | ||||||
| const { Search } = Input; | const { Search } = Input; | ||||||
|  | @ -76,7 +77,7 @@ const Crontab = () => { | ||||||
|             wordBreak: 'break-all', |             wordBreak: 'break-all', | ||||||
|             marginBottom: 0, |             marginBottom: 0, | ||||||
|             color: '#1890ff', |             color: '#1890ff', | ||||||
|             cursor: 'pointer' |             cursor: 'pointer', | ||||||
|           }} |           }} | ||||||
|           ellipsis={{ tooltip: text, rows: 2 }} |           ellipsis={{ tooltip: text, rows: 2 }} | ||||||
|           onClick={() => { |           onClick={() => { | ||||||
|  | @ -270,9 +271,14 @@ const Crontab = () => { | ||||||
|         record.sub_id ? ( |         record.sub_id ? ( | ||||||
|           <Name |           <Name | ||||||
|             service={() => |             service={() => | ||||||
|               request.get(`${config.apiPrefix}subscriptions/${record.sub_id}`) |               request.get(`${config.apiPrefix}subscriptions/${record.sub_id}`, { | ||||||
|  |                 onError: noop, | ||||||
|  |               }) | ||||||
|             } |             } | ||||||
|             options={{ ready: record?.sub_id, cacheKey: record.sub_id }} |             options={{ | ||||||
|  |               ready: record?.sub_id, | ||||||
|  |               cacheKey: record.sub_id, | ||||||
|  |             }} | ||||||
|           /> |           /> | ||||||
|         ) : ( |         ) : ( | ||||||
|           '-' |           '-' | ||||||
|  |  | ||||||
|  | @ -1,29 +1,44 @@ | ||||||
| import intl from 'react-intl-universal' | import intl from 'react-intl-universal'; | ||||||
| import { message } from 'antd'; | import { message } from 'antd'; | ||||||
| import config from './config'; | import config from './config'; | ||||||
| import { history } from '@umijs/max'; | import { history } from '@umijs/max'; | ||||||
| import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios'; | import axios, { | ||||||
|  |   AxiosError, | ||||||
|  |   AxiosInstance, | ||||||
|  |   AxiosRequestConfig, | ||||||
|  |   AxiosResponse, | ||||||
|  |   InternalAxiosRequestConfig, | ||||||
|  | } from 'axios'; | ||||||
| 
 | 
 | ||||||
| interface IResponseData { | export interface IResponseData { | ||||||
|   code?: number; |   code?: number; | ||||||
|   data?: any; |   data?: any; | ||||||
|   message?: string; |   message?: string; | ||||||
|   error?: any; |   error?: any; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Override< | export type Override< | ||||||
|   T, |   T, | ||||||
|   K extends Partial<{ [P in keyof T]: any }> | string, |   K extends Partial<{ [P in keyof T]: any }> | string, | ||||||
| > = K extends string | > = K extends string | ||||||
|   ? Omit<T, K> & { [P in keyof T]: T[P] | unknown } |   ? Omit<T, K> & { [P in keyof T]: T[P] | unknown } | ||||||
|   : Omit<T, keyof K> & K; |   : Omit<T, keyof K> & K; | ||||||
| 
 | 
 | ||||||
|  | export interface ICustomConfig { | ||||||
|  |   onError?: (res: AxiosResponse<unknown, any>) => void; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| message.config({ | message.config({ | ||||||
|   duration: 2, |   duration: 2, | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| const time = Date.now(); | const time = Date.now(); | ||||||
| const errorHandler = function (error: AxiosError) { | const errorHandler = function ( | ||||||
|  |   error: Override< | ||||||
|  |     AxiosError<IResponseData>, | ||||||
|  |     { config: InternalAxiosRequestConfig & ICustomConfig } | ||||||
|  |   >, | ||||||
|  | ) { | ||||||
|   if (error.response) { |   if (error.response) { | ||||||
|     const msg = error.response.data |     const msg = error.response.data | ||||||
|       ? error.response.data.message || error.message || error.response.data |       ? error.response.data.message || error.message || error.response.data | ||||||
|  | @ -38,6 +53,10 @@ const errorHandler = function (error: AxiosError) { | ||||||
|         history.push('/login'); |         history.push('/login'); | ||||||
|       } |       } | ||||||
|     } else { |     } else { | ||||||
|  |       if (typeof error.config?.onError === 'function') { | ||||||
|  |         return error.config?.onError(error.response); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       message.error({ |       message.error({ | ||||||
|         content: msg, |         content: msg, | ||||||
|         style: { maxWidth: 500, margin: '0 auto' }, |         style: { maxWidth: 500, margin: '0 auto' }, | ||||||
|  | @ -105,21 +124,21 @@ export const request = _request as Override< | ||||||
|   { |   { | ||||||
|     get<T = IResponseData, D = any>( |     get<T = IResponseData, D = any>( | ||||||
|       url: string, |       url: string, | ||||||
|       config?: AxiosRequestConfig<D>, |       config?: AxiosRequestConfig<D> & ICustomConfig, | ||||||
|     ): Promise<T>; |     ): Promise<T>; | ||||||
|     delete<T = IResponseData, D = any>( |     delete<T = IResponseData, D = any>( | ||||||
|       url: string, |       url: string, | ||||||
|       config?: AxiosRequestConfig<D>, |       config?: AxiosRequestConfig<D> & ICustomConfig, | ||||||
|     ): Promise<T>; |     ): Promise<T>; | ||||||
|     post<T = IResponseData, D = any>( |     post<T = IResponseData, D = any>( | ||||||
|       url: string, |       url: string, | ||||||
|       data?: D, |       data?: D, | ||||||
|       config?: AxiosRequestConfig<D>, |       config?: AxiosRequestConfig<D> & ICustomConfig, | ||||||
|     ): Promise<T>; |     ): Promise<T>; | ||||||
|     put<T = IResponseData, D = any>( |     put<T = IResponseData, D = any>( | ||||||
|       url: string, |       url: string, | ||||||
|       data?: D, |       data?: D, | ||||||
|       config?: AxiosRequestConfig<D>, |       config?: AxiosRequestConfig<D> & ICustomConfig, | ||||||
|     ): Promise<T>; |     ): Promise<T>; | ||||||
|   } |   } | ||||||
| >; | >; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 whyour
						whyour