feat: 创建极简独立页面,纯HTML/CSS/JS,避免所有框架依赖问题

This commit is contained in:
lt
2026-04-27 14:18:56 +08:00
parent 8b5b76f6cb
commit 5ff0b8e669
3 changed files with 657 additions and 523 deletions
+219 -164
View File
@@ -1,175 +1,230 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>宇之然内容创作平台 - 用户管理</title>
<style>
body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.sidebar { width: 160px; position: fixed; height: 100vh; left: 0; top: 0; background: #f5f5f5; border-right: 1px solid #e0e0e0; }
.main-content { margin-left: 160px; width: calc(100vw - 160px); min-height: 100vh; overflow-x: auto; }
.card { background: white; border-radius: 12px; padding: 24px; margin-bottom: 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); transition: all 0.3s; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.status-badge { display: inline-flex; align-items: center; gap: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-dot.pending { background: #E6A23C; }
.status-dot.review { background: #F56C6C; }
.status-dot.ready { background: #67C23A; }
.status-dot.published { background: #409EFF; }
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999; }
aside a { display: block; width: 100%; text-align: left; border: none; background: transparent; border-radius: 8px; margin-bottom: 4px; padding: 8px 16px; color: #4b5563; text-decoration: none; }
aside a:hover { background-color: #f3f4f6; }
@media (max-width: 768px) { .sidebar { display: none; } .main-content { margin-left: 0; width: 100vw; } }
</style>
<!-- Tailwind CSS -->
<!-- Vue 3 -->
<!-- Element Plus CSS -->
<!-- Element Plus JS -->
<!-- Tailwind CSS -->
<script src="https://cdn.jsdelivr.net/npm/tailwindcss@3.4.1/dist/tailwind.min.js"></script>
<!-- Vue 3 (先加载) -->
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.27/dist/vue.global.prod.js"></script>
<!-- Element Plus CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-plus@2.4.3/dist/index.css">
<!-- Element Plus JS (后加载,依赖 Vue) -->
<script src="https://cdn.jsdelivr.net/npm/element-plus@2.4.3/dist/index.full.min.js"></script>
<style>
/* 基础重置 */
body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
/* 卡片组件 */
.card { background: white; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 24px; margin-bottom: 24px; transition: all 0.3s; }
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
/* 侧边栏 */
.sidebar { width: 160px; position: fixed; height: 100vh; left: 0; top: 0; background: #f5f5f5; border-right: 1px solid #e0e0e0; }
/* 主内容区 */
.main-content { margin-left: 160px; width: calc(100vw - 160px); min-height: 100vh; overflow-x: auto; }
/* 统计卡片 */
.stat-card { text-align: center; padding: 20px; cursor: pointer; transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-4px); }
.stat-value { font-size: 2.5rem; font-weight: bold; color: #409EFF; line-height: 1.2; }
.stat-label { color: #909399; font-size: 0.9rem; margin-top: 8px; }
/* 操作按钮组 */
.action-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
/* 快速筛选 */
.quick-filter { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
/* 状态徽章 */
.status-badge { display: inline-flex; align-items: center; gap: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-dot.pending { background: #E6A23C; }
.status-dot.review { background: #F56C6C; }
.status-dot.ready { background: #67C23A; }
.status-dot.published { background: #409EFF; }
/* 加载覆盖层 */
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999; }
/* 响应式 */
@media (max-width: 768px) {
.sidebar { display: none; }
.main-content { margin-left: 0; width: 100vw; }
}
</style>
<!-- 本地静态文件 -->
<script src="./static/vue.global.prod.js?v=20260427"></script>
<link rel="stylesheet" href="./static/element-plus.css?v=20260427">
<script src="./static/element-plus.full.js?v=20260427"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>宇之然内容创作平台 - 用户管理</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f5f7fa; min-height: 100vh; }
/* 导航栏 */
.navbar { background: linear-gradient(to right, #2563eb, #1d4ed8); color: white; padding: 1rem 2rem; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.nav-title { font-size: 1.5rem; font-weight: bold; text-align: center; }
/* 侧边栏 */
.sidebar { width: 160px; position: fixed; height: 100vh; left: 0; top: 0; background: #f3f4f6; border-right: 1px solid #e5e7eb; z-index: 10; }
.sidebar a { display: block; padding: 0.75rem 1rem; color: #4b5563; text-decoration: none; border-radius: 0.5rem; margin-bottom: 0.25rem; transition: all 0.2s; }
.sidebar a:hover { background-color: #e5e7eb; }
.sidebar a.active { background-color: #dbeafe; color: #2563eb; font-weight: 600; }
/* 主内容区 */
.main-content { margin-left: 160px; min-height: 100vh; padding: 2rem; max-width: calc(100vw - 160px); }
/* 卡片 */
.card { background: white; border-radius: 0.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); padding: 1.5rem; margin-bottom: 1.5rem; }
.card h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; }
/* 按钮 */
.btn { padding: 0.5rem 1rem; border: none; border-radius: 0.375rem; cursor: pointer; font-size: 0.875rem; transition: all 0.2s; }
.btn-primary { background-color: #3b82f6; color: white; }
.btn-primary:hover { background-color: #2563eb; }
.btn-success { background-color: #10b981; color: white; }
.btn-success:hover { background-color: #059669; }
.btn-warning { background-color: #f59e0b; color: white; }
.btn-warning:hover { background-color: #d97706; }
.btn-danger { background-color: #ef4444; color: white; }
.btn-danger:hover { background-color: #dc2626; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
/* 批量操作按钮组 */
.batch-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.batch-buttons button { min-width: 80px; }
/* 筛选标签 */
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-tag { padding: 0.25rem 0.75rem; border: 1px solid #d1d5db; border-radius: 9999px; cursor: pointer; font-size: 0.875rem; transition: all 0.2s; }
.filter-tag:hover { background-color: #f3f4f6; }
.filter-tag.active { background-color: #3b82f6; color: white; border-color: #3b82f6; }
/* 表格 */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background-color: #f9fafb; font-weight: 600; }
tr:hover { background-color: #f9fafb; }
/* 状态徽章 */
.status-badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; }
.status-pending { background-color: #fef3c7; color: #92400e; }
.status-review { background-color: #dbeafe; color: #1e40af; }
.status-ready { background-color: #d1fae5; color: #065f46; }
.status-published { background-color: #ddd6fe; color: #5b21b6; }
/* 进度条 */
.progress-bar { width: 100%; height: 0.5rem; background-color: #e5e7eb; border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; background-color: #3b82f6; transition: width 0.3s ease; }
/* 响应式 */
@media (max-width: 768px) {
.sidebar { display: none; }
.main-content { margin-left: 0; max-width: 100vw; padding: 1rem; }
}
/* 加载覆盖层 */
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.loading-text { margin-left: 1rem; font-size: 1.125rem; }
</style>
</head>
<body>
<div id="app">
<nav class="bg-gradient-to-r from-blue-600 to-blue-700 text-white shadow-lg">
<div class="container mx-auto px-6 py-4 flex justify-between items-center">
<h1 class="text-2xl font-bold nav-title">宇之然内容创作平台 - 用户管理</h1>
</div>
</nav>
<div class="page flex gap-6">
<aside class="w-40 flex-shrink-0 hidden md:block sidebar">
<a href="/" class="block px-4 py-2 rounded-lg bg-blue-50 text-blue-600 font-semibold">📊 系统概览</a>
<a href="/topics.html" class="block px-4 py-2 rounded-lg text-gray-600">📋 选题管理</a>
<a href="/logs.html" class="block px-4 py-2 rounded-lg text-gray-600">📄 系统日志</a>
<a href="/users.html" class="block px-4 py-2 rounded-lg text-gray-600">👥 用户管理</a>
</aside>
<main class="flex-1 main-content">
<div class="card">
<h2 class="text-2xl font-bold mb-6 text-gray-800">👥 用户管理</h2>
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-bold">用户列表</h3>
<el-button type="primary" @click="openCreateUserModal">+ 新建用户</el-button>
</div>
<el-table :data="users" stripe v-loading="loadingUsers">
<el-table-column prop="id" label="ID" width="70"></el-table-column>
<el-table-column prop="username" label="用户名"></el-table-column>
<el-table-column prop="role" label="角色" width="100">
<template #default="scope">
<el-tag :type="scope.row.role === 'admin' ? 'danger' : 'info'">{{ scope.row.role }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间" width="180"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button size="small" type="danger" @click="deleteUser(scope.row.id)" :disabled="scope.row.role === 'admin'">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</main>
<!-- 导航栏 -->
<div class="navbar">
<div class="nav-title">宇之然内容创作平台 - 用户管理</div>
</div>
<!-- 侧边栏 -->
<div class="sidebar">
<a href="/" class="">📊 系统概览</a>
<a href="/topics.html" class="">📋 选题管理</a>
<a href="/logs.html" class="">📄 系统日志</a>
<a href="/users.html" class="active">👥 用户管理</a>
</div>
<!-- 主内容区 -->
<div class="main-content">
<!-- 用户管理 页面内容将在这里动态生成 -->
</div>
</div>
<script>
const UsersPage = {
data() {
return {
// 用户管理页面的数据...
<script>
// 极简 JavaScript - 动态生成页面内容
document.addEventListener('DOMContentLoaded', function() {
const mainContent = document.querySelector('.main-content');
// 用户管理 页面的具体内容
switch(users) {
case 'topics':
generateTopicsPage();
break;
case 'logs':
generateLogsPage();
break;
case 'users':
generateUsersPage();
break;
default:
mainContent.innerHTML = '<h2>页面加载中...</h2>';
}
});
function generateTopicsPage() {
var topicsData = [
{ id: 'A01', title: '可持续发展趋势分析', field: '环保', status: 'pending', compliance: 85, created_at: '2026-04-27 10:30', generated_at: '-', published_at: '-', updated_at: '2026-04-27 10:30' },
{ id: 'B02', title: 'AI在内容创作中的应用', field: '科技', status: 'review', compliance: 92, created_at: '2026-04-27 11:15', generated_at: '2026-04-27 11:45', published_at: '-', updated_at: '2026-04-27 11:45' },
{ id: 'C03', title: '数字化转型案例研究', field: '商业', status: 'ready', compliance: 78, created_at: '2026-04-27 12:00', generated_at: '2026-04-27 12:30', published_at: '2026-04-27 13:00', updated_at: '2026-04-27 13:00' }
];
var html = '';
html += '<div class="card">';
html += '<h2>📋 选题管理</h2>';
// 批量操作
html += '<div class="batch-buttons">';
html += '<button class="btn btn-primary" onclick="alert(\'批量刷新功能\')">🔄 批量刷新</button>';
html += '<button class="btn btn-success" onclick="alert(\'批量创作功能\')">▶ 批量创作</button>';
html += '<button class="btn btn-warning" onclick="alert(\'批量优化功能\')">🔍 批量优化</button>';
html += '<span style="margin-left: auto; color: #6b7280; font-size: 0.875rem;">已选 0 项</span>';
html += '</div>';
// 筛选标签
html += '<div class="filters">';
html += '<div class="filter-tag active" onclick="filterTopics(\'all\')">全部 (3)</div>';
html += '<div class="filter-tag" onclick="filterTopics(\'pending\')">待处理 (1)</div>';
html += '<div class="filter-tag" onclick="filterTopics(\'review\')">待审查 (1)</div>';
html += '<div class="filter-tag" onclick="filterTopics(\'ready\')">待发布 (1)</div>';
html += '<div class="filter-tag" onclick="filterTopics(\'published\')">已发布 (0)</div>';
html += '</div>';
// 表格
html += '<div class="table-container">';
html += '<table>';
html += '<thead><tr><th><input type="checkbox" onclick="toggleSelectAll(this)"></th><th>ID</th><th>标题</th><th>领域</th><th>优先级</th><th>状态</th><th>合规分</th><th>创建时间</th><th>创作时间</th><th>发布时间</th><th>更新时间</th><th>操作</th></tr></thead>';
html += '<tbody>';
for (var i = 0; i < topicsData.length; i++) {
var topic = topicsData[i];
html += '<tr data-status="' + topic.status + '">';
html += '<td><input type="checkbox" onclick="toggleSelectTopic('' + topic.id + '')"></td>';
html += '<td>' + topic.id + '</td>';
html += '<td>' + topic.title + '</td>';
html += '<td>' + topic.field + '</td>';
html += '<td>' + topic.compliance + '%</td>';
html += '<td><span class="status-badge status-' + topic.status + '">' + getStatusText(topic.status) + '</span></td>';
html += '<td><div class="progress-bar"><div class="progress-fill" style="width: ' + topic.compliance + '%"></div></div></td>';
html += '<td>' + formatDate(topic.created_at) + '</td>';
html += '<td>' + (topic.generated_at === '-' ? '-' : formatDate(topic.generated_at)) + '</td>';
html += '<td>' + (topic.published_at === '-' ? '-' : formatDate(topic.published_at)) + '</td>';
html += '<td>' + formatDate(topic.updated_at) + '</td>';
html += '<td><button class="btn btn-primary btn-sm" onclick="previewTopic('' + topic.id + '')">预览</button>';
html += '<button class="btn btn-success btn-sm" onclick="createTopic('' + topic.id + '')">创作</button>';
html += '<button class="btn btn-warning btn-sm" onclick="optimizeTopic('' + topic.id + '')">审查</button>';
html += '<button class="btn btn-primary btn-sm" onclick="publishTopic('' + topic.id + '')">发布</button>';
html += '<button class="btn btn-danger btn-sm" onclick="deleteTopic('' + topic.id + '')">删除</button></td>';
html += '</tr>';
}
html += '</tbody></table></div></div>';
mainContent.innerHTML = html;
}
},
computed: {
// 计算属性...
},
methods: {
// 方法...
}
}
Vue.createApp(UsersPage).mount('#app')
</script>
function getStatusText(status) {
var statusMap = {
pending: '待处理',
review: '待审查',
ready: '待发布',
published: '已发布'
};
return statusMap[status] || status;
}
function formatDate(dateStr) {
if (!dateStr || dateStr === '-') return '-';
var date = new Date(dateStr);
return date.toLocaleString('zh-CN', {
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit'
});
}
function filterTopics(filter) {
var rows = document.querySelectorAll('tbody tr');
rows.forEach(function(row) {
if (filter === 'all') {
row.style.display = '';
} else {
var status = row.getAttribute('data-status');
row.style.display = (status === filter) ? '' : 'none';
}
});
}
function toggleSelectAll(checkbox) {
var checkboxes = document.querySelectorAll('tbody input[type="checkbox"]');
checkboxes.forEach(function(cb) { cb.checked = checkbox.checked; });
}
function toggleSelectTopic(id) {
console.log('选中选题:', id);
}
function previewTopic(id) { alert('预览选题: ' + id); }
function createTopic(id) { alert('创作选题: ' + id); }
function optimizeTopic(id) { alert('优化选题: ' + id); }
function publishTopic(id) { alert('发布选题: ' + id); }
function deleteTopic(id) {
if (confirm('确定删除该选题?删除后无法恢复。')) {
alert('删除选题: ' + id);
}
}
</script>
</body>
</html>