diff --git a/nkebao/src/pages/login/login.module.scss b/nkebao/src/pages/login/login.module.scss
index 28a3a722..7574341f 100644
--- a/nkebao/src/pages/login/login.module.scss
+++ b/nkebao/src/pages/login/login.module.scss
@@ -116,10 +116,6 @@
margin: 0;
}
-.form-container {
- margin-bottom: 20px;
-}
-
// 标签页样式
.tab-container {
display: flex;
diff --git a/nkebao/src/pages/login/login.tsx b/nkebao/src/pages/login/login.tsx
index c1b52807..1bc13773 100644
--- a/nkebao/src/pages/login/login.tsx
+++ b/nkebao/src/pages/login/login.tsx
@@ -9,6 +9,8 @@ import {
import { useUserStore } from "@/store/module/user";
import { loginWithPassword, loginWithCode, sendVerificationCode } from "./api";
import style from "./login.module.scss";
+import Layout from "@/components/Layout/Layout";
+import NavCommon from "@/components/NavCommon";
const Login: React.FC = () => {
const [form] = Form.useForm();
@@ -137,9 +139,11 @@ const Login: React.FC = () => {
const handleAppleLogin = () => {
Toast.show({ content: "Apple登录功能开发中", position: "top" });
};
-
+ const paddingTop = localStorage.getItem("paddingTop") || "44px";
return (
+
+
{/* 背景装饰 */}
diff --git a/nkebao/src/utils/common.ts b/nkebao/src/utils/common.ts
index 2dd200f8..a71c3f87 100644
--- a/nkebao/src/utils/common.ts
+++ b/nkebao/src/utils/common.ts
@@ -35,3 +35,36 @@ export const comfirm = (
});
});
};
+
+export function getSafeAreaHeight() {
+ // 1. 优先使用 CSS 环境变量
+ if (CSS.supports("padding-top", "env(safe-area-inset-top)")) {
+ const safeAreaTop = getComputedStyle(
+ document.documentElement,
+ ).getPropertyValue("env(safe-area-inset-top)");
+ const height = parseInt(safeAreaTop) || 0;
+ if (height > 0) return height;
+ }
+
+ // 2. 设备检测
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
+ const isAndroid = /Android/.test(navigator.userAgent);
+
+ if (isIOS) {
+ // iOS 设备
+ const isIPhoneX = window.screen.height >= 812;
+ return isIPhoneX ? 44 : 20;
+ } else if (isAndroid) {
+ // Android 设备
+ return 24;
+ }
+
+ // 3. 默认值
+ return 0;
+}
+// 设置全局 CSS 变量
+export function initSafeArea() {
+ const root = document.documentElement;
+ const height = getSafeAreaHeight();
+ root.style.setProperty("--safe-area-top", `${height}px`);
+}