From 20dcb9ea9851c815f710ab4cb469356ca7051dd3 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Sun, 28 Apr 2024 14:05:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=81=E6=B0=B4=E7=BA=BFanchor-point?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/config/config.ts | 1 - react-ui/src/app.tsx | 2 ++ react-ui/src/overrides.less | 8 ++++- .../src/pages/Pipeline/editPipeline/index.jsx | 8 ++--- react-ui/src/requestConfig.ts | 36 ++++++++++--------- react-ui/src/styles/theme.less | 8 ++++- react-ui/src/types.ts | 6 ++++ react-ui/src/utils/ui.tsx | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-) diff --git a/react-ui/config/config.ts b/react-ui/config/config.ts index 4d7d3db8..405f85cb 100644 --- a/react-ui/config/config.ts +++ b/react-ui/config/config.ts @@ -163,5 +163,4 @@ export default defineConfig({ }, javascriptEnabled: true, }, - // plugins: ['umi-plugin-keep-alive'], }); diff --git a/react-ui/src/app.tsx b/react-ui/src/app.tsx index f8a3221b..db9ce231 100644 --- a/react-ui/src/app.tsx +++ b/react-ui/src/app.tsx @@ -29,6 +29,8 @@ export async function getInitialState(): Promise<{ loading?: boolean; fetchUserInfo?: () => Promise; }> { + console.log('getInitialState'); + const fetchUserInfo = async () => { try { const response = await getUserInfo({ diff --git a/react-ui/src/overrides.less b/react-ui/src/overrides.less index 1b766517..c65420fb 100644 --- a/react-ui/src/overrides.less +++ b/react-ui/src/overrides.less @@ -1,3 +1,9 @@ +/* + * @Author: 赵伟 + * @Date: 2024-04-28 08:47:43 + * @Description: 覆盖 antd 样式 + */ + // 设置 Table 可以滑动 .vertical-scroll-table { .ant-table-wrapper { @@ -9,7 +15,7 @@ height: 100%; .ant-table { - height: calc(100% - 74px); + height: calc(100% - 74px); // 分页控件的高度 .ant-table-container { height: 100%; diff --git a/react-ui/src/pages/Pipeline/editPipeline/index.jsx b/react-ui/src/pages/Pipeline/editPipeline/index.jsx index 406468e3..be5366dd 100644 --- a/react-ui/src/pages/Pipeline/editPipeline/index.jsx +++ b/react-ui/src/pages/Pipeline/editPipeline/index.jsx @@ -380,10 +380,10 @@ const EditPipeline = () => { return ( cfg.anchorPoints || [ // 四个 - // [0.5, 0], - // [0.5, 1], - [0, 0.5], - [1, 0.5], + [0.5, 0], + [0.5, 1], + // [0, 0.5], + // [1, 0.5], ] ); }, diff --git a/react-ui/src/requestConfig.ts b/react-ui/src/requestConfig.ts index 1d832c37..501e78c5 100644 --- a/react-ui/src/requestConfig.ts +++ b/react-ui/src/requestConfig.ts @@ -1,11 +1,11 @@ /* * @Author: 赵伟 * @Date: 2024-03-25 13:52:54 - * @Description: + * @Description: 网络请求配置,详情请参考 https://umijs.org/docs/max/request */ import type { RequestConfig } from '@umijs/max'; import { message } from 'antd'; -import { clearSessionToken, getAccessToken, getRefreshToken, getTokenExpireTime } from './access'; +import { clearSessionToken, getAccessToken } from './access'; import { setRemoteMenu } from './services/session'; import { gotoLoginPage } from './utils/ui'; @@ -21,21 +21,25 @@ export const requestConfig: RequestConfig = { const authHeader = headers['Authorization']; const isToken = headers['isToken']; if (!authHeader && isToken !== false) { - const expireTime = getTokenExpireTime(); - if (expireTime) { - const left = Number(expireTime) - new Date().getTime(); - const refreshToken = getRefreshToken(); - if (left < 0 && refreshToken) { - clearSessionToken(); - } else { - const accessToken = getAccessToken(); - if (accessToken) { - headers['Authorization'] = `Bearer ${accessToken}`; - } - } - } else { - clearSessionToken(); + const accessToken = getAccessToken(); + if (accessToken) { + headers['Authorization'] = `Bearer ${accessToken}`; } + // const expireTime = getTokenExpireTime(); + // if (expireTime) { + // const left = Number(expireTime) - new Date().getTime(); + // const refreshToken = getRefreshToken(); + // if (left < 0 && refreshToken) { + // clearSessionToken(); + // } else { + // const accessToken = getAccessToken(); + // if (accessToken) { + // headers['Authorization'] = `Bearer ${accessToken}`; + // } + // } + // } else { + // clearSessionToken(); + // } } return { url, options }; }, diff --git a/react-ui/src/styles/theme.less b/react-ui/src/styles/theme.less index 64b78619..0f93891e 100644 --- a/react-ui/src/styles/theme.less +++ b/react-ui/src/styles/theme.less @@ -1,4 +1,10 @@ -// 全局颜色变量 +/* + * @Author: 赵伟 + * @Date: 2024-04-28 08:47:43 + * @Description: 全局变量,可以直接在 less 文件里使用,无需引入;也可以导入到 js 里使用;为 antd 主题修改提供常量值 + */ + +// 颜色 @primary-color: #1664ff; // 主色调 @primary-color-hover: #69b1ff; @background-color: #f9fafb; // 页面背景颜色 diff --git a/react-ui/src/types.ts b/react-ui/src/types.ts index dcf74581..8e49075e 100644 --- a/react-ui/src/types.ts +++ b/react-ui/src/types.ts @@ -1,3 +1,9 @@ +/* + * @Author: 赵伟 + * @Date: 2024-04-08 09:54:39 + * @Description: 定义全局类型,比如无关联的页面都需要要的类型 + */ + // 流水线全局参数 export type PipelineGlobalParam = { param_name: string; diff --git a/react-ui/src/utils/ui.tsx b/react-ui/src/utils/ui.tsx index 1ac54b1a..ddf83f6f 100644 --- a/react-ui/src/utils/ui.tsx +++ b/react-ui/src/utils/ui.tsx @@ -48,7 +48,7 @@ export const getFileListFromEvent = (e: any) => { // 去登录页面 export const gotoLoginPage = (toHome: boolean = true) => { - const { search, pathname } = window.location; + const { pathname, search } = window.location; const urlParams = new URLSearchParams(); urlParams.append('redirect', pathname + search); const newSearch = toHome ? '' : urlParams.toString();