Files

401 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>App Manager</title>
<style>
:root {
--bg: #000000;
--bg-color: #000000;
--card-bg: #1C1C1E;
--border-color: #343434;
--text-color: #e0e0e0;
--text-muted: #666;
--accent-color: #ff9800;
--search-bg: #121212;
--search-border: #333;
--inset-shadow: rgba(0,0,0,0.5);
}
:root.light-theme {
--bg: #fafafa;
--bg-color: #fafafa;
--card-bg: #ffffff;
--border-color: #e0e0e0;
--text-color: #1a1a1a;
--text-muted: #888;
--accent-color: #ff9800;
--search-bg: #f0f0f0;
--search-border: #ccc;
--inset-shadow: rgba(0,0,0,0.05);
}
/* 🔒 1. 锁死整个页面,禁止外层滚动和橡皮筋回弹 */
html, body {
background: var(--bg-color);
color: var(--text-color);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
margin: 0;
padding: 0;
width: 100vw;
height: 100dvh; /* 使用 100dvh 适配移动端浏览器工具栏 */
overflow: hidden; /* 🔒 全局禁止页面滚动 */
overscroll-behavior: none; /* 🔒 禁用 iOS 橡皮筋回弹效果 */
touch-action: none; /* 🔒 默认屏蔽一切滑动与缩放手势 */
-webkit-user-select: none;
user-select: none;
display: flex;
flex-direction: column; /* 使用 Flex 垂直布局 */
}
body, button, input, select, .item {
touch-action: manipulation; /* 允许常规点击,防双击缩放 */
}
/* 2. 固定顶栏 Header,不参与滚动 */
.header {
position: relative;
background: var(--bg-color);
padding: 20px 20px 14px 20px;
display: flex;
flex-direction: column;
gap: 10px;
z-index: 100;
border-bottom: 1px solid var(--border-color);
flex-shrink: 0; /* 🔒 防止头部被压缩 */
touch-action: pan-y; /* 允许 Header 上的交互操作 */
}
.title {
font-size: 1.5rem;
font-weight: bold;
color: var(--accent-color);
letter-spacing: 0.5px;
}
.search-wrapper {
position: relative;
}
.search-icon {
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
color: var(--text-color);
opacity: 0.6;
pointer-events: none;
}
.search-bar {
background: var(--search-bg);
border: 1px solid var(--search-border);
border-radius: 10px;
padding: 10px 15px 10px 32px;
color: var(--text-color);
font-size: 0.95rem;
outline: none;
box-shadow: inset 0 2px 4px var(--inset-shadow);
width: 100%;
box-sizing: border-box;
touch-action: manipulation;
}
.search-bar:focus {
border-color: var(--accent-color);
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.85rem;
color: var(--text-muted);
}
select {
background: var(--search-bg);
border: 1px solid var(--search-border);
border-radius: 8px;
color: var(--text-color);
padding: 5px 10px;
outline: none;
font-size: 0.85rem;
touch-action: manipulation;
}
/* 🔒 3. 仅让列表容器可以独立滚动 */
.list-container {
flex: 1; /* 占据剩余全部高度 */
display: flex;
flex-direction: column;
gap: 10px;
padding: 16px 20px 20px 20px;
overflow-y: auto; /* 🔒 开启仅列表区的纵向滚动 */
-webkit-overflow-scrolling: touch; /* iOS 顺滑滚动 */
overscroll-behavior-y: contain; /* 阻止滚动链传递到底层 */
touch-action: pan-y; /* 🔒 仅允许在列表区上下滑动 */
box-sizing: border-box;
}
.item {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 10px;
padding: 12px 16px;
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
transition: all 0.15s ease;
}
.item:active {
background: var(--search-bg);
transform: scale(0.995);
}
.item-info {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 0;
flex: 1;
}
.item-name {
font-size: 1.05rem;
font-weight: 600;
color: var(--text-color);
line-height: 1.35;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
word-break: break-word;
}
.item-date {
font-size: 0.75rem;
color: var(--text-muted);
}
.item-size {
font-size: 0.8rem;
color: var(--accent-color);
font-weight: 500;
white-space: nowrap;
flex-shrink: 0;
margin-left: 12px;
}
.close-manager-btn {
position: absolute;
top: 15px;
right: 20px;
background: transparent;
border: none;
color: var(--text-muted);
font-size: 2rem;
cursor: pointer;
line-height: 1;
padding: 5px;
transition: color 0.1s;
touch-action: manipulation;
}
.close-manager-btn:active {
color: var(--accent-color);
}
.splash-screen {
position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh;
background-color: var(--bg); z-index: 999999;
display: flex; flex-direction: column; justify-content: center; align-items: center;
display: none; pointer-events: auto; user-select: none; -webkit-user-select: none;
}
.splash-content { text-align: center; }
.splash-icon { font-size: 64px; display: block; margin-bottom: 16px; }
.splash-title {
font-size: 24px; font-weight: bold; color: var(--text); letter-spacing: 1.5px;
font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui,sans-serif;
}
</style>
<script>
const urlParams = new URLSearchParams(window.location.search);
const isStandalone = (window.self === window.top) || urlParams.get('mode') === 'standalone';
function syncThemeWithAppView() {
const savedTheme = localStorage.getItem('appview_theme') || 'system';
let activeTheme = savedTheme;
if (savedTheme === 'system') {
const topWin = window.top || window;
activeTheme = topWin.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
if (activeTheme === 'light') document.documentElement.classList.add("light-theme");
else document.documentElement.classList.remove("light-theme");
}
syncThemeWithAppView();
window.addEventListener('storage', (e) => { if (e.key === 'appview_theme') syncThemeWithAppView(); });
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if ((localStorage.getItem('appview_theme') || 'system') === 'system') syncThemeWithAppView();
});
window.addEventListener('message', (e) => {
if (e.data && e.data.type === "hide_splash") {
const splash = document.getElementById('splash-screen');
if (splash) splash.style.display = "none";
}
});
// 🛡️ 全局网页防双指缩放/双击放大金钟罩
function initGlobalAntiPinchGuard() {
// A. 全局彻底拦截 iOS Safari 专属缩放手势
document.addEventListener('gesturestart', (e) => e.preventDefault());
document.addEventListener('gesturechange', (e) => e.preventDefault());
document.addEventListener('gestureend', (e) => e.preventDefault());
// B. 拦截所有移动端浏览器的多指 (双指/三指) 捏合拉伸放缩
document.addEventListener('touchstart', (e) => {
if (e.touches.length > 1 && e.cancelable) e.preventDefault();
}, { passive: false });
document.addEventListener('touchmove', (e) => {
if (e.touches.length > 1 && e.cancelable) e.preventDefault();
}, { passive: false });
// C. 拦截快速双击放大 (Double-tap zoom)
let lastTouchEnd = 0;
document.addEventListener('touchend', (e) => {
const now = Date.now();
const targetTag = e.target.tagName.toLowerCase();
// 放行输入框和下拉菜单的常规点击
if (targetTag === 'input' || targetTag === 'select' || targetTag === 'option') return;
if (now - lastTouchEnd <= 300) {
if (e.cancelable) e.preventDefault();
}
lastTouchEnd = now;
}, { passive: false });
}
// 启动金钟罩
initGlobalAntiPinchGuard();
</script>
</head>
<body>
<div id="splash-screen" class="splash-screen">
<div class="splash-content">
<span class="splash-icon">🎛️</span>
<div class="splash-title">ComfyUI AppBuilder</div>
</div>
</div>
<div class="header">
<button id="close-manager" class="close-manager-btn">&times;</button>
<div class="title" data-i18n="title-apps">🗂️ My Apps</div>
<div class="search-wrapper">
<svg class="search-icon" viewBox="0 0 24 24" fill="none">
<circle cx="11" cy="11" r="7" stroke="currentColor" stroke-width="2"/>
<line x1="16.5" y1="16.5" x2="21" y2="21" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
</svg>
<input type="text" id="search" class="search-bar" placeholder-i18n="search_apps" placeholder="Search your apps...">
</div>
<div class="toolbar">
<span id="count">0 apps available</span>
<select id="sort">
<option data-i18n="date_desc" value="date_desc">Newest First</option>
<option data-i18n="date_asc" value="date_asc">Oldest First</option>
<option data-i18n="name_asc" value="name_asc">Name A-Z</option>
<option data-i18n="name_desc" value="name_desc">Name Z-A</option>
</select>
</div>
</div>
<!-- 仅此列表区可以独立纵向滚动 -->
<div class="list-container" id="list"></div>
<script type="text/javascript" src="./i18n/i18n.js"></script>
<script>
let allWorkflows = [];
window.addEventListener('DOMContentLoaded', async () => {
await loadI18n();
if (isStandalone) {
const closeBtn = document.getElementById('close-manager');
if (closeBtn) closeBtn.style.display = 'none';
}
await loadList();
});
async function loadList() {
try {
const res = await fetch('/appbuilder/workflows');
if (res.ok) {
allWorkflows = await res.json();
renderList();
}
} catch(e) { console.error("Load list failed:", e); }
}
function formatFileSize(bytes) {
if (!bytes || bytes <= 0) return "0 B";
const units = ["B", "KB", "MB", "GB"];
let i = 0; let num = bytes;
while (num >= 1024 && i < units.length - 1) { num /= 1024; i++; }
let str;
if (num >= 1000) str = num.toFixed(0);
else if (num >= 100) str = num.toFixed(1);
else if (num >= 10) str = num.toFixed(2);
else if (i === 0) str = num.toFixed(0);
else str = num.toFixed(3);
return `${str} ${units[i]}`;
}
function renderList() {
const searchVal = document.getElementById("search").value.toLowerCase();
const sortBy = document.getElementById("sort").value;
const container = document.getElementById("list");
let filtered = allWorkflows.filter(w => w.name.toLowerCase().includes(searchVal));
filtered.sort((a, b) => {
if (sortBy === "date_desc") return b.mtime - a.mtime;
if (sortBy === "date_asc") return a.mtime - b.mtime;
if (sortBy === "name_asc") return a.name.localeCompare(b.name);
if (sortBy === "name_desc") return b.name.localeCompare(a.name);
});
document.getElementById("count").innerText = t('available_apps', '{0} apps available', filtered.length);
container.innerHTML = "";
filtered.forEach(item => {
const el = document.createElement("div");
el.className = "item";
const formattedDate = new Date(item.mtime * 1000).toLocaleString();
const sizeFormatted = formatFileSize(item.size);
const cleanName = item.name.replace(".json", "");
el.innerHTML = `
<div class="item-info">
<span class="item-name">${cleanName}</span>
<span class="item-date">${formattedDate}</span>
</div>
<span class="item-size">${sizeFormatted}</span>
`;
el.onclick = () => {
if (isStandalone) {
window.location.href = `app_view.html?app=${encodeURIComponent(item.name)}&mode=standalone&nocache`;
} else {
const splash = document.getElementById('splash-screen');
splash.style.display = "flex";
window.parent.postMessage({ type: "load_workflow", filename: item.name }, "*");
}
};
container.appendChild(el);
});
}
document.getElementById("search").oninput = renderList;
document.getElementById("sort").onchange = renderList;
document.getElementById("close-manager").onclick = () => {
window.parent.postMessage({ type: "close_app_manager" }, "*");
};
</script>
</body>
</html>