解决打包报错 添加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">
<head>
<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" />
<title>Vite + React + TS</title>
<title>NEER-APP-H5</title>
</head>
<body>
<div id="root"></div>

View File

@ -1,6 +1,6 @@
import "./App.css";
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 Download from "./pages/Download";
import SelectCountry from "./pages/SelectCountry";

View File

@ -15,7 +15,7 @@ const service = axios.create({
});
// 统一请求拦截,可配置自定义 headers 例如 language、token 等
service.interceptors.request.use(
(config: AxiosRequestConfig) => {
(config: any): any => {
// 确保 headers 对象存在
if (!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 { useTranslation } from "react-i18next";
import { Form, Input, Button } from "antd-mobile";
import "../pages/SignIn.scss";
import { useCountdown } from "../hooks/useCountdown";
import { sendCode, signUp } from "../api";
import { sendCodeTypes, signUpTypes } from "../type/SignIn";
import { sendCodeTypes, signUpTypes,ErrorType } from "../type/SignIn";
import { Toast } from "antd-mobile";
function EmailForm() {
@ -48,14 +49,20 @@ function EmailForm() {
},
});
}
} catch (error) {
Toast.show({
content: error?.msg,
afterClose: () => {
start(60 * 1000);
},
});
} catch (error:unknown) {
// 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) {
const typedError = error as ErrorType; // 使用类型断言
Toast.show({
content: typedError.msg,
afterClose: () => {
start(60 * 1000);
},
});
} else {
// 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred');
}
console.warn(error);
}
};
@ -87,13 +94,17 @@ function EmailForm() {
content: res.data.msg,
});
}
} catch (error) {
Toast.show({
content: error?.msg,
afterClose: () => {
start(60 * 1000);
},
});
} catch (error:unknown) {
// 检查 error 是否是 ErrorType 类型
if (typeof error === 'object' && error !== null && 'msg' in error) {
const typedError = error as ErrorType; // 使用类型断言
Toast.show({
content: typedError.msg,
});
} else {
// 处理不是 ErrorType 类型的错误
console.log('An unexpected error occurred');
}
console.warn(error);
}
};

View File

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

View File

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

View File

@ -1,6 +1,7 @@
import googleIcon from '../assets/img/google.png'
import appStoreIcon from '../assets/img/app_store.png'
import { useTranslation } from "react-i18next";
import Logo from "../assets/img/logo.png"
import "./Download.scss";
@ -9,7 +10,9 @@ function Download() {
return (
<div className="container">
<div className="logo"></div>
<div className="logo">
<img src={Logo} alt="" />
</div>
<div className="btn-box">
<div className="btn-item">
<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 gobackIcon from "../assets/iconfont/goback.svg";
import searchIcon from "../assets/iconfont/search.svg";
@ -62,7 +62,7 @@ function SelectCountry() {
className={`area-item ${isSelected && "selected"}`}
onClick={() => handleSelectCountry(item, index)}
>
<span>{item[lang]}</span>
<span>{(item as never)[lang]}</span>
<span>{item.code}</span>
</div>
);
@ -75,7 +75,7 @@ function SelectCountry() {
className={`area-item ${isSelected && "selected"}`}
onClick={() => handleSelectCountry(item, index)}
>
<span>{item[lang]}</span>
<span>{(item as never)[lang]}</span>
<span>{item.code}</span>
</div>
);

View File

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

View File

@ -4,6 +4,7 @@ import phoneIconSelect from "../assets/iconfont/phone_Select.svg";
import phoneIcon from "../assets/iconfont/phone.svg";
import emailIcon from "../assets/iconfont/email.svg";
import emailIconSelect from "../assets/iconfont/email_Select.svg";
import Logo from "../assets/img/logo.png"
import "./SignIn.scss";
import EmailForm from "../components/EmailForm";
import PhoneForm from "../components/PhoneForm";
@ -33,7 +34,9 @@ function SignIn() {
}, [previousPathName]);
return (
<div className="container">
<div className="logo"></div>
<div className="logo">
<img src={Logo} alt="" />
</div>
<div className="tabs">
<div
className={`tabs-button ${selectIndex === 0 && "selected"}`}

View File

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

View File

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