refactor(VoiceMaterialLibrary): 去掉声音复刻列表的本地数据假分页
This commit is contained in:
@@ -22,10 +22,6 @@ export default function VoiceMaterialLibrary() {
|
||||
const [uploadName, setUploadName] = useState('');
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||
|
||||
// 分页
|
||||
const [audioPage, setAudioPage] = useState(1);
|
||||
const pageSize = 20;
|
||||
|
||||
// 重命名状态
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
const [editingName, setEditingName] = useState('');
|
||||
@@ -428,7 +424,7 @@ export default function VoiceMaterialLibrary() {
|
||||
) : (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16, flex: 1, overflow: 'auto' }}>
|
||||
<div className="voice-list" style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 12, alignContent: 'start', alignItems: 'start' }}>
|
||||
{voiceMaterials.slice((audioPage - 1) * pageSize, audioPage * pageSize).map(m => (
|
||||
{voiceMaterials.map(m => (
|
||||
<div key={m.id} className="voice-row" style={{ cursor: 'default' }}>
|
||||
<div className="voice-row-main">
|
||||
<div className="voice-row-info">
|
||||
@@ -485,29 +481,7 @@ export default function VoiceMaterialLibrary() {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{voiceMaterials.length > pageSize && (
|
||||
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', gap: 12, padding: '8px 0' }}>
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
style={{ padding: '4px 12px', fontSize: 'var(--font-sm)' }}
|
||||
onClick={() => setAudioPage(p => Math.max(1, p - 1))}
|
||||
disabled={audioPage <= 1}
|
||||
>
|
||||
上一页
|
||||
</button>
|
||||
<span style={{ fontSize: 'var(--font-sm)', color: 'var(--text-secondary)' }}>
|
||||
{audioPage} / {Math.ceil(voiceMaterials.length / pageSize)}
|
||||
</span>
|
||||
<button
|
||||
className="btn btn-secondary"
|
||||
style={{ padding: '4px 12px', fontSize: 'var(--font-sm)' }}
|
||||
onClick={() => setAudioPage(p => Math.min(Math.ceil(voiceMaterials.length / pageSize), p + 1))}
|
||||
disabled={audioPage >= Math.ceil(voiceMaterials.length / pageSize)}
|
||||
>
|
||||
下一页
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user