Files
ns2.0/templates/all_apps.html

342 lines
6.5 KiB
HTML
Executable File

{% extends "base.html" %}
{% block content %}
<div class="category-page">
<div class="header">
<a href="{{ url_for('index') }}" class="back-link" title="返回首页">
<i class="fas fa-arrow-left"></i>
</a>
<div class="header-title">
<h1>全部应用 ({{ apps|length }}个)</h1>
</div>
</div>
<div class="apps-grid" style="margin: 0; padding: 0;">
{% for app in apps %}
<div class="app-card" onclick="window.location.href='/app/{{ app.id }}'">
<div class="app-icon">
{% if 'http' in app.icon_path %}
<img data-src="{{ app.icon_path }}" alt="{{ app.name }}" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
{% else %}
<img data-src="{{ url_for('static', filename='uploads/' + app.icon_path) }}" alt="{{ app.name }}" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
{% endif %}
</div>
<div class="app-info">
<h3>{{ app.name }}</h3>
</div>
</div>
{% endfor %}
</div>
</div>
<style>
.category-page {
max-width: 1200px;
margin: 60px auto 20px;
padding: 0 15px;
}
.header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 20px;
background: white;
padding: 5px 20px 5px 20px;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.back-link {
color: #666;
text-decoration: none;
padding: 8px;
border-radius: 50%;
background: #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
transition: transform 0.3s ease;
flex-shrink: 0;
}
.back-link:hover {
transform: translateY(-2px);
}
.header-title {
flex: 1;
}
.header h1 {
margin: 0;
font-size: 20px;
color: #333;
font-weight: 500;
font-family: "SimHei", "黑体", sans-serif;
text-align: left;
padding-right: auto;
margin-right: auto;
}
/* PC端网格布局 */
.apps-grid {
display: flex;
flex-wrap: wrap;
gap: 0;
justify-content: flex-start;
background: white;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
padding: 10px;
}
.app-card {
width: 80px; /* PC端固定宽度 */
padding: 6px;
box-sizing: border-box;
text-align: center;
}
.app-icon {
width: 48px;
height: 48px;
margin: 0 auto 4px;
}
.app-icon img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 12px;
opacity: 0;
transition: opacity 0.3s ease;
}
.app-icon img.loaded {
opacity: 1;
}
.app-info h3 {
font-size: 11px;
margin: 0;
color: #333;
text-align: center;
line-height: 1.2;
height: 2.4em;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
/* 移动端适配 */
@media (max-width: 768px) {
.category-page {
padding: 0 10px;
}
.header {
margin-bottom: 15px;
}
.apps-grid {
padding: 6px;
justify-content: center; /* 移动端居中显示 */
}
.app-card {
width: 25%; /* 移动端四列布局 */
padding: 4px;
}
.app-icon {
width: 42px;
height: 42px;
margin-bottom: 3px;
}
.app-info h3 {
font-size: 10px;
}
}
/* 超小屏幕适配 */
@media (max-width: 320px) {
.apps-grid {
padding: 4px;
}
.app-card {
padding: 3px;
}
.app-icon {
width: 38px;
height: 38px;
}
.app-info h3 {
font-size: 9px;
}
}
/* 暗色模式样式 */
[data-theme="dark"] .category-page {
background: #1a1a1a;
}
[data-theme="dark"] .header {
background: #242424;
}
[data-theme="dark"] .header h1 {
color: #fff;
}
[data-theme="dark"] .back-link {
color: #ccc;
background: #333;
}
[data-theme="dark"] .back-link:hover {
background: #444;
color: #fff;
}
[data-theme="dark"] .apps-grid {
background: #242424;
}
[data-theme="dark"] .app-card {
background: #242424;
}
[data-theme="dark"] .app-info h3 {
color: #fff;
}
/* 添加全局过渡效果 */
* {
transition: background-color 0.3s ease, color 0.3s ease;
}
/* 确保 apps-grid 也有过渡效果 */
.apps-grid {
transition: background-color 0.3s ease;
background: #fff;
}
[data-theme="dark"] .apps-grid {
background: #242424;
}
/* 修改 app-card 的悬停效果 */
.app-card {
cursor: pointer;
transition: transform 0.3s ease, background-color 0.3s ease;
}
.app-card:hover {
transform: translateY(-2px);
}
[data-theme="dark"] .app-card:hover {
background: #333;
}
/* 优化返回按钮的触摸反馈 */
.back-link {
-webkit-tap-highlight-color: rgba(0,0,0,0);
cursor: pointer;
transition: all 0.3s ease;
}
.back-link:active {
opacity: 0.7;
}
@media (hover: hover) {
.back-link:hover {
opacity: 0.8;
}
}
/* 添加到现有样式的末尾 */
.floating-buttons {
position: fixed;
bottom: 40px;
right: 20px;
z-index: 1000;
display: flex;
flex-direction: column;
gap: 10px;
}
.theme-toggle {
width: 40px;
height: 40px;
border-radius: 50%;
border: none;
background: #fff;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
padding: 0;
}
.theme-toggle:hover {
transform: scale(1.1);
}
/* 暗色模式样式 */
[data-theme="dark"] .theme-toggle {
background: #333;
color: #fff;
}
/* 响应式调整 */
@media (max-width: 768px) {
.floating-buttons {
bottom: 30px;
right: 15px;
gap: 8px;
}
.theme-toggle {
width: 36px;
height: 36px;
}
}
</style>
<script>
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
img.src = img.dataset.src;
img.onload = () => {
img.classList.add('loaded');
};
observer.unobserve(img);
}
});
}, {
rootMargin: '50px 0px',
threshold: 0.01
});
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('img[data-src]').forEach(img => {
imageObserver.observe(img);
});
});
</script>
{% endblock %}