197 lines
11 KiB
HTML
197 lines
11 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}应用管理{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="card">
|
|
<div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<a href="{{ url_for('add_app') }}" class="btn btn-primary btn-sm">
|
|
<i class="fas fa-plus"></i> 添加应用
|
|
</a>
|
|
</div>
|
|
<div>
|
|
<form class="d-flex" method="GET">
|
|
<input type="hidden" name="category" value="{{ category_filter }}">
|
|
<input type="text" name="search" class="form-control form-control-sm me-2" placeholder="搜索应用..." value="{{ search_query }}">
|
|
<button type="submit" class="btn btn-sm btn-light">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="mb-3">
|
|
<form class="row g-3">
|
|
<div class="col-auto">
|
|
<select name="category" class="form-select">
|
|
<option value="">所有分类</option>
|
|
{% for cat_id, cat_data in categories.items() %}
|
|
<option value="{{ cat_id }}" {% if category_filter == cat_id %}selected{% endif %}>
|
|
{{ cat_data.name }} (主分类)
|
|
</option>
|
|
{% for sub_id, sub_data in cat_data.sub.items() %}
|
|
<option value="{{ sub_id }}" {% if category_filter == sub_id %}selected{% endif %}>
|
|
{{ sub_data.name }}
|
|
</option>
|
|
{% endfor %}
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-auto">
|
|
<button type="submit" class="btn btn-primary">筛选</button>
|
|
{% if category_filter or search_query %}
|
|
<a href="{{ url_for('index') }}" class="btn btn-secondary ms-2">重置</a>
|
|
{% endif %}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- 桌面端显示表格 -->
|
|
<div class="d-none d-md-block">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>图标</th>
|
|
<th>标题</th>
|
|
<th>分类/权重</th>
|
|
<th>URL</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for app in apps %}
|
|
<tr>
|
|
<td>
|
|
{% if app.icon.startswith('/upload/icon/') %}
|
|
<img src="{{ app.icon }}" style="max-width: 24px; max-height: 24px;" class="img-fluid">
|
|
{% else %}
|
|
<i class="fas {{ app.icon }} fa-lg"></i>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{{ app.title }}
|
|
{% if app.get('private', False) %}
|
|
<span class="badge bg-warning text-dark ms-2">私有</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
<div class="d-flex flex-wrap gap-1">
|
|
<span class="badge d-flex align-items-center" style="background-color: {{ categories[app.category.main].color }}; color: white;">
|
|
{{ categories[app.category.main].name }}
|
|
<span class="badge bg-light text-dark ms-1">{{ categories[app.category.main].weight }}</span>
|
|
</span>
|
|
{% if app.category.sub %}
|
|
<span class="badge d-flex align-items-center" style="background-color: {{ categories[app.category.main].sub[app.category.sub].color }}; color: white;">
|
|
{{ categories[app.category.main].sub[app.category.sub].name }}
|
|
<span class="badge bg-light text-dark ms-1">{{ categories[app.category.main].sub[app.category.sub].weight }}</span>
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td><a href="{{ app.url }}" target="_blank">{{ app.url[:30] }}...</a></td>
|
|
<td>
|
|
<a href="{{ url_for('edit_app', index=(current_page-1)*per_page + loop.index0) }}" class="btn btn-sm btn-warning">
|
|
<i class="fas fa-edit"></i> 编辑
|
|
</a>
|
|
<a href="{{ url_for('delete_app', index=(current_page-1)*per_page + loop.index0) }}" class="btn btn-sm btn-danger" onclick="return confirm('确定删除吗?')">
|
|
<i class="fas fa-trash"></i> 删除
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
{% else %}
|
|
<tr>
|
|
<td colspan="5" class="text-center">没有找到匹配的应用</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 移动端显示卡片 -->
|
|
<div class="d-md-none">
|
|
<div class="row">
|
|
{% for app in apps %}
|
|
<div class="col-12 mb-3">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row align-items-center">
|
|
<div class="col-3">
|
|
{% if app.icon.startswith('/upload/icon/') %}
|
|
<img src="{{ app.icon }}" class="img-fluid rounded">
|
|
{% else %}
|
|
<i class="fas {{ app.icon }} fa-2x"></i>
|
|
{% endif %}
|
|
</div>
|
|
<div class="col-9">
|
|
<h5 class="card-title mb-1">
|
|
{{ app.title }}
|
|
{% if app.get('private', False) %}
|
|
<span class="badge bg-warning text-dark ms-1">私有</span>
|
|
{% endif %}
|
|
</h5>
|
|
<div class="d-flex flex-wrap gap-1 mb-1">
|
|
<span class="badge d-flex align-items-center" style="background-color: {{ categories[app.category.main].color }}; color: white;">
|
|
{{ categories[app.category.main].name }}
|
|
<span class="badge bg-light text-dark ms-1">{{ categories[app.category.main].weight }}</span>
|
|
</span>
|
|
{% if app.category.sub %}
|
|
<span class="badge d-flex align-items-center" style="background-color: {{ categories[app.category.main].sub[app.category.sub].color }}; color: white;">
|
|
{{ categories[app.category.main].sub[app.category.sub].name }}
|
|
<span class="badge bg-light text-dark ms-1">{{ categories[app.category.main].sub[app.category.sub].weight }}</span>
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
<p class="card-text mb-2">
|
|
<a href="{{ app.url }}" target="_blank" class="text-truncate d-block">{{ app.url }}</a>
|
|
</p>
|
|
<div class="d-flex gap-2">
|
|
<a href="{{ url_for('edit_app', index=(current_page-1)*per_page + loop.index0) }}" class="btn btn-sm btn-warning flex-grow-1">
|
|
<i class="fas fa-edit"></i> 编辑
|
|
</a>
|
|
<a href="{{ url_for('delete_app', index=(current_page-1)*per_page + loop.index0) }}" class="btn btn-sm btn-danger flex-grow-1" onclick="return confirm('确定删除吗?')">
|
|
<i class="fas fa-trash"></i> 删除
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="col-12">
|
|
<div class="alert alert-info text-center">没有找到匹配的应用</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 分页导航 -->
|
|
{% if total_pages > 1 %}
|
|
<nav aria-label="Page navigation">
|
|
<ul class="pagination justify-content-center">
|
|
<li class="page-item {% if current_page == 1 %}disabled{% endif %}">
|
|
<a class="page-link" href="{{ url_for('index', page=current_page-1, category=category_filter, search=search_query) }}" aria-label="Previous">
|
|
<span aria-hidden="true">«</span>
|
|
</a>
|
|
</li>
|
|
|
|
{% for page_num in range(1, total_pages + 1) %}
|
|
<li class="page-item {% if page_num == current_page %}active{% endif %}">
|
|
<a class="page-link" href="{{ url_for('index', page=page_num, category=category_filter, search=search_query) }}">{{ page_num }}</a>
|
|
</li>
|
|
{% endfor %}
|
|
|
|
<li class="page-item {% if current_page == total_pages %}disabled{% endif %}">
|
|
<a class="page-link" href="{{ url_for('index', page=current_page+1, category=category_filter, search=search_query) }}" aria-label="Next">
|
|
<span aria-hidden="true">»</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endblock %} |