设计前端页面和布局框架

This commit is contained in:
2026-03-24 14:08:29 +08:00
parent 3afbc78c06
commit b7e9699dbd
49 changed files with 3188 additions and 6 deletions

2
frontend/.env.example Normal file
View File

@@ -0,0 +1,2 @@
# API 基础地址
VITE_API_BASE_URL=http://localhost:8000/api/v1

24
frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

5
frontend/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Vue 3 + TypeScript + Vite
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).

13
frontend/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<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" />
<title>frontend</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

34
frontend/package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview"
},
"dependencies": {
"@vueuse/core": "^14.2.1",
"axios": "^1.13.6",
"naive-ui": "^2.44.1",
"pinia": "^3.0.4",
"vue": "^3.5.30",
"vue-router": "^5.0.3"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.2.1",
"@tailwindcss/typography": "^0.5.19",
"@types/node": "^24.12.0",
"@vitejs/plugin-vue": "^6.0.5",
"@vue/tsconfig": "^0.9.0",
"autoprefixer": "^10.4.27",
"lightningcss": "^1.32.0",
"lightningcss-win32-x64-msvc": "^1.32.0",
"postcss": "^8.5.8",
"tailwindcss": "^4.2.1",
"typescript": "~5.9.3",
"vite": "^8.0.0",
"vue-tsc": "^3.2.5"
}
}

View File

@@ -0,0 +1,6 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
autoprefixer: {},
},
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.3 KiB

24
frontend/public/icons.svg Normal file
View File

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="bluesky-icon" viewBox="0 0 16 17">
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
</symbol>
<symbol id="discord-icon" viewBox="0 0 20 19">
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
</symbol>
<symbol id="documentation-icon" viewBox="0 0 21 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
</symbol>
<symbol id="github-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
</symbol>
<symbol id="social-icon" viewBox="0 0 20 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
</symbol>
<symbol id="x-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
</symbol>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

15
frontend/src/App.vue Normal file
View File

@@ -0,0 +1,15 @@
<script setup lang="ts">
import { RouterView } from 'vue-router'
</script>
<template>
<div id="app" class="min-h-screen">
<RouterView />
</div>
</template>
<style scoped>
#app {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
</style>

29
frontend/src/api/auth.ts Normal file
View File

@@ -0,0 +1,29 @@
import { http } from './index'
import type { UserLoginRequest, UserRegisterRequest, TokenResponse, User } from '@/types'
export const authApi = {
// 用户登录
login(data: UserLoginRequest) {
return http.post<TokenResponse>('/auth/login', data)
},
// 用户注册
register(data: UserRegisterRequest) {
return http.post<User>('/auth/register', data)
},
// 获取当前用户信息
getCurrentUser() {
return http.get<User>('/auth/me')
},
// 刷新 Token
refreshToken(refreshToken: string) {
return http.post<TokenResponse>('/auth/refresh', { refresh_token: refreshToken })
},
// 登出
logout() {
return http.post('/auth/logout')
},
}

69
frontend/src/api/index.ts Normal file
View File

@@ -0,0 +1,69 @@
import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios'
import type { ApiResponse } from '@/types'
// 创建 axios 实例
const request: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/api/v1',
timeout: 10000,
headers: {
'Content-Type': 'application/json',
},
})
// 请求拦截器
request.interceptors.request.use(
(config: any) => {
// 从 localStorage 获取 token
const token = localStorage.getItem('access_token')
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
return config
},
(error: any) => {
return Promise.reject(error)
}
)
// 响应拦截器
request.interceptors.response.use(
(response: AxiosResponse<ApiResponse>) => {
return response
},
(error: any) => {
if (error.response) {
const { status } = error.response
// 401 未授权,跳转登录页
if (status === 401) {
localStorage.removeItem('access_token')
window.location.href = '/login'
}
return Promise.reject(error.response.data)
}
return Promise.reject(error)
}
)
// 封装请求方法
export const http = {
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
return request.get(url, config)
},
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
return request.post(url, data, config)
},
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
return request.put(url, data, config)
},
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
return request.delete(url, config)
},
}
export default request

34
frontend/src/api/post.ts Normal file
View File

@@ -0,0 +1,34 @@
import { http } from './index'
import type { Post, PostCreateRequest, PostUpdateRequest, PostListResponse, PageParams } from '@/types'
export const postApi = {
// 获取文章列表
getList(params?: PageParams & { category_id?: string; tag_id?: string }) {
return http.get<PostListResponse>('/posts', { params })
},
// 获取单篇文章
getDetail(id: string) {
return http.get<Post>(`/posts/${id}`)
},
// 创建文章
create(data: PostCreateRequest) {
return http.post<Post>('/posts', data)
},
// 更新文章
update(id: string, data: PostUpdateRequest) {
return http.put<Post>(`/posts/${id}`, data)
},
// 删除文章
delete(id: string) {
return http.delete(`/posts/${id}`)
},
// 增加浏览量
incrementView(id: string) {
return http.post(`/posts/${id}/view`)
},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

View File

@@ -0,0 +1,227 @@
<script setup lang="ts">
import { RouterLink } from 'vue-router'
const currentYear = new Date().getFullYear()
</script>
<template>
<footer class="footer">
<div class="footer-container">
<div class="footer-grid">
<!-- 博客信息 -->
<div class="footer-section footer-about">
<div class="footer-logo">
<div class="logo-icon">A</div>
<span class="logo-text">ACG Blog</span>
</div>
<p class="footer-desc">
专注于二次元文化的博客平台分享动漫游戏同人创作等内容
</p>
<div class="social-links">
<a href="#" class="social-link" title="GitHub">GH</a>
<a href="#" class="social-link" title="Twitter">X</a>
<a href="#" class="social-link" title="Telegram">TG</a>
</div>
</div>
<!-- 快速链接 -->
<div class="footer-section">
<h4 class="footer-title">快速链接</h4>
<ul class="footer-links">
<li><RouterLink to="/">首页</RouterLink></li>
<li><RouterLink to="/about">关于</RouterLink></li>
<li><RouterLink to="/archive">归档</RouterLink></li>
<li><RouterLink to="/login">登录</RouterLink></li>
</ul>
</div>
<!-- 合作伙伴 -->
<div class="footer-section">
<h4 class="footer-title">合作伙伴</h4>
<ul class="footer-links">
<li><a href="#">B站</a></li>
<li><a href="#">NGA</a></li>
<li><a href="#">AcFun</a></li>
</ul>
</div>
</div>
<!-- 版权信息 -->
<div class="footer-bottom">
<p>© {{ currentYear }} ACG Blog. All rights reserved.</p>
<div class="footer-legal">
<a href="#">隐私政策</a>
<a href="#">服务条款</a>
</div>
</div>
</div>
</footer>
</template>
<style scoped>
.footer {
background: linear-gradient(to bottom, transparent, rgba(249, 250, 251, 0.5));
margin-top: 4rem;
}
:global(.dark) .footer {
background: linear-gradient(to bottom, transparent, rgba(17, 24, 39, 0.5));
}
.footer-container {
max-width: 1280px;
margin: 0 auto;
padding: 3rem 1rem;
}
.footer-grid {
display: grid;
grid-template-columns: 1fr;
gap: 2rem;
}
@media (min-width: 768px) {
.footer-grid {
grid-template-columns: 2fr 1fr 1fr;
}
}
.footer-section {
min-width: 0;
}
.footer-logo {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 1rem;
}
.logo-icon {
width: 2.5rem;
height: 2.5rem;
border-radius: 0.5rem;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
font-size: 1.25rem;
}
.logo-text {
font-size: 1.25rem;
font-weight: bold;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.footer-desc {
font-size: 0.875rem;
color: #6B7280;
line-height: 1.6;
margin-bottom: 1rem;
}
:global(.dark) .footer-desc {
color: #9CA3AF;
}
.social-links {
display: flex;
gap: 0.75rem;
}
.social-link {
width: 2.25rem;
height: 2.25rem;
border-radius: 9999px;
background: #F3F4F6;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 600;
color: #6B7280;
text-decoration: none;
transition: all 0.2s;
}
:global(.dark) .social-link {
background: #374151;
color: #9CA3AF;
}
.social-link:hover {
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
color: white;
transform: translateY(-2px);
}
.footer-title {
font-weight: 600;
margin-bottom: 1rem;
color: #FFB7C5;
}
.footer-links {
list-style: none;
padding: 0;
margin: 0;
}
.footer-links li {
margin-bottom: 0.5rem;
}
.footer-links a {
color: #6B7280;
text-decoration: none;
font-size: 0.875rem;
transition: color 0.2s;
}
:global(.dark) .footer-links a {
color: #9CA3AF;
}
.footer-links a:hover {
color: #FFB7C5;
}
.footer-bottom {
margin-top: 2rem;
padding-top: 2rem;
border-top: 1px solid #E5E7EB;
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
text-align: center;
}
:global(.dark) .footer-bottom {
border-top-color: #374151;
}
@media (min-width: 768px) {
.footer-bottom {
flex-direction: row;
justify-content: space-between;
}
}
.footer-bottom p {
font-size: 0.875rem;
color: #9CA3AF;
}
.footer-legal {
display: flex;
gap: 1rem;
}
.footer-legal a {
font-size: 0.875rem;
color: #9CA3AF;
text-decoration: none;
transition: color 0.2s;
}
.footer-legal a:hover {
color: #FFB7C5;
}
</style>

View File

@@ -0,0 +1,267 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
const isVisible = ref(false)
onMounted(() => {
setTimeout(() => {
isVisible.value = true
}, 100)
})
const phrases = ['探索二次元世界', '分享动漫资讯', '记录游戏攻略', '展现同人创作']
const currentPhrase = ref(0)
setInterval(() => {
currentPhrase.value = (currentPhrase.value + 1) % phrases.length
}, 3000)
</script>
<template>
<section class="hero">
<!-- 背景动画 -->
<div class="hero-bg">
<div class="orb orb-1"></div>
<div class="orb orb-2"></div>
<div class="orb orb-3"></div>
</div>
<!-- 内容 -->
<div class="hero-content" :class="{ visible: isVisible }">
<!-- 标题 -->
<h1 class="hero-title">ACG Blog</h1>
<!-- 动态标语 -->
<div class="phrase-container">
<p class="phrase">{{ phrases[currentPhrase] }}<span class="cursor">|</span></p>
</div>
<!-- 描述 -->
<p class="hero-desc">
这里是二次元爱好者的聚集地我们分享动漫游戏同人创作的点点滴滴
</p>
<!-- 按钮组 -->
<div class="hero-buttons">
<RouterLink to="/" class="btn-primary">开始阅读</RouterLink>
<RouterLink to="/about" class="btn-secondary">了解更多</RouterLink>
</div>
</div>
<!-- 统计数字 -->
<div class="stats" :class="{ visible: isVisible }">
<div class="stat-item">
<div class="stat-number">66+</div>
<div class="stat-label">精彩文章</div>
</div>
<div class="stat-item">
<div class="stat-number">8+</div>
<div class="stat-label">精选分类</div>
</div>
<div class="stat-item">
<div class="stat-number">42+</div>
<div class="stat-label">热门标签</div>
</div>
<div class="stat-item">
<div class="stat-number">10k+</div>
<div class="stat-label">访问量</div>
</div>
</div>
</section>
</template>
<style scoped>
.hero {
min-height: 60vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
padding: 6rem 1rem 3rem;
background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,231,246,0.3));
}
:global(.dark) .hero {
background: linear-gradient(135deg, rgba(17,24,39,0.9), rgba(88,28,135,0.2));
}
.hero-bg {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.orb {
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.5;
animation: float 20s ease-in-out infinite;
}
.orb-1 {
width: 400px;
height: 400px;
background: linear-gradient(135deg, #FFB7C5, #FF69B4);
top: -100px;
left: -100px;
}
.orb-2 {
width: 300px;
height: 300px;
background: linear-gradient(135deg, #A8D8EA, #87CEEB);
bottom: -50px;
right: -50px;
animation-delay: -5s;
}
.orb-3 {
width: 250px;
height: 250px;
background: linear-gradient(135deg, #D4B5E6, #B57EDC);
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
animation-delay: -10s;
}
@keyframes float {
0%, 100% { transform: translate(0, 0) scale(1); }
25% { transform: translate(30px, -30px) scale(1.05); }
50% { transform: translate(-20px, 20px) scale(0.95); }
75% { transform: translate(-30px, -20px) scale(1.02); }
}
.hero-content {
position: relative;
z-index: 1;
text-align: center;
opacity: 0;
transform: translateY(20px);
transition: all 0.8s ease;
}
.hero-content.visible {
opacity: 1;
transform: translateY(0);
}
.hero-title {
font-size: 3rem;
font-weight: bold;
margin-bottom: 1rem;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6, #A8D8EA);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
@media (min-width: 768px) {
.hero-title {
font-size: 4.5rem;
}
}
.phrase-container {
height: 2.5rem;
margin-bottom: 1.5rem;
}
.phrase {
font-size: 1.25rem;
color: #6B7280;
}
:global(.dark) .phrase {
color: #D1D5DB;
}
.cursor {
animation: blink 1s step-end infinite;
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
.hero-desc {
max-width: 42rem;
margin: 0 auto 2rem;
font-size: 1rem;
color: #9CA3AF;
line-height: 1.75;
}
.hero-buttons {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 1rem;
}
.btn-primary {
padding: 0.875rem 2rem;
border-radius: 9999px;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
color: white;
font-weight: 600;
text-decoration: none;
box-shadow: 0 4px 15px rgba(255, 183, 197, 0.4);
transition: all 0.3s;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(255, 183, 197, 0.6);
}
.btn-secondary {
padding: 0.875rem 2rem;
border-radius: 9999px;
border: 2px solid #FFB7C5;
color: #FFB7C5;
font-weight: 600;
text-decoration: none;
transition: all 0.3s;
}
.btn-secondary:hover {
background: #FFB7C5;
color: white;
}
.stats {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 2rem;
max-width: 640px;
margin-top: 3rem;
opacity: 0;
transform: translateY(20px);
transition: all 0.8s ease 0.3s;
}
.stats.visible {
opacity: 1;
transform: translateY(0);
}
.stat-item {
text-align: center;
}
.stat-number {
font-size: 1.5rem;
font-weight: bold;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.stat-label {
font-size: 0.875rem;
color: #6B7280;
margin-top: 0.25rem;
}
:global(.dark) .stat-label {
color: #9CA3AF;
}
</style>

View File

@@ -0,0 +1,179 @@
<script setup lang="ts">
import { useThemeStore } from '@/store/theme'
import { useUserStore } from '@/store/user'
import { RouterLink } from 'vue-router'
const themeStore = useThemeStore()
const userStore = useUserStore()
</script>
<template>
<nav class="navbar">
<div class="nav-container">
<!-- Logo -->
<RouterLink to="/" class="logo">
<div class="logo-icon">A</div>
<span class="logo-text">ACG Blog</span>
</RouterLink>
<!-- 导航链接 -->
<div class="nav-links">
<RouterLink to="/" class="nav-link">首页</RouterLink>
<RouterLink to="/category" class="nav-link">分类</RouterLink>
<RouterLink to="/archive" class="nav-link">归档</RouterLink>
<RouterLink to="/about" class="nav-link">关于</RouterLink>
</div>
<!-- 右侧操作区 -->
<div class="nav-actions">
<!-- 主题切换 -->
<button @click="themeStore.toggleTheme()" class="action-btn">
{{ themeStore.theme === 'light' ? '☀️' : themeStore.theme === 'dark' ? '🌙' : '🌗' }}
</button>
<!-- 登录按钮 -->
<RouterLink v-if="!userStore.isLoggedIn" to="/login" class="login-btn">
登录
</RouterLink>
<RouterLink v-else to="/profile" class="user-avatar">
{{ userStore.user?.username?.[0]?.toUpperCase() || 'U' }}
</RouterLink>
</div>
</div>
</nav>
</template>
<style scoped>
.navbar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 50;
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(12px);
border-bottom: 1px solid rgba(229, 231, 235, 0.5);
}
:global(.dark) .navbar {
background: rgba(17, 24, 39, 0.85);
border-bottom-color: rgba(75, 85, 99, 0.5);
}
.nav-container {
max-width: 1280px;
margin: 0 auto;
padding: 0 1rem;
height: 4rem;
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
display: flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
}
.logo-icon {
width: 2rem;
height: 2rem;
border-radius: 0.5rem;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
font-size: 1.125rem;
}
.logo-text {
font-size: 1.25rem;
font-weight: bold;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.nav-links {
display: none;
gap: 1.5rem;
}
@media (min-width: 768px) {
.nav-links {
display: flex;
}
}
.nav-link {
position: relative;
color: #6B7280;
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
transition: color 0.2s;
}
:global(.dark) .nav-link {
color: #9CA3AF;
}
.nav-link:hover,
.nav-link.router-link-active {
color: #FFB7C5;
}
.nav-actions {
display: flex;
align-items: center;
gap: 0.75rem;
}
.action-btn {
width: 2.25rem;
height: 2.25rem;
border-radius: 9999px;
display: flex;
align-items: center;
justify-content: center;
background: #F3F4F6;
border: none;
cursor: pointer;
transition: all 0.2s;
}
:global(.dark) .action-btn {
background: #374151;
}
.action-btn:hover {
background: #FFB7C5;
}
.login-btn {
padding: 0.5rem 1rem;
border-radius: 9999px;
border: 2px solid #FFB7C5;
color: #FFB7C5;
font-size: 0.875rem;
font-weight: 500;
text-decoration: none;
transition: all 0.2s;
}
.login-btn:hover {
background: #FFB7C5;
color: white;
}
.user-avatar {
width: 2.25rem;
height: 2.25rem;
border-radius: 9999px;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: 600;
text-decoration: none;
}
</style>

View File

@@ -0,0 +1,251 @@
<script setup lang="ts">
import { RouterLink } from 'vue-router'
import type { Post } from '@/types'
interface Props {
post: Post
}
defineProps<Props>()
</script>
<template>
<article class="post-card">
<RouterLink :to="`/post/${post.id}`" class="post-link">
<!-- 封面图 -->
<div class="post-cover">
<img v-if="post.cover_image" :src="post.cover_image" :alt="post.title" class="cover-img" />
<div v-else class="cover-placeholder">
<span>📖</span>
</div>
<span class="status-badge" :class="post.status">{{ post.status === 'published' ? '已发布' : post.status === 'draft' ? '草稿' : '归档' }}</span>
</div>
<!-- 内容区 -->
<div class="post-content">
<!-- 分类 -->
<div class="post-tags" v-if="post.category || (post.tags && post.tags.length)">
<RouterLink v-if="post.category" :to="`/category/${post.category.id}`" class="category-tag">
{{ post.category.name }}
</RouterLink>
<RouterLink v-for="tag in (post.tags || []).slice(0, 2)" :key="tag.id" :to="`/tag/${tag.id}`" class="tag">
#{{ tag.name }}
</RouterLink>
</div>
<!-- 标题 -->
<h3 class="post-title">{{ post.title }}</h3>
<!-- 摘要 -->
<p v-if="post.summary" class="post-summary">{{ post.summary }}</p>
<!-- 底部信息 -->
<div class="post-meta">
<div class="author">
<div class="author-avatar">{{ post.author.username?.[0]?.toUpperCase() || 'U' }}</div>
<span class="author-name">{{ post.author.username }}</span>
</div>
<div class="meta-right">
<span class="views">👁 {{ post.view_count }}</span>
<span class="date">{{ new Date(post.created_at).toLocaleDateString('zh-CN') }}</span>
</div>
</div>
</div>
</RouterLink>
</article>
</template>
<style scoped>
.post-card {
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(12px);
border-radius: 1rem;
overflow: hidden;
transition: all 0.3s;
}
:global(.dark) .post-card {
background: rgba(17, 24, 39, 0.8);
}
.post-card:hover {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
transform: translateY(-4px);
}
.post-link {
display: block;
text-decoration: none;
color: inherit;
}
.post-cover {
position: relative;
height: 12rem;
overflow: hidden;
}
.cover-img {
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.5s;
}
.post-card:hover .cover-img {
transform: scale(1.1);
}
.cover-placeholder {
width: 100%;
height: 100%;
background: linear-gradient(135deg, #FFE4E9, #A8D8EA);
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
}
.status-badge {
position: absolute;
top: 0.75rem;
left: 0.75rem;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 500;
background: rgba(255, 255, 255, 0.9);
color: #6B7280;
}
:global(.dark) .status-badge {
background: rgba(17, 24, 39, 0.9);
color: #9CA3AF;
}
.status-badge.published {
background: rgba(220, 252, 231, 0.95);
color: #22C55E;
}
.status-badge.draft {
background: rgba(254, 215, 170, 0.95);
color: #F97316;
}
.post-content {
padding: 1.25rem;
}
.post-tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 0.75rem;
}
.category-tag {
padding: 0.125rem 0.625rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 500;
background: linear-gradient(135deg, #FFB7C5, #A8D8EA);
color: white;
text-decoration: none;
transition: transform 0.2s;
}
.category-tag:hover {
transform: scale(1.05);
}
.tag {
padding: 0.125rem 0.5rem;
border-radius: 0.25rem;
font-size: 0.75rem;
background: #F3F4F6;
color: #6B7280;
text-decoration: none;
transition: all 0.2s;
}
:global(.dark) .tag {
background: #374151;
color: #9CA3AF;
}
.tag:hover {
background: #FFB7C5;
color: white;
}
.post-title {
font-size: 1.125rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: #1F2937;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
transition: color 0.2s;
}
:global(.dark) .post-title {
color: #F3F4F6;
}
.post-card:hover .post-title {
color: #FFB7C5;
}
.post-summary {
font-size: 0.875rem;
color: #6B7280;
line-height: 1.6;
margin-bottom: 1rem;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
:global(.dark) .post-summary {
color: #9CA3AF;
}
.post-meta {
display: flex;
justify-content: space-between;
align-items: center;
}
.author {
display: flex;
align-items: center;
gap: 0.5rem;
}
.author-avatar {
width: 1.5rem;
height: 1.5rem;
border-radius: 9999px;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 0.75rem;
font-weight: 600;
}
.author-name {
font-size: 0.875rem;
color: #6B7280;
}
:global(.dark) .author-name {
color: #9CA3AF;
}
.meta-right {
display: flex;
align-items: center;
gap: 0.75rem;
font-size: 0.75rem;
color: #9CA3AF;
}
.views {
display: flex;
align-items: center;
gap: 0.25rem;
}
</style>

View File

@@ -0,0 +1,321 @@
<script setup lang="ts">
import { ref } from 'vue'
import { RouterLink } from 'vue-router'
const categories = ref([
{ id: '1', name: '动漫资讯', slug: 'anime', post_count: 12 },
{ id: '2', name: '游戏攻略', slug: 'game', post_count: 8 },
{ id: '3', name: '二次元美图', slug: 'pictures', post_count: 25 },
{ id: '4', name: '同人创作', slug: 'fanwork', post_count: 15 },
])
const tags = ref([
'原神', '崩坏星穹铁道', '我的世界', 'EVA',
'约定的梦幻岛', '咒术回战', 'Cosplay', '手办'
])
const hotPosts = ref([
{ id: '1', title: '《原神》4.2版本前瞻:芙宁娜技能演示', view_count: 5200 },
{ id: '2', title: '2024年必追的10部春季新番', view_count: 3800 },
{ id: '3', title: '《崩坏星穹铁道》角色强度榜更新', view_count: 2900 },
{ id: '4', title: '二次元手游开服大横评', view_count: 2100 },
{ id: '5', title: '手办入坑指南:从萌新到进阶', view_count: 1800 },
])
</script>
<template>
<aside class="sidebar">
<!-- 关于卡片 -->
<div class="sidebar-card">
<div class="about-header">
<div class="about-avatar">🎌</div>
<h3 class="about-title">ACG Blog</h3>
</div>
<p class="about-desc">专注于二次元文化的博客平台分享动漫游戏同人创作等内容</p>
<div class="about-stats">
<div class="about-stat">
<span class="stat-value pink">66</span>
<span class="stat-name">文章</span>
</div>
<div class="about-stat">
<span class="stat-value blue">8</span>
<span class="stat-name">分类</span>
</div>
<div class="about-stat">
<span class="stat-value purple">42</span>
<span class="stat-name">标签</span>
</div>
</div>
</div>
<!-- 分类列表 -->
<div class="sidebar-card">
<h3 class="sidebar-title">分类</h3>
<ul class="category-list">
<li v-for="cat in categories" :key="cat.id">
<RouterLink :to="`/category/${cat.slug}`" class="category-item">
<span>{{ cat.name }}</span>
<span class="category-count">{{ cat.post_count }}</span>
</RouterLink>
</li>
</ul>
</div>
<!-- 标签云 -->
<div class="sidebar-card">
<h3 class="sidebar-title">标签</h3>
<div class="tag-cloud">
<RouterLink v-for="tag in tags" :key="tag" :to="`/tag/${tag}`" class="tag">
{{ tag }}
</RouterLink>
</div>
</div>
<!-- 热门文章 -->
<div class="sidebar-card">
<h3 class="sidebar-title">热门文章</h3>
<ul class="hot-list">
<li v-for="(post, index) in hotPosts" :key="post.id">
<RouterLink :to="`/post/${post.id}`" class="hot-item">
<span class="hot-rank" :class="`rank-${index + 1}`">{{ index + 1 }}</span>
<div class="hot-content">
<div class="hot-title">{{ post.title }}</div>
<div class="hot-views">{{ post.view_count }} 阅读</div>
</div>
</RouterLink>
</li>
</ul>
</div>
<!-- 备案信息 -->
<div class="copyright">
<p>© 2024 ACG Blog. All rights reserved.</p>
</div>
</aside>
</template>
<style scoped>
.sidebar {
width: 100%;
}
@media (min-width: 1024px) {
.sidebar {
width: 320px;
flex-shrink: 0;
}
}
.sidebar-card {
background: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(12px);
border-radius: 1rem;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
:global(.dark) .sidebar-card {
background: rgba(17, 24, 39, 0.8);
}
.about-header {
text-align: center;
margin-bottom: 1rem;
}
.about-avatar {
width: 5rem;
height: 5rem;
margin: 0 auto 0.75rem;
border-radius: 50%;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
}
.about-title {
font-size: 1.125rem;
font-weight: bold;
}
.about-desc {
font-size: 0.875rem;
color: #6B7280;
text-align: center;
margin-bottom: 1rem;
line-height: 1.6;
}
:global(.dark) .about-desc {
color: #9CA3AF;
}
.about-stats {
display: flex;
justify-content: center;
gap: 1.5rem;
}
.about-stat {
text-align: center;
}
.stat-value {
font-size: 1.25rem;
font-weight: bold;
display: block;
}
.stat-value.pink { color: #FFB7C5; }
.stat-value.blue { color: #A8D8EA; }
.stat-value.purple { color: #D4B5E6; }
.stat-name {
font-size: 0.75rem;
color: #6B7280;
}
:global(.dark) .stat-name {
color: #9CA3AF;
}
.sidebar-title {
font-size: 1rem;
font-weight: 600;
margin-bottom: 1rem;
padding-bottom: 0.75rem;
border-bottom: 2px solid #FFB7C5;
color: #FFB7C5;
}
.category-list {
list-style: none;
padding: 0;
margin: 0;
}
.category-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 0.75rem;
border-radius: 0.5rem;
color: #6B7280;
text-decoration: none;
transition: all 0.2s;
}
:global(.dark) .category-item {
color: #9CA3AF;
}
.category-item:hover {
background: rgba(255, 183, 197, 0.2);
color: #FFB7C5;
transform: translateX(4px);
}
.category-count {
font-size: 0.75rem;
background: #F3F4F6;
padding: 0.125rem 0.5rem;
border-radius: 9999px;
}
:global(.dark) .category-count {
background: #374151;
}
.tag-cloud {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.tag {
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
background: rgba(255, 183, 197, 0.3);
color: #6B7280;
text-decoration: none;
transition: all 0.2s;
}
:global(.dark) .tag {
background: rgba(212, 181, 230, 0.2);
color: #9CA3AF;
}
.tag:hover {
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
color: white;
transform: scale(1.05);
}
.hot-list {
list-style: none;
padding: 0;
margin: 0;
}
.hot-item {
display: flex;
align-items: flex-start;
gap: 0.75rem;
padding: 0.5rem 0;
text-decoration: none;
transition: transform 0.2s;
}
.hot-item:hover {
transform: translateX(4px);
}
.hot-rank {
width: 1.5rem;
height: 1.5rem;
border-radius: 0.375rem;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.75rem;
font-weight: 600;
flex-shrink: 0;
background: #F3F4F6;
color: #6B7280;
}
:global(.dark) .hot-rank {
background: #374151;
color: #9CA3AF;
}
.rank-1 { background: linear-gradient(135deg, #FFD700, #FFA500); color: white; }
.rank-2 { background: linear-gradient(135deg, #C0C0C0, #A8A8A8); color: white; }
.rank-3 { background: linear-gradient(135deg, #CD7F32, #B87333); color: white; }
.hot-content {
flex: 1;
min-width: 0;
}
.hot-title {
font-size: 0.875rem;
color: #374151;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
transition: color 0.2s;
}
:global(.dark) .hot-title {
color: #D1D5DB;
}
.hot-item:hover .hot-title {
color: #FFB7C5;
}
.hot-views {
font-size: 0.75rem;
color: #9CA3AF;
margin-top: 0.25rem;
}
.copyright {
text-align: center;
font-size: 0.75rem;
color: #9CA3AF;
padding: 1rem 0;
}
</style>

View File

@@ -0,0 +1,49 @@
<template>
<div class="admin-layout min-h-screen">
<nav class="glass fixed top-0 left-0 right-0 z-50">
<div class="max-w-6xl mx-auto px-4 py-4 flex justify-between items-center">
<div class="text-xl font-bold text-acg-pink">管理后台</div>
<RouterLink to="/" class="text-sm hover:text-acg-pink">返回前台</RouterLink>
</div>
</nav>
<div class="pt-20 px-4 max-w-6xl mx-auto">
<div class="flex gap-6">
<!-- 侧边栏 -->
<aside class="w-48 flex-shrink-0">
<nav class="glass rounded-xl p-4 space-y-2">
<RouterLink
to="/admin/dashboard"
class="block px-4 py-2 rounded-lg hover:bg-acg-pink/10 transition-colors"
>
仪表盘
</RouterLink>
<RouterLink
to="/admin/posts"
class="block px-4 py-2 rounded-lg hover:bg-acg-pink/10 transition-colors"
>
文章管理
</RouterLink>
<RouterLink
to="/admin/categories"
class="block px-4 py-2 rounded-lg hover:bg-acg-pink/10 transition-colors"
>
分类管理
</RouterLink>
<RouterLink
to="/admin/tags"
class="block px-4 py-2 rounded-lg hover:bg-acg-pink/10 transition-colors"
>
标签管理
</RouterLink>
</nav>
</aside>
<!-- 主内容区 -->
<main class="flex-1">
<RouterView />
</main>
</div>
</div>
</div>
</template>

12
frontend/src/main.ts Normal file
View File

@@ -0,0 +1,12 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
// import naive-ui (按需引入,后续按需配置)
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.mount('#app')

View File

@@ -0,0 +1,99 @@
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import { useUserStore } from '@/store/user'
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Home',
component: () => import('@/views/Home.vue'),
},
{
path: '/post/:id',
name: 'PostDetail',
component: () => import('@/views/PostDetail.vue'),
},
{
path: '/category/:id',
name: 'Category',
component: () => import('@/views/Category.vue'),
},
{
path: '/about',
name: 'About',
component: () => import('@/views/About.vue'),
},
{
path: '/login',
name: 'Login',
component: () => import('@/views/auth/Login.vue'),
},
{
path: '/register',
name: 'Register',
component: () => import('@/views/auth/Register.vue'),
},
{
path: '/profile',
name: 'Profile',
component: () => import('@/views/user/Profile.vue'),
meta: { requiresAuth: true },
},
{
path: '/admin',
name: 'Admin',
component: () => import('@/layouts/AdminLayout.vue'),
meta: { requiresAuth: true, requiresAdmin: true },
children: [
{
path: '',
redirect: '/admin/dashboard',
},
{
path: 'dashboard',
name: 'AdminDashboard',
component: () => import('@/views/admin/Dashboard.vue'),
},
{
path: 'posts',
name: 'AdminPosts',
component: () => import('@/views/admin/PostManage.vue'),
},
{
path: 'categories',
name: 'AdminCategories',
component: () => import('@/views/admin/CategoryManage.vue'),
},
{
path: 'tags',
name: 'AdminTags',
component: () => import('@/views/admin/TagManage.vue'),
},
],
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/views/NotFound.vue'),
},
]
const router = createRouter({
history: createWebHistory(),
routes,
})
// 路由守卫
router.beforeEach((to, _from, next) => {
const userStore = useUserStore()
const token = localStorage.getItem('access_token')
if (to.meta.requiresAuth && !token) {
next({ name: 'Login' })
} else if (to.meta.requiresAdmin && userStore.user?.is_active !== true) {
next({ name: 'Home' })
} else {
next()
}
})
export default router

View File

@@ -0,0 +1,2 @@
export { useUserStore } from './user'
export { useThemeStore } from './theme'

View File

@@ -0,0 +1,43 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
type Theme = 'light' | 'dark' | 'auto'
export const useThemeStore = defineStore('theme', () => {
// 状态
const theme = ref<Theme>((localStorage.getItem('theme') as Theme) || 'light')
// Actions
function setTheme(newTheme: Theme) {
theme.value = newTheme
localStorage.setItem('theme', newTheme)
applyTheme(newTheme)
}
function applyTheme(t: Theme) {
const html = document.documentElement
if (t === 'auto') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
html.classList.toggle('dark', prefersDark)
} else {
html.classList.toggle('dark', t === 'dark')
}
}
function toggleTheme() {
const themes: Theme[] = ['light', 'dark', 'auto']
const currentIndex = themes.indexOf(theme.value)
const nextTheme = themes[(currentIndex + 1) % themes.length]
setTheme(nextTheme)
}
// 初始化主题
applyTheme(theme.value)
return {
theme,
setTheme,
toggleTheme,
}
})

View File

@@ -0,0 +1,64 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import type { User } from '@/types'
import { authApi } from '@/api/auth'
export const useUserStore = defineStore('user', () => {
// 状态
const user = ref<User | null>(null)
const token = ref<string | null>(localStorage.getItem('access_token'))
// 计算属性
const isLoggedIn = computed(() => !!token.value)
const isAdmin = computed(() => user.value?.is_active === true)
// Actions
function setToken(newToken: string | null) {
token.value = newToken
if (newToken) {
localStorage.setItem('access_token', newToken)
} else {
localStorage.removeItem('access_token')
}
}
function setUser(newUser: User | null) {
user.value = newUser
}
async function fetchUser() {
if (!token.value) return
try {
const response = await authApi.getCurrentUser()
setUser(response.data)
} catch (error) {
console.error('Failed to fetch user:', error)
setToken(null)
setUser(null)
}
}
async function login(email: string, password: string) {
const response = await authApi.login({ email, password })
setToken(response.data.access_token)
await fetchUser()
}
function logout() {
setToken(null)
setUser(null)
}
return {
user,
token,
isLoggedIn,
isAdmin,
setToken,
setUser,
fetchUser,
login,
logout,
}
})

12
frontend/src/style.css Normal file
View File

@@ -0,0 +1,12 @@
@import "tailwindcss";
/* 全局样式 */
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* {
box-sizing: border-box;
}

109
frontend/src/types/index.ts Normal file
View File

@@ -0,0 +1,109 @@
// 用户相关类型
export interface User {
id: string
username: string
email: string
avatar?: string
is_active: boolean
created_at: string
updated_at: string
}
export interface UserLoginRequest {
email: string
password: string
}
export interface UserRegisterRequest {
username: string
email: string
password: string
}
export interface TokenResponse {
access_token: string
token_type: string
}
// 文章相关类型
export interface Post {
id: string
title: string
slug: string
content: string
summary?: string
cover_image?: string
author: User
category?: Category
tags: Tag[]
view_count: number
status: 'draft' | 'published' | 'archived'
created_at: string
updated_at: string
}
export interface PostCreateRequest {
title: string
content: string
summary?: string
cover_image?: string
category_id?: string
tags?: string[]
status?: 'draft' | 'published'
}
export interface PostUpdateRequest {
title?: string
content?: string
summary?: string
cover_image?: string
category_id?: string
tags?: string[]
status?: 'draft' | 'published' | 'archived'
}
export interface PostListResponse {
items: Post[]
total: number
page: number
page_size: number
}
// 分类相关类型
export interface Category {
id: string
name: string
slug: string
description?: string
created_at: string
}
// 标签相关类型
export interface Tag {
id: string
name: string
created_at: string
}
// 评论相关类型
export interface Comment {
id: string
content: string
author?: User
created_at: string
parent_id?: string
replies?: Comment[]
}
// API 响应类型
export interface ApiResponse<T = any> {
code: number
message: string
data: T
}
// 分页请求参数
export interface PageParams {
page?: number
page_size?: number
}

View File

@@ -0,0 +1,19 @@
<template>
<div class="about">
<nav class="glass fixed top-0 left-0 right-0 z-50">
<div class="max-w-4xl mx-auto px-4 py-4">
<RouterLink to="/" class="text-acg-pink hover:underline"> 返回首页</RouterLink>
</div>
</nav>
<main class="pt-20 px-4 max-w-4xl mx-auto">
<div class="glass rounded-xl p-8">
<h1 class="text-3xl font-bold mb-4">关于 ACG Blog</h1>
<p class="text-gray-600 dark:text-gray-400 leading-relaxed">
ACG Blog 是一个专注于二次元文化的博客平台使用 Vue 3 + TypeScript + Naive UI 构建
在这里你可以分享你的二次元生活动漫评论游戏攻略等内容
</p>
</div>
</main>
</div>
</template>

View File

@@ -0,0 +1,25 @@
<script setup lang="ts">
import { useRoute } from 'vue-router'
const route = useRoute()
const categoryId = route.params.id as string
</script>
<template>
<div class="category">
<nav class="glass fixed top-0 left-0 right-0 z-50">
<div class="max-w-6xl mx-auto px-4 py-4">
<RouterLink to="/" class="text-acg-pink hover:underline"> 返回首页</RouterLink>
</div>
</nav>
<main class="pt-20 px-4 max-w-6xl mx-auto">
<div class="glass rounded-xl p-8">
<h1 class="text-2xl font-bold mb-4">分类 - {{ categoryId }}</h1>
<div class="text-gray-600 dark:text-gray-400">
分类内容加载中...
</div>
</div>
</main>
</div>
</template>

243
frontend/src/views/Home.vue Normal file
View File

@@ -0,0 +1,243 @@
<script setup lang="ts">
import { ref } from 'vue'
import Navbar from '@/components/Navbar.vue'
import Hero from '@/components/Hero.vue'
import PostCard from '@/components/PostCard.vue'
import Sidebar from '@/components/Sidebar.vue'
import Footer from '@/components/Footer.vue'
import type { Post } from '@/types'
// 模拟文章数据 - 后端完成后替换为真实API调用
const posts = ref<Post[]>([
{
id: '1',
title: '《原神》4.2版本前瞻:芙宁娜技能演示与剧情预测',
slug: 'genshin-4-2-preview',
content: '',
summary: '4.2版本即将到来,让我们提前了解水神芙宁娜的技能机制以及可能的剧情发展...',
cover_image: 'https://images.unsplash.com/photo-1542751371-adc38448a05e?w=800',
author: { id: '1', username: 'Miyako', email: '', is_active: true, created_at: '', updated_at: '' },
category: { id: '1', name: '游戏攻略', slug: 'game', created_at: '' },
tags: [{ id: '1', name: '原神', created_at: '' }, { id: '2', name: '攻略', created_at: '' }],
view_count: 5200,
status: 'published',
created_at: '2024-03-15T10:00:00Z',
updated_at: '2024-03-15T10:00:00Z'
},
{
id: '2',
title: '2024年必追的10部春季新番推荐',
slug: 'spring-2024-anime',
content: '',
summary: '春天到了又到了补番的季节本期为大家带来2024年春季最值得期待的新番动画...',
cover_image: 'https://images.unsplash.com/photo-1535016120720-40c6874c3b1c?w=800',
author: { id: '2', username: 'Akari', email: '', is_active: true, created_at: '', updated_at: '' },
category: { id: '2', name: '动漫资讯', slug: 'anime', created_at: '' },
tags: [{ id: '3', name: '新番', created_at: '' }, { id: '4', name: '推荐', created_at: '' }],
view_count: 3800,
status: 'published',
created_at: '2024-03-14T08:00:00Z',
updated_at: '2024-03-14T08:00:00Z'
},
{
id: '3',
title: '《崩坏星穹铁道》角色强度榜 - 3月版',
slug: 'honkai-star-rail-tier-list',
content: '',
summary: '版本强势角色有哪些本期强度榜为你详细分析当前版本的T0、T1角色...',
cover_image: 'https://images.unsplash.com/photo-1550745165-9bc0b252726f?w=800',
author: { id: '1', username: 'Miyako', email: '', is_active: true, created_at: '', updated_at: '' },
category: { id: '1', name: '游戏攻略', slug: 'game', created_at: '' },
tags: [{ id: '2', name: '崩坏星穹铁道', created_at: '' }, { id: '5', name: '强度榜', created_at: '' }],
view_count: 2900,
status: 'published',
created_at: '2024-03-13T15:30:00Z',
updated_at: '2024-03-13T15:30:00Z'
},
{
id: '4',
title: '手办入坑指南:从萌新到进阶的全方位攻略',
slug: 'figure-beginner-guide',
content: '',
summary: '想入手第一只手办但不知道如何选择?这篇指南将带你了解手办的各种分类、选购渠道...',
cover_image: 'https://images.unsplash.com/photo-1608889175123-8ee362201f81?w=800',
author: { id: '3', username: 'Sakura', email: '', is_active: true, created_at: '', updated_at: '' },
category: { id: '3', name: '二次元美图', slug: 'pictures', created_at: '' },
tags: [{ id: '6', name: '手办', created_at: '' }, { id: '7', name: '教程', created_at: '' }],
view_count: 2100,
status: 'published',
created_at: '2024-03-12T12:00:00Z',
updated_at: '2024-03-12T12:00:00Z'
},
{
id: '5',
title: '同人创作分享:用画笔描绘心中的二次元世界',
slug: 'fanart-sharing',
content: '',
summary: '本期收录了多位优秀画师的作品,让我们一起欣赏这些充满想象力的同人创作...',
cover_image: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800',
author: { id: '2', username: 'Akari', email: '', is_active: true, created_at: '', updated_at: '' },
category: { id: '4', name: '同人创作', slug: 'fanwork', created_at: '' },
tags: [{ id: '8', name: '同人', created_at: '' }, { id: '9', name: '绘画', created_at: '' }],
view_count: 1800,
status: 'published',
created_at: '2024-03-11T09:00:00Z',
updated_at: '2024-03-11T09:00:00Z'
},
{
id: '6',
title: '《约定的梦幻岛》最新话解析:剧情走向深度分析',
slug: 'neverland-analysis',
content: '',
summary: '最新一话的剧情信息量巨大,让我们来深度分析一下剧情走向和角色心理...',
cover_image: 'https://images.unsplash.com/photo-1518709268805-4e9042af9f23?w=800',
author: { id: '4', username: 'Ken', email: '', is_active: true, created_at: '', updated_at: '' },
category: { id: '2', name: '动漫资讯', slug: 'anime', created_at: '' },
tags: [{ id: '10', name: '约定的梦幻岛', created_at: '' }, { id: '11', name: '分析', created_at: '' }],
view_count: 1500,
status: 'published',
created_at: '2024-03-10T20:00:00Z',
updated_at: '2024-03-10T20:00:00Z'
}
])
const categories = [
{ name: '全部', slug: '' },
{ name: '动漫资讯', slug: 'anime' },
{ name: '游戏攻略', slug: 'game' },
{ name: '二次元美图', slug: 'pictures' },
{ name: '同人创作', slug: 'fanwork' },
]
const selectedCategory = ref('')
</script>
<template>
<div class="home">
<Navbar />
<Hero />
<main class="main-container">
<!-- 分类筛选 -->
<section class="category-section">
<div class="category-buttons">
<button
v-for="cat in categories"
:key="cat.slug"
@click="selectedCategory = cat.slug"
class="category-btn"
:class="{ active: selectedCategory === cat.slug }"
>
{{ cat.name }}
</button>
</div>
</section>
<!-- 文章列表 + 侧边栏 -->
<div class="content-layout">
<!-- 文章列表 -->
<section class="posts-section">
<h2 class="section-title">最新文章</h2>
<div class="posts-grid">
<PostCard v-for="post in posts" :key="post.id" :post="post" />
</div>
</section>
<!-- 侧边栏 -->
<Sidebar />
</div>
</main>
<Footer />
</div>
</template>
<style scoped>
.home {
min-height: 100vh;
}
.main-container {
max-width: 1280px;
margin: 0 auto;
padding: 3rem 1rem;
}
.category-section {
margin-bottom: 2rem;
}
.category-buttons {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.75rem;
}
.category-btn {
padding: 0.5rem 1.25rem;
border-radius: 9999px;
font-size: 0.875rem;
font-weight: 500;
color: #6B7280;
background: #F3F4F6;
border: none;
cursor: pointer;
transition: all 0.2s;
}
:global(.dark) .category-btn {
background: #374151;
color: #9CA3AF;
}
.category-btn:hover {
background: rgba(255, 183, 197, 0.3);
color: #FFB7C5;
}
.category-btn.active {
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
color: white;
}
.content-layout {
display: flex;
flex-direction: column;
gap: 2rem;
}
@media (min-width: 1024px) {
.content-layout {
flex-direction: row;
align-items: flex-start;
}
}
.posts-section {
flex: 1;
min-width: 0;
}
.section-title {
font-size: 1.5rem;
font-weight: bold;
margin-bottom: 1.5rem;
background: linear-gradient(135deg, #FFB7C5, #D4B5E6);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.posts-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1.5rem;
}
@media (min-width: 640px) {
.posts-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1024px) {
.posts-grid {
grid-template-columns: repeat(2, 1fr);
}
}
</style>

View File

@@ -0,0 +1,13 @@
<script setup lang="ts">
import { RouterLink } from 'vue-router'
</script>
<template>
<div class="not-found min-h-screen flex items-center justify-center px-4">
<div class="text-center">
<h1 class="text-6xl font-bold text-acg-pink mb-4">404</h1>
<p class="text-xl mb-6">页面不存在</p>
<RouterLink to="/" class="btn-acg">返回首页</RouterLink>
</div>
</div>
</template>

View File

@@ -0,0 +1,25 @@
<script setup lang="ts">
import { useRoute } from 'vue-router'
const route = useRoute()
const postId = route.params.id as string
</script>
<template>
<div class="post-detail">
<nav class="glass fixed top-0 left-0 right-0 z-50">
<div class="max-w-4xl mx-auto px-4 py-4">
<RouterLink to="/" class="text-acg-pink hover:underline"> 返回首页</RouterLink>
</div>
</nav>
<main class="pt-20 px-4 max-w-4xl mx-auto">
<div class="glass rounded-xl p-8">
<h1 class="text-3xl font-bold mb-4">文章详情 - {{ postId }}</h1>
<div class="text-gray-600 dark:text-gray-400">
文章内容加载中...
</div>
</div>
</main>
</div>
</template>

View File

@@ -0,0 +1,8 @@
<template>
<div class="category-manage">
<h1 class="text-2xl font-bold mb-6">分类管理</h1>
<div class="glass rounded-xl p-6">
<p class="text-gray-600 dark:text-gray-400">分类管理功能开发中...</p>
</div>
</div>
</template>

View File

@@ -0,0 +1,19 @@
<template>
<div class="dashboard">
<h1 class="text-2xl font-bold mb-6">仪表盘</h1>
<div class="grid gap-4 md:grid-cols-3">
<div class="glass rounded-xl p-6">
<h3 class="text-gray-600 dark:text-gray-400">文章总数</h3>
<p class="text-3xl font-bold text-acg-pink">0</p>
</div>
<div class="glass rounded-xl p-6">
<h3 class="text-gray-600 dark:text-gray-400">用户总数</h3>
<p class="text-3xl font-bold text-acg-blue">0</p>
</div>
<div class="glass rounded-xl p-6">
<h3 class="text-gray-600 dark:text-gray-400">总访问量</h3>
<p class="text-3xl font-bold text-acg-purple">0</p>
</div>
</div>
</div>
</template>

View File

@@ -0,0 +1,8 @@
<template>
<div class="post-manage">
<h1 class="text-2xl font-bold mb-6">文章管理</h1>
<div class="glass rounded-xl p-6">
<p class="text-gray-600 dark:text-gray-400">文章管理功能开发中...</p>
</div>
</div>
</template>

View File

@@ -0,0 +1,8 @@
<template>
<div class="tag-manage">
<h1 class="text-2xl font-bold mb-6">标签管理</h1>
<div class="glass rounded-xl p-6">
<p class="text-gray-600 dark:text-gray-400">标签管理功能开发中...</p>
</div>
</div>
</template>

View File

@@ -0,0 +1,55 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const email = ref('')
const password = ref('')
async function handleLogin() {
// TODO: 实现登录逻辑
console.log('Login:', email.value, password.value)
router.push('/')
}
</script>
<template>
<div class="login min-h-screen flex items-center justify-center px-4">
<div class="glass rounded-xl p-8 w-full max-w-md">
<h1 class="text-2xl font-bold text-center mb-6">登录</h1>
<form @submit.prevent="handleLogin" class="space-y-4">
<div>
<label class="block text-sm font-medium mb-2">邮箱</label>
<input
v-model="email"
type="email"
placeholder="请输入邮箱"
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-acg-pink"
required
/>
</div>
<div>
<label class="block text-sm font-medium mb-2">密码</label>
<input
v-model="password"
type="password"
placeholder="请输入密码"
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-acg-pink"
required
/>
</div>
<button type="submit" class="w-full btn-acg">
登录
</button>
</form>
<p class="text-center mt-4 text-sm">
还没有账号
<RouterLink to="/register" class="text-acg-pink hover:underline">立即注册</RouterLink>
</p>
</div>
</div>
</template>

View File

@@ -0,0 +1,67 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const username = ref('')
const email = ref('')
const password = ref('')
async function handleRegister() {
// TODO: 实现注册逻辑
console.log('Register:', username.value, email.value, password.value)
router.push('/login')
}
</script>
<template>
<div class="register min-h-screen flex items-center justify-center px-4">
<div class="glass rounded-xl p-8 w-full max-w-md">
<h1 class="text-2xl font-bold text-center mb-6">注册</h1>
<form @submit.prevent="handleRegister" class="space-y-4">
<div>
<label class="block text-sm font-medium mb-2">用户名</label>
<input
v-model="username"
type="text"
placeholder="请输入用户名"
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-acg-pink"
required
/>
</div>
<div>
<label class="block text-sm font-medium mb-2">邮箱</label>
<input
v-model="email"
type="email"
placeholder="请输入邮箱"
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-acg-pink"
required
/>
</div>
<div>
<label class="block text-sm font-medium mb-2">密码</label>
<input
v-model="password"
type="password"
placeholder="请输入密码"
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-acg-pink"
required
/>
</div>
<button type="submit" class="w-full btn-acg">
注册
</button>
</form>
<p class="text-center mt-4 text-sm">
已有账号
<RouterLink to="/login" class="text-acg-pink hover:underline">立即登录</RouterLink>
</p>
</div>
</div>
</template>

View File

@@ -0,0 +1,28 @@
<script setup lang="ts">
import { useUserStore } from '@/store/user'
const userStore = useUserStore()
</script>
<template>
<div class="profile">
<nav class="glass fixed top-0 left-0 right-0 z-50">
<div class="max-w-4xl mx-auto px-4 py-4">
<RouterLink to="/" class="text-acg-pink hover:underline"> 返回首页</RouterLink>
</div>
</nav>
<main class="pt-20 px-4 max-w-4xl mx-auto">
<div class="glass rounded-xl p-8">
<h1 class="text-2xl font-bold mb-4">个人中心</h1>
<div v-if="userStore.user">
<p>用户名: {{ userStore.user.username }}</p>
<p>邮箱: {{ userStore.user.email }}</p>
</div>
<div v-else>
加载中...
</div>
</div>
</main>
</div>
</template>

View File

@@ -0,0 +1,22 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
// 二次元风格配色
'acg-pink': '#FFB7C5',
'acg-pink-light': '#FFE4E9',
'acg-blue': '#A8D8EA',
'acg-purple': '#D4B5E6',
'acg-yellow': '#FFF4BD',
},
},
},
plugins: [
require('@tailwindcss/typography'),
],
}

View File

@@ -0,0 +1,22 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"types": ["vite/client"],
/* Path Alias */
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
}

7
frontend/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}

View File

@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

22
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,22 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:8000',
changeOrigin: true,
},
},
},
})