diff --git a/public/runtime-config.js b/public/runtime-config.js index 3ab824d..22fbb82 100644 --- a/public/runtime-config.js +++ b/public/runtime-config.js @@ -1,2 +1,3 @@ window.BACKEND_ADDRESS = "http://localhost:8080"; +//window.BACKEND_ADDRESS = "http://43.138.83.20:10001"; window.BACKEND_TIMEOUT = 10000; \ No newline at end of file diff --git a/src/config/BaseWebConfig.js b/src/config/BaseWebConfig.js index 637abcd..ba1f459 100644 --- a/src/config/BaseWebConfig.js +++ b/src/config/BaseWebConfig.js @@ -1,5 +1,6 @@ const baseWebConfig ={ baseUrl: 'http://localhost:8080', + //baseUrl: 'http://43.138.83.20:10001', timeout: 10000, } diff --git a/src/page/Dashboard/UserManagement/AddUserDrawer.jsx b/src/page/Dashboard/UserManagement/AddUserDrawer.jsx index bf84d93..c8d6bac 100644 --- a/src/page/Dashboard/UserManagement/AddUserDrawer.jsx +++ b/src/page/Dashboard/UserManagement/AddUserDrawer.jsx @@ -95,13 +95,13 @@ const AddUserDrawer = props => { > - - + */} {/* [ responsive: ['lg'], render: (text) => {text} }, - { - title: '专业', - dataIndex: 'department', - key: 'department', - responsive: ['lg'], - render: (text) => {text} - }, + //{ + // title: '专业', + // dataIndex: 'department', + // key: 'department', + // responsive: ['lg'], + // render: (text) => {text} + //}, //{ // title: '研究室', // dataIndex: 'researchRoom', diff --git a/src/routes/RouteSlashFix.jsx b/src/routes/RouteSlashFix.jsx new file mode 100644 index 0000000..44a5670 --- /dev/null +++ b/src/routes/RouteSlashFix.jsx @@ -0,0 +1,43 @@ +import { useEffect, useLocation, useNavigate } from 'react-router-dom'; + +/** + * 自动修正路径中的多余斜杠(如 /path/ → /path,//path → /path) + * 确保 React Router 能正确匹配路由,避免因斜杠问题导致 404/403 + */ +const RouteSlashFix = () => { + // 获取当前路径信息 + const location = useLocation(); + // 用于导航的方法 + const navigate = useNavigate(); + + useEffect(() => { + const { pathname, search, hash } = location; + let fixedPath = pathname; + + // 修正1:去除末尾多余的斜杠(根路径 / 除外) + if (fixedPath !== '/' && fixedPath.endsWith('/')) { + fixedPath = fixedPath.slice(0, -1); // 例如 /data-check/ → /data-check + } + + // 修正2:去除路径中间的连续斜杠(如 //data-check → /data-check,/data//check → /data/check) + if (fixedPath.includes('//')) { + fixedPath = fixedPath.replace(/\/+/g, '/'); // 多个斜杠替换为一个 + } + + // 如果路径有修正,更新路由(不改变用户看到的 URL 显示) + if (fixedPath !== pathname) { + navigate( + { pathname: fixedPath, search, hash }, // 修正后的路径 + { + replace: true, // 替换历史记录,避免回退时重复跳转 + state: location.state // 保留原路由状态(如传递的参数) + } + ); + } + }, [location, navigate]); // 仅当路径变化时执行 + + // 该组件不渲染任何内容,仅处理路径修正逻辑 + return null; +}; + +export default RouteSlashFix; \ No newline at end of file