233e23016c
- 文章 HTML 存储从文件系统迁移至 articles 表,删除 releases 目录 - 合规审查从 DB 读取 HTML,审查结果写回 DB,通过后自动推进至待发布 - 新增 todayCount 筛选按钮,与系统概览统计数据一致 - 全屏预览修复:提升 z-index 超过侧边栏,添加退出全屏/关闭按钮 - 统一 '优化' → '审查' 命名,消除前后端术语不一致 - 调度器创作完成后自动触发审查(生成 → 审查 → 待发布) - 清理旧备份/调试文件、过期大纲和研究笔记
115 lines
7.0 KiB
HTML
115 lines
7.0 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">
|
|
<link rel="stylesheet" href="theme-modern.css">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: #f5f7fa; color: #303133; }
|
|
|
|
.main-content { display: flex; flex: 1; max-width: 1400px; margin: 0 auto; min-height: calc(100vh - 60px); }
|
|
.content-area { flex: 1; padding: 24px; overflow-y: auto; }
|
|
.card { background: white; border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); overflow-x: auto; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
|
|
|
|
|
|
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
|
|
.page-title { font-size: 24px; font-weight: 700; color: #303133; display: flex; align-items: center; gap: 8px; }
|
|
.controls { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
|
|
.log-container { max-height: 600px; overflow-y: auto; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; }
|
|
.log-container pre { margin: 0; padding: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 13px; line-height: 1.6; color: #303133; }
|
|
|
|
@media (max-width: 768px) {
|
|
.content-area { padding: 16px; padding-bottom: 80px; }
|
|
.card { padding: 16px; }
|
|
.controls { flex-direction: column; align-items: stretch; }
|
|
.controls .el-select, .controls .el-date-picker { width: 100% !important; }
|
|
.log-container { max-height: calc(100vh - 250px); }
|
|
.log-container pre { font-size: 11px; padding: 12px; }
|
|
}
|
|
</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="logs" :is-admin="isAdmin" @navigate="redirectToPage"></navigation-component>
|
|
<div class="main-content">
|
|
<main class="content-area">
|
|
<div class="card page-fade">
|
|
<div class="page-header">
|
|
<h2 class="page-title">📄 系统日志</h2>
|
|
</div>
|
|
<div class="controls">
|
|
<el-select v-model="logType" placeholder="日志类型" style="width: 180px;">
|
|
<el-option label="创作日志" value="creator"></el-option>
|
|
<el-option label="审查日志" value="optimizer"></el-option>
|
|
<el-option label="收集日志" value="collector"></el-option>
|
|
</el-select>
|
|
<el-date-picker v-model="logDate" type="date" placeholder="选择日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD"></el-date-picker>
|
|
<el-button type="primary" @click="fetchLogs" :loading="loadingLogs">加载日志</el-button>
|
|
</div>
|
|
<div v-if="logContent" class="log-container">
|
|
<pre>{{ logContent }}</pre>
|
|
</div>
|
|
<el-empty v-else description="请选择类型和日期,点击加载"></el-empty>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
<script src="vue.global.prod.js"></script>
|
|
<script src="element-plus.full.js"></script>
|
|
<script>
|
|
const LogsApp = {
|
|
data() {
|
|
const today = new Date().toISOString().split('T')[0];
|
|
return {
|
|
isLoggedIn: false, isAdmin: false, currentUser: { username: '' },
|
|
logType: 'creator', logDate: today, logContent: '', loadingLogs: false
|
|
}
|
|
},
|
|
methods: {
|
|
async fetchLogs() {
|
|
if (!this.logType || !this.logDate) { this.$message.warning('请选择日志类型和日期'); return; }
|
|
this.loadingLogs = true;
|
|
try {
|
|
const token = localStorage.getItem('authToken');
|
|
if (!token) { this.$message.error('请先登录'); return; }
|
|
const response = await fetch(`/api/logs?type=${encodeURIComponent(this.logType)}&date=${encodeURIComponent(this.logDate)}`, {
|
|
headers: { 'Authorization': 'Bearer ' + token }
|
|
});
|
|
if (!response.ok) { const errorData = await response.json().catch(() => ({})); throw new Error(errorData.detail || `请求失败: ${response.status}`); }
|
|
const data = await response.json();
|
|
this.logContent = `日志类型:${data.type}\n日期:${data.date}\n\n${data.content || '(日志文件为空)'}`;
|
|
this.$message.success('日志加载成功');
|
|
} catch (error) {
|
|
console.error('获取日志失败:', error);
|
|
this.$message.error(`获取日志失败: ${error.message}`);
|
|
this.logContent = '';
|
|
} finally { this.loadingLogs = false; }
|
|
},
|
|
handleLogout() { localStorage.removeItem('authToken'); localStorage.removeItem('userRole'); localStorage.removeItem('currentUser'); window.location.href = '/login.html'; },
|
|
redirectToPage(page) { window.location.href = page.startsWith('/') ? page : '/' + page; },
|
|
checkAuth() {
|
|
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; })
|
|
.catch(() => { localStorage.removeItem('authToken'); localStorage.removeItem('userRole'); localStorage.removeItem('currentUser'); window.location.href = '/login.html'; });
|
|
}
|
|
},
|
|
mounted() { this.checkAuth(); }
|
|
};
|
|
const app = Vue.createApp(LogsApp);
|
|
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');
|
|
</script>
|
|
</body>
|
|
</html>
|