You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.5 KiB

{% extends "base.html" %}
{% block title %}收件箱 - 邮件系统{% endblock %}
{% block content %}
<div class="main-layout">
<div class="sidebar">
<a href="{{ url_for('inbox') }}" class="active">📥 收件箱</a>
<a href="{{ url_for('starred') }}">⭐ 星标邮件</a>
<a href="{{ url_for('sent') }}">📤 已发送</a>
<a href="{{ url_for('drafts') }}">📝 草稿箱</a>
<a href="{{ url_for('contacts') }}">📇 通讯录</a>
<a href="{{ url_for('compose') }}">✏️ 写邮件</a>
</div>
<div class="main-content">
<div class="card">
<h2 style="margin-bottom: 1rem;">收件箱</h2>
{% if emails %}
{% for email in emails %}
<div class="email-item {% if not email.is_read %}unread{% endif %}"
onclick="location.href='{{ url_for('view_email', id=email.id) }}'">
<button class="star-btn {% if email.is_starred %}starred{% endif %}"
onclick="event.stopPropagation(); toggleStar({{ email.id }}, this);"
title="{{ '取消星标' if email.is_starred else '添加星标' }}">
{{ '⭐' if email.is_starred else '☆' }}
</button>
<div class="email-subject">
<div>{{ email.sender_address }}</div>
<div style="color: #6b7280;">{{ email.subject or '(无主题)' }}</div>
</div>
<div class="email-date">{{ email.created_at.strftime('%Y-%m-%d %H:%M') }}</div>
<a href="{{ url_for('delete_email', id=email.id) }}" class="btn btn-danger" style="margin-left: 1rem;"
onclick="event.stopPropagation();">删除</a>
</div>
{% endfor %}
{% else %}
<p style="color: #6b7280; text-align: center; padding: 2rem;">暂无邮件</p>
{% endif %}
</div>
</div>
</div>
<script>
function toggleStar(emailId, btn) {
fetch('/email/' + emailId + '/star', {
method: 'POST',
headers: { 'X-Requested-With': 'XMLHttpRequest' }
})
.then(response => response.json())
.then(data => {
if (data.success) {
btn.textContent = data.is_starred ? '⭐' : '☆';
btn.classList.toggle('starred', data.is_starred);
btn.title = data.is_starred ? '取消星标' : '添加星标';
}
});
}
</script>
{% endblock %}