项目文件夹

文件
yf e32cb17edf feat: photo gallery with static_site + function on Tencent Cloud
- Static frontend (gallery, lightbox, drag-drop upload)
- Function API (upload/list/delete/share/ai-caption)
- PG + object_storage + model_router via ref:
2026-08-10 10:56:00 +08:00

265 行
6.7 KiB
HTML

<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>在线相册 · AI 识图</title>
<style>
:root {
color-scheme: light dark;
--ink: #1a1a2e;
--paper: #f5f5f5;
--card: #ffffff;
--accent: #6c5ce7;
--accent-hover: #5b4bd6;
--line: #e0e0e0;
--muted: #999;
--danger: #e5484d;
--ok: #00b894;
--shadow: 0 4px 20px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
min-height: 100svh;
background: var(--paper);
color: var(--ink);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
header {
background: var(--card);
border-bottom: 1px solid var(--line);
padding: 16px 24px;
display: flex;
align-items: center;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 10;
box-shadow: var(--shadow);
}
header h1 { font-size: 1.25rem; font-weight: 700; }
header .stats { font-size: 0.8rem; color: var(--muted); }
.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
/* upload zone */
.upload-zone {
border: 2px dashed var(--line);
border-radius: 16px;
padding: 40px 20px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
background: var(--card);
margin-bottom: 24px;
}
.upload-zone:hover, .upload-zone.dragover {
border-color: var(--accent);
background: rgba(108, 92, 231, 0.04);
transform: scale(1.01);
}
.upload-zone .icon { font-size: 3rem; }
.upload-zone p { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
.upload-progress { margin-top: 12px; }
.upload-item {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 12px;
border-radius: 8px;
background: rgba(108, 92, 231, 0.08);
font-size: 0.85rem;
margin-top: 6px;
}
.upload-item .spinner { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* gallery */
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 16px;
}
.photo-card {
background: var(--card);
border-radius: 12px;
overflow: hidden;
box-shadow: var(--shadow);
transition: transform 0.15s;
position: relative;
}
.photo-card:hover { transform: translateY(-4px); }
.photo-thumb {
width: 100%;
aspect-ratio: 1;
object-fit: cover;
background: var(--paper);
cursor: pointer;
}
.photo-info { padding: 10px 14px; }
.photo-name {
font-size: 0.85rem;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.photo-meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.photo-actions {
display: flex;
gap: 4px;
padding: 0 14px 12px;
flex-wrap: wrap;
}
.btn {
border: none;
border-radius: 6px;
padding: 5px 10px;
font-size: 0.72rem;
cursor: pointer;
font-weight: 600;
transition: background 0.15s;
}
.btn-accent { background: rgba(108, 92, 231, 0.12); color: var(--accent); }
.btn-accent:hover { background: rgba(108, 92, 231, 0.22); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: rgba(229,72,77,0.1); }
.ai-badge {
position: absolute;
top: 8px;
right: 8px;
background: rgba(108, 92, 231, 0.9);
color: #fff;
font-size: 0.65rem;
padding: 3px 8px;
border-radius: 999px;
display: none;
}
.ai-badge.show { display: block; }
.loading-overlay {
position: absolute;
inset: 0;
background: rgba(0,0,0,0.5);
display: none;
align-items: center;
justify-content: center;
color: #fff;
font-size: 0.8rem;
}
.loading-overlay.show { display: flex; }
/* lightbox */
.lightbox {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.9);
display: none;
align-items: center;
justify-content: center;
z-index: 100;
padding: 20px;
}
.lightbox.show { display: flex; }
.lightbox img {
max-width: 90vw;
max-height: 80vh;
border-radius: 8px;
}
.lightbox-info {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(255,255,255,0.95);
border-radius: 12px;
padding: 14px 20px;
max-width: 90vw;
font-size: 0.85rem;
text-align: center;
}
.lightbox-info .caption { color: var(--ink); line-height: 1.5; }
.lightbox-info .caption-label { font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.lightbox-close {
position: absolute;
top: 20px;
right: 20px;
background: rgba(255,255,255,0.2);
color: #fff;
border: none;
border-radius: 50%;
width: 40px;
height: 40px;
font-size: 1.2rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.35); }
/* share modal */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0,0,0,0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 200;
}
.modal {
background: var(--card);
border-radius: 12px;
padding: 24px;
max-width: 480px;
width: 90%;
}
.modal h3 { margin-bottom: 12px; }
.modal .share-link { display: flex; gap: 8px; margin-top: 12px; }
.modal input {
flex: 1;
border: 1px solid var(--line);
border-radius: 6px;
padding: 8px 12px;
font-size: 0.85rem;
}
.modal .close { margin-top: 16px; width: 100%; }
.empty {
text-align: center;
padding: 60px 20px;
color: var(--muted);
}
.empty .icon { font-size: 4rem; }
.empty p { margin-top: 12px; font-size: 0.9rem; }
</style>
</head>
<body>
<header>
<h1>🖼️ 在线相册</h1>
<span class="stats" id="headerStats">加载中...</span>
</header>
<div class="container">
<div class="upload-zone" id="uploadZone" onclick="document.getElementById('fileInput').click()">
<div class="icon">📸</div>
<p>点击或拖拽图片到此处上传</p>
<input type="file" id="fileInput" accept="image/*" style="display:none" multiple>
</div>
<div class="upload-progress" id="uploadProgress"></div>
<div class="gallery" id="gallery"></div>
</div>
<!-- lightbox -->
<div class="lightbox" id="lightbox">
<button class="lightbox-close" onclick="closeLightbox()"></button>
<img id="lightboxImg" src="" alt="" />
<div class="lightbox-info" id="lightboxInfo" style="display:none">
<div class="caption-label">🤖 AI 识图</div>
<div class="caption" id="lightboxCaption"></div>
</div>
</div>
<script src="/assets/app.js"></script>
<script src="/assets/app.js"></script>
</body>
</html>