解决打包报错 添加logo

This commit is contained in:
xia.zhang 2024-01-31 16:36:19 +08:00
parent d22ed38a28
commit d5462cd595
13 changed files with 82 additions and 47 deletions

View File

@ -2,9 +2,9 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <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>Vite + React + TS</title> <title>NEER-APP-H5</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@ -1,6 +1,6 @@
import "./App.css"; import "./App.css";
import { useEffect } from "react"; import { useEffect } from "react";
import { BrowserRouter as Router, Route, Routes, Navigate } from "react-router-dom"; import { BrowserRouter 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";

View File

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

BIN
src/assets/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

View File

@ -1,10 +1,11 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { useState, useEffect } from "react"; import { useState, useEffect } 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 } from "../type/SignIn"; import { sendCodeTypes, signUpTypes,ErrorType } from "../type/SignIn";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
function EmailForm() { function EmailForm() {
@ -48,14 +49,20 @@ function EmailForm() {
}, },
}); });
} }
} catch (error) { } catch (error:unknown) {
// 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) {
const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: error?.msg, content: typedError.msg,
afterClose: () => { afterClose: () => {
start(60 * 1000); start(60 * 1000);
}, },
}); });
} else {
// 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred');
}
console.warn(error); console.warn(error);
} }
}; };
@ -87,13 +94,17 @@ function EmailForm() {
content: res.data.msg, content: res.data.msg,
}); });
} }
} catch (error) { } catch (error:unknown) {
// 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) {
const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: error?.msg, content: typedError.msg,
afterClose: () => {
start(60 * 1000);
},
}); });
} else {
// 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred');
}
console.warn(error); console.warn(error);
} }
}; };

View File

@ -6,7 +6,7 @@ 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 } from "../type/SignIn"; import { sendCodeTypes, signUpTypes,ErrorType} from "../type/SignIn";
import { Toast } from "antd-mobile"; import { Toast } from "antd-mobile";
function PhoneForm() { function PhoneForm() {
@ -62,13 +62,20 @@ function PhoneForm() {
}, },
}); });
} }
} catch (error) { } catch (error:unknown) {
// 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) {
const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: error?.msg, content: typedError.msg,
afterClose: () => { afterClose: () => {
start(60 * 1000); start(60 * 1000);
}, },
}); });
} else {
// 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred');
}
console.warn(error); console.warn(error);
} }
}; };
@ -98,13 +105,17 @@ function PhoneForm() {
content: res.data.msg, content: res.data.msg,
}) })
} }
} catch (error) { } catch (error:unknown) {
// 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) {
const typedError = error as ErrorType; // 使用类型断言
Toast.show({ Toast.show({
content: error?.msg, content: typedError.msg,
afterClose: () => {
start(60 * 1000);
},
}); });
} else {
// 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred');
}
console.warn(error); console.warn(error);
} }

View File

@ -8,10 +8,12 @@
.logo { .logo {
width: 4.25rem; width: 4.25rem;
height: 4.25rem; height: 4.25rem;
background: #bf62ff;
border-radius: 50%;
margin-left: 50%; margin-left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
img {
width: 100%;
height: 100%;
}
} }
.btn-box { .btn-box {

View File

@ -1,6 +1,7 @@
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 "./Download.scss"; import "./Download.scss";
@ -9,7 +10,9 @@ function Download() {
return ( return (
<div className="container"> <div className="container">
<div className="logo"></div> <div className="logo">
<img src={Logo} alt="" />
</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="" />

View File

@ -1,4 +1,4 @@
import { useState, useEffect } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import gobackIcon from "../assets/iconfont/goback.svg"; import gobackIcon from "../assets/iconfont/goback.svg";
import searchIcon from "../assets/iconfont/search.svg"; import searchIcon from "../assets/iconfont/search.svg";
@ -62,7 +62,7 @@ function SelectCountry() {
className={`area-item ${isSelected && "selected"}`} className={`area-item ${isSelected && "selected"}`}
onClick={() => handleSelectCountry(item, index)} onClick={() => handleSelectCountry(item, index)}
> >
<span>{item[lang]}</span> <span>{(item as never)[lang]}</span>
<span>{item.code}</span> <span>{item.code}</span>
</div> </div>
); );
@ -75,7 +75,7 @@ function SelectCountry() {
className={`area-item ${isSelected && "selected"}`} className={`area-item ${isSelected && "selected"}`}
onClick={() => handleSelectCountry(item, index)} onClick={() => handleSelectCountry(item, index)}
> >
<span>{item[lang]}</span> <span>{(item as never)[lang]}</span>
<span>{item.code}</span> <span>{item.code}</span>
</div> </div>
); );

View File

@ -8,10 +8,12 @@
.logo { .logo {
width: 4.25rem; width: 4.25rem;
height: 4.25rem; height: 4.25rem;
background: #bf62ff;
border-radius: 50%;
margin-left: 50%; margin-left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
img {
width: 100%;
height: 100%;
}
} }
.tabs { .tabs {

View File

@ -4,6 +4,7 @@ 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 "./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";
@ -33,7 +34,9 @@ function SignIn() {
}, [previousPathName]); }, [previousPathName]);
return ( return (
<div className="container"> <div className="container">
<div className="logo"></div> <div className="logo">
<img src={Logo} alt="" />
</div>
<div className="tabs"> <div className="tabs">
<div <div
className={`tabs-button ${selectIndex === 0 && "selected"}`} className={`tabs-button ${selectIndex === 0 && "selected"}`}

View File

@ -13,4 +13,6 @@ export interface signUpTypes {
authCode:string authCode:string
shareCode: string; shareCode: string;
} }
export interface ErrorType {
msg: any;
}

View File

@ -2,9 +2,10 @@
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"skipLibCheck": true, "skipLibCheck": true,
"module": "ESNext", "module": "commonjs",
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true,
"sourceMap":true
}, },
"include": ["vite.config.ts"] "include": ["vite.config.ts"]
} }