273 lines
13 KiB
HTML
273 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="icon" href="/favicon.svg?v={{ version }}" type="image/svg+xml">
|
|
<title>Secrets — 回收站</title>
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Inter:wght@400;500;600&display=swap');
|
|
:root {
|
|
--bg: #0d1117; --surface: #161b22; --surface2: #21262d;
|
|
--border: #30363d; --text: #e6edf3; --text-muted: #8b949e;
|
|
--accent: #58a6ff; --accent-hover: #79b8ff;
|
|
}
|
|
body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; min-height: 100vh; }
|
|
.layout { display: flex; min-height: 100vh; }
|
|
.sidebar {
|
|
width: 200px; flex-shrink: 0; background: #0b1220; border-right: 1px solid rgba(240,246,252,0.08);
|
|
padding: 20px 12px; display: flex; flex-direction: column; gap: 20px;
|
|
}
|
|
.sidebar-logo { font-family: 'Inter', sans-serif; font-size: 16px; font-weight: 700;
|
|
color: #fff; text-decoration: none; padding: 0 10px; }
|
|
.sidebar-menu { display: grid; gap: 6px; }
|
|
.sidebar-link {
|
|
padding: 10px 12px; border-radius: 10px; color: #8b949e; text-decoration: none;
|
|
font-size: 13px; font-weight: 500;
|
|
}
|
|
.sidebar-link:hover { background: rgba(56,139,253,0.14); color: #fff; }
|
|
.sidebar-link.active { background: rgba(56,139,253,0.14); color: #fff; }
|
|
.content-shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
|
.topbar {
|
|
background: transparent; border-bottom: none; padding: 0 24px;
|
|
display: flex; align-items: center; gap: 12px; min-height: 44px;
|
|
}
|
|
.topbar-spacer { flex: 1; }
|
|
.nav-user { font-size: 14px; color: #8b949e; }
|
|
.lang-bar { display: flex; gap: 2px; background: rgba(240,246,252,0.06); border-radius: 8px; padding: 2px; }
|
|
.lang-btn { padding: 4px 10px; border: none; background: none; color: #8b949e;
|
|
font-size: 12px; cursor: pointer; border-radius: 6px; }
|
|
.lang-btn.active { background: rgba(240,246,252,0.1); color: #fff; }
|
|
.btn-sign-out {
|
|
padding: 6px 14px; border-radius: 10px; border: 1px solid rgba(240,246,252,0.12);
|
|
background: #161b22; color: #c9d1d9; font-size: 13px; text-decoration: none; cursor: pointer;
|
|
}
|
|
.btn-sign-out:hover { border-color: rgba(56,139,253,0.45); color: #fff; }
|
|
.main { padding: 16px 16px 24px; flex: 1; }
|
|
.card { background: #111827; border: 1px solid rgba(240,246,252,0.08); border-radius: 18px;
|
|
padding: 20px; width: 100%; }
|
|
.card-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; color: #fff; }
|
|
.card-subtitle { color: #8b949e; font-size: 14px; margin-bottom: 18px; }
|
|
table { width: 100%; border-collapse: collapse; }
|
|
th, td { text-align: left; padding: 14px 12px; border-top: 1px solid rgba(240,246,252,0.08); vertical-align: top; }
|
|
th { color: #8b949e; font-size: 12px; font-weight: 600; }
|
|
td { font-size: 13px; color: #c9d1d9; }
|
|
.mono { font-family: 'JetBrains Mono', monospace; }
|
|
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
|
|
.btn { border: 1px solid rgba(240,246,252,0.12); background: #161b22; color: #c9d1d9; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px; font-family: inherit; }
|
|
.btn:hover { border-color: rgba(56,139,253,0.45); color: #fff; }
|
|
.btn-danger { color: #f85149; }
|
|
.empty { color: #8b949e; font-size: 14px; padding: 20px 0; }
|
|
.pagination {
|
|
display: flex; align-items: center; gap: 12px; margin-top: 18px;
|
|
justify-content: center; padding: 12px 0;
|
|
}
|
|
.page-btn {
|
|
padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(240,246,252,0.12);
|
|
background: #161b22; color: #c9d1d9; text-decoration: none;
|
|
font-size: 13px; cursor: pointer;
|
|
}
|
|
.page-btn:hover { border-color: rgba(56,139,253,0.45); color: #fff; }
|
|
.page-btn.disabled {
|
|
padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(240,246,252,0.12);
|
|
background: #161b22; color: #6e7681; font-size: 13px;
|
|
opacity: 0.5; cursor: not-allowed;
|
|
}
|
|
.page-info {
|
|
color: #8b949e; font-size: 13px; font-family: 'JetBrains Mono', monospace;
|
|
}
|
|
@media (max-width: 900px) {
|
|
.layout { flex-direction: column; }
|
|
.sidebar {
|
|
width: 100%; border-right: none; border-bottom: 1px solid rgba(240,246,252,0.08);
|
|
padding: 16px; gap: 14px;
|
|
}
|
|
.sidebar-menu { flex-direction: row; flex-wrap: wrap; }
|
|
.sidebar-link { flex: 1; text-align: center; min-width: 72px; }
|
|
.main { padding: 20px 12px 28px; }
|
|
.card { padding: 16px; }
|
|
.topbar { padding: 12px 16px; flex-wrap: wrap; }
|
|
table, thead, tbody, th, td, tr { display: block; }
|
|
thead { display: none; }
|
|
tr { border-top: 1px solid rgba(240,246,252,0.08); padding: 12px 0; }
|
|
td { border-top: none; padding: 6px 0; }
|
|
td::before {
|
|
display: block; color: #8b949e; font-size: 11px;
|
|
margin-bottom: 4px; text-transform: uppercase;
|
|
content: attr(data-label);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="layout">
|
|
<aside class="sidebar">
|
|
<a href="/dashboard" class="sidebar-logo">secrets</a>
|
|
<nav class="sidebar-menu">
|
|
<a href="/dashboard" class="sidebar-link" data-i18n="navMcp">MCP</a>
|
|
<a href="/entries" class="sidebar-link" data-i18n="navEntries">条目</a>
|
|
<a href="/trash" class="sidebar-link active" data-i18n="navTrash">回收站</a>
|
|
<a href="/audit" class="sidebar-link" data-i18n="navAudit">审计</a>
|
|
</nav>
|
|
</aside>
|
|
|
|
<div class="content-shell">
|
|
<div class="topbar">
|
|
<span class="topbar-spacer"></span>
|
|
<span class="nav-user">{{ user_name }}{% if !user_email.is_empty() %} · {{ user_email }}{% endif %}</span>
|
|
<div class="lang-bar">
|
|
<button class="lang-btn" onclick="setLang('zh-CN')">简</button>
|
|
<button class="lang-btn" onclick="setLang('zh-TW')">繁</button>
|
|
<button class="lang-btn" onclick="setLang('en')">EN</button>
|
|
</div>
|
|
<form action="/auth/logout" method="post" style="display:inline">
|
|
<button type="submit" class="btn-sign-out" data-i18n="signOut">退出</button>
|
|
</form>
|
|
</div>
|
|
|
|
<main class="main">
|
|
<section class="card">
|
|
<div class="card-title" data-i18n="trashTitle">回收站</div>
|
|
<div class="card-subtitle" data-i18n="trashSubtitle">已删除条目会保留 3 个月,可在此恢复或永久删除。</div>
|
|
|
|
{% if entries.is_empty() %}
|
|
<div class="empty" data-i18n="emptyTrash">回收站为空。</div>
|
|
{% else %}
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th data-i18n="colName">名称</th>
|
|
<th data-i18n="colType">类型</th>
|
|
<th data-i18n="colFolder">文件夹</th>
|
|
<th data-i18n="colDeletedAt">删除时间</th>
|
|
<th data-i18n="colActions">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for entry in entries %}
|
|
<tr data-trash-entry-id="{{ entry.id }}">
|
|
<td class="mono" data-label="名称">{{ entry.name }}</td>
|
|
<td class="mono" data-label="类型">{{ entry.entry_type }}</td>
|
|
<td class="mono" data-label="文件夹">{{ entry.folder }}</td>
|
|
<td class="mono" data-label="删除时间" title="{{ entry.deleted_at_iso }}">{{ entry.deleted_at_label }}</td>
|
|
<td data-label="操作">
|
|
<div class="row-actions">
|
|
<button type="button" class="btn btn-restore" data-i18n="btnRestore">恢复</button>
|
|
<button type="button" class="btn btn-danger btn-purge" data-i18n="btnPurge">永久删除</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% endif %}
|
|
|
|
{% if total_count > 0 %}
|
|
<div class="pagination">
|
|
{% if current_page > 1 %}
|
|
<a class="page-btn" href="/trash?page={{ current_page - 1 }}" data-i18n="prevPage">上一页</a>
|
|
{% else %}
|
|
<span class="page-btn disabled" data-i18n="prevPage">上一页</span>
|
|
{% endif %}
|
|
<span class="page-info">{{ current_page }} / {{ total_pages }}</span>
|
|
{% if current_page < total_pages %}
|
|
<a class="page-btn" href="/trash?page={{ current_page + 1 }}" data-i18n="nextPage">下一页</a>
|
|
{% else %}
|
|
<span class="page-btn disabled" data-i18n="nextPage">下一页</span>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</section>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/static/i18n.js?v={{ version }}"></script>
|
|
<script>
|
|
(function () {
|
|
I18N_PAGE = {
|
|
'zh-CN': {
|
|
navMcp: 'MCP', navEntries: '条目', navTrash: '回收站', navAudit: '审计',
|
|
signOut: '退出', trashTitle: '回收站', trashSubtitle: '已删除条目会保留 3 个月,可在此恢复或永久删除。',
|
|
emptyTrash: '回收站为空。', colName: '名称', colType: '类型', colFolder: '文件夹',
|
|
colDeletedAt: '删除时间', colActions: '操作', btnRestore: '恢复', btnPurge: '永久删除',
|
|
prevPage: '上一页', nextPage: '下一页',
|
|
mobileLabelName: '名称', mobileLabelType: '类型', mobileLabelFolder: '文件夹',
|
|
mobileLabelDeletedAt: '删除时间', mobileLabelActions: '操作'
|
|
},
|
|
'zh-TW': {
|
|
navMcp: 'MCP', navEntries: '條目', navTrash: '回收站', navAudit: '審計',
|
|
signOut: '退出', trashTitle: '回收站', trashSubtitle: '已刪除條目會保留 3 個月,可在此恢復或永久刪除。',
|
|
emptyTrash: '回收站為空。', colName: '名稱', colType: '類型', colFolder: '文件夾',
|
|
colDeletedAt: '刪除時間', colActions: '操作', btnRestore: '恢復', btnPurge: '永久刪除',
|
|
prevPage: '上一頁', nextPage: '下一頁',
|
|
mobileLabelName: '名稱', mobileLabelType: '類型', mobileLabelFolder: '文件夾',
|
|
mobileLabelDeletedAt: '刪除時間', mobileLabelActions: '操作'
|
|
},
|
|
en: {
|
|
navMcp: 'MCP', navEntries: 'Entries', navTrash: 'Trash', navAudit: 'Audit',
|
|
signOut: 'Sign out', trashTitle: 'Trash', trashSubtitle: 'Deleted entries are kept for 3 months. Restore or permanently delete them here.',
|
|
emptyTrash: 'Trash is empty.', colName: 'Name', colType: 'Type', colFolder: 'Folder',
|
|
colDeletedAt: 'Deleted at', colActions: 'Actions', btnRestore: 'Restore', btnPurge: 'Purge',
|
|
prevPage: 'Previous', nextPage: 'Next',
|
|
mobileLabelName: 'Name', mobileLabelType: 'Type', mobileLabelFolder: 'Folder',
|
|
mobileLabelDeletedAt: 'Deleted at', mobileLabelActions: 'Actions'
|
|
}
|
|
};
|
|
|
|
window.applyPageLang = function () {
|
|
document.querySelectorAll('tbody tr').forEach(function (tr) {
|
|
['Name', 'Type', 'Folder', 'DeletedAt', 'Actions'].forEach(function (col) {
|
|
var td = tr.querySelector('[data-label]');
|
|
});
|
|
});
|
|
};
|
|
|
|
applyLang();
|
|
})();
|
|
|
|
document.querySelectorAll('tr[data-trash-entry-id]').forEach(function (row) {
|
|
var entryId = row.getAttribute('data-trash-entry-id');
|
|
var restoreButton = row.querySelector('.btn-restore');
|
|
var purgeButton = row.querySelector('.btn-purge');
|
|
|
|
restoreButton.addEventListener('click', function () {
|
|
fetch('/api/trash/' + encodeURIComponent(entryId) + '/restore', {
|
|
method: 'POST',
|
|
credentials: 'same-origin'
|
|
}).then(function (response) {
|
|
return response.json().then(function (body) {
|
|
if (!response.ok) throw new Error(body.error || ('HTTP ' + response.status));
|
|
return body;
|
|
});
|
|
}).then(function () {
|
|
row.remove();
|
|
if (!document.querySelector('tr[data-trash-entry-id]')) window.location.reload();
|
|
}).catch(function (error) {
|
|
window.alert(error.message || String(error));
|
|
});
|
|
});
|
|
|
|
purgeButton.addEventListener('click', function () {
|
|
if (!window.confirm(t('confirmPurge') || '确定永久删除该条目?此操作不可撤销。')) return;
|
|
fetch('/api/trash/' + encodeURIComponent(entryId), {
|
|
method: 'DELETE',
|
|
credentials: 'same-origin'
|
|
}).then(function (response) {
|
|
return response.json().then(function (body) {
|
|
if (!response.ok) throw new Error(body.error || ('HTTP ' + response.status));
|
|
return body;
|
|
});
|
|
}).then(function () {
|
|
row.remove();
|
|
if (!document.querySelector('tr[data-trash-entry-id]')) window.location.reload();
|
|
}).catch(function (error) {
|
|
window.alert(error.message || String(error));
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|