fix: 保留用户/规则高级设置并增强节点运行时恢复 (#468)

* fix: 用户编辑时 maxConn 字段未正确回填

- User 接口添加 maxConn 类型定义
- handleEdit 中回填 maxConn 值
- normalizeUserItem 添加 maxConn 字段处理

解决编辑用户时最大连接数显示为 0 的问题

* fix: 保留转发设置并增强节点运行时恢复
This commit is contained in:
sagit
2026-04-25 18:12:13 +08:00
committed by GitHub
parent 9b923a2d0b
commit 3f374df724
30 changed files with 744 additions and 123 deletions
+18 -27
View File
@@ -5,7 +5,7 @@ import {
useNavigate,
Navigate,
} from "react-router-dom";
import { useEffect, useState } from "react";
import { useEffect } from "react";
import { AnimatePresence } from "framer-motion";
import IndexPage from "@/pages/index";
@@ -39,32 +39,7 @@ const ProtectedRoute = ({
skipLayout?: boolean;
}) => {
const isH5 = useH5Mode();
const navigate = useNavigate();
const [authenticated, setAuthenticated] = useState(() => isLoggedIn());
useEffect(() => {
const handleSessionChange = () => {
const loggedIn = isLoggedIn();
setAuthenticated(loggedIn);
if (!loggedIn) {
navigate("/", { replace: true });
}
};
window.addEventListener(SESSION_UPDATED_EVENT, handleSessionChange);
return () => {
window.removeEventListener(SESSION_UPDATED_EVENT, handleSessionChange);
};
}, [navigate]);
useEffect(() => {
if (!authenticated) {
navigate("/", { replace: true });
}
}, [authenticated, navigate]);
const authenticated = isLoggedIn();
if (!authenticated) {
return <Navigate replace to="/" />;
@@ -103,6 +78,22 @@ const LoginRoute = () => {
function App() {
const location = useLocation();
const navigate = useNavigate();
// 全局登录状态监听,当检测到未登录且不在首页时,跳转到首页
useEffect(() => {
const handleSessionUpdate = () => {
if (!isLoggedIn() && location.pathname !== "/") {
navigate("/", { replace: true });
}
};
window.addEventListener(SESSION_UPDATED_EVENT, handleSessionUpdate);
return () => {
window.removeEventListener(SESSION_UPDATED_EVENT, handleSessionUpdate);
};
}, [location.pathname, navigate]);
// 处理自定义背景图片
useEffect(() => {