Compare commits

...

5 Commits

Author SHA1 Message Date
john bc75c7885c 🐞 fix:
修复倒计时bug,删除eslint
2024-06-03 14:38:18 +08:00
john 3795aedede 🐞 fix:
修复已知bug
2024-05-24 10:21:29 +08:00
john 2173394a71 update 2024-05-22 18:47:27 +08:00
john 7d465ca568 update(修改页面) 2024-05-22 18:34:41 +08:00
xia.zhang d6ebf4aef5 注册页 2024-05-22 17:41:51 +08:00
30 changed files with 2684 additions and 1976 deletions

View File

@ -1,2 +1,4 @@
VITE_APP_DEV = 'dev-api' VITE_APP_DEV = 'dev-api'
VITE_API_URL = 'http://192.168.10.166:8096' # VITE_API_URL = 'http://192.168.10.166:8096'
# VITE_API_URL = 'https://8.217.122.133:10020'
VITE_API_URL = 'https://api.pineer.cc'

View File

@ -1,2 +1,4 @@
VITE_APP_DEV = 'prod-api' VITE_APP_DEV = 'prod-api'
VITE_API_URL = 'http://192.168.10.166:8096' # VITE_API_URL = 'http://192.168.10.166:8096'
# VITE_API_URL = 'https://8.217.122.133:10020'
VITE_API_URL = 'https://api.pineer.cc'

View File

@ -1,18 +0,0 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}

BIN
.yarn/install-state.gz Normal file

Binary file not shown.

1
.yarnrc.yml Normal file
View File

@ -0,0 +1 @@
nodeLinker: node-modules

View File

@ -1,30 +1,27 @@
# React + TypeScript + Vite <!--
* @LastEditors: John
* @Date: 2024-04-12 19:24:25
* @LastEditTime: 2024-06-03 14:37:23
* @Author: John
-->
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. ## Git Flow
Currently, two official plugins are available: - 初始化Git Flow
git flow init
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh - 创建一个新功能分支
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh git flow feature start new-feature
## Expanding the ESLint configuration - 完成功能开发
git flow feature finish new-feature
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: - 创建一个release分支
git flow release start 1.0.0
- Configure the top-level `parserOptions` property like this: - 完成release分支
git flow release finish 1.0.0
```js - 紧急修复
export default { git flow hotfix start hotfix-issue
// other rules... git flow hotfix finish hotfix-issue
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
}
```
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

View File

@ -1,10 +1,5 @@
import React from 'react' import ReactDOM from "react-dom/client";
import ReactDOM from 'react-dom/client' import App from "./App.tsx";
import App from './App.tsx' import "./index.css";
import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render( ReactDOM.createRoot(document.getElementById("root")!).render(<App />);
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@ -1,10 +1,16 @@
<!doctype html> <!--
* @LastEditors: John
* @Date: 2024-05-22 18:06:14
* @LastEditTime: 2024-05-22 18:43:14
* @Author: John
-->
<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/img/logo.png" /> <link rel="icon" type="image/svg+xml" href="/src/assets/img/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NEER-APP-H5</title> <title>Pioneer</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@ -6,7 +6,6 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
@ -18,18 +17,14 @@
"react-i18next": "^14.0.1", "react-i18next": "^14.0.1",
"react-router-dom": "^6.21.3", "react-router-dom": "^6.21.3",
"sass": "^1.70.0", "sass": "^1.70.0",
"ts-md5": "^1.3.1",
"zustand": "^4.5.0" "zustand": "^4.5.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.11.7", "@types/node": "^20.11.7",
"@types/react": "^18.2.43", "@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17", "@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react-swc": "^3.5.0", "@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"typescript": "^5.3.3", "typescript": "^5.3.3",
"vite": "^5.0.8" "vite": "^5.0.8"
} }

View File

@ -1,8 +1,6 @@
#root { #root {
max-width: 1280px; /* max-width: 1280px; */
margin: 0 auto; /* margin: 0 auto; */
padding: 2rem; padding: 2rem;
text-align: center; text-align: center;
} }

View File

@ -1,17 +1,23 @@
/*
* @LastEditors: John
* @Date: 2024-05-22 18:06:14
* @LastEditTime: 2024-05-22 18:45:10
* @Author: John
*/
import "./App.css"; import "./App.css";
import { useEffect } from "react"; import { useEffect } from "react";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; import { HashRouter as Router, Route, Routes } from "react-router-dom";
import SignIn from "./pages/SignIn"; import SignIn from "./pages/SignIn";
import Download from "./pages/Download"; import Download from "./pages/Download";
import SelectCountry from "./pages/SelectCountry"; import SelectCountry from "./pages/SelectCountry";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
function App() { function App() {
const {i18n} = useTranslation() const { i18n } = useTranslation();
const lang:string = navigator.language.split('-')[1].toLocaleLowerCase() const lang: string = navigator.language.split("-")[1].toLocaleLowerCase();
useEffect(()=>{ useEffect(() => {
i18n.changeLanguage(lang) i18n.changeLanguage("en");
},[ i18n,lang]) }, [i18n, lang]);
return ( return (
<Router> <Router>
<div> <div>

View File

@ -2,13 +2,27 @@ import { request } from "./request";
import { AxiosRequestConfig } from 'axios'; import { AxiosRequestConfig } from 'axios';
//发送验证码 //发送验证码
export const sendCode = <T>(params: any,config:AxiosRequestConfig) => export const sendCode = <T>(params: {
areaCode?: string; // 区号,只有手机号才有
account: string; // 账号(邮箱或手机号)
status: 1 | 2; // 1=登录 2=注册
signature: string;
timestamp: string;
},config:AxiosRequestConfig) =>
request.get<T>("/api/account/sendVerificationCode", params, { request.get<T>("/api/account/sendVerificationCode", params, {
timeout: 15000, timeout: 15000,
...config ...config
}); });
//注册 //注册
export const signUp = <T>(params: any,config:AxiosRequestConfig) => export const signUp = <T>(params: {
account: string; // account
area?: string; // 顶级区域:朝鲜/平壤、中国/广东
areaCode?: string; // 区号,只有手机号才有
authCode: string; // 验证码
district?: string; // 二级区域:具体的区域
shareCode: string; // invitation code
userName: string; // 用户名称
},config:AxiosRequestConfig) =>
request.post<T>("/api/account/signUp", params, { request.post<T>("/api/account/signUp", params, {
timeout: 15000, timeout: 15000,
...config ...config

View File

@ -16,7 +16,7 @@ const service = axios.create({
// 统一请求拦截,可配置自定义 headers 例如 language、token 等 // 统一请求拦截,可配置自定义 headers 例如 language、token 等
service.interceptors.request.use( service.interceptors.request.use(
(config: any): any => { (config: any): any => {
// 确保 headers 对象存在 // 确保 headers 对象存在
if (!config.headers) { if (!config.headers) {
config.headers = {}; config.headers = {};
} }

View File

@ -9,7 +9,7 @@
<g> <g>
<path <path
d="M15.38570390625,3.583333L2.33317390625,3.583333C2.2623339062500003,3.583333,2.19317390625,3.592083,2.12692390625,3.6091670000000002L8.449003906249999,9.93083C8.61171390625,10.09349,8.87546390625,10.09349,9.03817390625,9.93083L15.38570390625,3.583333ZM16.28690390625,3.86042L11.19520390625,8.952079999999999L16.33070390625,14.0871C16.436903906250002,13.9471,16.49980390625,13.7725,16.49980390625,13.5833L16.49980390625,4.41667C16.49980390625,4.20292,16.41940390625,4.00833,16.28730390625,3.86042L16.28690390625,3.86042ZM15.48150390625,14.4167L10.60650390625,9.54125L9.62733390625,10.52042C9.13916390625,11.00867,8.347593906250001,11.00867,7.85942390625,10.52042L6.88067390625,9.54125L2.05400390625,14.3688C2.14150390625,14.3996,2.23525390625,14.4167,2.33358390625,14.4167L15.48190390625,14.4167L15.48150390625,14.4167ZM1.51275390625,13.7308L6.29150390625,8.95167L1.5306709062500001,4.19167C1.51018390625,4.26491,1.4998099062499999,4.34061,1.49983690625,4.41667L1.49983690625,13.5833C1.49983690625,13.6333,1.50400390625,13.6829,1.51275390625,13.7308ZM2.33317390625,2.75L15.66650390625,2.75C16.58700390625,2.75,17.33320390625,3.4961919999999997,17.33320390625,4.41667L17.33320390625,13.5833C17.33320390625,14.5038,16.58700390625,15.25,15.66650390625,15.25L2.33317390625,15.25C1.41269590625,15.25,0.66650390625,14.5038,0.66650390625,13.5833L0.66650390625,4.41667C0.666503757238,3.4961919999999997,1.41269590625,2.75,2.33317390625,2.75Z" d="M15.38570390625,3.583333L2.33317390625,3.583333C2.2623339062500003,3.583333,2.19317390625,3.592083,2.12692390625,3.6091670000000002L8.449003906249999,9.93083C8.61171390625,10.09349,8.87546390625,10.09349,9.03817390625,9.93083L15.38570390625,3.583333ZM16.28690390625,3.86042L11.19520390625,8.952079999999999L16.33070390625,14.0871C16.436903906250002,13.9471,16.49980390625,13.7725,16.49980390625,13.5833L16.49980390625,4.41667C16.49980390625,4.20292,16.41940390625,4.00833,16.28730390625,3.86042L16.28690390625,3.86042ZM15.48150390625,14.4167L10.60650390625,9.54125L9.62733390625,10.52042C9.13916390625,11.00867,8.347593906250001,11.00867,7.85942390625,10.52042L6.88067390625,9.54125L2.05400390625,14.3688C2.14150390625,14.3996,2.23525390625,14.4167,2.33358390625,14.4167L15.48190390625,14.4167L15.48150390625,14.4167ZM1.51275390625,13.7308L6.29150390625,8.95167L1.5306709062500001,4.19167C1.51018390625,4.26491,1.4998099062499999,4.34061,1.49983690625,4.41667L1.49983690625,13.5833C1.49983690625,13.6333,1.50400390625,13.6829,1.51275390625,13.7308ZM2.33317390625,2.75L15.66650390625,2.75C16.58700390625,2.75,17.33320390625,3.4961919999999997,17.33320390625,4.41667L17.33320390625,13.5833C17.33320390625,14.5038,16.58700390625,15.25,15.66650390625,15.25L2.33317390625,15.25C1.41269590625,15.25,0.66650390625,14.5038,0.66650390625,13.5833L0.66650390625,4.41667C0.666503757238,3.4961919999999997,1.41269590625,2.75,2.33317390625,2.75Z"
fill="#333333" fill-opacity="1" /> fill="#999999" fill-opacity="1" />
</g> </g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -9,7 +9,7 @@
<g> <g>
<path <path
d="M15.38570390625,3.583333L2.33317390625,3.583333C2.2623339062500003,3.583333,2.19317390625,3.592083,2.12692390625,3.6091670000000002L8.449003906249999,9.93083C8.61171390625,10.09349,8.87546390625,10.09349,9.03817390625,9.93083L15.38570390625,3.583333ZM16.28690390625,3.86042L11.19520390625,8.952079999999999L16.33070390625,14.0871C16.436903906250002,13.9471,16.49980390625,13.7725,16.49980390625,13.5833L16.49980390625,4.41667C16.49980390625,4.20292,16.41940390625,4.00833,16.28730390625,3.86042L16.28690390625,3.86042ZM15.48150390625,14.4167L10.60650390625,9.54125L9.62733390625,10.52042C9.13916390625,11.00867,8.347593906250001,11.00867,7.85942390625,10.52042L6.88067390625,9.54125L2.05400390625,14.3688C2.14150390625,14.3996,2.23525390625,14.4167,2.33358390625,14.4167L15.48190390625,14.4167L15.48150390625,14.4167ZM1.51275390625,13.7308L6.29150390625,8.95167L1.5306709062500001,4.19167C1.51018390625,4.26491,1.4998099062499999,4.34061,1.49983690625,4.41667L1.49983690625,13.5833C1.49983690625,13.6333,1.50400390625,13.6829,1.51275390625,13.7308ZM2.33317390625,2.75L15.66650390625,2.75C16.58700390625,2.75,17.33320390625,3.4961919999999997,17.33320390625,4.41667L17.33320390625,13.5833C17.33320390625,14.5038,16.58700390625,15.25,15.66650390625,15.25L2.33317390625,15.25C1.41269590625,15.25,0.66650390625,14.5038,0.66650390625,13.5833L0.66650390625,4.41667C0.666503757238,3.4961919999999997,1.41269590625,2.75,2.33317390625,2.75Z" d="M15.38570390625,3.583333L2.33317390625,3.583333C2.2623339062500003,3.583333,2.19317390625,3.592083,2.12692390625,3.6091670000000002L8.449003906249999,9.93083C8.61171390625,10.09349,8.87546390625,10.09349,9.03817390625,9.93083L15.38570390625,3.583333ZM16.28690390625,3.86042L11.19520390625,8.952079999999999L16.33070390625,14.0871C16.436903906250002,13.9471,16.49980390625,13.7725,16.49980390625,13.5833L16.49980390625,4.41667C16.49980390625,4.20292,16.41940390625,4.00833,16.28730390625,3.86042L16.28690390625,3.86042ZM15.48150390625,14.4167L10.60650390625,9.54125L9.62733390625,10.52042C9.13916390625,11.00867,8.347593906250001,11.00867,7.85942390625,10.52042L6.88067390625,9.54125L2.05400390625,14.3688C2.14150390625,14.3996,2.23525390625,14.4167,2.33358390625,14.4167L15.48190390625,14.4167L15.48150390625,14.4167ZM1.51275390625,13.7308L6.29150390625,8.95167L1.5306709062500001,4.19167C1.51018390625,4.26491,1.4998099062499999,4.34061,1.49983690625,4.41667L1.49983690625,13.5833C1.49983690625,13.6333,1.50400390625,13.6829,1.51275390625,13.7308ZM2.33317390625,2.75L15.66650390625,2.75C16.58700390625,2.75,17.33320390625,3.4961919999999997,17.33320390625,4.41667L17.33320390625,13.5833C17.33320390625,14.5038,16.58700390625,15.25,15.66650390625,15.25L2.33317390625,15.25C1.41269590625,15.25,0.66650390625,14.5038,0.66650390625,13.5833L0.66650390625,4.41667C0.666503757238,3.4961919999999997,1.41269590625,2.75,2.33317390625,2.75Z"
fill="#BF62FF" fill-opacity="1" /> fill="#FCB44B" fill-opacity="1" />
</g> </g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -1,20 +1,26 @@
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
import { useState, useEffect } from "react"; import { useState, useEffect, useRef } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Form, Input, Button } from "antd-mobile"; import { Form, Input, Button } from "antd-mobile";
import "../pages/SignIn.scss"; import "../pages/SignIn.scss";
import { useCountdown } from "../hooks/useCountdown"; import { useCountdown } from "../hooks/useCountdown";
import { sendCode, signUp } from "../api"; import { sendCode, signUp } from "../api";
import { sendCodeTypes, signUpTypes,ErrorType } from "../type/SignIn"; import { sendCodeTypes, signUpTypes, ErrorType } from "../type/SignIn";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import { Md5 } from "ts-md5";
import { FormInstance } from "antd-mobile/es/components/form";
function EmailForm() { function EmailForm() {
const formRef = useRef<FormInstance>(null);
const navigate = useNavigate();
const { t } = useTranslation(); const { t } = useTranslation();
const { start, time } = useCountdown(); const { start, time } = useCountdown();
const [email, setEmail] = useState(""); const [email, setEmail] = useState("");
const [authCode, setAuthCode] = useState(""); const [authCode, setAuthCode] = useState("");
const [shareCode, setShareCode] = useState(""); const [shareCode, setShareCode] = useState("");
const [remainingTime, setRemainingTime] = useState(0); const [remainingTime, setRemainingTime] = useState(0);
const config = { const config = {
headers: { headers: {
"Accept-Language": navigator.language, "Accept-Language": navigator.language,
@ -25,50 +31,55 @@ function EmailForm() {
if (email === "") { if (email === "") {
return; return;
} }
const timestamp = `${new Date().getTime()}`;
const res = await sendCode<sendCodeTypes>( const res = await sendCode<sendCodeTypes>(
{ {
account: email, account: email,
areaCode: "", areaCode: "",
status: 2, status: 2,
signature: Md5.hashStr(`Neer${email},${2},${timestamp}GetCode`),
timestamp,
}, },
config config
); );
console.log("res", res); console.log("res", res);
if (res.status === 200 && res.data.data.sms) { if (res.status === 200 && res.data.data.sms) {
Toast.show({ Toast.show({
content: t('send successfully'), content: t("send successfully"),
afterClose: () => { afterClose: () => {
start(60 * 1000); start(60 * 1000);
}, },
}); });
} else { } else {
Toast.show({ Toast.show({
content: t('Send failure'), content: t("Send failure"),
afterClose: () => { afterClose: () => {
start(60 * 1000); // start(60 * 1000);
}, },
}); });
} }
} catch (error:unknown) { } catch (error: unknown) {
// 检查 error 是否是 ErrorType 类型 // 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) { if (typeof error === "object" && error !== null && "msg" in error) {
const typedError = error as ErrorType; // 使用类型断言 const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: typedError.msg, content: typedError.msg,
afterClose: () => { afterClose: () => {
start(60 * 1000); // start(60 * 1000);
}, },
}); });
} else { } else {
// 处理不是 ErrorType 类型的错误 // 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred'); console.log("An unexpected error occurred");
} }
console.warn(error); console.warn(error);
} }
}; };
useEffect(() => { useEffect(() => {
setRemainingTime(time / 1000); setRemainingTime(time / 1000);
}, [time]); }, [time]);
const handleSignUp = async () => { const handleSignUp = async () => {
if (email === "" || authCode === "") { if (email === "" || authCode === "") {
return; return;
@ -80,37 +91,47 @@ function EmailForm() {
area: "", area: "",
areaCode: "", areaCode: "",
authCode: authCode, authCode: authCode,
shareCode: shareCode, shareCode: shareCode || formRef.current?.getFieldValue("shareCode"),
userName: "",
}, },
config config
); );
console.log("res", res); console.log("res", res);
if (res.status === 200 && res.data.data.token) { if (res.status === 200 && res.data.data.token) {
console.log(111);
Toast.show({ Toast.show({
content: res.data.msg, content: res.data.msg,
}); });
setTimeout(() => {
navigate("/Download");
}, 1000);
} else { } else {
Toast.show({ Toast.show({
content: res.data.msg, content: res.data.msg,
}); });
} }
} catch (error:unknown) { } catch (error: unknown) {
// 检查 error 是否是 ErrorType 类型 // 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) { if (typeof error === "object" && error !== null && "msg" in error) {
const typedError = error as ErrorType; // 使用类型断言 const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: typedError.msg, content: typedError.msg,
}); });
} else { } else {
// 处理不是 ErrorType 类型的错误 // 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred'); console.log("An unexpected error occurred");
} }
console.warn(error); console.warn(error);
} }
}; };
return ( return (
<Form <Form
ref={formRef}
name="form" name="form"
initialValues={{
shareCode: getShareCode(window.location.search),
}}
footer={ footer={
<Button <Button
block block
@ -172,4 +193,19 @@ function EmailForm() {
); );
} }
const getShareCode = (url: string) => {
const newStr = url.replace("?", "")?.split("&");
if (!newStr) return "";
const shareStr = newStr.find((item) => item.includes("shareCode"));
if (!shareStr) return "";
if (shareStr) {
const code = shareStr.split("=")[1];
if (code) {
// setShareCode(code)
return code;
}
}
return "";
};
export default EmailForm; export default EmailForm;

View File

@ -1,4 +1,4 @@
import { useState, useEffect } from "react"; import { useState, useEffect, useRef } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Form, Input, Button } from "antd-mobile"; import { Form, Input, Button } from "antd-mobile";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
@ -6,10 +6,12 @@ import "../pages/SignIn.scss";
import useUserStore from "../store/user.ts"; import useUserStore from "../store/user.ts";
import { useCountdown } from "../hooks/useCountdown"; import { useCountdown } from "../hooks/useCountdown";
import { sendCode, signUp } from "../api"; import { sendCode, signUp } from "../api";
import { sendCodeTypes, signUpTypes,ErrorType} from "../type/SignIn"; import { sendCodeTypes, signUpTypes, ErrorType } from "../type/SignIn";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
import { Md5 } from "ts-md5";
import { FormInstance } from "antd-mobile/es/components/form/form";
function PhoneForm() { function PhoneForm() {
const formRef = useRef<FormInstance>(null);
const { t } = useTranslation(); const { t } = useTranslation();
const { start, time } = useCountdown(); const { start, time } = useCountdown();
const navigate = useNavigate(); const navigate = useNavigate();
@ -19,6 +21,22 @@ function PhoneForm() {
UpdateCurrentPhoneNumber, UpdateCurrentPhoneNumber,
UpdatePreviousPathName, UpdatePreviousPathName,
} = useUserStore(); } = useUserStore();
const getShareCode = (url: string) => {
const newStr = url.replace("?", "")?.split("&");
if (!newStr) return "";
const shareStr = newStr.find((item) => item.includes("shareCode"));
if (!shareStr) return "";
if (shareStr) {
const code = shareStr.split("=")[1];
if (code) {
// setShareCode(code)
return code;
}
}
return "";
};
const defaultAreaCode = "+1"; const defaultAreaCode = "+1";
const [authCode, setAuthCode] = useState(""); const [authCode, setAuthCode] = useState("");
const [shareCode, setShareCode] = useState(""); const [shareCode, setShareCode] = useState("");
@ -41,89 +59,107 @@ function PhoneForm() {
if (CurrentPhoneNumber === "") { if (CurrentPhoneNumber === "") {
return; return;
} }
const res = await sendCode<sendCodeTypes>({ const timestamp = `${new Date().getTime()}`;
account: CurrentPhoneNumber, const res = await sendCode<sendCodeTypes>(
areaCode: SelectCountry?.code, {
status: 2, account: CurrentPhoneNumber,
},config); areaCode: SelectCountry?.code || defaultAreaCode,
status: 2,
signature: Md5.hashStr(
`Neer${CurrentPhoneNumber},${2},${timestamp}GetCode`
),
timestamp,
},
config
);
console.log("res", res); console.log("res", res);
if (res.status === 200 && res.data.data.sms) { if (res.status === 200 && res.data.data.sms) {
console.log(111);
Toast.show({ Toast.show({
content:t('send successfully'), content: t("send successfully"),
afterClose: () => { afterClose: () => {
start(60 * 1000); start(60 * 1000);
}, },
}); });
} else { } else {
Toast.show({ Toast.show({
content: t('Send failure'), content: t("Send failure"),
afterClose: () => { afterClose: () => {
start(60 * 1000); // start(60 * 1000);
}, },
}); });
} }
} catch (error:unknown) { } catch (error: unknown) {
// 检查 error 是否是 ErrorType 类型 // 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) { if (typeof error === "object" && error !== null && "msg" in error) {
const typedError = error as ErrorType; // 使用类型断言 const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: typedError.msg, content: typedError.msg,
afterClose: () => { afterClose: () => {
start(60 * 1000); // start(60 * 1000);
}, },
}); });
} else { } else {
// 处理不是 ErrorType 类型的错误 // 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred'); console.log("An unexpected error occurred");
} }
console.warn(error); console.warn(error);
} }
}; };
useEffect(() => { useEffect(() => {
setRemainingTime(time / 1000) setRemainingTime(time / 1000);
}, [time]); }, [time]);
const handleSignUp = async () =>{ const handleSignUp = async () => {
if(CurrentPhoneNumber === '' || authCode === '') { if (CurrentPhoneNumber === "" || authCode === "") {
return return;
} }
try { try {
const res = await signUp<signUpTypes>({ const res = await signUp<signUpTypes>(
account:CurrentPhoneNumber, {
area:SelectCountry?.cn, account: CurrentPhoneNumber,
areaCode:SelectCountry?.code, area: SelectCountry?.cn,
authCode:authCode, areaCode: SelectCountry?.code,
shareCode:shareCode authCode: authCode,
},config) shareCode: shareCode || formRef.current?.getFieldValue("shareCode"),
console.log('res',res) userName: "",
if(res.status === 200 && res.data.data.token) { },
config
);
console.log("res", res);
if (res.status === 200 && res.data.data.token) {
Toast.show({ Toast.show({
content: res.data.msg, content: res.data.msg,
}) });
}else { setTimeout(() => {
navigate("/Download");
}, 1000);
} else {
Toast.show({ Toast.show({
content: res.data.msg, content: res.data.msg,
}) });
} }
} catch (error:unknown) { } catch (error: unknown) {
// 检查 error 是否是 ErrorType 类型 // 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) { if (typeof error === "object" && error !== null && "msg" in error) {
const typedError = error as ErrorType; // 使用类型断言 const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: typedError.msg, content: typedError.msg,
}); });
} else { } else {
// 处理不是 ErrorType 类型的错误 // 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred'); console.log("An unexpected error occurred");
} }
console.warn(error); console.warn(error);
} }
}; };
return ( return (
<Form <Form
name="form" name="form"
ref={formRef}
initialValues={{
shareCode: getShareCode(window.location.search),
}}
footer={ footer={
<Button <Button
block block

View File

@ -1,24 +1,23 @@
{ {
"E-mail": "电子邮件", "E-mail": "電子郵件",
"phone":"电话", "phone": "電話",
"Please enter your email address":"请输入您的电子邮件地址", "Please enter your email address": "請輸入您的電子郵件地址",
"Please enter the email verification code":"请输入电子邮件验证码", "Please enter the email verification code": "請輸入電子郵件驗證碼",
"Please enter your phone number":"请输入您的电话号码", "Please enter your phone number": "請輸入您的電話號碼",
"Please enter SMS verification code":"请输入短信验证码", "Please enter SMS verification code": "請輸入短信驗證碼",
"Send verification code":"发送验证码", "Send verification code": "發送驗證碼",
"Please enter the invitation code (optional)":"请输入邀请码(可选)", "Please enter the invitation code (optional)": "請輸入邀請碼(可選)",
"register":"注册", "register": "注冊",
"If you already have an account":"如果你已经有一个帐户", "If you already have an account": "已有帳戶",
"download the APP directly":"直接下载APP", "download the APP directly": "直接下載APP",
"Continuing to represent you in agreeing to our":"继续代表你方同意我们的", "Continuing to represent you in agreeing to our": "繼續代表妳方同意我們的",
"Terms of Service":"服务条款", "Terms of Service": "服務條款",
"and":"和", "and": "和",
"Privacy Policy":"隐私政策", "Privacy Policy": "隱私政策",
"Select country/region":"选择国家/地区", "Select country/region": "選擇國家/地區",
"seconds": "秒", "seconds": "秒",
"Official Website":"官方网站", "Official Website": "官方網站",
"Download":"下载", "Download": "下載",
"send successfully":"发送成功", "send successfully": "發送成功",
"Send failure":"发送失败" "Send failure": "發送失敗"
} }

View File

@ -7,7 +7,7 @@
"Please enter SMS verification code":"Please enter SMS verification code", "Please enter SMS verification code":"Please enter SMS verification code",
"Send verification code":"Send verification code", "Send verification code":"Send verification code",
"Please enter the invitation code (optional)":"Please enter the invitation code (optional)", "Please enter the invitation code (optional)":"Please enter the invitation code (optional)",
"register":"register", "register":"Register",
"If you already have an account":"If you already have an account", "If you already have an account":"If you already have an account",
"download the APP directly":"download the APP directly", "download the APP directly":"download the APP directly",
"Continuing to represent you in agreeing to our":"Continuing to represent you in agreeing to our", "Continuing to represent you in agreeing to our":"Continuing to represent you in agreeing to our",

View File

@ -1,5 +1,5 @@
: body,
{ html {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5; line-height: 1.5;
font-weight: 400; font-weight: 400;
@ -13,16 +13,19 @@
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
#root { #root {
padding: 0; padding: 0;
background: #fafafb; background: #fafafb;
} }
a { a {
font-weight: 500; font-weight: 500;
color: #646cff; color: #646cff;
text-decoration: inherit; text-decoration: inherit;
} }
a:hover { a:hover {
color: #535bf2; color: #535bf2;
} }
@ -51,23 +54,31 @@ button {
cursor: pointer; cursor: pointer;
transition: border-color 0.25s; transition: border-color 0.25s;
} }
button:hover { button:hover {
border-color: #646cff; border-color: #646cff;
} }
button:focus, button:focus,
button:focus-visible { button:focus-visible {
outline: 4px auto -webkit-focus-ring-color; outline: 4px auto -webkit-focus-ring-color;
} }
.adm-form-item-feedback-error {
text-align: left;
}
@media (prefers-color-scheme: light) { @media (prefers-color-scheme: light) {
:root { :root {
color: #213547; color: #213547;
background-color: #ffffff; background-color: #ffffff;
} }
a:hover { a:hover {
color: #747bff; color: #747bff;
} }
button { button {
background-color: #f9f9f9; background-color: #f9f9f9;
} }
} }

View File

@ -1,10 +1,5 @@
import React from 'react' import ReactDOM from "react-dom/client";
import ReactDOM from 'react-dom/client' import App from "./App.tsx";
import App from './App.tsx' import "./index.css";
import './index.css' import "./i18n/config.ts";
import './i18n/config.ts' ReactDOM.createRoot(document.getElementById("root")!).render(<App />);
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@ -1,5 +1,5 @@
.container { .container {
background: #fafafb; background: #131313;
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
padding: 4.625rem 2.5rem; padding: 4.625rem 2.5rem;
@ -18,12 +18,16 @@
.btn-box { .btn-box {
margin-top: 11.4375rem; margin-top: 11.4375rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.btn-item { .btn-item {
width: 18.4375rem; width: 18.4375rem;
height: 2.75rem; height: 2.75rem;
border-radius: .3125rem; border-radius: .3125rem;
box-sizing: border-box; box-sizing: border-box;
border: .0625rem solid #BF62FF; border: .0625rem solid #FCB44B;
margin-bottom: 1.25rem; margin-bottom: 1.25rem;
display: flex; display: flex;
align-items: center; align-items: center;
@ -36,7 +40,7 @@
a { a {
font-family: PingFang SC; font-family: PingFang SC;
font-size: 1.125rem; font-size: 1.125rem;
color: #333333; color: #ffffff;
} }
} }
} }

View File

@ -1,5 +1,5 @@
import googleIcon from '../assets/img/google.png' // import googleIcon from '../assets/img/google.png'
import appStoreIcon from '../assets/img/app_store.png' // import appStoreIcon from '../assets/img/app_store.png'
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import Logo from "../assets/img/logo.png" import Logo from "../assets/img/logo.png"
@ -14,19 +14,19 @@ function Download() {
<img src={Logo} alt="" /> <img src={Logo} alt="" />
</div> </div>
<div className="btn-box"> <div className="btn-box">
<div className="btn-item"> {/* <div className="btn-item">
<img src={googleIcon}alt="" /> <img src={googleIcon}alt="" />
<a href="">Google Play</a> <a>Google Play</a>
</div> </div>
<div className="btn-item"> <div className="btn-item">
<img src={appStoreIcon} alt="" /> <img src={appStoreIcon} alt="" />
<a href="">App Store</a> <a>App Store</a>
</div> */}
<div className="btn-item">
<a href="https://d.pineer.cc/app-release.apk">{t('Download')} APK</a>
</div> </div>
<div className="btn-item"> <div className="btn-item">
<a href="http://8.217.122.133/upload/apk/app-release.apk">{t('Download')} APK</a> <a href="https://www.pineer.cc">{t('Official Website')}</a>
</div>
<div className="btn-item">
<a href="">{t('Official Website')}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -55,7 +55,7 @@
} }
} }
.area-box { .area-box {
overflow: scroll; overflow-y: scroll;
height: calc(100vh - 7.5rem); height: calc(100vh - 7.5rem);
padding: 0 1.5rem; padding: 0 1.5rem;
box-sizing: border-box; box-sizing: border-box;
@ -69,8 +69,8 @@
line-height: 3.25rem; line-height: 3.25rem;
border-bottom: .0625rem solid #D8D8D8; border-bottom: .0625rem solid #D8D8D8;
&.selected { &.selected {
border-bottom: .0625rem solid #BF62FF; border-bottom: .0625rem solid #FCB44B;
color: #BF62FF; color: #FCB44B;
} }
} }
} }

View File

@ -1,15 +1,32 @@
.popoverContainer {
.adm-popover-inner {
.adm-popover-inner-content {
padding: 0 !important;
}
}
}
.container { .container {
background: #fafafb; background: #fafafb;
width: 100vw; width: 100vw;
min-height: 100vh; min-height: 100vh;
padding: 4.625rem 2.5rem; padding: 4.625rem 2.5rem;
box-sizing: border-box; box-sizing: border-box;
position: relative;
.language {
position: absolute;
right: 3rem;
top: 2rem;
color: #fff;
}
.logo { .logo {
width: 4.25rem; width: 4.25rem;
height: 4.25rem; height: 4.25rem;
margin-left: 50%; margin-left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -26,14 +43,16 @@
font-size: 18px; font-size: 18px;
font-weight: normal; font-weight: normal;
line-height: normal; line-height: normal;
color: #333333; color: #999999;
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 2.0625rem; margin-right: 2.0625rem;
&.selected { &.selected {
border-bottom: .0625rem solid #BF62FF; border-bottom: .0625rem solid #FCB44B;
color:#BF62FF; color: #FCB44B;
} }
img { img {
margin-right: .4375rem; margin-right: .4375rem;
} }
@ -47,16 +66,19 @@
} }
.adm-list-item { .adm-list-item {
background: #FFFFFF; background: #333333;
margin-bottom: 1.7rem; margin-bottom: 1.7rem;
width: 100%; width: 100%;
height: 2.75rem; height: 2.75rem;
border-radius: .3125rem; border-radius: .3125rem;
box-sizing: border-box; box-sizing: border-box;
border: 1px solid #999999 !important; border: 1px solid #56512c !important;
box-shadow: 0px 2px 5px 0px rgba(153, 153, 153, 50%); // box-shadow: 0px 2px 5px 0px rgba(153, 153, 153, 50%);
padding-left: 0; padding-left: 0;
.adm-input-element { .adm-input-element {
color: #c6c6c6;
&::placeholder { &::placeholder {
font-size: .75rem; font-size: .75rem;
color: #999999 color: #999999
@ -67,55 +89,70 @@
.adm-list-item-content { .adm-list-item-content {
border-style: none; border-style: none;
} }
.adm-list-item-content-main { .adm-list-item-content-main {
padding: 0; padding: 0;
} }
.adm-input { .adm-input {
padding: .75rem 0; padding: 0.5rem 0 0.6rem 0;
padding-left: .625rem; padding-left: .625rem;
} }
.send-code { .send-code {
font-family: PingFang SC; font-family: PingFang SC;
font-size: .75rem; font-size: .75rem;
color: #BF62FF; color: #0957c0;
margin-bottom:.9375rem; margin-bottom: 1.5375rem;
margin-top: -0.5rem;
text-align: right; text-align: right;
} }
.adm-form-footer { .adm-form-footer {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.submit-btn { .submit-btn {
display: flex;
justify-content: center;
align-items: center;
width: 6.1875rem; width: 6.1875rem;
height: 2.75rem; height: 2.75rem;
border-radius: .3125rem; border-radius: .3125rem;
background: #BF62FF; background: #FCB44B;
font-family: PingFang SC; font-family: PingFang SC;
font-size: .75rem; font-size: .75rem;
color: #FFFFFF; color: #333;
} }
.to-download { .to-download {
font-family: PingFang SC; font-family: PingFang SC;
font-size: .875rem; font-size: .875rem;
color: #BF62FF; color: #0957c0;
} }
.terms-service { .terms-service {
font-family: PingFang SC; font-family: PingFang SC;
font-size: .75rem; font-size: .75rem;
text-align: center; text-align: center;
width: 100%; width: 100%;
margin-top: 5rem; margin-top: 5rem;
p { p {
color: #999999; color: #999999;
} }
span {
color:#BF62FF; span>a {
color: #0957c0;
} }
} }
.phone-box { .phone-box {
display: flex; display: flex;
align-items: center; align-items: center;
border-radius: .3125rem; border-radius: .3125rem;
span { span {
width: 3.75rem; width: 3.75rem;
height: 2.6rem; height: 2.6rem;
@ -123,18 +160,17 @@
text-align: center; text-align: center;
font-family: PingFang SC; font-family: PingFang SC;
font-size: .75rem; font-size: .75rem;
color: #666666; color: #c6c6c6;
background: #EAEAEA; background: #333333;
border-right: .0625rem solid #999999; border-right: .0625rem solid #5d5d5d;
border-left: .0625rem solid #999999;
border-bottom: .0625rem solid #999999;
border-top-left-radius: .3125rem; border-top-left-radius: .3125rem;
border-bottom-left-radius: .3125rem; border-bottom-left-radius: .3125rem;
} }
.adm-input { .adm-input {
padding-top: 0.55rem; padding-top: 0rem;
padding-left: 0.625rem; padding-left: 0.625rem;
padding-bottom: 0; padding-bottom: 0.1rem;
} }
} }
} }

View File

@ -1,39 +1,101 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation, getI18n } from "react-i18next";
import phoneIconSelect from "../assets/iconfont/phone_Select.svg"; import phoneIconSelect from "../assets/iconfont/phone_Select.svg";
import phoneIcon from "../assets/iconfont/phone.svg"; import phoneIcon from "../assets/iconfont/phone.svg";
import emailIcon from "../assets/iconfont/email.svg"; import emailIcon from "../assets/iconfont/email.svg";
import emailIconSelect from "../assets/iconfont/email_Select.svg"; import emailIconSelect from "../assets/iconfont/email_Select.svg";
import Logo from "../assets/img/logo.png" import Logo from "../assets/img/logo.png";
import "./SignIn.scss"; import "./SignIn.scss";
import EmailForm from "../components/EmailForm"; import EmailForm from "../components/EmailForm";
import PhoneForm from "../components/PhoneForm"; import PhoneForm from "../components/PhoneForm";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import useUserStore from "../store/user.ts"; import useUserStore from "../store/user.ts";
import { Popover } from "antd-mobile";
console.log('language',navigator.language)
function SignIn() { function SignIn() {
const { t } = useTranslation(); const { t, i18n } = useTranslation();
const lang: string = getI18n().language;
const [visible, setVisible] = useState(false);
const [selectIndex, setSelectIndex] = useState<number>(0); const [selectIndex, setSelectIndex] = useState<number>(0);
const {previousPathName,UpdatePreviousPathName} = useUserStore() const { previousPathName, UpdatePreviousPathName } = useUserStore();
const navigate = useNavigate(); const navigate = useNavigate();
const handleTabs = (num: number) => { const handleTabs = (num: number) => {
return () => { return () => {
UpdatePreviousPathName('/'); UpdatePreviousPathName("/");
setSelectIndex(num); setSelectIndex(num);
}; };
}; };
useEffect(() => { useEffect(() => {
// 当组件加载时,保存当前路径 // 当组件加载时,保存当前路径
console.log("previousPathName", previousPathName); console.log("previousPathName", previousPathName);
if (previousPathName === "/SelectCountry") { if (previousPathName === "/SelectCountry") {
setSelectIndex(1); setSelectIndex(1);
} }
}, [previousPathName]); }, [previousPathName]);
return ( return (
<div className="container"> <div className="container">
<div className="language">
<Popover
className="popoverContainer"
mode="dark"
visible={visible}
placement="bottom-end"
trigger="click"
content={
<ul
style={{
listStyle: "none",
display: "flex",
flexDirection: "column",
justifyContent: "flex-start",
alignItems: "center",
margin: 0,
padding: "5px 10px",
fontSize: 14,
background: "#333333",
borderRadius: 6,
}}
>
<li
style={{
borderBottom: "1px solid #2f2f2f",
padding: "5px 10px",
cursor: "pointer",
}}
>
<span
onClick={() => {
i18n.changeLanguage("cn");
setVisible(false);
}}
>
</span>
</li>
<li style={{ padding: "5px 10px", cursor: "pointer" }}>
<span
onClick={() => {
i18n.changeLanguage("en");
setVisible(false);
}}
>
English
</span>
</li>
</ul>
}
>
<span
style={{ cursor: "pointer" }}
onClick={() => setVisible(!visible)}
>
{lang === "cn" ? "中文" : "English"}
</span>
</Popover>
</div>
<div className="logo"> <div className="logo">
<img src={Logo} alt="" /> <img src={Logo} alt="" />
</div> </div>
@ -55,15 +117,31 @@ function SignIn() {
</div> </div>
{selectIndex === 0 && <EmailForm></EmailForm>} {selectIndex === 0 && <EmailForm></EmailForm>}
{selectIndex === 1 && <PhoneForm></PhoneForm>} {selectIndex === 1 && <PhoneForm></PhoneForm>}
<div className="to-download" onClick={()=> navigate("/Download")}> <div className="to-download">
<p>{t("If you already have an account")}</p> <p style={{ color: "#999999" }}>
<p>{t("download the APP directly")}</p> {t("If you already have an account")}
</p>
<p onClick={() => navigate("/Download")}>
{t("download the APP directly")}
</p>
</div> </div>
<div className="terms-service"> <div className="terms-service">
<p>{t("Continuing to represent you in agreeing to our")}</p> <p>{t("Continuing to represent you in agreeing to our")}</p>
<p> <p>
<span>{t("Terms of Service")}</span> {t("and")}{" "} <span>
<span>{t("Privacy Policy")}</span> <a
target="_blank"
href="https://lm0-1.gitbook.io/terms-of-service/"
>
{t("Terms of Service")}
</a>
</span>{" "}
{t("and")}{" "}
<span>
<a target="_blank" href="https://lm0-1.gitbook.io/privacy-policy/">
{t("Privacy Policy")}
</a>
</span>
</p> </p>
</div> </div>
</div> </div>

4033
yarn.lock

File diff suppressed because it is too large Load Diff