feat(MyWorks): 草稿箱增加翻页(每页 8 条,复用成片分页组件)
This commit is contained in:
@@ -374,6 +374,9 @@ export default function MyWorks() {
|
||||
const totalPages = Math.ceil(products.length / PAGE_SIZE);
|
||||
const paginatedProducts = products.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE);
|
||||
|
||||
const totalDraftPages = Math.ceil(drafts.length / PAGE_SIZE);
|
||||
const paginatedDrafts = drafts.slice((currentPage - 1) * PAGE_SIZE, currentPage * PAGE_SIZE);
|
||||
|
||||
return (
|
||||
<div className="content-page content-page-compact">
|
||||
{/* 页面标题和 Tab 区域 */}
|
||||
@@ -425,31 +428,44 @@ export default function MyWorks() {
|
||||
</>
|
||||
)}
|
||||
{activeTab === 'drafts' && (
|
||||
<div className="drafts-list-container">
|
||||
{drafts.length > 0 ? (
|
||||
<div className="drafts-list">
|
||||
{drafts.map(draft => (
|
||||
<DraftListItem
|
||||
key={draft.id}
|
||||
draft={draft}
|
||||
onClick={handleOpenDraft}
|
||||
isEditing={editingDraftId === draft.id}
|
||||
editValue={editDraftTitle}
|
||||
onEdit={e => handleEditDraft(e, draft)}
|
||||
onSave={saveDraftTitle}
|
||||
onChange={setEditDraftTitle}
|
||||
onDelete={e => openDeleteDraftModal(e, draft)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="empty-state-full">
|
||||
<div className="empty-state-icon"><svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg></div>
|
||||
<p className="empty-state-title">暂无草稿</p>
|
||||
<p className="empty-state-desc">开始创作后会保存草稿在这里</p>
|
||||
<>
|
||||
<div className="drafts-list-container">
|
||||
{paginatedDrafts.length > 0 ? (
|
||||
<div className="drafts-list">
|
||||
{paginatedDrafts.map(draft => (
|
||||
<DraftListItem
|
||||
key={draft.id}
|
||||
draft={draft}
|
||||
onClick={handleOpenDraft}
|
||||
isEditing={editingDraftId === draft.id}
|
||||
editValue={editDraftTitle}
|
||||
onEdit={e => handleEditDraft(e, draft)}
|
||||
onSave={saveDraftTitle}
|
||||
onChange={setEditDraftTitle}
|
||||
onDelete={e => openDeleteDraftModal(e, draft)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="empty-state-full">
|
||||
<div className="empty-state-icon"><svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg></div>
|
||||
<p className="empty-state-title">暂无草稿</p>
|
||||
<p className="empty-state-desc">开始创作后会保存草稿在这里</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{totalDraftPages > 1 && (
|
||||
<div className="pagination-container">
|
||||
<div className="pagination">
|
||||
<button className="pagination-btn nav" disabled={currentPage === 1} onClick={() => setCurrentPage(p => Math.max(1, p - 1))}>上一页</button>
|
||||
{Array.from({ length: totalDraftPages }, (_, i) => i + 1).map(page => (
|
||||
<button key={page} className={`pagination-btn ${currentPage === page ? 'active' : ''}`} onClick={() => setCurrentPage(page)}>{page}</button>
|
||||
))}
|
||||
<button className="pagination-btn nav" disabled={currentPage === totalDraftPages} onClick={() => setCurrentPage(p => Math.min(totalDraftPages, p + 1))}>下一页</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user