| <!DOCTYPE html>
|
| <html lang="zh-CN">
|
| <head>
|
| <meta charset="UTF-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| <title>{{ .title }}</title>
|
| <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
|
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
| <link rel="stylesheet" href="/static/css/styles.css">
|
| <style>
|
| :root {
|
| --sidebar-width: 240px;
|
| --header-height: 64px;
|
| --primary-color: #4285f4;
|
| --secondary-color: #34a853;
|
| --danger-color: #ea4335;
|
| --warning-color: #fbbc05;
|
| --dark-bg: #202124;
|
| --light-bg: #f8f9fa;
|
| --card-bg: #ffffff;
|
| --border-color: #dadce0;
|
| }
|
|
|
| body {
|
| font-family: 'Roboto', sans-serif;
|
| margin: 0;
|
| padding: 0;
|
| background-color: var(--light-bg);
|
| color: #202124;
|
| display: flex;
|
| min-height: 100vh;
|
| }
|
|
|
|
|
| .sidebar {
|
| width: var(--sidebar-width);
|
| background: var(--dark-bg);
|
| color: white;
|
| position: fixed;
|
| height: 100vh;
|
| left: 0;
|
| top: 0;
|
| z-index: 100;
|
| box-shadow: 2px 0 10px rgba(0,0,0,0.1);
|
| transition: all 0.3s ease;
|
| }
|
|
|
| .sidebar-header {
|
| height: var(--header-height);
|
| display: flex;
|
| align-items: center;
|
| padding: 0 20px;
|
| border-bottom: 1px solid rgba(255,255,255,0.1);
|
| }
|
|
|
| .sidebar-logo {
|
| font-size: 1.5rem;
|
| font-weight: 700;
|
| color: white;
|
| display: flex;
|
| align-items: center;
|
| gap: 10px;
|
| }
|
|
|
| .sidebar-logo i {
|
| color: var(--primary-color);
|
| }
|
|
|
| .sidebar-menu {
|
| padding: 20px 0;
|
| }
|
|
|
| .menu-item {
|
| padding: 12px 20px;
|
| display: flex;
|
| align-items: center;
|
| gap: 12px;
|
| color: rgba(255,255,255,0.8);
|
| text-decoration: none;
|
| transition: all 0.2s ease;
|
| border-left: 3px solid transparent;
|
| }
|
|
|
| .menu-item:hover {
|
| background: rgba(255,255,255,0.05);
|
| color: white;
|
| }
|
|
|
| .menu-item.active {
|
| background: rgba(66, 133, 244, 0.1);
|
| color: var(--primary-color);
|
| border-left: 3px solid var(--primary-color);
|
| }
|
|
|
| .menu-item i {
|
| font-size: 1.2rem;
|
| width: 24px;
|
| text-align: center;
|
| }
|
|
|
|
|
| .main-content {
|
| flex: 1;
|
| margin-left: var(--sidebar-width);
|
| padding: 20px;
|
| transition: all 0.3s ease;
|
| }
|
|
|
| .header {
|
| height: var(--header-height);
|
| display: flex;
|
| align-items: center;
|
| justify-content: space-between;
|
| padding: 0 20px;
|
| margin-bottom: 20px;
|
| }
|
|
|
| .page-title {
|
| font-size: 1.8rem;
|
| font-weight: 500;
|
| color: var(--dark-bg);
|
| margin: 0;
|
| }
|
|
|
| .header-actions {
|
| display: flex;
|
| gap: 10px;
|
| }
|
|
|
|
|
| .dashboard {
|
| display: grid;
|
| grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
| gap: 20px;
|
| margin-bottom: 30px;
|
| }
|
|
|
| .stat-card {
|
| background: var(--card-bg);
|
| border-radius: 10px;
|
| padding: 20px;
|
| box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
| transition: all 0.3s ease;
|
| display: flex;
|
| flex-direction: column;
|
| position: relative;
|
| overflow: hidden;
|
| }
|
|
|
| .stat-card:hover {
|
| transform: translateY(-5px);
|
| box-shadow: 0 8px 25px rgba(0,0,0,0.1);
|
| }
|
|
|
| .stat-card::before {
|
| content: '';
|
| position: absolute;
|
| top: 0;
|
| left: 0;
|
| width: 5px;
|
| height: 100%;
|
| background: var(--primary-color);
|
| }
|
|
|
| .stat-card.api-card::before {
|
| background: var(--secondary-color);
|
| }
|
|
|
| .stat-card.security-card::before {
|
| background: var(--danger-color);
|
| }
|
|
|
| .stat-icon {
|
| font-size: 2rem;
|
| margin-bottom: 15px;
|
| color: var(--primary-color);
|
| }
|
|
|
| .api-card .stat-icon {
|
| color: var(--secondary-color);
|
| }
|
|
|
| .security-card .stat-icon {
|
| color: var(--danger-color);
|
| }
|
|
|
| .stat-title {
|
| font-size: 1.1rem;
|
| font-weight: 500;
|
| margin-bottom: 5px;
|
| }
|
|
|
| .stat-value {
|
| font-size: 2rem;
|
| font-weight: 700;
|
| margin-bottom: 10px;
|
| }
|
|
|
| .stat-actions {
|
| margin-top: auto;
|
| display: flex;
|
| gap: 10px;
|
| }
|
|
|
|
|
| .content-card {
|
| background: var(--card-bg);
|
| border-radius: 10px;
|
| box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
| overflow: hidden;
|
| margin-bottom: 30px;
|
| animation: fadeIn 0.5s ease-out;
|
| }
|
|
|
| .card-header {
|
| padding: 15px 20px;
|
| background: var(--primary-color);
|
| color: white;
|
| display: flex;
|
| align-items: center;
|
| justify-content: space-between;
|
| }
|
|
|
| .card-header h2 {
|
| margin: 0;
|
| font-size: 1.3rem;
|
| font-weight: 500;
|
| }
|
|
|
| .card-header-actions {
|
| display: flex;
|
| gap: 10px;
|
| }
|
|
|
| .card-body {
|
| padding: 20px;
|
| }
|
|
|
| .data-table {
|
| width: 100%;
|
| border-collapse: collapse;
|
| }
|
|
|
| .data-table th {
|
| text-align: left;
|
| padding: 12px 15px;
|
| background: rgba(66, 133, 244, 0.05);
|
| border-bottom: 2px solid var(--primary-color);
|
| font-weight: 500;
|
| color: var(--dark-bg);
|
| }
|
|
|
| .data-table td {
|
| padding: 12px 15px;
|
| border-bottom: 1px solid var(--border-color);
|
| }
|
|
|
| .data-table tr:last-child td {
|
| border-bottom: none;
|
| }
|
|
|
| .data-table tr {
|
| transition: all 0.2s ease;
|
| }
|
|
|
| .data-table tr:hover {
|
| background: rgba(66, 133, 244, 0.05);
|
| }
|
|
|
| .token-cell {
|
| max-width: 200px;
|
| overflow: hidden;
|
| text-overflow: ellipsis;
|
| white-space: nowrap;
|
| font-family: 'Courier New', monospace;
|
| }
|
|
|
| .actions-cell {
|
| width: 100px;
|
| }
|
|
|
|
|
| .form-card {
|
| background: var(--card-bg);
|
| border-radius: 10px;
|
| box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
| overflow: hidden;
|
| margin-bottom: 30px;
|
| }
|
|
|
| .form-header {
|
| padding: 15px 20px;
|
| background: var(--secondary-color);
|
| color: white;
|
| }
|
|
|
| .form-header h2 {
|
| margin: 0;
|
| font-size: 1.3rem;
|
| font-weight: 500;
|
| }
|
|
|
| .form-body {
|
| padding: 20px;
|
| }
|
|
|
| .form-group {
|
| margin-bottom: 20px;
|
| }
|
|
|
| .form-group label {
|
| display: block;
|
| margin-bottom: 8px;
|
| font-weight: 500;
|
| color: var(--dark-bg);
|
| }
|
|
|
| .form-control {
|
| width: 100%;
|
| padding: 12px 15px;
|
| border: 1px solid var(--border-color);
|
| border-radius: 5px;
|
| font-size: 1rem;
|
| transition: all 0.3s ease;
|
| }
|
|
|
| .form-control:focus {
|
| outline: none;
|
| border-color: var(--primary-color);
|
| box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.2);
|
| }
|
|
|
|
|
| .btn {
|
| padding: 10px 15px;
|
| border-radius: 5px;
|
| border: none;
|
| font-size: 0.9rem;
|
| font-weight: 500;
|
| cursor: pointer;
|
| display: inline-flex;
|
| align-items: center;
|
| justify-content: center;
|
| gap: 8px;
|
| transition: all 0.3s ease;
|
| text-decoration: none;
|
| }
|
|
|
| .btn-primary {
|
| background: var(--primary-color);
|
| color: white;
|
| }
|
|
|
| .btn-primary:hover {
|
| background: #3367d6;
|
| transform: translateY(-2px);
|
| box-shadow: 0 4px 10px rgba(66, 133, 244, 0.3);
|
| }
|
|
|
| .btn-success {
|
| background: var(--secondary-color);
|
| color: white;
|
| }
|
|
|
| .btn-success:hover {
|
| background: #2e7d32;
|
| transform: translateY(-2px);
|
| box-shadow: 0 4px 10px rgba(52, 168, 83, 0.3);
|
| }
|
|
|
| .btn-danger {
|
| background: var(--danger-color);
|
| color: white;
|
| }
|
|
|
| .btn-danger:hover {
|
| background: #c62828;
|
| transform: translateY(-2px);
|
| box-shadow: 0 4px 10px rgba(234, 67, 53, 0.3);
|
| }
|
|
|
| .btn-outline {
|
| background: transparent;
|
| border: 1px solid var(--primary-color);
|
| color: var(--primary-color);
|
| }
|
|
|
| .btn-outline:hover {
|
| background: rgba(66, 133, 244, 0.1);
|
| transform: translateY(-2px);
|
| }
|
|
|
|
|
| .token-box {
|
| background: rgba(66, 133, 244, 0.05);
|
| border: 1px dashed var(--primary-color);
|
| border-radius: 8px;
|
| padding: 15px;
|
| font-family: 'Courier New', monospace;
|
| position: relative;
|
| margin: 15px 0;
|
| transition: all 0.3s ease;
|
| }
|
|
|
| .token-box:hover {
|
| background: rgba(66, 133, 244, 0.1);
|
| transform: translateY(-2px);
|
| }
|
|
|
| .token-box-header {
|
| display: flex;
|
| justify-content: space-between;
|
| align-items: center;
|
| margin-bottom: 10px;
|
| }
|
|
|
| .token-box-title {
|
| font-weight: 500;
|
| color: var(--dark-bg);
|
| }
|
|
|
| .token-box-actions {
|
| display: flex;
|
| gap: 10px;
|
| }
|
|
|
| .token-value {
|
| word-break: break-all;
|
| font-size: 1rem;
|
| color: var(--dark-bg);
|
| }
|
|
|
| .copy-btn {
|
| background: transparent;
|
| border: none;
|
| color: var(--primary-color);
|
| cursor: pointer;
|
| padding: 5px;
|
| border-radius: 3px;
|
| transition: all 0.2s ease;
|
| }
|
|
|
| .copy-btn:hover {
|
| background: rgba(66, 133, 244, 0.1);
|
| }
|
|
|
|
|
| @keyframes fadeIn {
|
| from {
|
| opacity: 0;
|
| transform: translateY(20px);
|
| }
|
| to {
|
| opacity: 1;
|
| transform: translateY(0);
|
| }
|
| }
|
|
|
| @keyframes pulse {
|
| 0% {
|
| box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.4);
|
| }
|
| 70% {
|
| box-shadow: 0 0 0 10px rgba(66, 133, 244, 0);
|
| }
|
| 100% {
|
| box-shadow: 0 0 0 0 rgba(66, 133, 244, 0);
|
| }
|
| }
|
|
|
|
|
| @media (max-width: 992px) {
|
| .sidebar {
|
| width: 70px;
|
| }
|
|
|
| .sidebar-logo span,
|
| .menu-item span {
|
| display: none;
|
| }
|
|
|
| .main-content {
|
| margin-left: 70px;
|
| }
|
|
|
| .dashboard {
|
| grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
| }
|
| }
|
|
|
| @media (max-width: 768px) {
|
| .dashboard {
|
| grid-template-columns: 1fr;
|
| }
|
|
|
| .header {
|
| flex-direction: column;
|
| align-items: flex-start;
|
| gap: 10px;
|
| height: auto;
|
| padding: 15px 0;
|
| }
|
|
|
| .header-actions {
|
| width: 100%;
|
| }
|
| }
|
| </style>
|
| </head>
|
| <body>
|
|
|
| <div class="sidebar">
|
| <div class="sidebar-header">
|
| <div class="sidebar-logo">
|
| <i class="fas fa-shield-alt"></i>
|
| <span>管理控制台</span>
|
| </div>
|
| </div>
|
| <div class="sidebar-menu">
|
| <a href="/admin/credentials" class="menu-item active">
|
| <i class="fas fa-key"></i>
|
| <span>凭据管理</span>
|
| </a>
|
| <a href="/admin/change-password" class="menu-item">
|
| <i class="fas fa-lock"></i>
|
| <span>密码管理</span>
|
| </a>
|
| <a href="/admin/reset-password" class="menu-item">
|
| <i class="fas fa-sync-alt"></i>
|
| <span>重置密码</span>
|
| </a>
|
| <a href="/admin/login" class="menu-item">
|
| <i class="fas fa-sign-out-alt"></i>
|
| <span>退出登录</span>
|
| </a>
|
| </div>
|
| </div>
|
|
|
|
|
| <div class="main-content">
|
| <div class="header">
|
| <h1 class="page-title">凭据管理控制台</h1>
|
| <div class="header-actions">
|
| <a href="/admin/credentials/reload" class="btn btn-outline">
|
| <i class="fas fa-sync-alt"></i> 重新加载凭据
|
| </a>
|
| </div>
|
| </div>
|
|
|
|
|
| <div class="dashboard">
|
| <div class="stat-card">
|
| <div class="stat-icon">
|
| <i class="fas fa-key"></i>
|
| </div>
|
| <div class="stat-title">凭据总数</div>
|
| <div class="stat-value">{{ len .credentials }}</div>
|
| <div class="stat-actions">
|
| <a href="#add-credential" class="btn btn-outline">添加凭据</a>
|
| </div>
|
| </div>
|
|
|
| <div class="stat-card api-card">
|
| <div class="stat-icon">
|
| <i class="fas fa-plug"></i>
|
| </div>
|
| <div class="stat-title">API令牌状态</div>
|
| <div class="stat-value">{{ if .apiToken }}已生成{{ else }}未生成{{ end }}</div>
|
| <div class="stat-actions">
|
| <a href="#api-token" class="btn btn-outline">管理令牌</a>
|
| </div>
|
| </div>
|
|
|
| <div class="stat-card security-card">
|
| <div class="stat-icon">
|
| <i class="fas fa-shield-alt"></i>
|
| </div>
|
| <div class="stat-title">安全管理</div>
|
| <div class="stat-value">
|
| <i class="fas fa-check-circle" style="font-size: 1.5rem; color: var(--secondary-color);"></i>
|
| </div>
|
| <div class="stat-actions">
|
| <a href="/admin/change-password" class="btn btn-outline">修改密码</a>
|
| </div>
|
| </div>
|
| </div>
|
|
|
|
|
| <div class="content-card">
|
| <div class="card-header">
|
| <h2><i class="fas fa-key"></i> 凭据列表</h2>
|
| <div class="card-header-actions">
|
| <a href="#add-credential" class="btn btn-outline">
|
| <i class="fas fa-plus"></i> 添加凭据
|
| </a>
|
| </div>
|
| </div>
|
| <div class="card-body">
|
| <table class="data-table">
|
| <thead>
|
| <tr>
|
| <th>ID</th>
|
| <th>邮箱</th>
|
| <th>令牌</th>
|
| <th>操作</th>
|
| </tr>
|
| </thead>
|
| <tbody>
|
| {{ range .credentials }}
|
| <tr>
|
| <td>{{ .ID }}</td>
|
| <td>{{ .Email }}</td>
|
| <td class="token-cell">{{ .Token }}</td>
|
| <td class="actions-cell">
|
| <form action="/admin/credentials/delete/{{ .ID }}" method="POST" onsubmit="return confirm('确定要删除这个凭据吗?');">
|
| <button type="submit" class="btn btn-danger">
|
| <i class="fas fa-trash"></i>
|
| </button>
|
| </form>
|
| </td>
|
| </tr>
|
| {{ else }}
|
| <tr>
|
| <td colspan="4" style="text-align: center;">没有凭据</td>
|
| </tr>
|
| {{ end }}
|
| </tbody>
|
| </table>
|
| </div>
|
| </div>
|
|
|
|
|
| <div id="api-token" class="content-card">
|
| <div class="card-header" style="background: var(--secondary-color);">
|
| <h2><i class="fas fa-plug"></i> API访问令牌</h2>
|
| </div>
|
| <div class="card-body">
|
| <p>使用此令牌访问API端点,例如 /v1/chat/completions。在请求头中添加:</p>
|
|
|
| <div class="token-box" style="background-color: #f8f9fa;">
|
| <div class="token-box-header">
|
| <div class="token-box-title">请求头格式</div>
|
| <div class="token-box-actions">
|
| <button class="copy-btn" onclick="copyToClipboard('Authorization: Bearer YOUR_TOKEN')">
|
| <i class="fas fa-copy"></i>
|
| </button>
|
| </div>
|
| </div>
|
| <div class="token-value">Authorization: Bearer YOUR_TOKEN</div>
|
| </div>
|
|
|
| <p>当前令牌:</p>
|
|
|
| {{ if .apiToken }}
|
| <div class="token-box">
|
| <div class="token-box-header">
|
| <div class="token-box-title">API令牌</div>
|
| <div class="token-box-actions">
|
| <button class="copy-btn" onclick="copyToClipboard('{{ .apiToken }}')">
|
| <i class="fas fa-copy"></i>
|
| </button>
|
| </div>
|
| </div>
|
| <div class="token-value">{{ .apiToken }}</div>
|
| </div>
|
| {{ else }}
|
| <div class="token-box" style="color: #6c757d; text-align: center;">
|
| <i class="fas fa-exclamation-circle"></i> 尚未生成令牌
|
| </div>
|
| {{ end }}
|
|
|
| <form action="/admin/apitoken/generate" method="POST" onsubmit="return confirm('生成新令牌将使现有令牌失效。确定要继续吗?');" style="margin-top: 20px;">
|
| <button type="submit" class="btn btn-success">
|
| <i class="fas fa-{{ if .apiToken }}sync-alt{{ else }}plus{{ end }}"></i>
|
| {{ if .apiToken }}重置令牌{{ else }}生成令牌{{ end }}
|
| </button>
|
| </form>
|
| </div>
|
| </div>
|
|
|
|
|
| <div id="add-credential" class="form-card">
|
| <div class="form-header">
|
| <h2><i class="fas fa-plus-circle"></i> 添加新凭据</h2>
|
| </div>
|
| <div class="form-body">
|
| <form action="/admin/credentials" method="POST">
|
| <div class="form-group">
|
| <label for="email">邮箱地址</label>
|
| <input type="email" id="email" name="email" class="form-control" required placeholder="例如:user@example.com">
|
| </div>
|
|
|
| <div class="form-group">
|
| <label for="token">API令牌</label>
|
| <input type="text" id="token" name="token" class="form-control" required placeholder="输入Atlassian API令牌">
|
| </div>
|
|
|
| <button type="submit" class="btn btn-success">
|
| <i class="fas fa-save"></i> 保存凭据
|
| </button>
|
| </form>
|
| </div>
|
| </div>
|
| </div>
|
|
|
|
|
| <script>
|
| function copyToClipboard(text) {
|
| navigator.clipboard.writeText(text).then(() => {
|
|
|
| alert('已复制到剪贴板');
|
| }).catch(err => {
|
| console.error('复制失败:', err);
|
| });
|
| }
|
| </script>
|
| </body>
|
| </html> |