- 创建 SVG 格式 favicon(蓝色文档+翻译箭头+中文标记) - 在所有前台页面添加 favicon:index, login, register, history, pricing, translation - 在所有后台管理页面添加 favicon
156 lines
8.3 KiB
HTML
156 lines
8.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>用户权限配置 - 后台管理</title>
|
|
<link rel="icon" href="/static/img/favicon.svg" type="image/svg+xml">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
|
|
<style>
|
|
body { background-color: #f5f5f5; }
|
|
.sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 250px; background: #343a40; padding-top: 60px; }
|
|
.sidebar .nav-link { color: #adb5bd; padding: 12px 20px; }
|
|
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,0.1); }
|
|
.main-content { margin-left: 250px; padding: 20px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav class="sidebar">
|
|
<div class="position-absolute top-0 w-100 p-3 border-bottom border-secondary">
|
|
<h5 class="text-white mb-0"><i class="bi bi-gear-fill"></i> 后台管理</h5>
|
|
</div>
|
|
<ul class="nav flex-column">
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.dashboard') }}"><i class="bi bi-speedometer2"></i> 数据概览</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.users') }}"><i class="bi bi-people"></i> 用户管理</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.translations') }}"><i class="bi bi-file-text"></i> 翻译记录</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.cache_list') }}"><i class="bi bi-database"></i> 缓存管理</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.packages') }}"><i class="bi bi-box-seam"></i> 数据包套餐</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.stats') }}"><i class="bi bi-bar-chart"></i> 统计报表</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.logs') }}"><i class="bi bi-list-check"></i> 操作日志</a></li>
|
|
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.llm_config') }}"><i class="bi bi-cpu"></i> 大模型配置</a></li>
|
|
<li class="nav-item"><a class="nav-link active" href="{{ url_for('admin.settings') }}"><i class="bi bi-sliders"></i> 系统配置</a></li>
|
|
</ul>
|
|
<div class="position-absolute bottom-0 w-100 p-3 border-top border-secondary">
|
|
<a href="/" class="btn btn-outline-light btn-sm w-100"><i class="bi bi-house"></i> 返回前台</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="main-content">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h4><i class="bi bi-sliders"></i> 用户权限配置</h4>
|
|
<div>
|
|
<a href="{{ url_for('admin.membership_settings') }}" class="btn btn-outline-primary">
|
|
<i class="bi bi-credit-card"></i> 会员套餐配置
|
|
</a>
|
|
<a href="{{ url_for('admin.settings') }}" class="btn btn-outline-secondary">
|
|
<i class="bi bi-gear"></i> 基础设置
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<form id="limitsForm">
|
|
<div class="row">
|
|
{% for user_type, limits in limits_config.items() %}
|
|
<div class="col-md-4 mb-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h6 class="mb-0">
|
|
{% if user_type == 'guest' %}👤 访客
|
|
{% elif user_type == 'free' %}🆓 免费用户
|
|
{% elif user_type == 'vip_basic' %}⭐ 基础会员
|
|
{% elif user_type == 'vip_pro' %}⭐⭐ 专业会员
|
|
{% elif user_type == 'vip_enterprise' %}👑 企业会员
|
|
{% endif %}
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">每日翻译次数</label>
|
|
<input type="number" class="form-control" name="{{ user_type }}_daily_translations"
|
|
value="{{ limits.daily_translations }}">
|
|
<small class="text-muted">输入 0 表示无限制</small>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">单文件最大页数</label>
|
|
<input type="number" class="form-control" name="{{ user_type }}_max_pages"
|
|
value="{{ limits.max_pages }}">
|
|
<small class="text-muted">输入 0 表示无限制</small>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label class="form-label">最大文件大小 (MB)</label>
|
|
<input type="number" class="form-control" name="{{ user_type }}_max_file_size"
|
|
value="{{ limits.max_file_size / 1024 / 1024 | round(0) }}">
|
|
</div>
|
|
|
|
<div class="text-muted small">
|
|
<strong>默认值:</strong><br>
|
|
次数: {{ default_limits.get(user_type, {}).get('daily_translations', 'N/A') }}<br>
|
|
页数: {{ default_limits.get(user_type, {}).get('max_pages', 'N/A') }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="bi bi-check-circle"></i> 保存配置
|
|
</button>
|
|
<button type="button" class="btn btn-outline-secondary" onclick="resetDefaults()">
|
|
<i class="bi bi-arrow-counterclockwise"></i> 恢复默认
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</main>
|
|
|
|
<script>
|
|
const defaultLimits = {{ default_limits | tojson }};
|
|
|
|
document.getElementById('limitsForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(this);
|
|
const data = {};
|
|
|
|
{% for user_type in limits_config.keys() %}
|
|
data['{{ user_type }}'] = {
|
|
daily_translations: parseInt(formData.get('{{ user_type }}_daily_translations')),
|
|
max_pages: parseInt(formData.get('{{ user_type }}_max_pages')),
|
|
max_file_size: parseInt(formData.get('{{ user_type }}_max_file_size')) * 1024 * 1024
|
|
};
|
|
{% endfor %}
|
|
|
|
fetch('/admin/settings/user-limits', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify(data)
|
|
})
|
|
.then(r => r.json())
|
|
.then(result => {
|
|
if (result.success) {
|
|
alert('配置已保存');
|
|
} else {
|
|
alert('保存失败: ' + result.error);
|
|
}
|
|
});
|
|
});
|
|
|
|
function resetDefaults() {
|
|
if (!confirm('确定恢复为默认配置?')) return;
|
|
|
|
for (const [type, limits] of Object.entries(defaultLimits)) {
|
|
const dailyInput = document.querySelector(`[name="${type}_daily_translations"]`);
|
|
const pagesInput = document.querySelector(`[name="${type}_max_pages"]`);
|
|
const sizeInput = document.querySelector(`[name="${type}_max_file_size"]`);
|
|
|
|
if (dailyInput) dailyInput.value = limits.daily_translations;
|
|
if (pagesInput) pagesInput.value = limits.max_pages;
|
|
if (sizeInput) sizeInput.value = limits.max_file_size / 1024 / 1024;
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |