新增后台管理
This commit is contained in:
27
src/main/resources/db/sys_user.sql
Normal file
27
src/main/resources/db/sys_user.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- 后台管理用户表
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
|
||||
CREATE TABLE `sys_user` (
|
||||
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
`username` VARCHAR(50) NOT NULL COMMENT '用户名',
|
||||
`password` VARCHAR(100) NOT NULL COMMENT '密码(MD5加密)',
|
||||
`real_name` VARCHAR(50) DEFAULT NULL COMMENT '真实姓名',
|
||||
`email` VARCHAR(100) DEFAULT NULL COMMENT '邮箱',
|
||||
`telephone` VARCHAR(20) DEFAULT NULL COMMENT '手机号',
|
||||
`avatar` VARCHAR(255) DEFAULT NULL COMMENT '头像URL',
|
||||
`login_ip` VARCHAR(50) DEFAULT NULL COMMENT '最后登录IP',
|
||||
`login_time` DATETIME DEFAULT NULL COMMENT '最后登录时间',
|
||||
`status` TINYINT(1) DEFAULT 1 COMMENT '状态:0-禁用 1-启用',
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
`create_time` DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_username` (`username`),
|
||||
KEY `idx_status` (`status`),
|
||||
KEY `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='后台管理用户表';
|
||||
|
||||
-- 插入默认管理员账号(密码为:admin123,MD5加密后)
|
||||
INSERT INTO `sys_user` (`username`, `password`, `real_name`, `email`, `status`, `remark`)
|
||||
VALUES
|
||||
('admin', 'e10adc3949ba59abbe56e057f20f883e', '系统管理员', 'admin@corewing.com', 1, '超级管理员账号');
|
||||
494
src/main/resources/static/admin/index.html
Normal file
494
src/main/resources/static/admin/index.html
Normal file
@@ -0,0 +1,494 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>后台管理系统</title>
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #5B5FDE;
|
||||
--secondary-color: #0EA5E9;
|
||||
--accent-color: #FF6B6B;
|
||||
--error-color: #F43F5E;
|
||||
--success-color: #10B981;
|
||||
--warning-color: #F59E0B;
|
||||
--info-color: #3B82F6;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #F3F4F6;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* 侧边栏样式 */
|
||||
.sidebar {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
color: white;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 180px;
|
||||
box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 18px 12px;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.sidebar-header h4 {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar-header i {
|
||||
margin-right: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
padding: 9px 10px;
|
||||
border-radius: 8px;
|
||||
margin: 3px 0;
|
||||
transition: all 0.3s;
|
||||
font-weight: 500;
|
||||
font-size: 13px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sidebar .nav-link i {
|
||||
width: 18px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover {
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
transform: translateX(5px);
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
background-color: rgba(255, 255, 255, 0.25);
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 12px 8px;
|
||||
}
|
||||
|
||||
.btn-logout {
|
||||
width: 100%;
|
||||
padding: 9px;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
color: white;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.btn-logout:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
/* 顶部导航栏 */
|
||||
.navbar {
|
||||
background-color: white;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
padding: 12px 25px;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #4B5563;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.user-info i {
|
||||
font-size: 20px;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
/* 主内容区 */
|
||||
.main-content {
|
||||
margin-left: 180px;
|
||||
}
|
||||
|
||||
/* 内容区域 */
|
||||
.content-wrapper {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
/* 欢迎卡片 */
|
||||
.welcome-card {
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
color: white;
|
||||
border-radius: 16px;
|
||||
padding: 35px;
|
||||
margin-bottom: 25px;
|
||||
box-shadow: 0 10px 30px rgba(91, 95, 222, 0.2);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.welcome-card::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
top: -80px;
|
||||
right: -80px;
|
||||
}
|
||||
|
||||
.welcome-card h2 {
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.welcome-card p {
|
||||
font-size: 15px;
|
||||
opacity: 0.95;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* 统计卡片 */
|
||||
.stat-card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 25px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s;
|
||||
border: 1px solid #E5E7EB;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.stat-card i {
|
||||
font-size: 40px;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.stat-card h3 {
|
||||
font-size: 30px;
|
||||
font-weight: 700;
|
||||
margin: 12px 0 6px;
|
||||
color: #1F2937;
|
||||
}
|
||||
|
||||
.stat-card p {
|
||||
color: #6B7280;
|
||||
font-size: 13px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.stat-card.primary i { color: var(--primary-color); }
|
||||
.stat-card.success i { color: var(--success-color); }
|
||||
.stat-card.warning i { color: var(--warning-color); }
|
||||
.stat-card.info i { color: var(--info-color); }
|
||||
|
||||
/* 页面标题 */
|
||||
.page-title {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* 卡片容器 */
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
border: 1px solid #E5E7EB;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
/* 响应式 */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
position: static;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.welcome-card {
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
.welcome-card h2 {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- 侧边栏 -->
|
||||
<nav class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h4>
|
||||
<i class="bi bi-shield-lock-fill"></i>
|
||||
CoreWing
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-menu">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a :class="['nav-link', currentPage === 'dashboard' ? 'active' : '']"
|
||||
href="#"
|
||||
@click.prevent="currentPage = 'dashboard'">
|
||||
<i class="bi bi-speedometer2"></i>
|
||||
仪表盘
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a :class="['nav-link', currentPage === 'users' ? 'active' : '']"
|
||||
href="#"
|
||||
@click.prevent="currentPage = 'users'">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
用户管理
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a :class="['nav-link', currentPage === 'settings' ? 'active' : '']"
|
||||
href="#"
|
||||
@click.prevent="currentPage = 'settings'">
|
||||
<i class="bi bi-gear-fill"></i>
|
||||
系统设置
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-footer">
|
||||
<button class="btn-logout" @click="handleLogout">
|
||||
<i class="bi bi-box-arrow-right me-2"></i>
|
||||
退出登录
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<main class="main-content">
|
||||
<!-- 顶部导航栏 -->
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<div class="container-fluid">
|
||||
<span class="navbar-brand">欢迎回来</span>
|
||||
<div class="user-info">
|
||||
<i class="bi bi-person-circle"></i>
|
||||
<span>{{ userInfo.realName || userInfo.username }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="content-wrapper">
|
||||
<!-- 仪表盘 -->
|
||||
<div v-if="currentPage === 'dashboard'">
|
||||
<div class="welcome-card">
|
||||
<h2>
|
||||
<i class="bi bi-emoji-smile"></i>
|
||||
你好,{{ userInfo.realName || userInfo.username }}!
|
||||
</h2>
|
||||
<p class="mb-0 mt-2">欢迎使用 CoreWing 后台管理系统</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card primary">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<h3>1,234</h3>
|
||||
<p>总用户数</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card success">
|
||||
<i class="bi bi-file-earmark-text-fill"></i>
|
||||
<h3>567</h3>
|
||||
<p>文档数量</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="stat-card warning">
|
||||
<i class="bi bi-graph-up"></i>
|
||||
<h3>89%</h3>
|
||||
<p>系统负载</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户管理 -->
|
||||
<div v-if="currentPage === 'users'">
|
||||
<h3 class="page-title">用户管理</h3>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p>用户管理功能开发中...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 系统设置 -->
|
||||
<div v-if="currentPage === 'settings'">
|
||||
<h3 class="page-title">系统设置</h3>
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<p>系统设置功能开发中...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Vue 3 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js"></script>
|
||||
|
||||
<!-- Axios -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 5 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
userInfo: {
|
||||
username: '',
|
||||
realName: '',
|
||||
userId: ''
|
||||
},
|
||||
currentPage: 'dashboard'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async loadUserInfo() {
|
||||
// 从 localStorage 获取用户信息
|
||||
this.userInfo.username = localStorage.getItem('username') || '';
|
||||
this.userInfo.realName = localStorage.getItem('realName') || '';
|
||||
this.userInfo.userId = localStorage.getItem('userId') || '';
|
||||
|
||||
// 也可以从服务器获取最新的用户信息
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
try {
|
||||
axios.defaults.headers.common['satoken'] = token;
|
||||
const response = await axios.get('/sys/user/info');
|
||||
if (response.data.code === 200) {
|
||||
const user = response.data.data;
|
||||
this.userInfo.username = user.username;
|
||||
this.userInfo.realName = user.realName || user.username;
|
||||
this.userInfo.userId = user.id;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async handleLogout() {
|
||||
if (confirm('确定要退出登录吗?')) {
|
||||
try {
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
axios.defaults.headers.common['satoken'] = token;
|
||||
await axios.post('/sys/user/logout');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('退出登录失败:', error);
|
||||
} finally {
|
||||
// 清除本地存储
|
||||
localStorage.clear();
|
||||
// 跳转到登录页
|
||||
window.location.href = '/admin/login.html';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
checkLogin() {
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token) {
|
||||
// 未登录,跳转到登录页
|
||||
window.location.href = '/admin/login.html';
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 检查登录状态
|
||||
this.checkLogin();
|
||||
// 加载用户信息
|
||||
this.loadUserInfo();
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
497
src/main/resources/static/admin/login.html
Normal file
497
src/main/resources/static/admin/login.html
Normal file
@@ -0,0 +1,497 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>后台管理系统 - 登录</title>
|
||||
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap Icons -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #5B5FDE;
|
||||
--secondary-color: #0EA5E9;
|
||||
--accent-color: #FF6B6B;
|
||||
--error-color: #F43F5E;
|
||||
--success-color: #10B981;
|
||||
--warning-color: #F59E0B;
|
||||
--info-color: #3B82F6;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(135deg, #5B5FDE 0%, #0EA5E9 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
padding: 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 背景装饰圆圈 */
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
top: -200px;
|
||||
right: -200px;
|
||||
animation: float 6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
body::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 50%;
|
||||
bottom: -100px;
|
||||
left: -100px;
|
||||
animation: float 8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0%, 100% { transform: translateY(0px) rotate(0deg); }
|
||||
50% { transform: translateY(-20px) rotate(5deg); }
|
||||
}
|
||||
|
||||
.login-container {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
max-width: 1800px;
|
||||
display: flex;
|
||||
background: white;
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 左侧装饰区域 */
|
||||
.login-decoration {
|
||||
flex: 0.9;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
padding: 60px 50px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: white;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.login-decoration::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 50%;
|
||||
top: -80px;
|
||||
left: -80px;
|
||||
}
|
||||
|
||||
.login-decoration::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 50%;
|
||||
bottom: -60px;
|
||||
right: -60px;
|
||||
}
|
||||
|
||||
.decoration-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.decoration-icon {
|
||||
font-size: 140px;
|
||||
margin-bottom: 40px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
.decoration-content h2 {
|
||||
font-size: 42px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 20px;
|
||||
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.decoration-content p {
|
||||
font-size: 18px;
|
||||
opacity: 0.95;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 右侧表单区域 */
|
||||
.login-form-section {
|
||||
flex: 1.3;
|
||||
padding: 60px 120px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.form-header {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.form-header h3 {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #1F2937;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.form-header p {
|
||||
color: #6B7280;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
position: absolute;
|
||||
left: 18px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--primary-color);
|
||||
font-size: 20px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 16px 18px 16px 52px;
|
||||
border: 2px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
font-size: 16px;
|
||||
transition: all 0.3s;
|
||||
background-color: #F9FAFB;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary-color);
|
||||
background-color: white;
|
||||
box-shadow: 0 0 0 4px rgba(91, 95, 222, 0.1);
|
||||
}
|
||||
|
||||
.form-control::placeholder {
|
||||
color: #9CA3AF;
|
||||
}
|
||||
|
||||
.btn-login {
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
color: white;
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
box-shadow: 0 4px 15px rgba(91, 95, 222, 0.3);
|
||||
}
|
||||
|
||||
.btn-login:hover:not(:disabled) {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px rgba(91, 95, 222, 0.4);
|
||||
}
|
||||
|
||||
.btn-login:active:not(:disabled) {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.btn-login:disabled {
|
||||
opacity: 0.7;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 14px 18px;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
animation: slideDown 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background-color: #D1FAE5;
|
||||
color: var(--success-color);
|
||||
border: 1px solid var(--success-color);
|
||||
}
|
||||
|
||||
.alert-danger {
|
||||
background-color: #FEE2E2;
|
||||
color: var(--error-color);
|
||||
border: 1px solid var(--error-color);
|
||||
}
|
||||
|
||||
.alert i {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.login-footer {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #E5E7EB;
|
||||
}
|
||||
|
||||
.login-footer small {
|
||||
color: #6B7280;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.spinner-border {
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.login-decoration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
.login-form-section {
|
||||
padding: 40px 30px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="login-container">
|
||||
<!-- 左侧装饰区域 -->
|
||||
<div class="login-decoration">
|
||||
<div class="decoration-content">
|
||||
<div class="decoration-icon">
|
||||
<i class="bi bi-shield-lock-fill"></i>
|
||||
</div>
|
||||
<h2>CoreWing</h2>
|
||||
<p>后台管理系统</p>
|
||||
<p style="margin-top: 20px; opacity: 0.85;">
|
||||
安全 · 高效 · 智能
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧表单区域 -->
|
||||
<div class="login-form-section">
|
||||
<div class="form-header">
|
||||
<h3>欢迎回来</h3>
|
||||
<p>请登录您的账号以继续</p>
|
||||
</div>
|
||||
|
||||
<!-- 提示消息 -->
|
||||
<div v-if="message.text" :class="'alert alert-' + message.type" role="alert">
|
||||
<i :class="'bi bi-' + (message.type === 'success' ? 'check-circle-fill' : 'exclamation-circle-fill')"></i>
|
||||
<span>{{ message.text }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<form @submit.prevent="handleLogin">
|
||||
<div class="form-group">
|
||||
<label class="form-label">用户名</label>
|
||||
<div class="input-wrapper">
|
||||
<i class="bi bi-person-fill input-icon"></i>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="loginForm.username"
|
||||
placeholder="请输入用户名"
|
||||
required
|
||||
autocomplete="username">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label">密码</label>
|
||||
<div class="input-wrapper">
|
||||
<i class="bi bi-lock-fill input-icon"></i>
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="loginForm.password"
|
||||
placeholder="请输入密码"
|
||||
required
|
||||
autocomplete="current-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn-login"
|
||||
:disabled="loading">
|
||||
<span v-if="loading">
|
||||
<span class="spinner-border spinner-border-sm" role="status" style="margin-right: 8px;"></span>
|
||||
登录中...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="bi bi-box-arrow-in-right" style="margin-right: 8px;"></i>
|
||||
登录
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="login-footer">
|
||||
<small>默认管理员账号:admin / admin123</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Vue 3 -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js"></script>
|
||||
|
||||
<!-- Axios -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@1.4.0/dist/axios.min.js"></script>
|
||||
|
||||
<!-- Bootstrap 5 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
loginForm: {
|
||||
username: '',
|
||||
password: ''
|
||||
},
|
||||
loading: false,
|
||||
message: {
|
||||
text: '',
|
||||
type: 'success' // success, danger
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async handleLogin() {
|
||||
// 表单验证
|
||||
if (!this.loginForm.username || !this.loginForm.password) {
|
||||
this.showMessage('请填写完整的登录信息', 'danger');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
this.message.text = '';
|
||||
|
||||
try {
|
||||
const response = await axios.post('/sys/user/login', this.loginForm);
|
||||
|
||||
if (response.data.code === 200) {
|
||||
// 登录成功
|
||||
this.showMessage('登录成功,正在跳转...', 'success');
|
||||
|
||||
// 保存 token 和用户信息
|
||||
localStorage.setItem('token', response.data.data.token);
|
||||
localStorage.setItem('userId', response.data.data.userId);
|
||||
localStorage.setItem('username', response.data.data.username);
|
||||
localStorage.setItem('realName', response.data.data.realName || '');
|
||||
|
||||
// 2秒后跳转到主页
|
||||
setTimeout(() => {
|
||||
window.location.href = '/admin/index.html';
|
||||
}, 2000);
|
||||
} else {
|
||||
// 登录失败
|
||||
this.showMessage(response.data.message || '登录失败', 'danger');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('登录错误:', error);
|
||||
this.showMessage(
|
||||
error.response?.data?.message || '登录失败,请稍后重试',
|
||||
'danger'
|
||||
);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
showMessage(text, type) {
|
||||
this.message.text = text;
|
||||
this.message.type = type;
|
||||
|
||||
// 3秒后自动清除消息(错误消息)
|
||||
if (type === 'danger') {
|
||||
setTimeout(() => {
|
||||
this.message.text = '';
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 检查是否已登录
|
||||
const token = localStorage.getItem('token');
|
||||
if (token) {
|
||||
// 如果已有 token,尝试跳转到主页
|
||||
// window.location.href = '/admin/index.html';
|
||||
}
|
||||
}
|
||||
}).mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,93 @@
|
||||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>CoreWing - 后台管理系统</title>
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #5B5FDE;
|
||||
--secondary-color: #0EA5E9;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 72px;
|
||||
margin-bottom: 20px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 48px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 18px;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.3);
|
||||
border-top-color: white;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// 自动跳转到后台登录页面
|
||||
window.location.href = '/admin/login.html';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>hello word!!!</h1>
|
||||
<p>this is a html page</p>
|
||||
<div class="container">
|
||||
<div class="logo">🚀</div>
|
||||
<h1>CoreWing</h1>
|
||||
<p>后台管理系统</p>
|
||||
<div class="loading">
|
||||
<div class="spinner"></div>
|
||||
<span>正在跳转...</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user