Compare commits
No commits in common. "b8fe29d5ba98b7606f9da10bbfdbd0f602b65ebd" and "b6193c2d63418ced7a4ff0c63fac2ac650650d9f" have entirely different histories.
b8fe29d5ba
...
b6193c2d63
@ -75,49 +75,26 @@
|
||||
}
|
||||
|
||||
.inheritor-card-footer {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #f0ebe3;
|
||||
}
|
||||
|
||||
.inheritor-card .stat-item {
|
||||
display: flex !important;
|
||||
flex-direction: row !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
gap: 4px !important;
|
||||
padding: 8px 6px !important;
|
||||
background: #f5f0e8 !important;
|
||||
border-radius: 6px !important;
|
||||
white-space: nowrap !important;
|
||||
transition: all 0.3s ease !important;
|
||||
border: 1px solid #e8e3db !important;
|
||||
min-height: 36px !important;
|
||||
.stat-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.inheritor-card .stat-item:hover {
|
||||
background: #ffe7c8 !important;
|
||||
border-color: #d4a574 !important;
|
||||
transform: translateY(-1px) !important;
|
||||
.stat-item .anticon {
|
||||
font-size: 14px;
|
||||
color: #d4a574;
|
||||
}
|
||||
|
||||
.inheritor-card .stat-item .anticon {
|
||||
font-size: 14px !important;
|
||||
color: #d4a574 !important;
|
||||
flex-shrink: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.inheritor-card .stat-item .ant-typography {
|
||||
color: #666666 !important;
|
||||
font-size: 12px !important;
|
||||
font-weight: 600 !important;
|
||||
white-space: nowrap !important;
|
||||
margin: 0 !important;
|
||||
line-height: 1 !important;
|
||||
.stat-item .ant-typography {
|
||||
color: #999999;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react'
|
||||
import { Card, Avatar, Tag, Typography } from 'antd'
|
||||
import { Card, Avatar, Tag, Space, Typography } from 'antd'
|
||||
import { UserOutlined, EyeOutlined, TeamOutlined } from '@ant-design/icons'
|
||||
import { Link } from 'react-router-dom'
|
||||
import type { Inheritor } from '@types/index'
|
||||
@ -50,14 +50,16 @@ const InheritorCard: React.FC<InheritorCardProps> = ({ item, hoverable = true })
|
||||
</Paragraph>
|
||||
|
||||
<div className="inheritor-card-footer">
|
||||
<div className="stat-item">
|
||||
<TeamOutlined />
|
||||
<Text type="secondary">{item.followers.toLocaleString()}</Text>
|
||||
</div>
|
||||
<div className="stat-item">
|
||||
<EyeOutlined />
|
||||
<Text type="secondary">{item.viewCount.toLocaleString()}</Text>
|
||||
</div>
|
||||
<Space size="large">
|
||||
<span className="stat-item">
|
||||
<TeamOutlined />
|
||||
<Text type="secondary">{item.followers.toLocaleString()}</Text>
|
||||
</span>
|
||||
<span className="stat-item">
|
||||
<EyeOutlined />
|
||||
<Text type="secondary">{item.viewCount.toLocaleString()}</Text>
|
||||
</span>
|
||||
</Space>
|
||||
</div>
|
||||
</Card>
|
||||
</Link>
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
.news-card-link {
|
||||
text-decoration: none;
|
||||
display: block;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.news-card {
|
||||
@ -11,8 +10,6 @@
|
||||
overflow: hidden;
|
||||
transition: all 0.3s ease;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.news-card:hover {
|
||||
@ -57,19 +54,9 @@
|
||||
padding: 4px 12px;
|
||||
}
|
||||
|
||||
/* Ant Design Card Body 样式覆盖 */
|
||||
.news-card .ant-card-body {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 卡片内容 */
|
||||
.news-card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: 4px 0 0 0;
|
||||
}
|
||||
|
||||
.news-card-title {
|
||||
@ -78,7 +65,6 @@
|
||||
color: #2c2c2c;
|
||||
margin-bottom: 8px;
|
||||
line-height: 1.5;
|
||||
height: 48px;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
@ -91,7 +77,6 @@
|
||||
color: #666666;
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.5;
|
||||
height: 20px;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 1;
|
||||
@ -104,16 +89,12 @@
|
||||
color: #666666;
|
||||
margin-bottom: 12px;
|
||||
line-height: 1.6;
|
||||
height: 45px;
|
||||
}
|
||||
|
||||
.news-card-meta {
|
||||
margin-bottom: 12px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
min-height: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
@ -121,12 +102,10 @@
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.meta-item .anticon {
|
||||
color: #999999;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.news-card-tags {
|
||||
@ -134,7 +113,6 @@
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.news-tag {
|
||||
@ -148,21 +126,17 @@
|
||||
align-items: center;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
margin-top: auto;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.news-card-footer .stat-item {
|
||||
.stat-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.news-card-footer .stat-item .anticon {
|
||||
.stat-item .anticon {
|
||||
color: #999999;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
|
||||
@ -51,7 +51,9 @@ const NewsCard: React.FC<NewsCardProps> = ({ item, hoverable = true }) => {
|
||||
>
|
||||
<div className="news-card-content">
|
||||
<h3 className="news-card-title">{item.title}</h3>
|
||||
<p className="news-card-subtitle">{item.subtitle || '\u00A0'}</p>
|
||||
{item.subtitle && (
|
||||
<p className="news-card-subtitle">{item.subtitle}</p>
|
||||
)}
|
||||
|
||||
<Paragraph ellipsis={{ rows: 2 }} className="news-card-summary">
|
||||
{item.summary}
|
||||
|
||||
@ -117,38 +117,6 @@
|
||||
color: #c8363d;
|
||||
}
|
||||
|
||||
/* 用户信息区域 */
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-left: 24px;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
padding: 4px 12px;
|
||||
border-radius: 20px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.user-info:hover {
|
||||
background-color: rgba(200, 54, 61, 0.08);
|
||||
}
|
||||
|
||||
.user-nickname {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #2c2c2c;
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.auth-buttons .ant-btn {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 移动端菜单按钮 */
|
||||
.mobile-menu-btn {
|
||||
display: none;
|
||||
@ -178,10 +146,6 @@
|
||||
.mobile-menu-btn {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.user-nickname {
|
||||
max-width: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
@ -202,21 +166,4 @@
|
||||
.logo-subtitle {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.user-nickname {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.auth-buttons {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.auth-buttons .ant-btn {
|
||||
padding: 4px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { Link, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { Menu, Drawer, Button, Space, Avatar, Dropdown } from 'antd'
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import { Menu, Drawer, Button, Space } from 'antd'
|
||||
import {
|
||||
MenuOutlined,
|
||||
HomeOutlined,
|
||||
@ -13,25 +13,17 @@ import {
|
||||
ExperimentOutlined,
|
||||
FileTextOutlined,
|
||||
InfoCircleOutlined,
|
||||
UserOutlined,
|
||||
LoginOutlined,
|
||||
LogoutOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import type { MenuProps } from 'antd'
|
||||
import { useUserStore } from '@store/useUserStore'
|
||||
import './Header.css'
|
||||
|
||||
type MenuItem = Required<MenuProps>['items'][number]
|
||||
|
||||
const Header: React.FC = () => {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const [scrolled, setScrolled] = useState(false)
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
|
||||
|
||||
// 获取用户状态
|
||||
const { user, isAuthenticated, logout } = useUserStore()
|
||||
|
||||
// 监听滚动事件,添加导航栏背景效果
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
@ -71,30 +63,6 @@ const Header: React.FC = () => {
|
||||
},
|
||||
]
|
||||
|
||||
// 处理退出登录
|
||||
const handleLogout = () => {
|
||||
logout()
|
||||
navigate('/')
|
||||
}
|
||||
|
||||
// 用户下拉菜单
|
||||
const userMenuItems: MenuItem[] = [
|
||||
{
|
||||
key: 'user-center',
|
||||
icon: <UserOutlined />,
|
||||
label: <Link to="/user/center">个人中心</Link>,
|
||||
},
|
||||
{
|
||||
type: 'divider',
|
||||
},
|
||||
{
|
||||
key: 'logout',
|
||||
icon: <LogoutOutlined />,
|
||||
label: '退出登录',
|
||||
onClick: handleLogout,
|
||||
},
|
||||
]
|
||||
|
||||
// 获取当前选中的菜单项
|
||||
const getSelectedKeys = () => {
|
||||
const path = location.pathname
|
||||
@ -140,29 +108,6 @@ const Header: React.FC = () => {
|
||||
/>
|
||||
</nav>
|
||||
|
||||
{/* 用户信息区域 */}
|
||||
<div className="header-actions">
|
||||
{isAuthenticated && user ? (
|
||||
<Dropdown menu={{ items: userMenuItems }} placement="bottomRight">
|
||||
<Space className="user-info" style={{ cursor: 'pointer' }}>
|
||||
<Avatar src={user.avatar} icon={<UserOutlined />} />
|
||||
<span className="user-nickname">{user.nickname}</span>
|
||||
</Space>
|
||||
</Dropdown>
|
||||
) : (
|
||||
<Space className="auth-buttons">
|
||||
<Link to="/login">
|
||||
<Button type="text" icon={<LoginOutlined />}>
|
||||
登录
|
||||
</Button>
|
||||
</Link>
|
||||
<Link to="/register">
|
||||
<Button type="primary">注册</Button>
|
||||
</Link>
|
||||
</Space>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 移动端菜单按钮 */}
|
||||
<Button
|
||||
type="text"
|
||||
|
||||
@ -6,149 +6,75 @@
|
||||
}
|
||||
|
||||
.page-header {
|
||||
background: linear-gradient(135deg, #fafaf8 0%, #f5f0e8 50%, #fafaf8 100%);
|
||||
padding: 80px 0 40px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(135deg, #d4a574 0%, #c8a060 100%);
|
||||
padding: 60px 0;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 装饰性背景圆圈 */
|
||||
.page-header::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -30%;
|
||||
right: 5%;
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
background: radial-gradient(circle, rgba(200, 54, 61, 0.06) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
.user-profile {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.page-header::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -30%;
|
||||
left: 5%;
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
background: radial-gradient(circle, rgba(212, 165, 116, 0.06) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.user-profile-card {
|
||||
background: #ffffff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
||||
padding: 40px;
|
||||
border: 1px solid rgba(232, 227, 219, 0.6);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.user-profile-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
margin-bottom: 32px;
|
||||
padding-bottom: 32px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.user-avatar-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.user-avatar-wrapper .ant-avatar {
|
||||
border: 4px solid #f5f0e8;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.user-info-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.user-info-content h2 {
|
||||
.user-profile h2 {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #2c2c2c;
|
||||
margin: 0 0 8px 0;
|
||||
font-family: 'Noto Serif SC', 'Songti SC', serif;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
margin: 16px 0 8px;
|
||||
}
|
||||
|
||||
.user-email {
|
||||
font-size: 14px;
|
||||
color: #999999;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-left: auto;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.user-actions .ant-btn {
|
||||
border-radius: 8px;
|
||||
font-weight: 500;
|
||||
height: 38px;
|
||||
padding: 0 20px;
|
||||
.user-actions button {
|
||||
border-radius: 20px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
color: #ffffff;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.user-actions .ant-btn-default {
|
||||
border-color: #d9d9d9;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.user-actions .ant-btn-default:hover {
|
||||
border-color: #c8363d;
|
||||
color: #c8363d;
|
||||
.user-actions button:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-color: rgba(255, 255, 255, 0.4);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.user-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
background: linear-gradient(135deg, #fafaf8 0%, #f5f0e8 100%);
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
padding: 32px;
|
||||
border-radius: 12px;
|
||||
transition: all 0.3s ease;
|
||||
border: 1px solid transparent;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.stat-item:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
border-color: rgba(200, 54, 61, 0.2);
|
||||
.user-stats .ant-statistic {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-icon {
|
||||
font-size: 32px;
|
||||
color: #c8363d;
|
||||
margin-bottom: 12px;
|
||||
display: block;
|
||||
.user-stats .ant-statistic-title {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
.user-stats .ant-statistic-content {
|
||||
color: #ffffff;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #2c2c2c;
|
||||
margin: 0 0 4px 0;
|
||||
font-family: 'Noto Serif SC', 'Songti SC', serif;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 13px;
|
||||
color: #999999;
|
||||
margin: 0;
|
||||
.user-stats .anticon {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
/* 页面内容 */
|
||||
@ -225,30 +151,6 @@
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 992px) {
|
||||
.user-profile-header {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.user-info-content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.user-email {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
margin-left: 0;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.user-stats {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.user-stats {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
@ -256,41 +158,11 @@
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.page-header {
|
||||
padding: 60px 0 30px;
|
||||
}
|
||||
|
||||
.user-profile-card {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.user-profile-header {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
.user-avatar-wrapper .ant-avatar {
|
||||
width: 80px !important;
|
||||
height: 80px !important;
|
||||
}
|
||||
|
||||
.user-info-content h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.user-actions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.user-actions .ant-btn {
|
||||
flex: 1;
|
||||
padding: 40px 0;
|
||||
}
|
||||
|
||||
.user-stats {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Tabs, Card, Avatar, Button, List, Empty, Tag, Row, Col } from 'antd'
|
||||
import { Tabs, Card, Avatar, Button, List, Empty, Tag, Row, Col, Statistic } from 'antd'
|
||||
import {
|
||||
UserOutlined,
|
||||
HeartOutlined,
|
||||
@ -12,7 +12,6 @@ import {
|
||||
EditOutlined,
|
||||
TrophyOutlined,
|
||||
ClockCircleOutlined,
|
||||
MailOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import { useUserStore } from '@store/useUserStore'
|
||||
@ -70,41 +69,33 @@ const UserCenter: React.FC = () => {
|
||||
<div className="user-center-page">
|
||||
<div className="page-header">
|
||||
<div className="container">
|
||||
<div className="user-profile-card">
|
||||
<div className="user-profile-header">
|
||||
<div className="user-avatar-wrapper">
|
||||
<Row gutter={[24, 24]}>
|
||||
<Col xs={24} md={8}>
|
||||
<div className="user-profile">
|
||||
<Avatar size={100} src={user.avatar} icon={<UserOutlined />} />
|
||||
</div>
|
||||
<div className="user-info-content">
|
||||
<h2>{user.username}</h2>
|
||||
<p className="user-email">
|
||||
<MailOutlined />
|
||||
{user.email}
|
||||
</p>
|
||||
<p className="user-email">{user.email}</p>
|
||||
<div className="user-actions">
|
||||
<Button icon={<EditOutlined />}>编辑资料</Button>
|
||||
<Button onClick={handleLogout}>退出登录</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="user-actions">
|
||||
<Button icon={<EditOutlined />}>编辑资料</Button>
|
||||
</Col>
|
||||
<Col xs={24} md={16}>
|
||||
<div className="user-stats">
|
||||
<Statistic
|
||||
title="收藏数"
|
||||
value={user.favorites.length}
|
||||
prefix={<HeartOutlined />}
|
||||
/>
|
||||
<Statistic
|
||||
title="评论数"
|
||||
value={0}
|
||||
prefix={<CommentOutlined />}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="user-stats">
|
||||
<div className="stat-item">
|
||||
<HeartOutlined className="stat-icon" />
|
||||
<div className="stat-value">{user.favorites.length}</div>
|
||||
<div className="stat-label">收藏数</div>
|
||||
</div>
|
||||
<div className="stat-item">
|
||||
<CommentOutlined className="stat-icon" />
|
||||
<div className="stat-value">0</div>
|
||||
<div className="stat-label">评论数</div>
|
||||
</div>
|
||||
<div className="stat-item">
|
||||
<ClockCircleOutlined className="stat-icon" />
|
||||
<div className="stat-value">0</div>
|
||||
<div className="stat-label">学习时长(小时)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -5,72 +5,33 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #fafaf8 0%, #f5f0e8 50%, #fafaf8 100%);
|
||||
background: linear-gradient(135deg, #f5f0e8 0%, #ffffff 100%);
|
||||
padding: 40px 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.login-page::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
right: -10%;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: radial-gradient(circle, rgba(200, 54, 61, 0.08) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.login-page::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -50%;
|
||||
left: -10%;
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
background: radial-gradient(circle, rgba(212, 165, 116, 0.08) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
max-width: 1000px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0;
|
||||
background: #ffffff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background: #ffffff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
||||
padding: 48px 40px;
|
||||
border: 1px solid rgba(232, 227, 219, 0.6);
|
||||
padding: 60px 50px;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.logo-badge {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
background: linear-gradient(135deg, #c8363d 0%, #a82e34 100%);
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ffffff;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
font-family: 'Noto Serif SC', 'Songti SC', serif;
|
||||
margin: 0 auto 20px;
|
||||
box-shadow: 0 4px 12px rgba(200, 54, 61, 0.3);
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.login-header h1 {
|
||||
font-size: 24px;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #2c2c2c;
|
||||
margin-bottom: 8px;
|
||||
@ -83,48 +44,137 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.login-options {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.forgot-link {
|
||||
color: #d4a574;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.forgot-link:hover {
|
||||
color: #c8a060;
|
||||
}
|
||||
|
||||
.social-login {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.social-btn {
|
||||
flex: 1;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.social-btn.wechat {
|
||||
color: #07c160;
|
||||
border-color: #07c160;
|
||||
}
|
||||
|
||||
.social-btn.wechat:hover {
|
||||
color: #ffffff;
|
||||
background: #07c160;
|
||||
border-color: #07c160;
|
||||
}
|
||||
|
||||
.social-btn.alipay {
|
||||
color: #1677ff;
|
||||
border-color: #1677ff;
|
||||
}
|
||||
|
||||
.social-btn.alipay:hover {
|
||||
color: #ffffff;
|
||||
background: #1677ff;
|
||||
border-color: #1677ff;
|
||||
}
|
||||
|
||||
.register-link {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
margin-top: 24px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.register-link a {
|
||||
color: #c8363d;
|
||||
color: #d4a574;
|
||||
font-weight: 500;
|
||||
margin-left: 4px;
|
||||
transition: color 0.3s ease;
|
||||
cursor: pointer !important;
|
||||
text-decoration: none;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.register-link a:hover {
|
||||
color: #a82e34;
|
||||
text-decoration: underline;
|
||||
cursor: pointer !important;
|
||||
color: #c8a060;
|
||||
}
|
||||
|
||||
/* 所有链接统一手型光标 */
|
||||
.login-card a {
|
||||
cursor: pointer !important;
|
||||
/* 插图区域 */
|
||||
.login-illustration {
|
||||
background: linear-gradient(135deg, #d4a574 0%, #c8a060 100%);
|
||||
padding: 60px 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.illustration-content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.illustration-content h2 {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 16px;
|
||||
color: #ffffff;
|
||||
font-family: 'Noto Serif SC', 'Songti SC', serif;
|
||||
}
|
||||
|
||||
.illustration-content p {
|
||||
font-size: 16px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.illustration-image {
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
margin: 0 auto;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.illustration-image img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 992px) {
|
||||
.login-container {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.login-illustration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
padding: 40px 30px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.login-card {
|
||||
padding: 40px 24px;
|
||||
padding: 30px 20px;
|
||||
}
|
||||
|
||||
.login-header h1 {
|
||||
font-size: 22px;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.logo-badge {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
.social-login {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react'
|
||||
import { Form, Input, Button, message } from 'antd'
|
||||
import { UserOutlined, LockOutlined } from '@ant-design/icons'
|
||||
import { Form, Input, Button, message, Divider } from 'antd'
|
||||
import { UserOutlined, LockOutlined, WechatOutlined, AlipayOutlined } from '@ant-design/icons'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import { useUserStore } from '@store/useUserStore'
|
||||
import './Login.css'
|
||||
@ -32,7 +32,6 @@ const Login: React.FC = () => {
|
||||
<div className="login-container">
|
||||
<div className="login-card">
|
||||
<div className="login-header">
|
||||
<div className="logo-badge">非遗</div>
|
||||
<h1>欢迎回来</h1>
|
||||
<p>登录以继续您的非遗文化之旅</p>
|
||||
</div>
|
||||
@ -57,6 +56,14 @@ const Login: React.FC = () => {
|
||||
<Input.Password prefix={<LockOutlined />} placeholder="密码" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<div className="login-options">
|
||||
<Link to="/forgot-password" className="forgot-link">
|
||||
忘记密码?
|
||||
</Link>
|
||||
</div>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit" block loading={loading}>
|
||||
登录
|
||||
@ -64,10 +71,34 @@ const Login: React.FC = () => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
<Divider plain>其他登录方式</Divider>
|
||||
|
||||
<div className="social-login">
|
||||
<Button icon={<WechatOutlined />} className="social-btn wechat">
|
||||
微信登录
|
||||
</Button>
|
||||
<Button icon={<AlipayOutlined />} className="social-btn alipay">
|
||||
支付宝登录
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="register-link">
|
||||
还没有账号?<Link to="/register">立即注册</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="login-illustration">
|
||||
<div className="illustration-content">
|
||||
<h2>传承非遗文化</h2>
|
||||
<p>探索中华文化瑰宝,传承千年技艺精髓</p>
|
||||
<div className="illustration-image">
|
||||
<img
|
||||
src="https://images.unsplash.com/photo-1547618707-5e8b2c1f0f7c?w=600"
|
||||
alt="传统文化"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -5,72 +5,33 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #fafaf8 0%, #f5f0e8 50%, #fafaf8 100%);
|
||||
background: linear-gradient(135deg, #f5f0e8 0%, #ffffff 100%);
|
||||
padding: 40px 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.register-page::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
right: -10%;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: radial-gradient(circle, rgba(200, 54, 61, 0.08) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.register-page::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -50%;
|
||||
left: -10%;
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
background: radial-gradient(circle, rgba(212, 165, 116, 0.08) 0%, transparent 70%);
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.register-container {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
max-width: 1000px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0;
|
||||
background: #ffffff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.register-card {
|
||||
background: #ffffff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
||||
padding: 48px 40px;
|
||||
border: 1px solid rgba(232, 227, 219, 0.6);
|
||||
padding: 60px 50px;
|
||||
}
|
||||
|
||||
.register-header {
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.logo-badge {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
background: linear-gradient(135deg, #c8363d 0%, #a82e34 100%);
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ffffff;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
font-family: 'Noto Serif SC', 'Songti SC', serif;
|
||||
margin: 0 auto 20px;
|
||||
box-shadow: 0 4px 12px rgba(200, 54, 61, 0.3);
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.register-header h1 {
|
||||
font-size: 24px;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #2c2c2c;
|
||||
margin-bottom: 8px;
|
||||
@ -87,44 +48,99 @@
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
margin-top: 24px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.login-link a {
|
||||
color: #c8363d;
|
||||
color: #d4a574;
|
||||
font-weight: 500;
|
||||
margin-left: 4px;
|
||||
transition: color 0.3s ease;
|
||||
cursor: pointer !important;
|
||||
text-decoration: none;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.login-link a:hover {
|
||||
color: #a82e34;
|
||||
text-decoration: underline;
|
||||
cursor: pointer !important;
|
||||
color: #c8a060;
|
||||
}
|
||||
|
||||
/* 协议链接样式 */
|
||||
.register-card a {
|
||||
cursor: pointer !important;
|
||||
/* 插图区域 */
|
||||
.register-illustration {
|
||||
background: linear-gradient(135deg, #c8363d 0%, #a82f35 100%);
|
||||
padding: 60px 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.illustration-content {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.illustration-content h2 {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 16px;
|
||||
color: #ffffff;
|
||||
font-family: 'Noto Serif SC', 'Songti SC', serif;
|
||||
}
|
||||
|
||||
.illustration-content > p {
|
||||
font-size: 16px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.feature-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.feature-item {
|
||||
text-align: left;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
padding: 20px;
|
||||
border-radius: 12px;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.feature-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.feature-item h3 {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.feature-item p {
|
||||
font-size: 14px;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 992px) {
|
||||
.register-container {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.register-illustration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.register-card {
|
||||
padding: 40px 30px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.register-card {
|
||||
padding: 40px 24px;
|
||||
padding: 30px 20px;
|
||||
}
|
||||
|
||||
.register-header h1 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.logo-badge {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import React, { useState } from 'react'
|
||||
import { Form, Input, Button, message, Checkbox } from 'antd'
|
||||
import { UserOutlined, LockOutlined, MailOutlined } from '@ant-design/icons'
|
||||
import { UserOutlined, LockOutlined, MailOutlined, PhoneOutlined } from '@ant-design/icons'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import { useUserStore } from '@store/useUserStore'
|
||||
import './Register.css'
|
||||
@ -17,6 +17,7 @@ const Register: React.FC = () => {
|
||||
const onFinish = async (values: {
|
||||
username: string
|
||||
email: string
|
||||
phone: string
|
||||
password: string
|
||||
agree: boolean
|
||||
}) => {
|
||||
@ -28,11 +29,10 @@ const Register: React.FC = () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
await register(values.username, values.email, values.password)
|
||||
message.success('注册成功,欢迎加入非遗文化传承平台!')
|
||||
message.success('注册成功,欢迎加入非遗文化传承平台')
|
||||
navigate('/')
|
||||
} catch (error) {
|
||||
const err = error as Error
|
||||
message.error(err.message || '注册失败,请稍后重试')
|
||||
message.error('注册失败,请稍后重试')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
@ -43,7 +43,6 @@ const Register: React.FC = () => {
|
||||
<div className="register-container">
|
||||
<div className="register-card">
|
||||
<div className="register-header">
|
||||
<div className="logo-badge">非遗</div>
|
||||
<h1>加入我们</h1>
|
||||
<p>开启您的非遗文化传承之旅</p>
|
||||
</div>
|
||||
@ -75,6 +74,16 @@ const Register: React.FC = () => {
|
||||
<Input prefix={<MailOutlined />} placeholder="邮箱" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="phone"
|
||||
rules={[
|
||||
{ required: true, message: '请输入手机号' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号' },
|
||||
]}
|
||||
>
|
||||
<Input prefix={<PhoneOutlined />} placeholder="手机号" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="password"
|
||||
rules={[
|
||||
@ -106,12 +115,6 @@ const Register: React.FC = () => {
|
||||
<Form.Item
|
||||
name="agree"
|
||||
valuePropName="checked"
|
||||
rules={[
|
||||
{
|
||||
validator: (_, value) =>
|
||||
value ? Promise.resolve() : Promise.reject(new Error('请同意用户协议')),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Checkbox>
|
||||
我已阅读并同意
|
||||
@ -132,6 +135,30 @@ const Register: React.FC = () => {
|
||||
已有账号?<Link to="/login">立即登录</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="register-illustration">
|
||||
<div className="illustration-content">
|
||||
<h2>探索非遗之美</h2>
|
||||
<p>与千万用户一起,传承中华优秀传统文化</p>
|
||||
<div className="feature-list">
|
||||
<div className="feature-item">
|
||||
<div className="feature-icon">📚</div>
|
||||
<h3>在线学习</h3>
|
||||
<p>海量非遗课程,随时随地学习</p>
|
||||
</div>
|
||||
<div className="feature-item">
|
||||
<div className="feature-icon">👥</div>
|
||||
<h3>名师指导</h3>
|
||||
<p>跟随传承人学习传统技艺</p>
|
||||
</div>
|
||||
<div className="feature-item">
|
||||
<div className="feature-icon">🏆</div>
|
||||
<h3>获得认证</h3>
|
||||
<p>完成学习获得专业证书</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -296,65 +296,27 @@ export const getUserById = async (id: string): Promise<User | null> => {
|
||||
|
||||
export const login = async (username: string, password: string): Promise<User | null> => {
|
||||
await delay()
|
||||
|
||||
// Mock 登录逻辑 - 任意用户名密码都可以登录
|
||||
// 先查找是否已存在该用户
|
||||
let user = mockData.users.find((u) => u.username === username)
|
||||
|
||||
// 如果用户不存在,自动创建一个新用户(模拟登录)
|
||||
if (!user) {
|
||||
user = {
|
||||
id: `u${Date.now()}`,
|
||||
username: username,
|
||||
nickname: username,
|
||||
avatar: `https://api.dicebear.com/7.x/avataaars/svg?seed=${username}`,
|
||||
email: `${username}@example.com`,
|
||||
phone: '13800138000',
|
||||
bio: `我是 ${username},热爱非遗文化`,
|
||||
favorites: [],
|
||||
followedInheritors: [],
|
||||
enrolledCourses: [],
|
||||
registeredEvents: [],
|
||||
points: 0,
|
||||
level: 1,
|
||||
createdAt: new Date().toISOString().split('T')[0],
|
||||
}
|
||||
// 将新用户添加到mockData中
|
||||
mockData.users.push(user)
|
||||
}
|
||||
|
||||
return user
|
||||
// Mock 登录逻辑
|
||||
const user = mockData.users.find((u) => u.username === username)
|
||||
return user || null
|
||||
}
|
||||
|
||||
export const register = async (userData: Partial<User>): Promise<User> => {
|
||||
await delay()
|
||||
|
||||
// Mock 注册逻辑 - 自动创建用户
|
||||
const username = userData.username || `user${Date.now()}`
|
||||
|
||||
// 检查用户名是否已存在
|
||||
const existingUser = mockData.users.find((u) => u.username === username)
|
||||
if (existingUser) {
|
||||
throw new Error('用户名已存在')
|
||||
}
|
||||
|
||||
const newUser: User = {
|
||||
id: `u${Date.now()}`,
|
||||
username: username,
|
||||
nickname: userData.nickname || username,
|
||||
avatar: userData.avatar || `https://api.dicebear.com/7.x/avataaars/svg?seed=${username}`,
|
||||
email: userData.email || `${username}@example.com`,
|
||||
phone: userData.phone,
|
||||
bio: userData.bio,
|
||||
username: userData.username || '',
|
||||
nickname: userData.nickname || '',
|
||||
avatar: userData.avatar || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=100',
|
||||
email: userData.email || '',
|
||||
favorites: [],
|
||||
followedInheritors: [],
|
||||
enrolledCourses: [],
|
||||
registeredEvents: [],
|
||||
points: 100, // 新用户赠送100积分
|
||||
points: 0,
|
||||
level: 1,
|
||||
createdAt: new Date().toISOString().split('T')[0],
|
||||
}
|
||||
|
||||
mockData.users.push(newUser)
|
||||
return newUser
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { create } from 'zustand'
|
||||
import { persist } from 'zustand/middleware'
|
||||
import type { User } from '@types/index'
|
||||
import { login as apiLogin, register as apiRegister, getUserById } from '@services/api'
|
||||
import { login as apiLogin, getUserById } from '@services/api'
|
||||
|
||||
interface UserState {
|
||||
user: User | null
|
||||
@ -14,7 +14,6 @@ interface UserState {
|
||||
|
||||
// Actions
|
||||
login: (username: string, password: string) => Promise<boolean>
|
||||
register: (username: string, email: string, password: string, phone?: string) => Promise<boolean>
|
||||
logout: () => void
|
||||
updateUser: (userData: Partial<User>) => void
|
||||
addFavorite: (heritageId: string) => void
|
||||
@ -48,23 +47,6 @@ export const useUserStore = create<UserState>()(
|
||||
}
|
||||
},
|
||||
|
||||
register: async (username: string, email: string, password: string, phone?: string) => {
|
||||
set({ isLoading: true })
|
||||
try {
|
||||
const user = await apiRegister({ username, email, password, phone })
|
||||
if (user) {
|
||||
set({ user, isAuthenticated: true, isLoading: false })
|
||||
return true
|
||||
}
|
||||
set({ isLoading: false })
|
||||
return false
|
||||
} catch (error) {
|
||||
console.error('Register failed:', error)
|
||||
set({ isLoading: false })
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
logout: () => {
|
||||
set({ user: null, isAuthenticated: false })
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user