add
This commit is contained in:
@@ -1,189 +0,0 @@
|
||||
<!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="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
<!-- 引入自定义配置和组件 -->
|
||||
<script src="../assets/js/config/system.js"></script>
|
||||
<script src="../assets/js/config/menu.js"></script>
|
||||
<script src="../assets/js/core/auth.js"></script>
|
||||
<script src="../assets/js/core/message.js"></script>
|
||||
<script src="../assets/js/core/loading.js"></script>
|
||||
<script src="../assets/js/components/sidebar.js"></script>
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../assets/css/dark-theme.css">
|
||||
<link rel="stylesheet" href="../assets/css/common.css">
|
||||
<style>
|
||||
.app-container {
|
||||
display: flex;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
.header {
|
||||
height: 60px;
|
||||
background-color: var(--bg-light-color);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 20px;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
}
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.logo-icon {
|
||||
font-size: 24px;
|
||||
color: var(--primary-color);
|
||||
margin-right: 10px;
|
||||
}
|
||||
.logo-text {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.username {
|
||||
margin-right: 15px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.logout-btn {
|
||||
background-color: var(--error-color);
|
||||
}
|
||||
.logout-btn:hover {
|
||||
background-color: #D32F2F;
|
||||
}
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
.main-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.page-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="dark-theme">
|
||||
<div class="app-container">
|
||||
<!-- 侧边栏 -->
|
||||
<div class="sidebar" id="sidebar"></div>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<div class="content-wrapper">
|
||||
<!-- 顶部导航 -->
|
||||
<div class="header">
|
||||
<div class="logo">
|
||||
<span class="logo-icon">💎</span>
|
||||
<span class="logo-text">资产管理系统</span>
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<span class="username" id="username">管理员</span>
|
||||
<button class="btn logout-btn" id="logout-btn">退出登录</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 页面内容容器 -->
|
||||
<div class="main-content">
|
||||
<div class="page-container" id="page-container">
|
||||
<!-- 页面内容将通过路由加载 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 初始化前验证登录状态
|
||||
Auth.checkLogin();
|
||||
|
||||
$(document).ready(() => {
|
||||
// 初始化侧边栏
|
||||
Sidebar.init($('#sidebar'));
|
||||
|
||||
// 初始化页面加载(默认加载数据概览)
|
||||
const defaultUrl = 'modules/dashboard.html';
|
||||
loadPage(defaultUrl);
|
||||
|
||||
// 退出登录事件
|
||||
$('#logout-btn').on('click', () => {
|
||||
if (confirm('确定要退出登录吗?')) {
|
||||
Auth.logout();
|
||||
}
|
||||
});
|
||||
|
||||
// 菜单链接点击事件(拦截默认跳转,实现AJAX加载)
|
||||
$('#sidebar').on('click', '.menu-link', (e) => {
|
||||
e.preventDefault();
|
||||
const url = $(e.currentTarget).attr('href');
|
||||
if (url) {
|
||||
loadPage(url);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 加载页面内容
|
||||
* @param {string} url - 页面URL
|
||||
*/
|
||||
function loadPage(url) {
|
||||
const container = $('#page-container');
|
||||
|
||||
try {
|
||||
Loading.show('加载页面中...');
|
||||
|
||||
// 加载页面内容
|
||||
container.load(url, (response, status, xhr) => {
|
||||
Loading.hide();
|
||||
|
||||
if (status === 'success') {
|
||||
// 更新浏览器历史记录
|
||||
history.pushState({ url }, '', url);
|
||||
Message.success('页面加载成功');
|
||||
} else {
|
||||
// 错误处理和重试
|
||||
container.html(`
|
||||
<div class="error-page card">
|
||||
<h3 style="color: var(--error-color); margin-bottom: 15px;">页面加载失败</h3>
|
||||
<p>错误信息: ${xhr.statusText}</p>
|
||||
<button class="btn btn-info" id="retry-btn" data-url="${url}">重试</button>
|
||||
</div>
|
||||
`);
|
||||
Message.error(`页面加载失败: ${xhr.statusText}`);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
Loading.hide();
|
||||
Message.error('页面加载异常,请重试');
|
||||
console.error('页面加载错误:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 重试按钮事件
|
||||
$(document).on('click', '#retry-btn', (e) => {
|
||||
const url = $(e.currentTarget).data('url');
|
||||
loadPage(url);
|
||||
});
|
||||
|
||||
// 监听浏览器前进后退事件
|
||||
window.addEventListener('popstate', (e) => {
|
||||
if (e.state && e.state.url) {
|
||||
loadPage(e.state.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,117 +0,0 @@
|
||||
<!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="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
<!-- 引入自定义配置和组件 -->
|
||||
<script src="../assets/js/config/system.js"></script>
|
||||
<script src="../assets/js/core/auth.js"></script>
|
||||
<script src="../assets/js/core/message.js"></script>
|
||||
<script src="../assets/js/core/loading.js"></script>
|
||||
<!-- 新增:引入Loading组件 -->
|
||||
<script src="../assets/js/components/loading.js"></script>
|
||||
<!-- 引入样式 -->
|
||||
<link rel="stylesheet" href="../assets/css/dark-theme.css">
|
||||
<link rel="stylesheet" href="../assets/css/common.css">
|
||||
<style>
|
||||
.login-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
background-color: var(--bg-light-color);
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
|
||||
padding: 30px;
|
||||
}
|
||||
.login-header {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.login-title {
|
||||
font-size: 24px;
|
||||
color: var(--primary-color);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.login-desc {
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.login-btn {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
font-size: 16px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="dark-theme">
|
||||
<div class="login-container">
|
||||
<div class="login-card">
|
||||
<div class="login-header">
|
||||
<h2 class="login-title">资产管理系统</h2>
|
||||
<p class="login-desc">金融资产一站式管理平台</p>
|
||||
</div>
|
||||
<form id="login-form">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="username">用户名</label>
|
||||
<input type="text" id="username" class="input" placeholder="请输入用户名" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="password">密码</label>
|
||||
<input type="password" id="password" class="input" placeholder="请输入密码" required>
|
||||
</div>
|
||||
<button type="submit" class="btn login-btn">登录</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 等待DOM完全加载后再执行
|
||||
$(document).ready(() => {
|
||||
// 登录表单提交事件
|
||||
$('#login-form').on('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const username = $('#username').val().trim();
|
||||
const password = $('#password').val().trim();
|
||||
|
||||
if (!username || !password) {
|
||||
Message.error('账号和密码不能为空');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Loading.show('正在登录...');
|
||||
const result = await Auth.login(username, password);
|
||||
Message.success(result.message);
|
||||
setTimeout(() => {
|
||||
window.location.href = 'index.html';
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
Message.error(error.message || '登录失败,请重试');
|
||||
} finally {
|
||||
Loading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user