196 lines
12 KiB
HTML
196 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{{.User.Username}}的个人主页 - lv8girl</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
:root {
|
|
--bg: #f0f7f0;
|
|
--surface: #ffffff;
|
|
--surface-light: #e8f0e8;
|
|
--border: #d0e0d0;
|
|
--text: #2c3e2c;
|
|
--text-soft: #5f6b5f;
|
|
--text-hint: #8f9f8f;
|
|
--primary: #3d9e4a;
|
|
--accent: #ffb347;
|
|
--gradient: linear-gradient(135deg, #3d9e4a, #5a9cff);
|
|
}
|
|
body.dark-mode {
|
|
--bg: #1a1e1a;
|
|
--surface: #1e261e;
|
|
--surface-light: #2a3a2a;
|
|
--border: #2a3a2a;
|
|
--text: #e0e8e0;
|
|
--text-soft: #b0bcb0;
|
|
--text-hint: #8a958a;
|
|
--primary: #6b8e6b;
|
|
--accent: #ffb347;
|
|
}
|
|
body { background: var(--bg); color: var(--text); font-family: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; line-height: 1.6; transition: background 0.3s, color 0.3s; }
|
|
.container { max-width: 1000px; margin: 0 auto; padding: 20px; }
|
|
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 1px solid var(--border); padding-bottom: 20px; }
|
|
.logo { font-size: 2rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
|
.logo span { font-size: 0.9rem; background: var(--accent); color: var(--surface); padding: 4px 12px; border-radius: 30px; margin-left: 10px; -webkit-text-fill-color: var(--surface); }
|
|
.nav-right { display: flex; align-items: center; gap: 15px; }
|
|
.nav-right a { color: var(--text-soft); text-decoration: none; padding: 6px 16px; border-radius: 30px; background: var(--surface-light); transition: 0.2s; }
|
|
.nav-right a:hover { background: var(--primary); color: white; }
|
|
.user-menu { position: relative; cursor: pointer; }
|
|
.user-name { display: flex; align-items: center; gap: 5px; background: var(--surface-light); padding: 6px 16px; border-radius: 30px; color: var(--text); }
|
|
.dropdown { position: absolute; top: 120%; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-width: 160px; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: 0.2s; z-index: 100; }
|
|
.user-menu:hover .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
|
|
.dropdown a { display: block; padding: 10px 16px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
|
|
.dropdown a:last-child { border-bottom: none; }
|
|
.dropdown a:hover { background: var(--surface-light); }
|
|
.theme-toggle { background: var(--surface-light); border: none; color: var(--text); font-size: 1.3rem; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
|
|
.theme-toggle:hover { background: var(--accent); color: var(--surface); }
|
|
.success-message, .error-message { padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; }
|
|
.success-message { background: var(--primary); color: white; }
|
|
.error-message { background: #ff6b6b; color: white; }
|
|
.profile-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 25px; margin-bottom: 30px; display: flex; gap: 25px; flex-wrap: wrap; }
|
|
.profile-avatar { width: 100px; height: 100px; border-radius: 50%; background: var(--gradient); overflow: hidden; display: flex; align-items: center; justify-content: center; color: white; font-size: 2.5rem; font-weight: 600; flex-shrink: 0; }
|
|
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
.profile-info { flex: 1; }
|
|
.profile-info h1 { font-size: 2rem; margin-bottom: 10px; color: var(--accent); }
|
|
.profile-info p { color: var(--text-soft); margin-bottom: 5px; }
|
|
.profile-stats { display: flex; gap: 30px; margin-top: 15px; }
|
|
.stat-item { text-align: center; }
|
|
.stat-number { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
|
|
.stat-label { color: var(--text-hint); font-size: 0.85rem; }
|
|
.edit-btn { display: inline-block; background: var(--gradient); color: white; border: none; border-radius: 30px; padding: 8px 25px; font-weight: 600; cursor: pointer; transition: 0.2s; margin-top: 15px; text-decoration: none; }
|
|
.edit-btn:hover { transform: scale(1.02); }
|
|
.avatar-upload-form { margin-top: 15px; padding: 15px; background: var(--surface-light); border-radius: 12px; border: 1px dashed var(--border); }
|
|
.file-input { margin-bottom: 10px; }
|
|
.file-input input[type="file"] { background: var(--surface); border: 1px solid var(--border); border-radius: 30px; padding: 8px 16px; width: 100%; color: var(--text); }
|
|
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
.section-title h2 { font-size: 1.5rem; font-weight: 600; color: var(--accent); }
|
|
.post-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
|
|
.post-item { display: flex; padding: 20px; border-bottom: 1px solid var(--border); transition: 0.2s; }
|
|
.post-item:hover { background: var(--surface-light); }
|
|
.post-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--gradient); margin-right: 15px; flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; }
|
|
.post-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
.post-content { flex: 1; }
|
|
.post-header { display: flex; align-items: center; gap: 15px; margin-bottom: 5px; flex-wrap: wrap; }
|
|
.post-author { font-weight: 600; color: var(--accent); }
|
|
.post-time { color: var(--text-hint); font-size: 0.85rem; }
|
|
.post-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 5px; }
|
|
.post-title a { color: var(--text); text-decoration: none; }
|
|
.post-title a:hover { color: var(--accent); }
|
|
.post-excerpt { color: var(--text-soft); font-size: 0.95rem; margin-bottom: 10px; }
|
|
.no-posts { padding: 40px; text-align: center; color: var(--text-hint); }
|
|
.footer { margin-top: 40px; padding: 20px 0; border-top: 1px solid var(--border); text-align: center; color: var(--text-hint); font-size: 0.9rem; }
|
|
.footer a { color: var(--text-hint); text-decoration: none; margin: 0 10px; }
|
|
.footer a:hover { color: var(--accent); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
|
<div class="nav-right">
|
|
{{if .IsLoggedIn}}
|
|
<a href="/messages">私信{{if gt .UnreadCount 0}}<span style="background:#ff6b6b;color:white;border-radius:50%;padding:2px 6px;font-size:0.7rem;margin-left:5px;">{{.UnreadCount}}</span>{{end}}</a>
|
|
<div class="user-menu">
|
|
<span class="user-name">{{.CurrentUsername}} ▼</span>
|
|
<div class="dropdown">
|
|
{{if eq .CurrentUserRole "admin"}}<a href="/admin">管理面板</a>{{end}}
|
|
<a href="/profile">个人主页</a>
|
|
<a href="/new-post">发表新帖</a>
|
|
<a href="/messages">私信</a>
|
|
<a href="/logout">登出</a>
|
|
</div>
|
|
</div>
|
|
{{else}}
|
|
<a href="/login">登录</a>
|
|
<a href="/register">注册</a>
|
|
{{end}}
|
|
<button class="theme-toggle" id="themeToggle">🌓</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="profile-card">
|
|
<div class="profile-avatar">
|
|
{{if .UserAvatar}}<img src="{{.UserAvatar}}" alt="avatar">{{else}}<span>{{slice .User.Username 0 1}}</span>{{end}}
|
|
</div>
|
|
<div class="profile-info">
|
|
<h1>{{.User.Username}}</h1>
|
|
<p>邮箱:{{.User.Email}}</p>
|
|
<p>注册时间:{{.User.CreatedAt.Format "2006-01-02"}}</p>
|
|
<div class="profile-stats">
|
|
<div class="stat-item">
|
|
<div class="stat-number">{{.PostCount}}</div>
|
|
<div class="stat-label">帖子</div>
|
|
</div>
|
|
</div>
|
|
{{if .IsOwner}}
|
|
<button class="edit-btn" onclick="toggleUpload()">修改头像</button>
|
|
<div id="uploadForm" style="display: none;" class="avatar-upload-form">
|
|
<form action="/upload-avatar" method="post" enctype="multipart/form-data">
|
|
<div class="file-input">
|
|
<input type="file" name="avatar" accept="image/*" required>
|
|
</div>
|
|
<button type="submit" class="edit-btn">上传新头像</button>
|
|
</form>
|
|
</div>
|
|
{{else}}
|
|
<a href="/send-message?to={{.User.ID}}" class="edit-btn" style="margin-top:10px;">📩 发送私信</a>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section-title">
|
|
<h2>{{if .IsOwner}}我的帖子{{else}}{{.User.Username}}的帖子{{end}}</h2>
|
|
</div>
|
|
|
|
{{if not .Posts}}
|
|
<div class="no-posts">
|
|
<p>暂无帖子</p>
|
|
{{if .IsOwner}}<p><a href="/new-post" style="color: var(--accent);">去发表第一篇</a></p>{{end}}
|
|
</div>
|
|
{{else}}
|
|
<div class="post-list">
|
|
{{range .Posts}}
|
|
<div class="post-item">
|
|
<div class="post-avatar">
|
|
{{if $.UserAvatar}}<img src="{{$.UserAvatar}}" alt="avatar">{{else}}<span>{{slice $.User.Username 0 1}}</span>{{end}}
|
|
</div>
|
|
<div class="post-content">
|
|
<div class="post-header">
|
|
<span class="post-author">{{$.User.Username}}</span>
|
|
<span class="post-time">{{.CreatedAt.Format "2006-01-02 15:04"}}</span>
|
|
</div>
|
|
<div class="post-title"><a href="/post/{{.ID}}">{{.Title}}</a></div>
|
|
<div class="post-excerpt">{{slice .Content 0 100}}{{if gt (len .Content) 100}}...{{end}}</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
<div class="footer">
|
|
<div>© 2025 lv8girl · 绿坝娘二次元论坛</div>
|
|
<div>
|
|
<a href="#">关于</a>
|
|
<a href="#">帮助</a>
|
|
<a href="#">隐私</a>
|
|
<a href="#">投稿</a>
|
|
<a href="https://icp.gov.moe/?keyword=20260911" target="_blank">萌ICP备20260911号</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const themeToggle = document.getElementById('themeToggle');
|
|
themeToggle.addEventListener('click', () => {
|
|
document.body.classList.toggle('dark-mode');
|
|
themeToggle.textContent = document.body.classList.contains('dark-mode') ? '☀️' : '🌓';
|
|
});
|
|
function toggleUpload() {
|
|
var form = document.getElementById('uploadForm');
|
|
form.style.display = form.style.display === 'none' ? 'block' : 'none';
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|