feat(ui): 新增 Skin Hub 品牌图标并统一登录页标识

- 新增蓝紫渐变宝石图标(SVG / ICO / apple-touch-icon / 192 / 512)
- 登录页品牌位由字母 S 换成同一 BrandMark
- index.html 补齐图标、theme-color 与页面描述
This commit is contained in:
yml2213
2026-10-21 22:40:12 +08:00
parent bab522bcb3
commit 6a2b95d300
7 changed files with 237 additions and 118 deletions
+8 -1
View File
@@ -2,8 +2,15 @@
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#2563eb" />
<meta
name="description"
content="Skin Hub 游戏皮肤分销平台:商品、订单、发货与钱包的一体化管理后台。"
/>
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" href="/favicon.ico" sizes="16x16 32x32 48x48" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<title>游戏皮肤分销系统</title> <title>游戏皮肤分销系统</title>
</head> </head>
<body> <body>
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

+205 -116
View File
@@ -1,138 +1,202 @@
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from "react";
import { useNavigate } from 'react-router-dom' import { useNavigate } from "react-router-dom";
import { Alert, Button, Divider, Form, Input, Space, Typography, message } from 'antd' import {
import { LockOutlined, RightOutlined, SafetyCertificateOutlined, UserOutlined } from '@ant-design/icons' Alert,
import { authApi } from '../api' Button,
import type { PreparedDeviceLogin } from '../types' Divider,
import { useAuth } from '../store/authContext' Form,
Input,
Space,
Typography,
message,
} from "antd";
import {
LockOutlined,
RightOutlined,
SafetyCertificateOutlined,
UserOutlined,
} from "@ant-design/icons";
import { authApi } from "../api";
import type { PreparedDeviceLogin } from "../types";
import { useAuth } from "../store/authContext";
type LoginForm = { type LoginForm = {
username: string username: string;
password: string password: string;
smsCode: string smsCode: string;
};
/** 与站点图标同源的品牌标记:蓝紫渐变 + 白色宝石。 */
function BrandMark({ size = 48 }: { size?: number }) {
return (
<svg
width={size}
height={size}
viewBox="0 0 64 64"
role="img"
aria-label="Skin Hub 游戏皮肤分销平台"
style={{ display: "block" }}
>
<defs>
<linearGradient
id="skinBrand"
x1="8"
y1="4"
x2="56"
y2="60"
gradientUnits="userSpaceOnUse"
>
<stop offset="0" stopColor="#3B82F6" />
<stop offset="0.55" stopColor="#2563EB" />
<stop offset="1" stopColor="#7C3AED" />
</linearGradient>
</defs>
<rect width="64" height="64" rx="17" fill="url(#skinBrand)" />
<polygon points="20,16 44,16 52,27 32,52 12,27" fill="#fff" />
<path
d="M12 27h40M20 16l6 11M44 16l-6 11M26 27l6 25 6-25"
fill="none"
stroke="#2563EB"
strokeWidth="1.8"
strokeLinejoin="round"
opacity="0.35"
/>
</svg>
);
} }
export default function Login() { export default function Login() {
const { login, applyLoginResult } = useAuth() const { login, applyLoginResult } = useAuth();
const navigate = useNavigate() const navigate = useNavigate();
const [form] = Form.useForm<LoginForm>() const [form] = Form.useForm<LoginForm>();
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false);
const [sending, setSending] = useState(false) const [sending, setSending] = useState(false);
const [countdown, setCountdown] = useState(0) const [countdown, setCountdown] = useState(0);
const [waiting, setWaiting] = useState(false) const [waiting, setWaiting] = useState(false);
const [phoneMasked, setPhoneMasked] = useState('') const [phoneMasked, setPhoneMasked] = useState("");
const timerRef = useRef<number | null>(null) const timerRef = useRef<number | null>(null);
const submittingRef = useRef(false) const submittingRef = useRef(false);
useEffect(() => { useEffect(() => {
return () => { return () => {
if (timerRef.current) window.clearInterval(timerRef.current) if (timerRef.current) window.clearInterval(timerRef.current);
} };
}, []) }, []);
const startCountdown = (seconds: number) => { const startCountdown = (seconds: number) => {
setCountdown(seconds) setCountdown(seconds);
if (timerRef.current) window.clearInterval(timerRef.current) if (timerRef.current) window.clearInterval(timerRef.current);
timerRef.current = window.setInterval(() => { timerRef.current = window.setInterval(() => {
setCountdown((current) => { setCountdown((current) => {
if (current <= 1) { if (current <= 1) {
if (timerRef.current) window.clearInterval(timerRef.current) if (timerRef.current) window.clearInterval(timerRef.current);
return 0 return 0;
} }
return current - 1 return current - 1;
}) });
}, 1000) }, 1000);
} };
const sendCode = async () => { const sendCode = async () => {
try { try {
const values = await form.validateFields(['username', 'password']) const values = await form.validateFields(["username", "password"]);
setSending(true) setSending(true);
const result = await authApi.sendLoginSmsCode(values.username.trim(), values.password) const result = await authApi.sendLoginSmsCode(
setPhoneMasked(result.phoneMasked) values.username.trim(),
startCountdown(60) values.password,
message.success(`验证码已发送至 ${result.phoneMasked}`) );
setPhoneMasked(result.phoneMasked);
startCountdown(60);
message.success(`验证码已发送至 ${result.phoneMasked}`);
} catch (error) { } catch (error) {
const text = error instanceof Error ? error.message : '验证码发送失败' const text = error instanceof Error ? error.message : "验证码发送失败";
if (text.includes('未绑定手机号')) { if (text.includes("未绑定手机号")) {
message.warning(`${text},可使用下方「旧账号仅密码登录」`) message.warning(`${text},可使用下方「旧账号仅密码登录」`);
} else { } else {
message.error(text) message.error(text);
} }
} finally { } finally {
setSending(false) setSending(false);
} }
} };
const onFinish = async (values: LoginForm) => { const onFinish = async (values: LoginForm) => {
if (submittingRef.current) return if (submittingRef.current) return;
submittingRef.current = true submittingRef.current = true;
setLoading(true) setLoading(true);
setWaiting(false) setWaiting(false);
try { try {
const prepared = await authApi.prepareLogin({ const prepared = await authApi.prepareLogin({
username: values.username.trim(), username: values.username.trim(),
password: values.password, password: values.password,
smsCode: values.smsCode.trim(), smsCode: values.smsCode.trim(),
apiBase: window.location.origin, apiBase: window.location.origin,
}) });
setPhoneMasked(prepared.phoneMasked) setPhoneMasked(prepared.phoneMasked);
setWaiting(true) setWaiting(true);
message.info('已发起本机验证,请在弹出的 DCAuth 窗口中确认') message.info("已发起本机验证,请在弹出的 DCAuth 窗口中确认");
launchProtocol(prepared.launchUrl) launchProtocol(prepared.launchUrl);
const result = await waitForDevice(prepared) const result = await waitForDevice(prepared);
applyLoginResult(result) applyLoginResult(result);
message.success('登录成功,欢迎回来!') message.success("登录成功,欢迎回来!");
navigate('/', { replace: true }) navigate("/", { replace: true });
} catch (error) { } catch (error) {
const text = error instanceof Error ? error.message : '登录失败,请检查账号密码' const text =
if (text.includes('未绑定手机号')) { error instanceof Error ? error.message : "登录失败,请检查账号密码";
message.warning(`${text},可使用下方「旧账号仅密码登录」`) if (text.includes("未绑定手机号")) {
} else if (text.includes('绑定设备不一致')) { message.warning(`${text},可使用下方「旧账号仅密码登录」`);
message.error('当前设备与账号绑定设备不一致,请联系管理员重置设备') } else if (text.includes("绑定设备不一致")) {
message.error("当前设备与账号绑定设备不一致,请联系管理员重置设备");
} else { } else {
message.error(text) message.error(text);
} }
} finally { } finally {
submittingRef.current = false submittingRef.current = false;
setLoading(false) setLoading(false);
setWaiting(false) setWaiting(false);
} }
} };
const submitLegacyLogin = async () => { const submitLegacyLogin = async () => {
if (submittingRef.current) return if (submittingRef.current) return;
let values: LoginForm let values: LoginForm;
try { try {
values = await form.validateFields(['username', 'password']) values = await form.validateFields(["username", "password"]);
} catch { } catch {
return return;
} }
submittingRef.current = true submittingRef.current = true;
setLoading(true) setLoading(true);
try { try {
await login(values.username.trim(), values.password) await login(values.username.trim(), values.password);
message.success('登录成功,欢迎回来!') message.success("登录成功,欢迎回来!");
navigate('/', { replace: true }) navigate("/", { replace: true });
} catch (error) { } catch (error) {
message.error(error instanceof Error ? error.message : '账号密码登录失败') message.error(
error instanceof Error ? error.message : "账号密码登录失败",
);
} finally { } finally {
submittingRef.current = false submittingRef.current = false;
setLoading(false) setLoading(false);
} }
} };
return ( return (
<div className="login-wrapper"> <div className="login-wrapper">
<div className="login-card"> <div className="login-card">
<Space direction="vertical" size="large" style={{ width: '100%' }}> <Space direction="vertical" size="large" style={{ width: "100%" }}>
<div style={{ textAlign: 'center' }}> <div style={{ textAlign: "center" }}>
<div className="login-logo">S</div> <div className="login-logo">
<Typography.Title level={3} style={{ margin: '0 0 6px 0', color: '#ffffff', fontWeight: 700 }}> <BrandMark size={48} />
</div>
<Typography.Title
level={3}
style={{ margin: "0 0 6px 0", color: "#ffffff", fontWeight: 700 }}
>
Skin Hub 游戏皮肤分销平台 Skin Hub 游戏皮肤分销平台
</Typography.Title> </Typography.Title>
<Typography.Text style={{ color: '#94a3b8', fontSize: 13 }}> <Typography.Text style={{ color: "#94a3b8", fontSize: 13 }}>
账号密码 + 短信验证码 + DCAuth 本机设备签名 账号密码 + 短信验证码 + DCAuth 本机设备签名
</Typography.Text> </Typography.Text>
</div> </div>
@@ -146,14 +210,19 @@ export default function Login() {
/> />
) : null} ) : null}
<Form form={form} layout="vertical" onFinish={onFinish} requiredMark={false}> <Form
form={form}
layout="vertical"
onFinish={onFinish}
requiredMark={false}
>
<Form.Item <Form.Item
name="username" name="username"
rules={[{ required: true, message: '请输入用户名' }]} rules={[{ required: true, message: "请输入用户名" }]}
style={{ marginBottom: 18 }} style={{ marginBottom: 18 }}
> >
<Input <Input
prefix={<UserOutlined style={{ color: '#64748b' }} />} prefix={<UserOutlined style={{ color: "#64748b" }} />}
placeholder="用户名(支持中文 / 英文)" placeholder="用户名(支持中文 / 英文)"
size="large" size="large"
autoComplete="username" autoComplete="username"
@@ -163,11 +232,11 @@ export default function Login() {
<Form.Item <Form.Item
name="password" name="password"
rules={[{ required: true, message: '请输入密码' }]} rules={[{ required: true, message: "请输入密码" }]}
style={{ marginBottom: 18 }} style={{ marginBottom: 18 }}
> >
<Input.Password <Input.Password
prefix={<LockOutlined style={{ color: '#64748b' }} />} prefix={<LockOutlined style={{ color: "#64748b" }} />}
placeholder="密码" placeholder="密码"
size="large" size="large"
autoComplete="current-password" autoComplete="current-password"
@@ -177,12 +246,14 @@ export default function Login() {
<Form.Item <Form.Item
name="smsCode" name="smsCode"
rules={[{ required: true, message: '请输入短信验证码' }]} rules={[{ required: true, message: "请输入短信验证码" }]}
style={{ marginBottom: 24 }} style={{ marginBottom: 24 }}
> >
<Input <Input
prefix={<SafetyCertificateOutlined style={{ color: '#64748b' }} />} prefix={
placeholder={`6 位短信验证码${phoneMasked ? `(${phoneMasked})` : ''}`} <SafetyCertificateOutlined style={{ color: "#64748b" }} />
}
placeholder={`6 位短信验证码${phoneMasked ? `(${phoneMasked})` : ""}`}
size="large" size="large"
maxLength={6} maxLength={6}
autoComplete="one-time-code" autoComplete="one-time-code"
@@ -195,9 +266,9 @@ export default function Login() {
loading={sending} loading={sending}
disabled={countdown > 0} disabled={countdown > 0}
onClick={() => void sendCode()} onClick={() => void sendCode()}
style={{ padding: 0, height: 'auto' }} style={{ padding: 0, height: "auto" }}
> >
{countdown > 0 ? `${countdown}s 后重发` : '获取验证码'} {countdown > 0 ? `${countdown}s 后重发` : "获取验证码"}
</Button> </Button>
} }
/> />
@@ -216,8 +287,9 @@ export default function Login() {
borderRadius: 8, borderRadius: 8,
fontSize: 15, fontSize: 15,
fontWeight: 600, fontWeight: 600,
background: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)', background:
boxShadow: '0 4px 14px rgba(37, 99, 235, 0.4)', "linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)",
boxShadow: "0 4px 14px rgba(37, 99, 235, 0.4)",
}} }}
> >
安全登录 · 拉起本机验证 安全登录 · 拉起本机验证
@@ -225,54 +297,71 @@ export default function Login() {
</Form.Item> </Form.Item>
</Form> </Form>
<Divider plain style={{ margin: '0 0 4px' }}> <Divider plain style={{ margin: "0 0 4px" }}>
<Typography.Text style={{ color: '#64748b', fontSize: 12 }}>未绑定手机号的历史账号</Typography.Text> <Typography.Text style={{ color: "#64748b", fontSize: 12 }}>
未绑定手机号的历史账号
</Typography.Text>
</Divider> </Divider>
<Button type="link" block disabled={loading} onClick={() => void submitLegacyLogin()}> <Button
type="link"
block
disabled={loading}
onClick={() => void submitLegacyLogin()}
>
旧账号仅密码登录 旧账号仅密码登录
</Button> </Button>
<Typography.Paragraph <Typography.Paragraph
style={{ fontSize: 12, margin: 0, textAlign: 'center', color: '#64748b' }} style={{
fontSize: 12,
margin: 0,
textAlign: "center",
color: "#64748b",
}}
> >
已绑定手机号的账号必须通过短信验证码与 DCAuth 本机签名登录 已绑定手机号的账号必须通过短信验证码与 DCAuth 本机签名登录
</Typography.Paragraph> </Typography.Paragraph>
</Space> </Space>
</div> </div>
</div> </div>
) );
} }
async function waitForDevice(prepared: PreparedDeviceLogin) { async function waitForDevice(prepared: PreparedDeviceLogin) {
for (let attempt = 0; attempt < 120; attempt += 1) { for (let attempt = 0; attempt < 120; attempt += 1) {
await sleep(1000) await sleep(1000);
const status = await authApi.deviceChallengeStatus(prepared.challengeId, prepared.pollToken) const status = await authApi.deviceChallengeStatus(
if (status.status === 'authorized' && status.deviceTicket) { prepared.challengeId,
prepared.pollToken,
);
if (status.status === "authorized" && status.deviceTicket) {
return authApi.completeLogin({ return authApi.completeLogin({
challengeId: prepared.challengeId, challengeId: prepared.challengeId,
pollToken: prepared.pollToken, pollToken: prepared.pollToken,
deviceTicket: status.deviceTicket, deviceTicket: status.deviceTicket,
}) });
} }
if (status.status === 'expired' || status.status === 'rejected') { if (status.status === "expired" || status.status === "rejected") {
throw new Error(status.message || '本机验证已过期,请重新登录') throw new Error(status.message || "本机验证已过期,请重新登录");
} }
if (attempt === 4) { if (attempt === 4) {
message.info('如果浏览器没有弹出 DCAuth,请先安装并运行一次 DCAuth 客户端') message.info(
"如果浏览器没有弹出 DCAuth,请先安装并运行一次 DCAuth 客户端",
);
} }
} }
throw new Error('等待本机验证超时,请确认 DCAuth 已安装并允许浏览器唤起') throw new Error("等待本机验证超时,请确认 DCAuth 已安装并允许浏览器唤起");
} }
function launchProtocol(url: string) { function launchProtocol(url: string) {
const anchor = document.createElement('a') const anchor = document.createElement("a");
anchor.href = url anchor.href = url;
anchor.style.display = 'none' anchor.style.display = "none";
document.body.appendChild(anchor) document.body.appendChild(anchor);
anchor.click() anchor.click();
window.setTimeout(() => anchor.remove(), 1000) window.setTimeout(() => anchor.remove(), 1000);
} }
function sleep(ms: number) { function sleep(ms: number) {
return new Promise((resolve) => window.setTimeout(resolve, ms)) return new Promise((resolve) => window.setTimeout(resolve, ms));
} }