浏览代码

add force webkit

wind 1 月之前
父节点
当前提交
531151227f
共有 5 个文件被更改,包括 311 次插入3 次删除
  1. 5 1
      src/app/layout.tsx
  2. 48 0
      src/app/user/login/login.module.css
  3. 198 0
      src/app/user/login/page.tsx
  4. 2 2
      src/components/Header/headerMobile.tsx
  5. 58 0
      src/lib/user.ts

+ 5 - 1
src/app/layout.tsx

@@ -34,7 +34,11 @@ export default function RootLayout({
 }>) {
   return (
     <html lang="en">
-      {/* <body className={`${geistSans.variable} ${geistMono.variable}`}>{children}</body> */}
+      <head>
+        <meta httpEquiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
+        <meta name="renderer" content="webkit" />
+        <meta name="force-rendering" content="webkit" />
+      </head>
       <body>{children}</body>
     </html>
   );

+ 48 - 0
src/app/user/login/login.module.css

@@ -0,0 +1,48 @@
+.container {
+  display: flex;
+  flex-direction: column;
+  height: 100vh;
+  overflow: auto;
+  background: @layout-body-background;
+}
+
+.lang {
+  width: 100%;
+  height: 40px;
+  line-height: 44px;
+  text-align: right;
+  :global(.ant-dropdown-trigger) {
+    margin-right: 24px;
+  }
+}
+
+.content {
+  flex: 1;
+  padding: 32px 0;
+}
+
+@media (min-width: @screen-md-min) {
+  .container {
+    background-image: url("https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg");
+    background-repeat: no-repeat;
+    background-position: center 110px;
+    background-size: 100%;
+  }
+
+  .content {
+    padding: 32px 0 24px;
+  }
+}
+
+.icon {
+  margin-left: 8px;
+  color: rgba(0, 0, 0, 0.2);
+  font-size: 24px;
+  vertical-align: middle;
+  cursor: pointer;
+  transition: color 0.3s;
+
+  &:hover {
+    color: @primary-color;
+  }
+}

+ 198 - 0
src/app/user/login/page.tsx

@@ -0,0 +1,198 @@
+// import { LockOutlined, MobileOutlined } from "@ant-design/icons";
+// import { LoginForm, ProForm, ProFormCaptcha, ProFormText } from "@ant-design/pro-components";
+// import { Alert, message, Tabs } from "antd";
+// import React, { useState } from "react";
+// import { history, SelectLang } from "umi";
+// import styles from "./login.module.css";
+// import { login, sendCaptcha } from "@/lib/user";
+// import Cookies from "js-cookie";
+// import { useModel } from "@@/plugin-model/useModel";
+// import { USER_TYPE_ADMIN, USER_TYPE_PLATFORM } from "@/services/constants";
+
+// const LoginMessage: React.FC<{ content: string }> = ({ content }) => (
+//   <Alert
+//     style={{
+//       marginBottom: 24,
+//     }}
+//     message={content}
+//     type="error"
+//     showIcon
+//   />
+// );
+
+// const Login: React.FC = () => {
+//   const [errorMsg, setErrorMsg] = useState<string>("");
+//   const [type, setType] = useState<string>("password");
+//   const [form] = ProForm.useForm();
+//   const { initialState, setInitialState } = useModel("@@initialState");
+
+//   const fetchUserInfo = async () => {
+//     const userInfo = await initialState?.fetchUserInfo?.();
+//     if (userInfo) {
+//       await setInitialState((s) => ({
+//         ...s,
+//         currentUser: userInfo,
+//       }));
+//     }
+//   };
+
+//   const handleSubmit = async (values: API.LoginParams) => {
+//     try {
+//       const response = await login({ ...values, type: type == "password" ? 0 : 1 });
+//       console.log(response);
+//       if (response.code === 200) {
+//         if (response.data?.type !== USER_TYPE_ADMIN && response.data?.type !== USER_TYPE_PLATFORM) {
+//           message.success("登录成功");
+//           await setInitialState((s) => ({
+//             ...s,
+//             currentUser: response.data,
+//           }));
+//           Cookies.set("ut", response!.data!.token!);
+//           await fetchUserInfo();
+//           if (!history) return;
+//           const { query } = history.location;
+//           const { redirect } = query as { redirect: string };
+//           history.push(redirect || "/welcome");
+//           return;
+//         } else {
+//           setErrorMsg("登录平台错误");
+//           return;
+//         }
+//       }
+//       // 如果失败去设置用户错误信息
+//       setErrorMsg(response.message || "");
+//     } catch (error) {
+//       message.error("登录失败,请重试!");
+//     }
+//   };
+
+//   return (
+//     <div className={styles.container}>
+//       <div className={styles.content}>
+//         <LoginForm
+//           form={form}
+//           title="高潜咨询"
+//           subTitle={"中国企业人效的未来"}
+//           initialValues={{}}
+//           actions={[]}
+//           onFinish={async (values) => {
+//             await handleSubmit(values as API.LoginParams);
+//           }}
+//         >
+//           <Tabs activeKey={type} onChange={setType}>
+//             <Tabs.TabPane key="password" tab={"手机号密码登录"} />
+//             <Tabs.TabPane key="captcha" tab={"手机号验证码登录"} />
+//           </Tabs>
+
+//           {errorMsg && <LoginMessage content={errorMsg} />}
+
+//           {type === "password" && (
+//             <>
+//               <ProFormText
+//                 fieldProps={{
+//                   size: "large",
+//                   prefix: <MobileOutlined className={styles.prefixIcon} />,
+//                 }}
+//                 name="phone"
+//                 placeholder="手机号"
+//                 rules={[
+//                   {
+//                     required: true,
+//                     message: "请输入手机号!",
+//                   },
+//                   {
+//                     pattern: /^1\d{10}$/,
+//                     message: "手机号格式错误!",
+//                   },
+//                 ]}
+//               />
+//               <ProFormText.Password
+//                 name="password"
+//                 fieldProps={{
+//                   size: "large",
+//                   prefix: <LockOutlined className={styles.prefixIcon} />,
+//                 }}
+//                 placeholder={"密码"}
+//                 rules={[
+//                   {
+//                     required: true,
+//                     message: "请输入密码",
+//                   },
+//                 ]}
+//               />
+//             </>
+//           )}
+
+//           {type === "captcha" && (
+//             <>
+//               <ProFormText
+//                 fieldProps={{
+//                   size: "large",
+//                   prefix: <MobileOutlined className={styles.prefixIcon} />,
+//                 }}
+//                 name="phone"
+//                 placeholder="手机号"
+//                 rules={[
+//                   {
+//                     required: true,
+//                     message: "请输入手机号!",
+//                   },
+//                   {
+//                     pattern: /^1\d{10}$/,
+//                     message: "手机号格式错误!",
+//                   },
+//                 ]}
+//               />
+//               <ProFormCaptcha
+//                 fieldProps={{
+//                   size: "large",
+//                   prefix: <LockOutlined className={styles.prefixIcon} />,
+//                 }}
+//                 captchaProps={{
+//                   size: "large",
+//                 }}
+//                 placeholder="请输入验证码"
+//                 captchaTextRender={(timing, count) => {
+//                   if (timing) {
+//                     return `${count} 获取验证码`;
+//                   }
+//                   return "获取验证码";
+//                 }}
+//                 name="captcha"
+//                 rules={[
+//                   {
+//                     required: true,
+//                     message: "请输入验证码!",
+//                   },
+//                 ]}
+//                 onGetCaptcha={async () => {
+//                   const phone = form.getFieldValue("phone");
+//                   if (!phone) {
+//                     message.error("请先输入手机号");
+//                     throw new Error("请先输入手机号");
+//                   }
+//                   const result = await sendCaptcha({
+//                     phone,
+//                   });
+//                   console.log(result);
+//                   if (result === false) {
+//                     return;
+//                   }
+//                   message.success("获取验证码成功");
+//                 }}
+//               />
+//             </>
+//           )}
+//           <div
+//             style={{
+//               marginBottom: 24,
+//             }}
+//           ></div>
+//         </LoginForm>
+//       </div>
+//       <div>@2024 高潜咨询</div>
+//     </div>
+//   );
+// };
+
+// export default Login;

+ 2 - 2
src/components/Header/headerMobile.tsx

@@ -61,8 +61,8 @@ const HeaderMobile: React.FC = () => {
         <div className={styles.content}>
           <Image
             alt="hero"
-            width={1080}
-            height={793}
+            width={400}
+            height={600}
             priority={true}
             src="https://hi-po.oss-cn-beijing.aliyuncs.com/img/web/cover2.jpg"
             className={styles["nav-cover"]}

+ 58 - 0
src/lib/user.ts

@@ -0,0 +1,58 @@
+const host = "https://hi-po.com.cn";
+
+export async function sendCaptcha(phone: string) {
+  const formData = new FormData();
+  formData.append("phone", phone);
+
+  const result = await fetch(`${host}/api/v1/user/sendCaptcha`, {
+    method: "POST",
+    body: formData,
+  });
+  const json = await result.json();
+  return json;
+}
+
+type LoginParams = {
+  type?: number;
+  username?: string;
+  password?: string;
+  captcha?: string;
+  sourceId?: number;
+};
+
+export async function login(params: LoginParams) {
+  const formData = new FormData();
+  Object.entries(params).forEach(([key, value]) => {
+    if (value !== undefined) {
+      formData.append(key, value.toString());
+    }
+  });
+  const result = await fetch(`${host}/api/v1/user/login`, {
+    method: "POST",
+    body: formData,
+  });
+  const json = await result.json();
+  return json;
+}
+
+type RegisterParams = {
+  phone?: string;
+  password?: string;
+  inviteCode?: string;
+  captcha?: string;
+};
+
+export async function register(params: RegisterParams) {
+  const formData = new FormData();
+  Object.entries(params).forEach(([key, value]) => {
+    if (value !== undefined) {
+      formData.append(key, value.toString());
+    }
+  });
+  const result = await fetch(`${host}/api/v1/user/register`, {
+    method: "POST",
+    body: formData,
+  });
+  const json = await result.json();
+  return json;
+}