fix: stabilize mobile uploads and show transfer speed
This commit is contained in:
1 parent
09d66092f5
commit
c0d155c608
12 files changed
+279
-69
No files matched your search
@@ -10,6 +10,18 @@ export function formatSize(bytes: number): string {
|
||||
return `${v >= 100 ? v.toFixed(0) : v.toFixed(1)} ${units[i]}`;
|
||||
}
|
||||
|
||||
export function formatTransferProgress(state: {
|
||||
progress: number;
|
||||
phase?: 'encrypting' | 'uploading';
|
||||
speedBytesPerSecond?: number;
|
||||
}): string {
|
||||
const phase = state.phase === 'encrypting' ? '加密中' : state.phase === 'uploading' ? '上传中' : '传输中';
|
||||
const speed = state.speedBytesPerSecond && state.speedBytesPerSecond > 0
|
||||
? ` · ${formatSize(state.speedBytesPerSecond)}/s`
|
||||
: '';
|
||||
return `${phase} ${Math.round(state.progress * 100)}%${speed}`;
|
||||
}
|
||||
|
||||
const timeFmt = new Intl.DateTimeFormat('zh-CN', { hour: '2-digit', minute: '2-digit', hour12: false });
|
||||
|
||||
export function formatTime(ts: number): string {
|
||||
|
||||
Reference in new issue
Block a user