Files
yu-zhi-ran/platform/frontend/login.html
T

245 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>
<script src="/static/vue.global.prod.js?v=20260421-0830"></script>
<link rel="stylesheet" href="/static/element-plus.css?v=20260421-0830" />
<script src="/static/element-plus.full.js?v=20260421-0830"></script>
<style>
.login-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
width: 100%;
max-width: 400px;
padding: 32px;
background: white;
border-radius: 16px;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.login-title {
text-align: center;
font-size: 28px;
font-weight: bold;
color: #1f2937;
margin-bottom: 32px;
}
.login-input {
width: 100%;
padding: 12px 16px;
border: 1px solid #d1d5db;
border-radius: 8px;
font-size: 16px;
margin-bottom: 16px;
outline: none;
transition: border-color 0.2s;
}
.login-input:focus {
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.login-button {
width: 100%;
padding: 12px;
background: #3b82f6;
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: background 0.2s;
}
.login-button:hover {
background: #2563eb;
}
.login-button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.login-footer {
text-align: center;
margin-top: 24px;
color: #6b7280;
font-size: 14px;
}
</style>
<!-- Tailwind CSS -->
<!-- Vue 3 -->
<!-- Element Plus CSS -->
<!-- Element Plus JS -->
<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>
</head>
<body>
<div class="login-container">
<div class="login-card">
<h1 class="login-title">宇之然内容创作平台</h1>
<form @submit.prevent="handleLogin">
<input
v-model="username"
class="login-input"
type="text"
placeholder="请输入用户名"
required
autocomplete="username"
/>
<input
v-model="password"
class="login-input"
type="password"
placeholder="请输入密码"
required
autocomplete="current-password"
/>
<button
class="login-button"
type="submit"
:disabled="loading"
:class="{'opacity-60 cursor-not-allowed': loading}"
>
{{ loading ? '登录中...' : '登录' }}
</button>
</form>
<p class="login-footer">
只有管理员用户可登录访问系统
</p>
</div>
</div>
<script>
const { ref } = Vue;
const { ElMessage } = ElementPlus;
const app = Vue.createApp({
name: 'LoginPage',
setup() {
const username = ref('');
const password = ref('');
const loading = ref(false);
const handleLogin = async () => {
if (!username.value.trim() || !password.value) {
ElMessage.warning('请输入用户名和密码');
return;
}
loading.value = true;
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: username.value.trim(),
password: password.value
})
});
const data = await response.json();
if (response.ok && data.token) {
// 保存认证信息
localStorage.setItem('auth_token', data.token);
localStorage.setItem('user_role', data.role || 'admin');
ElMessage.success('登录成功!正在跳转...');
// 延迟跳转,让用户看到成功消息
setTimeout(() => {
window.location.href = '/';
}, 1000);
} else {
ElMessage.error(data.message || data.error || '登录失败,请检查用户名和密码');
}
} catch (error) {
console.error('登录请求失败:', error);
ElMessage.error('网络连接失败,请检查服务是否正常运行');
} finally {
loading.value = false;
}
};
return {
username,
password,
loading,
handleLogin
};
}
});
app.use(ElementPlus);
app.mount('#app');
</script>
</body>
</html>