File size: 9,639 Bytes
bab9c3b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}管理页面{% endblock %}</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/javascript/javascript.min.js"></script>
<link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='favicon.png') }}">
{% block extra_css %}{% endblock %}
</head>
<body class="bg-gray-100 min-h-screen flex flex-col">
<!-- 顶部导航栏 -->
<nav class="bg-white shadow-lg">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between h-16">
<!-- 左侧 Logo 和导航链接 -->
<div class="flex">
<div class="flex-shrink-0 flex items-center">
<span class="text-xl font-bold text-gray-800">后台管理</span>
</div>
<!-- 导航链接 -->
<div class="hidden md:ml-6 md:flex md:space-x-4">
{% if session.get('role') == 'admin' %}
<a href="{{ url_for('chatgpt') }}"
class="{% if request.endpoint == 'chatgpt' %}bg-gray-900 text-white{% else %}text-gray-900 hover:bg-gray-700 hover:text-white{% endif %} px-3 py-2 rounded-md text-sm font-medium flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20"
fill="currentColor">
<path
d="M10.394 2.08a1 1 0 00-.788 0l-7 3a1 1 0 000 1.84L5.25 8.051a.999.999 0 01.356-.257l4-1.714a1 1 0 11.788 1.838L7.667 9.088l1.94.831a1 1 0 00.787 0l7-3a1 1 0 000-1.838l-7-3zM3.31 9.397L5 10.12v4.102a8.969 8.969 0 00-1.05-.174 1 1 0 01-.89-.89 11.115 11.115 0 01.25-3.762zM9.3 16.573A9.026 9.026 0 007 14.935v-3.957l1.818.78a3 3 0 002.364 0l5.508-2.361a11.026 11.026 0 01.25 3.762 1 1 0 01-.89.89 8.968 8.968 0 00-5.35 2.524 1 1 0 01-1.4 0zM6 18a1 1 0 001-1v-2.065a8.935 8.935 0 00-2-.712V17a1 1 0 001 1z" />
</svg>
ChatGPT
</a>
<a href="{{ url_for('claude') }}"
class="{% if request.endpoint == 'claude' %}bg-gray-900 text-white{% else %}text-gray-900 hover:bg-gray-700 hover:text-white{% endif %} px-3 py-2 rounded-md text-sm font-medium flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20"
fill="currentColor">
<path
d="M10.394 2.08a1 1 0 00-.788 0l-7 3a1 1 0 000 1.84L5.25 8.051a.999.999 0 01.356-.257l4-1.714a1 1 0 11.788 1.838L7.667 9.088l1.94.831a1 1 0 00.787 0l7-3a1 1 0 000-1.838l-7-3zM3.31 9.397L5 10.12v4.102a8.969 8.969 0 00-1.05-.174 1 1 0 01-.89-.89 11.115 11.115 0 01.25-3.762zM9.3 16.573A9.026 9.026 0 007 14.935v-3.957l1.818.78a3 3 0 002.364 0l5.508-2.361a11.026 11.026 0 01.25 3.762 1 1 0 01-.89.89 8.968 8.968 0 00-5.35 2.524 1 1 0 01-1.4 0zM6 18a1 1 0 001-1v-2.065a8.935 8.935 0 00-2-.712V17a1 1 0 001 1z" />
</svg>
Claude
</a>
<a href="{{ url_for('user_management') }}"
class="{% if request.endpoint == 'user_management' %}bg-gray-900 text-white{% else %}text-gray-900 hover:bg-gray-700 hover:text-white{% endif %} px-3 py-2 rounded-md text-sm font-medium flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20"
fill="currentColor">
<path
d="M9 6a3 3 0 11-6 0 3 3 0 016 0zM17 6a3 3 0 11-6 0 3 3 0 016 0zM12.93 17c.046-.327.07-.66.07-1a6.97 6.97 0 00-1.5-4.33A5 5 0 0119 16v1h-6.07zM6 11a5 5 0 015 5v1H1v-1a5 5 0 015-5z" />
</svg>
用户管理
</a>
{% endif %}
</div>
</div>
<!-- 右侧用户信息和退出按钮 -->
<div class="flex items-center">
{% if session.get('logged_in') %}
<div class="flex items-center">
<span class="text-gray-700 mr-4">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 inline-block mr-1"
viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-6-3a2 2 0 11-4 0 2 2 0 014 0zm-2 4a5 5 0 00-4.546 2.916A5.986 5.986 0 0010 16a5.986 5.986 0 004.546-2.084A5 5 0 0010 11z"
clip-rule="evenodd" />
</svg>
{{ session.get('username') }}
{% if session.get('role') == 'admin' %}
<span
class="bg-blue-100 text-blue-800 text-xs font-medium mr-2 px-2 py-0.5 rounded">管理员</span>
{% endif %}
</span>
<a href="{{ url_for('logout') }}"
class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20"
fill="currentColor">
<path fill-rule="evenodd"
d="M3 3a1 1 0 011 1v12a1 1 0 11-2 0V4a1 1 0 011-1zm7.707 3.293a1 1 0 010 1.414L9.414 9H17a1 1 0 110 2H9.414l1.293 1.293a1 1 0 01-1.414 1.414l-3-3a1 1 0 010-1.414l3-3a1 1 0 011.414 0z"
clip-rule="evenodd" />
</svg>
退出
</a>
</div>
{% endif %}
</div>
</div>
</div>
<!-- 移动端菜单按钮 -->
<div class="md:hidden">
<button type="button"
class="mobile-menu-button inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500"
aria-expanded="false">
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</div>
</nav>
<!-- 移动端导航菜单 -->
<div class="mobile-menu hidden md:hidden">
<div class="px-2 pt-2 pb-3 space-y-1">
{% if session.get('role') == 'admin' %}
<a href="{{ url_for('chatgpt') }}"
class="{% if request.endpoint == 'chatgpt' %}bg-gray-900 text-white{% else %}text-gray-900 hover:bg-gray-700 hover:text-white{% endif %} block px-3 py-2 rounded-md text-base font-medium">
ChatGPT
</a>
<a href="{{ url_for('claude') }}"
class="{% if request.endpoint == 'claude' %}bg-gray-900 text-white{% else %}text-gray-900 hover:bg-gray-700 hover:text-white{% endif %} block px-3 py-2 rounded-md text-base font-medium">
Claude
</a>
<a href="{{ url_for('user_management') }}"
class="{% if request.endpoint == 'user_management' %}bg-gray-900 text-white{% else %}text-gray-900 hover:bg-gray-700 hover:text-white{% endif %} block px-3 py-2 rounded-md text-base font-medium">
用户管理
</a>
{% endif %}
</div>
</div>
<!-- 主要内容区域 -->
<main class="flex-grow container mx-auto px-4 py-8">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="mb-4 p-4 rounded
{% if category == 'success' %}bg-green-100 text-green-700
{% elif category == 'danger' %}bg-red-100 text-red-700
{% else %}bg-blue-100 text-blue-700{% endif %}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</main>
{% block extra_js %}{% endblock %}
<script>
// 移动端菜单切换
document.querySelector('.mobile-menu-button').addEventListener('click', function () {
document.querySelector('.mobile-menu').classList.toggle('hidden');
});
</script>
</body>
</html> |