fix: 收口依赖兼容与会话撤销
为 miniprogram-ci 和 Jimp 依赖增加兼容 patch 与 smoke test;修复平台模板管理员路由漏配;收紧模板契约校验;为 admin/customer 增加 token 撤销和集中会话存储;同步品牌切换角色、doctor source hash、多屏宽截图证据和 CI 构建门禁。
This commit is contained in:
1 parent
4f0b50c7f1
commit
3017e3eb49
65 files changed
+1623
-975
No files matched your search
+14
-12
@@ -3,16 +3,17 @@ import { ChangePassword, Login } from "../features/auth/AuthPages.js";
|
||||
import { Dashboard } from "./Dashboard.js";
|
||||
import { AdminRouter } from "./AdminRouter.js";
|
||||
import { adminMessage as message } from "../components/AdminMessage.js";
|
||||
import { createApiClient } from "../lib/api.js";
|
||||
import { clearAdminSession, readAdminSession } from "../lib/auth-storage.js";
|
||||
|
||||
export function Root() {
|
||||
const [loggedIn, setLoggedIn] = useState(Boolean(localStorage.getItem("adminToken")));
|
||||
const [role, setRole] = useState(localStorage.getItem("adminRole") || "owner");
|
||||
const initialSession = readAdminSession();
|
||||
const [loggedIn, setLoggedIn] = useState(initialSession.loggedIn);
|
||||
const [role, setRole] = useState(initialSession.role);
|
||||
const [platformTemplateRole, setPlatformTemplateRole] = useState(
|
||||
localStorage.getItem("adminPlatformTemplateRole") || "none",
|
||||
);
|
||||
const [mustChangePassword, setMustChangePassword] = useState(
|
||||
localStorage.getItem("adminMustChangePassword") === "true",
|
||||
initialSession.platformTemplateRole,
|
||||
);
|
||||
const [mustChangePassword, setMustChangePassword] = useState(initialSession.mustChangePassword);
|
||||
React.useEffect(() => {
|
||||
const expire = () => {
|
||||
message.warning("登录状态已失效,请重新登录");
|
||||
@@ -21,12 +22,13 @@ export function Root() {
|
||||
window.addEventListener("admin-auth-expired", expire);
|
||||
return () => window.removeEventListener("admin-auth-expired", expire);
|
||||
}, []);
|
||||
const logout = () => {
|
||||
localStorage.removeItem("adminToken");
|
||||
localStorage.removeItem("adminRole");
|
||||
localStorage.removeItem("adminPlatformTemplateRole");
|
||||
localStorage.removeItem("adminMustChangePassword");
|
||||
setLoggedIn(false);
|
||||
const logout = async () => {
|
||||
try {
|
||||
await createApiClient().logoutAdmin();
|
||||
} finally {
|
||||
clearAdminSession();
|
||||
setLoggedIn(false);
|
||||
}
|
||||
};
|
||||
if (!loggedIn)
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user