9147d5e679
- 新增 navbar-component.js:固定页眉,统一标题、用户信息、退出按钮 - 重构所有页面(index/topics/logs/admin/users)使用 navbar-component - 清理原有 navbar 相关样式,避免冲突 - 导航组件增加 main-content padding-top 自动调整 - 修复导航按钮点击事件(确保 触发) - 导航组件样式强应用,解决遮挡和布局问题
549 lines
22 KiB
HTML
549 lines
22 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>宇之然内容创作平台</title>
|
|
<link rel="stylesheet" href="element-plus.css">
|
|
<style>
|
|
/* 深色渐变背景主题 */
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: #f5f7fa; color: #303133; }
|
|
/* 深色渐变: #1a1a2e → #16213e → #0f3460 */
|
|
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
|
min-height: 100vh;
|
|
color: #e0e6ed;
|
|
}
|
|
|
|
/* 导航栏 */
|
|
.navbar {
|
|
background: rgba(102, 126, 234, 0.15);
|
|
backdrop-filter: blur(20px);
|
|
border-bottom: 1px solid rgba(102, 126, 234, 0.2);
|
|
padding: 16px 24px;
|
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
.navbar-content {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
.navbar-title {
|
|
font-size: 20px;
|
|
font-weight: 700;
|
|
background: linear-gradient(90deg, #667eea, #764ba2);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
letter-spacing: -0.5px;
|
|
}
|
|
.navbar-user {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
}
|
|
.user-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
color: #a0aec0;
|
|
font-size: 14px;
|
|
}
|
|
.avatar {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 50%;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: white;
|
|
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
/* 主内容区 */
|
|
.main-content {
|
|
display: flex;
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
min-height: calc(100vh - 64px);
|
|
}
|
|
|
|
/* 侧边栏 */
|
|
.sidebar {
|
|
width: 200px;
|
|
background: rgba(26, 26, 46, 0.8);
|
|
backdrop-filter: blur(20px);
|
|
padding: 16px 12px;
|
|
border-right: 1px solid rgba(102, 126, 234, 0.1);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 内容区域 */
|
|
.content-area {
|
|
flex: 1;
|
|
padding: 32px;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
/* 页面切换 */
|
|
.page { display: none; animation: fadeIn 0.5s ease-out; }
|
|
.page.active { display: block; }
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(20px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
/* 统计卡片网格 */
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 40px;
|
|
}
|
|
.stat-card {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(102, 126, 234, 0.1);
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
cursor: pointer;
|
|
transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
.stat-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: -100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
|
|
transition: left 0.6s;
|
|
}
|
|
.stat-card:hover::before {
|
|
left: 100%;
|
|
}
|
|
.stat-card:hover {
|
|
transform: translateY(-8px) scale(1.02);
|
|
border-color: rgba(102, 126, 234, 0.4);
|
|
box-shadow: 0 12px 32px rgba(102, 126, 234, 0.2);
|
|
}
|
|
.stat-title {
|
|
font-size: 13px;
|
|
color: #a0aec0;
|
|
margin-bottom: 12px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
font-weight: 500;
|
|
}
|
|
.stat-value {
|
|
font-size: 36px;
|
|
font-weight: 800;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
line-height: 1.2;
|
|
}
|
|
.stat-card.primary .stat-value { background: linear-gradient(135deg, #667eea, #764ba2); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
|
.stat-card.success .stat-value { background: linear-gradient(135deg, #67c23a, #85e61d); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
|
.stat-card.warning .stat-value { background: linear-gradient(135deg, #e6a23c, #f5c543); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
|
.stat-card.danger .stat-value { background: linear-gradient(135deg, #f56c6c, #f79296); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
|
.stat-card.info .stat-value { background: linear-gradient(135deg, #409eff, #5cd0f3); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
|
|
|
/* 模块卡片 */
|
|
.module-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
|
gap: 20px;
|
|
}
|
|
.module-card {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(102, 126, 234, 0.1);
|
|
border-radius: 16px;
|
|
padding: 24px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
position: relative;
|
|
}
|
|
.module-card:hover {
|
|
transform: translateY(-6px);
|
|
border-color: rgba(102, 126, 234, 0.3);
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
}
|
|
.module-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 16px;
|
|
}
|
|
.module-title {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
color: #e0e6ed;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.module-status {
|
|
padding: 6px 12px;
|
|
border-radius: 20px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
background: rgba(103, 194, 58, 0.2);
|
|
color: #67c23a;
|
|
border: 1px solid rgba(103, 194, 58, 0.3);
|
|
}
|
|
.module-status.running {
|
|
animation: pulse 2s infinite;
|
|
}
|
|
@keyframes pulse {
|
|
0%, 100% { box-shadow: 0 0 0 0 rgba(103, 194, 58, 0.4); }
|
|
50% { box-shadow: 0 0 0 8px rgba(103, 194, 58, 0); }
|
|
}
|
|
.module-content {
|
|
font-size: 14px;
|
|
color: #a0aec0;
|
|
line-height: 1.8;
|
|
}
|
|
.module-content div {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 4px 0;
|
|
border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
|
|
}
|
|
.module-content div:last-child { border-bottom: none; }
|
|
|
|
/* 移动端导航 */
|
|
.mobile-nav {
|
|
display: none;
|
|
position: fixed;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
background: rgba(26, 26, 46, 0.95);
|
|
backdrop-filter: blur(20px);
|
|
border-top: 1px solid rgba(102, 126, 234, 0.2);
|
|
padding: 8px 0;
|
|
z-index: 1000;
|
|
box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 响应式 */
|
|
@media (max-width: 768px) {
|
|
.sidebar { display: none; }
|
|
.mobile-nav { display: flex; }
|
|
.content-area {
|
|
padding: 16px;
|
|
padding-bottom: 80px;
|
|
}
|
|
.stats-grid {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 12px;
|
|
}
|
|
.stat-card { padding: 16px; }
|
|
.stat-value { font-size: 24px; }
|
|
.module-grid { grid-template-columns: 1fr; }
|
|
}
|
|
</style>
|
|
<style>
|
|
body { background: #f5f7fa !important; color: #303133 !important; }
|
|
.navbar { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important; border-bottom: none !important; backdrop-filter: none !important; }
|
|
.navbar-title { background: none !important; -webkit-text-fill-color: white !important; color: white !important; }
|
|
.user-info { color: white !important; }
|
|
.avatar { background: rgba(255,255,255,0.2) !important; color: white !important; }
|
|
.sidebar { background: white !important; border-right: 1px solid #ebeef5 !important; backdrop-filter: none !important; }
|
|
|
|
|
|
.mobile-nav { background: white !important; border-top: 1px solid #ebeef5 !important; backdrop-filter: none !important; box-shadow: 0 -2px 8px rgba(0,0,0,0.1) !important; }
|
|
|
|
|
|
|
|
#page-overview h2, #page-overview h3, #page-overview .module-title { color: #303133 !important; }
|
|
#page-overview .module-content { color: #303133 !important; }
|
|
</style>
|
|
|
|
<script src="navigation-component.js"></script>
|
|
|
|
<script src="navbar-component.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="app">
|
|
<navbar-component
|
|
title="宇之然内容创作平台"
|
|
:username="currentUser.username"
|
|
:is-admin="isAdmin"
|
|
@logout="handleLogout"
|
|
></navbar-component>
|
|
|
|
<navigation-component
|
|
current-page="dashboard"
|
|
:is-admin="isAdmin"
|
|
@navigate="redirectToPage"
|
|
></navigation-component>
|
|
<div class="main-content" v-if="isLoggedIn">
|
|
<main class="content-area">
|
|
<!-- 系统概览页面 -->
|
|
<div id="page-overview" class="page" :class="{ active: currentPage === 'overview' }">
|
|
<h2 style="font-size: 28px; font-weight: 700; margin-bottom: 32px; color: #e0e6ed;">
|
|
📊 系统概览
|
|
</h2>
|
|
|
|
<!-- 统计卡片 -->
|
|
<div class="stats-grid">
|
|
<div class="stat-card primary" @click="goToTopics('')">
|
|
<div class="stat-title">选题总数</div>
|
|
<div class="stat-value">{{ stats.total }}</div>
|
|
</div>
|
|
<div class="stat-card warning" @click="goToTopics('pending')">
|
|
<div class="stat-title">待处理</div>
|
|
<div class="stat-value">{{ stats.pending }}</div>
|
|
</div>
|
|
<div class="stat-card danger" @click="goToTopics('review')">
|
|
<div class="stat-title">待审查</div>
|
|
<div class="stat-value">{{ stats.review }}</div>
|
|
</div>
|
|
<div class="stat-card success" @click="goToTopics('ready')">
|
|
<div class="stat-title">待发布</div>
|
|
<div class="stat-value">{{ stats.ready }}</div>
|
|
</div>
|
|
<div class="stat-card info" @click="goToTopics('published')">
|
|
<div class="stat-title">已发布</div>
|
|
<div class="stat-value">{{ stats.published }}</div>
|
|
</div>
|
|
<div class="stat-card primary" @click="goToTopics('')">
|
|
<div class="stat-title">今日新增</div>
|
|
<div class="stat-value">{{ stats.today }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 模块状态 -->
|
|
<h3 style="font-size: 20px; font-weight: 600; margin-bottom: 24px; color: #e0e6ed;">
|
|
🔧 模块状态
|
|
</h3>
|
|
<div class="module-grid">
|
|
<div class="module-card">
|
|
<div class="module-header">
|
|
<span class="module-title">🤖 内容创作引擎</span>
|
|
<span class="module-status running">运行中</span>
|
|
</div>
|
|
<div class="module-content">
|
|
<div><span>最后运行</span><span>2026-04-27 14:30</span></div>
|
|
<div><span>今日任务</span><span>12 个</span></div>
|
|
<div><span>成功率</span><span>95%</span></div>
|
|
</div>
|
|
</div>
|
|
<div class="module-card">
|
|
<div class="module-header">
|
|
<span class="module-title">🔍 内容优化器</span>
|
|
<span class="module-status running">运行中</span>
|
|
</div>
|
|
<div class="module-content">
|
|
<div><span>最后运行</span><span>2026-04-27 14:45</span></div>
|
|
<div><span>今日优化</span><span>8 个</span></div>
|
|
<div><span>平均提升</span><span>+12 分</span></div>
|
|
</div>
|
|
</div>
|
|
<div class="module-card">
|
|
<div class="module-header">
|
|
<span class="module-title">📡 内容收集器</span>
|
|
<span class="module-status running">运行中</span>
|
|
</div>
|
|
<div class="module-content">
|
|
<div><span>最后运行</span><span>2026-04-27 14:00</span></div>
|
|
<div><span>今日收集</span><span>24 个</span></div>
|
|
<div><span>来源平台</span><span>8 个</span></div>
|
|
</div>
|
|
</div>
|
|
<div class="module-card">
|
|
<div class="module-header">
|
|
<span class="module-title">📤 发布管理器</span>
|
|
<span class="module-status running">运行中</span>
|
|
</div>
|
|
<div class="module-content">
|
|
<div><span>最后运行</span><span>2026-04-27 13:30</span></div>
|
|
<div><span>今日发布</span><span>5 个</span></div>
|
|
<div><span>成功率</span><span>100%</span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<!-- 移动端导航 -->
|
|
<nav class="mobile-nav" v-if="isLoggedIn">
|
|
<button class="mobile-nav-btn" :class="{ active: currentPage === 'overview' }" @click="redirectToPage('/')">
|
|
📊 概览
|
|
</button>
|
|
<button class="mobile-nav-btn" :class="{ active: currentPage === 'topics' }" @click="redirectToPage('topics.html')">
|
|
📋 选题
|
|
</button>
|
|
<button class="mobile-nav-btn" :class="{ active: currentPage === 'logs' }" @click="redirectToPage('logs.html')">
|
|
📄 日志
|
|
</button>
|
|
<button v-if="isAdmin" class="mobile-nav-btn" :class="{ active: currentPage === 'users' }" @click="redirectToPage('users.html')">
|
|
👥 用户
|
|
</button>
|
|
</nav>
|
|
</div>
|
|
|
|
<script src="vue.global.prod.js"></script>
|
|
<script src="element-plus.full.js"></script>
|
|
<script>
|
|
const App = {
|
|
data() {
|
|
return {
|
|
isLoggedIn: false,
|
|
isAdmin: false,
|
|
currentUser: { username: '' },
|
|
currentPage: 'overview',
|
|
stats: {
|
|
total: 0,
|
|
pending: 0,
|
|
review: 0,
|
|
ready: 0,
|
|
published: 0,
|
|
today: 0
|
|
}
|
|
};
|
|
},
|
|
methods: {
|
|
async handleLogin() {
|
|
this.loginLoading = true;
|
|
this.loginError = '';
|
|
try {
|
|
const response = await fetch('/api/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(this.loginForm)
|
|
});
|
|
if (!response.ok) throw new Error('登录失败');
|
|
const data = await response.json();
|
|
localStorage.setItem('authToken', data.token);
|
|
this.currentUser = data.user;
|
|
this.isAdmin = data.user.role === 'admin';
|
|
this.isLoggedIn = true;
|
|
this.currentPage = 'overview';
|
|
this.fetchStats();
|
|
} catch (error) {
|
|
this.loginError = '用户名或密码错误';
|
|
} finally {
|
|
this.loginLoading = false;
|
|
}
|
|
},
|
|
handleLogout() {
|
|
localStorage.removeItem('authToken');
|
|
this.isLoggedIn = false;
|
|
this.currentUser = { username: '' };
|
|
this.isAdmin = false;
|
|
},
|
|
async fetchStats() {
|
|
try {
|
|
const token = localStorage.getItem('authToken');
|
|
if (!token) {
|
|
window.location.href = '/login.html';
|
|
return;
|
|
}
|
|
const response = await fetch('/api/system/status', {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
});
|
|
if (response.ok) {
|
|
const data = await response.json();
|
|
// API返回格式: { stats: { total, pending, review, ready, published, today } }
|
|
this.stats = {
|
|
total: data.stats?.total || 0,
|
|
pending: data.stats?.pending || 0,
|
|
review: data.stats?.review || 0,
|
|
ready: data.stats?.ready || 0,
|
|
published: data.stats?.published || 0,
|
|
today: data.stats?.today || 0
|
|
};
|
|
} else if (response.status === 401) {
|
|
// Token无效,清除并跳转登录
|
|
localStorage.removeItem('authToken');
|
|
window.location.href = '/login.html';
|
|
} else {
|
|
console.error('获取统计信息失败:', response.status, response.statusText);
|
|
this.stats = { total: 0, pending: 0, review: 0, ready: 0, published: 0, today: 0 };
|
|
}
|
|
} catch (error) {
|
|
console.error('获取统计信息失败:', error);
|
|
// 失败时设置为0,避免页面空白
|
|
this.stats = { total: 0, pending: 0, review: 0, ready: 0, published: 0, today: 0 };
|
|
}
|
|
},
|
|
goToTopics(filter) {
|
|
const url = filter ? '/topics.html?filter=' + encodeURIComponent(filter) : '/topics.html';
|
|
window.location.href = url;
|
|
},
|
|
redirectToPage(page) {
|
|
window.location.href = page.startsWith('/') ? page : '/' + page;
|
|
}
|
|
},
|
|
mounted() {
|
|
const token = localStorage.getItem('authToken');
|
|
if (!token) {
|
|
window.location.href = '/login.html';
|
|
return;
|
|
}
|
|
fetch('/api/auth/me', {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
})
|
|
.then(response => response.ok ? response.json() : Promise.reject())
|
|
.then(data => {
|
|
this.currentUser = data.user;
|
|
this.isAdmin = data.user.role === 'admin';
|
|
this.isLoggedIn = true;
|
|
this.currentPage = 'overview';
|
|
this.fetchStats();
|
|
})
|
|
.catch(() => {
|
|
localStorage.removeItem('authToken');
|
|
window.location.href = '/login.html';
|
|
});
|
|
}
|
|
};
|
|
|
|
const app = Vue.createApp(App);
|
|
app.use(ElementPlus);
|
|
// 安装导航组件
|
|
if (window.installNavbar) { window.installNavbar(app); }
|
|
// 安装导航组件
|
|
if (window.installNavigation) { window.installNavigation(app); } else if (window.NavigationComponent) { app.component("navigation-component", window.NavigationComponent); }
|
|
app.mount('#app');
|
|
|
|
// 调试代码:检查导航组件状态
|
|
setTimeout(() => {
|
|
const hasNav = !!document.querySelector('.navigation-wrapper');
|
|
const hasSidebar = !!document.querySelector('.navigation-wrapper .sidebar');
|
|
console.log('[调试] 导航wrapper:', hasNav);
|
|
console.log('[调试] 侧边栏:', hasSidebar);
|
|
if (!hasNav) {
|
|
console.error('[调试] 导航组件未渲染!window.NavigationComponent=', !!window.NavigationComponent);
|
|
console.error('[调试] app实例是否存在组件注册?', Vue && Vue.app && Vue.app._context.components['navigation-component']);
|
|
}
|
|
}, 100);
|
|
</script>
|
|
</body>
|
|
</html>
|