CDK_Change/templates/db_config.html

148 lines
9.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数据库配置 - CDK兑换系统</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="{{ url_for('static', filename='css/particle-bg.css') }}" rel="stylesheet">
</head>
<body>
<!-- Particles.js container -->
<div id="particles-js"></div>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h2>AzerothCore 数据库配置</h2>
<div>
<a href="{{ url_for('admin_dashboard') }}" class="btn btn-outline-primary btn-sm">返回仪表盘</a>
</div>
</div>
<div class="card-body">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }} mt-3" role="alert">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<form method="post" action="{{ url_for('db_config') }}" id="dbConfigForm">
<div class="row">
<div class="col-md-6">
<div class="card mb-4">
<div class="card-header">
<h4>账号数据库配置 (Auth DB)</h4>
</div>
<div class="card-body">
<div class="mb-3">
<label for="auth_host" class="form-label">主机地址</label>
<input type="text" class="form-control" id="auth_host" name="auth_host" value="{{ configs.get('auth_host', '127.0.0.1') }}" required>
</div>
<div class="mb-3">
<label for="auth_port" class="form-label">端口</label>
<input type="text" class="form-control" id="auth_port" name="auth_port" value="{{ configs.get('auth_port', '3306') }}" required>
</div>
<div class="mb-3">
<label for="auth_user" class="form-label">用户名</label>
<input type="text" class="form-control" id="auth_user" name="auth_user" value="{{ configs.get('auth_user', 'acore') }}" required>
</div>
<div class="mb-3">
<label for="auth_pass" class="form-label">密码</label>
<input type="password" class="form-control" id="auth_pass" name="auth_pass" value="{{ configs.get('auth_pass', '') }}" required>
</div>
<div class="mb-3">
<label for="auth_db" class="form-label">数据库名</label>
<input type="text" class="form-control" id="auth_db" name="auth_db" value="{{ configs.get('auth_db', 'acore_auth') }}" required>
</div>
<div class="mb-3">
<label for="auth_account_table" class="form-label">账号表名</label>
<input type="text" class="form-control" id="auth_account_table" name="auth_account_table" value="{{ configs.get('auth_account_table', 'account') }}" required>
</div>
<div class="text-center">
<button type="button" class="btn btn-info" onclick="testConnection('auth')">测试连接</button>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card mb-4">
<div class="card-header">
<h4>角色数据库配置 (Characters DB)</h4>
</div>
<div class="card-body">
<div class="mb-3">
<label for="char_host" class="form-label">主机地址</label>
<input type="text" class="form-control" id="char_host" name="char_host" value="{{ configs.get('char_host', '127.0.0.1') }}" required>
</div>
<div class="mb-3">
<label for="char_port" class="form-label">端口</label>
<input type="text" class="form-control" id="char_port" name="char_port" value="{{ configs.get('char_port', '3306') }}" required>
</div>
<div class="mb-3">
<label for="char_user" class="form-label">用户名</label>
<input type="text" class="form-control" id="char_user" name="char_user" value="{{ configs.get('char_user', 'acore') }}" required>
</div>
<div class="mb-3">
<label for="char_pass" class="form-label">密码</label>
<input type="password" class="form-control" id="char_pass" name="char_pass" value="{{ configs.get('char_pass', '') }}" required>
</div>
<div class="mb-3">
<label for="char_db" class="form-label">数据库名</label>
<input type="text" class="form-control" id="char_db" name="char_db" value="{{ configs.get('char_db', 'acore_characters') }}" required>
</div>
<div class="mb-3">
<label for="char_table" class="form-label">角色表名</label>
<input type="text" class="form-control" id="char_table" name="char_table" value="{{ configs.get('char_table', 'characters') }}" required>
</div>
<div class="text-center">
<button type="button" class="btn btn-info" onclick="testConnection('char')">测试连接</button>
</div>
</div>
</div>
</div>
</div>
<div class="text-center mt-3">
<button type="submit" class="btn btn-primary">保存配置</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script src="{{ url_for('static', filename='js/particles-config.js') }}"></script>
<script src="{{ url_for('static', filename='js/cursor-effects.js') }}"></script>
<script>
function testConnection(type) {
const form = document.getElementById('dbConfigForm');
const formData = new FormData(form);
formData.append('type', type);
fetch('{{ url_for("test_connection") }}', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('连接成功: ' + data.message);
} else {
alert('连接失败: ' + data.message);
}
})
.catch(error => {
alert('请求错误: ' + error);
});
}
</script>
</body>
</html>