|
|
|
@@ -3,166 +3,159 @@
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
<meta name="description" content="商品列表——浏览、下载与删除商品,并查看删除日志。">
|
|
|
|
|
<title>商品列表</title>
|
|
|
|
|
<style>
|
|
|
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
|
body {
|
|
|
|
|
font-family: "Microsoft YaHei", Arial, sans-serif;
|
|
|
|
|
background: #f5f6fa;
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
padding: 30px 20px;
|
|
|
|
|
}
|
|
|
|
|
.container {
|
|
|
|
|
max-width: 1200px;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
background: #fff;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
|
|
|
|
|
padding: 30px;
|
|
|
|
|
}
|
|
|
|
|
h1 { text-align: center; color: #2c3e50; margin-bottom: 20px; font-size: 28px; }
|
|
|
|
|
h2 { color: #2c3e50; font-size: 20px; margin: 30px 0 12px; }
|
|
|
|
|
.toolbar {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
}
|
|
|
|
|
.toolbar .status { font-size: 14px; color: #7f8c8d; }
|
|
|
|
|
.btn {
|
|
|
|
|
padding: 8px 20px;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
transition: background 0.2s;
|
|
|
|
|
}
|
|
|
|
|
.btn-primary { background: #3498db; color: #fff; }
|
|
|
|
|
.btn-primary:hover { background: #2980b9; }
|
|
|
|
|
.btn-success { background: #2ecc71; color: #fff; }
|
|
|
|
|
.btn-success:hover { background: #27ae60; }
|
|
|
|
|
.btn-danger { background: #e74c3c; color: #fff; }
|
|
|
|
|
.btn-danger:hover { background: #c0392b; }
|
|
|
|
|
.btn-warning { background: #f39c12; color: #fff; }
|
|
|
|
|
.btn-warning:hover { background: #e67e22; }
|
|
|
|
|
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
|
|
|
|
|
th, td {
|
|
|
|
|
padding: 12px 15px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
border-bottom: 1px solid #ecf0f1;
|
|
|
|
|
}
|
|
|
|
|
th { background: #f8f9fa; color: #2c3e50; font-weight: 600; }
|
|
|
|
|
tr:hover { background: #fafafa; }
|
|
|
|
|
.product-image {
|
|
|
|
|
width: 80px; height: 80px;
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
background: #f0f0f0;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
color: #999;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
.product-image img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
|
|
|
|
|
.empty { text-align: center; padding: 40px; color: #95a5a6; font-size: 16px; }
|
|
|
|
|
.error {
|
|
|
|
|
background: #fdedec; color: #e74c3c;
|
|
|
|
|
padding: 12px 20px; border-radius: 8px;
|
|
|
|
|
margin-bottom: 20px; display: none;
|
|
|
|
|
}
|
|
|
|
|
.modal-overlay {
|
|
|
|
|
display: none;
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0; left: 0; width: 100%; height: 100%;
|
|
|
|
|
background: rgba(0,0,0,0.5);
|
|
|
|
|
z-index: 999;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
.modal {
|
|
|
|
|
background: #fff;
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
padding: 30px;
|
|
|
|
|
width: 360px;
|
|
|
|
|
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
|
|
|
}
|
|
|
|
|
.modal h2 { margin-bottom: 20px; color: #2c3e50; }
|
|
|
|
|
.modal input {
|
|
|
|
|
width: 100%; padding: 10px 12px;
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
border: 1px solid #ddd;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
|
|
|
|
|
.login-status {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
padding: 6px 14px;
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
background: #ecf0f1;
|
|
|
|
|
}
|
|
|
|
|
.login-status.logged-in { background: #d5f5e3; color: #27ae60; }
|
|
|
|
|
/* Hallmark · shape: app screen · genre: modern-minimal · theme: Coral (deal 1/3, product-admin-screen-list-9604·e91f9651·2026-11-03·r0) · redesign: full
|
|
|
|
|
* nav: top bar, kept · signature: the product ledger (download and delete) · states: loading, empty, error, full
|
|
|
|
|
* axes: light/grotesk-sans/warm · posture: restrained · contrast: pass · v2.0.0 */
|
|
|
|
|
/* Hallmark · pre-emit critique: P4 H4 E3 S4 R5 V4 · weakest: E, contrast on muted labels; secondary text moved to ink-2 */
|
|
|
|
|
/* Hallmark · finish-review: subagent · 8 findings · 1 resolved 2 partial 5 listed · gap: focus trap, inline toasts and a loading skeleton are new behaviour, out of a redesign's scope */
|
|
|
|
|
@import url("./tokens.css");
|
|
|
|
|
@import url("./base.css");
|
|
|
|
|
|
|
|
|
|
.skip { position: absolute; left: var(--space-md); top: calc(-1 * var(--space-3xl)); z-index: var(--z-toast); padding: var(--space-xs) var(--space-md); background: var(--color-board); color: var(--color-board-type); border-radius: var(--radius-input); font-size: var(--text-sm); }
|
|
|
|
|
.skip:focus-visible { top: var(--space-md); }
|
|
|
|
|
|
|
|
|
|
.topbar { position: sticky; top: 0; z-index: var(--z-sticky-nav); background: var(--color-paper); border-bottom: 1px solid var(--color-rule); }
|
|
|
|
|
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
|
|
|
|
|
.brand { display: flex; align-items: center; gap: var(--space-2xs); }
|
|
|
|
|
.brand-mark { width: 10px; height: 10px; border-radius: 3px; background: var(--color-accent-2); }
|
|
|
|
|
.brand-title { font-size: var(--text-md); font-weight: 600; color: var(--color-ink); }
|
|
|
|
|
.topbar-actions { display: flex; align-items: center; gap: var(--space-2xs); }
|
|
|
|
|
|
|
|
|
|
.page { display: grid; gap: var(--space-xl); padding-block: var(--space-xl); }
|
|
|
|
|
|
|
|
|
|
.panel { background: var(--color-cotton); border: 1px solid var(--color-rule); border-radius: var(--radius-card); box-shadow: var(--cast-stock); overflow: hidden; }
|
|
|
|
|
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--color-rule); }
|
|
|
|
|
.panel-head h1, .panel-head h2 { font-size: var(--text-md); font-weight: 600; letter-spacing: 0; }
|
|
|
|
|
.status { font-size: var(--text-sm); color: var(--color-ink-2); }
|
|
|
|
|
|
|
|
|
|
.table-wrap { overflow-x: auto; }
|
|
|
|
|
table { width: 100%; border-collapse: collapse; }
|
|
|
|
|
th, td { padding: var(--space-sm) var(--space-md); text-align: left; border-bottom: 1px solid var(--color-rule); font-size: var(--text-sm); vertical-align: middle; }
|
|
|
|
|
th { color: var(--color-ink-2); font-weight: 500; font-size: var(--text-xs); background: var(--color-paper-2); }
|
|
|
|
|
tbody tr:last-child td { border-bottom: 0; }
|
|
|
|
|
tbody tr:hover { background: var(--color-paper-2); }
|
|
|
|
|
#productTable th:nth-child(1), #productTable td:nth-child(1),
|
|
|
|
|
#productTable th:nth-child(5), #productTable td:nth-child(5),
|
|
|
|
|
#logTable th:nth-child(1), #logTable td:nth-child(1),
|
|
|
|
|
#logTable th:nth-child(3), #logTable td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
|
|
|
|
|
#productTable th:nth-child(2), #productTable td:nth-child(2) { text-align: center; }
|
|
|
|
|
#productTable td:nth-child(6) { white-space: nowrap; }
|
|
|
|
|
#productTable td:nth-child(4) { color: var(--color-ink-2); }
|
|
|
|
|
|
|
|
|
|
.product-image { width: 48px; height: 48px; border-radius: var(--radius-input); background: var(--color-paper-3); overflow: hidden; display: inline-flex; align-items: center; justify-content: center; text-align: center; font-size: var(--text-xs); color: var(--color-ink-2); vertical-align: middle; }
|
|
|
|
|
.product-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
|
|
|
|
|
|
|
|
.price { font-weight: 600; }
|
|
|
|
|
|
|
|
|
|
.btn { display: inline-block; min-height: 34px; padding: 0 var(--space-md); border: 1px solid transparent; border-radius: var(--radius-stock); font-size: var(--text-sm); font-weight: 500; line-height: 32px; white-space: nowrap; cursor: pointer; background: transparent; transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out); }
|
|
|
|
|
.btn:active { transform: translateY(1px); }
|
|
|
|
|
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
|
|
|
|
|
.btn-primary, .btn-success { background: var(--color-board); color: var(--color-board-type); box-shadow: var(--cast-stock); }
|
|
|
|
|
.btn-primary:hover, .btn-success:hover { background: var(--color-ink-2); }
|
|
|
|
|
.btn-warning { color: var(--color-ink); border-color: var(--color-accent-2); }
|
|
|
|
|
.btn-warning:hover { background: color-mix(in oklab, var(--color-accent) 12%, transparent); }
|
|
|
|
|
.btn-danger { color: var(--color-error-ink); border-color: color-mix(in oklab, var(--color-error) 45%, transparent); }
|
|
|
|
|
.btn-danger:hover { background: color-mix(in oklab, var(--color-error) 10%, transparent); }
|
|
|
|
|
.btn-ghost { color: var(--color-ink-2); border-color: var(--color-rule); }
|
|
|
|
|
.btn-ghost:hover { background: var(--color-paper-2); }
|
|
|
|
|
|
|
|
|
|
.login-status { display: inline-block; padding: var(--space-2xs) var(--space-sm); border-radius: var(--radius-pill); font-size: var(--text-xs); color: var(--color-ink-2); background: var(--color-paper-2); border: 1px solid var(--color-rule); }
|
|
|
|
|
.login-status.logged-in { color: var(--color-accent-ink); background: color-mix(in oklab, var(--color-accent) 16%, var(--color-paper)); border-color: color-mix(in oklab, var(--color-accent) 35%, transparent); }
|
|
|
|
|
|
|
|
|
|
.empty { padding: var(--space-xl); text-align: center; color: var(--color-ink-2); font-size: var(--text-sm); }
|
|
|
|
|
.error { display: none; padding: var(--space-sm) var(--space-lg); color: var(--color-error-ink); background: color-mix(in oklab, var(--color-error) 8%, var(--color-paper)); border-bottom: 1px solid color-mix(in oklab, var(--color-error) 25%, transparent); font-size: var(--text-sm); }
|
|
|
|
|
|
|
|
|
|
.modal-overlay { display: none; position: fixed; inset: 0; background: var(--color-scrim); z-index: var(--z-modal); align-items: center; justify-content: center; padding: var(--space-md); }
|
|
|
|
|
.modal { width: 360px; max-width: 100%; background: var(--color-cotton); border: 1px solid var(--color-rule); border-radius: var(--radius-card); padding: var(--space-lg); box-shadow: var(--shadow-card); }
|
|
|
|
|
.modal h2 { font-size: var(--text-md); font-weight: 600; letter-spacing: 0; margin-bottom: var(--space-md); }
|
|
|
|
|
.modal label { display: block; margin-bottom: var(--space-2xs); font-size: var(--text-sm); color: var(--color-ink-2); }
|
|
|
|
|
.modal input { width: 100%; min-height: 36px; padding: 0 var(--space-sm); margin-bottom: var(--space-sm); border: 1px solid var(--color-muted); border-radius: var(--radius-input); background: var(--color-paper); color: var(--color-ink); font-size: var(--text-sm); }
|
|
|
|
|
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2xs); margin-top: var(--space-sm); }
|
|
|
|
|
|
|
|
|
|
@media (max-width: 40rem) {
|
|
|
|
|
.topbar-inner { padding-inline: var(--space-sm); }
|
|
|
|
|
.panel-head { padding: var(--space-sm) var(--space-md); }
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="container">
|
|
|
|
|
<h1>🛒 商品列表</h1>
|
|
|
|
|
<a class="skip" href="#main">跳到主要内容</a>
|
|
|
|
|
|
|
|
|
|
<div class="toolbar">
|
|
|
|
|
<div class="status" id="statusText">加载商品中...</div>
|
|
|
|
|
<div>
|
|
|
|
|
<span id="loginStatus" class="login-status">未登录</span>
|
|
|
|
|
<button id="loginBtn" class="btn btn-primary" style="margin-left:10px;">登录</button>
|
|
|
|
|
<button id="logoutBtn" class="btn btn-danger" style="margin-left:5px; display:none;">退出</button>
|
|
|
|
|
</div>
|
|
|
|
|
<header class="topbar">
|
|
|
|
|
<div class="topbar-inner container">
|
|
|
|
|
<div class="brand">
|
|
|
|
|
<span class="brand-mark" aria-hidden="true"></span>
|
|
|
|
|
<span class="brand-title">商品列表</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="topbar-actions">
|
|
|
|
|
<span id="loginStatus" class="login-status">未登录</span>
|
|
|
|
|
<button id="loginBtn" class="btn btn-primary">登录</button>
|
|
|
|
|
<button id="logoutBtn" class="btn btn-danger" style="display:none;">退出</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div class="error" id="errorBox"></div>
|
|
|
|
|
|
|
|
|
|
<table id="productTable" style="display:none;">
|
|
|
|
|
<main id="main" class="container page">
|
|
|
|
|
<section class="panel" aria-labelledby="products-heading">
|
|
|
|
|
<div class="panel-head">
|
|
|
|
|
<h1 id="products-heading">商品管理</h1>
|
|
|
|
|
<div class="status" id="statusText">加载商品中…</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="error" id="errorBox" role="alert"></div>
|
|
|
|
|
<div class="table-wrap">
|
|
|
|
|
<table id="productTable" style="display:none;">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
<th>图片</th>
|
|
|
|
|
<th>名称</th>
|
|
|
|
|
<th>描述</th>
|
|
|
|
|
<th>价格</th>
|
|
|
|
|
<th>操作</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
<th>图片</th>
|
|
|
|
|
<th>名称</th>
|
|
|
|
|
<th>描述</th>
|
|
|
|
|
<th>价格</th>
|
|
|
|
|
<th>操作</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody id="productBody"></tbody>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="emptyBox" class="empty" style="display:none;">暂无商品</div>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<h2>删除日志</h2>
|
|
|
|
|
<table id="logTable" style="display:none;">
|
|
|
|
|
<section class="panel" aria-labelledby="logs-heading">
|
|
|
|
|
<div class="panel-head">
|
|
|
|
|
<h2 id="logs-heading">删除日志</h2>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-wrap">
|
|
|
|
|
<table id="logTable" style="display:none;">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
<th>操作人</th>
|
|
|
|
|
<th>商品ID</th>
|
|
|
|
|
<th>删除时间</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
<th>操作人</th>
|
|
|
|
|
<th>商品ID</th>
|
|
|
|
|
<th>删除时间</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody id="logBody"></tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="logEmpty" class="empty" style="display:none;">暂无日志</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<div class="modal-overlay" id="modalOverlay">
|
|
|
|
|
<div class="modal">
|
|
|
|
|
<h2>用户登录</h2>
|
|
|
|
|
<input type="text" id="usernameInput" placeholder="用户名">
|
|
|
|
|
<input type="password" id="passwordInput" placeholder="密码">
|
|
|
|
|
<div class="modal-actions">
|
|
|
|
|
<button class="btn" id="cancelLogin">取消</button>
|
|
|
|
|
<button class="btn btn-primary" id="confirmLogin">登录</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="loginTitle">
|
|
|
|
|
<h2 id="loginTitle">用户登录</h2>
|
|
|
|
|
<label for="usernameInput">用户名</label>
|
|
|
|
|
<input type="text" id="usernameInput" placeholder="请输入用户名">
|
|
|
|
|
<label for="passwordInput">密码</label>
|
|
|
|
|
<input type="password" id="passwordInput" placeholder="请输入密码">
|
|
|
|
|
<div class="modal-actions">
|
|
|
|
|
<button class="btn btn-ghost" id="cancelLogin">取消</button>
|
|
|
|
|
<button class="btn btn-primary" id="confirmLogin">登录</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
@@ -186,7 +179,7 @@
|
|
|
|
|
|
|
|
|
|
// ========== 商品加载 ==========
|
|
|
|
|
async function loadProducts() {
|
|
|
|
|
$('statusText').textContent = '加载商品中...';
|
|
|
|
|
$('statusText').textContent = '加载商品中…';
|
|
|
|
|
$('errorBox').style.display = 'none';
|
|
|
|
|
try {
|
|
|
|
|
const res = await fetch(`${API}/prodect`);
|
|
|
|
@@ -260,8 +253,7 @@
|
|
|
|
|
|
|
|
|
|
const tdPrice = document.createElement('td');
|
|
|
|
|
const priceSpan = document.createElement('span');
|
|
|
|
|
priceSpan.style.color = '#e74c3c';
|
|
|
|
|
priceSpan.style.fontWeight = 'bold';
|
|
|
|
|
priceSpan.className = 'num price';
|
|
|
|
|
priceSpan.textContent = `¥${price.toFixed(2)}`;
|
|
|
|
|
tdPrice.appendChild(priceSpan);
|
|
|
|
|
tr.appendChild(tdPrice);
|
|
|
|
@@ -277,7 +269,6 @@
|
|
|
|
|
const delBtn = document.createElement('button');
|
|
|
|
|
delBtn.className = 'btn btn-danger';
|
|
|
|
|
delBtn.textContent = '删除';
|
|
|
|
|
delBtn.style.marginLeft = '6px';
|
|
|
|
|
delBtn.onclick = () => deleteProduct(p.id);
|
|
|
|
|
tdAction.appendChild(delBtn);
|
|
|
|
|
|
|
|
|
@@ -464,6 +455,9 @@
|
|
|
|
|
$('modalOverlay').onclick = e => {
|
|
|
|
|
if (e.target === $('modalOverlay')) hideLogin();
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener('keydown', e => {
|
|
|
|
|
if (e.key === 'Escape' && $('modalOverlay').style.display === 'flex') hideLogin();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ========== 初始化 ==========
|
|
|
|
|
updateLoginUI();
|
|
|
|
@@ -471,4 +465,4 @@
|
|
|
|
|
loadLogs();
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
</html>
|
|
|
|
|