Browse Source
fix: request pipeline and React Query optimization (#11693)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: afc163 <afc163@gmail.com>
pull/11704/head
afc163
6 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with
10 additions and
22 deletions
-
config/config.ts
-
src/app.tsx
-
src/pages/account/center/components/Projects/index.tsx
-
src/pages/dashboard/workplace/index.tsx
-
src/pages/list/search/projects/index.tsx
-
src/requestErrorConfig.ts
|
|
|
@ -109,7 +109,7 @@ export default defineConfig({ |
|
|
|
*/ |
|
|
|
moment2dayjs: { |
|
|
|
preset: 'antd', |
|
|
|
plugins: ['duration'], |
|
|
|
plugins: ['duration', 'relativeTime'], |
|
|
|
}, |
|
|
|
/** |
|
|
|
* @name 国际化插件 |
|
|
|
|
|
|
|
@ -3,7 +3,13 @@ import type { Settings as LayoutSettings } from '@ant-design/pro-components'; |
|
|
|
import { SettingDrawer } from '@ant-design/pro-components'; |
|
|
|
import type { RequestConfig, RunTimeLayoutConfig } from '@umijs/max'; |
|
|
|
import { history, Link } from '@umijs/max'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import relativeTime from 'dayjs/plugin/relativeTime'; |
|
|
|
import React from 'react'; |
|
|
|
|
|
|
|
// Initialize dayjs plugins globally
|
|
|
|
dayjs.extend(relativeTime); |
|
|
|
|
|
|
|
import { |
|
|
|
AvatarDropdown, |
|
|
|
AvatarName, |
|
|
|
|
|
|
|
@ -1,14 +1,12 @@ |
|
|
|
import { useQuery } from '@tanstack/react-query'; |
|
|
|
import { Card, List } from 'antd'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import relativeTime from 'dayjs/plugin/relativeTime'; |
|
|
|
import React from 'react'; |
|
|
|
import { AvatarList } from '@/components'; |
|
|
|
import type { ListItemDataType } from '../../data.d'; |
|
|
|
import { queryFakeList } from '../../service'; |
|
|
|
import useStyles from './index.style'; |
|
|
|
|
|
|
|
dayjs.extend(relativeTime); |
|
|
|
const Projects: React.FC = () => { |
|
|
|
const { styles } = useStyles(); |
|
|
|
// 获取tab列表数据
|
|
|
|
|
|
|
|
@ -4,15 +4,12 @@ import { useQuery } from '@tanstack/react-query'; |
|
|
|
import { Link } from '@umijs/max'; |
|
|
|
import { Avatar, Card, Col, List, Row, Skeleton, Statistic } from 'antd'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import relativeTime from 'dayjs/plugin/relativeTime'; |
|
|
|
import type { FC } from 'react'; |
|
|
|
import EditableLinkGroup from './components/EditableLinkGroup'; |
|
|
|
import type { ActivitiesType, CurrentUser } from './data.d'; |
|
|
|
import { fakeChartData, queryActivities, queryProjectNotice } from './service'; |
|
|
|
import useStyles from './style.style'; |
|
|
|
|
|
|
|
dayjs.extend(relativeTime); |
|
|
|
|
|
|
|
const links = [ |
|
|
|
{ |
|
|
|
title: '操作一', |
|
|
|
|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
import { useQuery } from '@tanstack/react-query'; |
|
|
|
import { Card, Col, Form, List, Row, Select, Typography } from 'antd'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import relativeTime from 'dayjs/plugin/relativeTime'; |
|
|
|
import type { FC } from 'react'; |
|
|
|
import { useState } from 'react'; |
|
|
|
import { AvatarList, StandardFormRow, TagSelect } from '@/components'; |
|
|
|
@ -10,8 +9,6 @@ import type { ListItemDataType } from './data.d'; |
|
|
|
import { queryFakeList } from './service'; |
|
|
|
import useStyles from './style.style'; |
|
|
|
|
|
|
|
dayjs.extend(relativeTime); |
|
|
|
|
|
|
|
const FormItem = Form.Item; |
|
|
|
const { Paragraph } = Typography; |
|
|
|
const getKey = (id: string, index: number) => `${id}-${index}`; |
|
|
|
|
|
|
|
@ -13,7 +13,7 @@ enum ErrorShowType { |
|
|
|
// 与后端约定的响应数据格式
|
|
|
|
interface ResponseStructure { |
|
|
|
success: boolean; |
|
|
|
data: any; |
|
|
|
data: unknown; |
|
|
|
errorCode?: number; |
|
|
|
errorMessage?: string; |
|
|
|
showType?: ErrorShowType; |
|
|
|
@ -63,7 +63,7 @@ export const errorConfig: RequestConfig = { |
|
|
|
}); |
|
|
|
break; |
|
|
|
case ErrorShowType.REDIRECT: |
|
|
|
// TODO: redirect
|
|
|
|
window.location.href = '/user/login'; |
|
|
|
break; |
|
|
|
default: |
|
|
|
message.error(errorMessage); |
|
|
|
@ -95,15 +95,5 @@ export const errorConfig: RequestConfig = { |
|
|
|
], |
|
|
|
|
|
|
|
// 响应拦截器
|
|
|
|
responseInterceptors: [ |
|
|
|
(response) => { |
|
|
|
// 拦截响应数据,进行个性化处理
|
|
|
|
const { data } = response as unknown as ResponseStructure; |
|
|
|
|
|
|
|
if (data?.success === false) { |
|
|
|
message.error('请求失败!'); |
|
|
|
} |
|
|
|
return response; |
|
|
|
}, |
|
|
|
], |
|
|
|
responseInterceptors: [], |
|
|
|
}; |
|
|
|
|