已更新同步按钮功能:
添加图标:按钮现在包含一个旋转图标 (fa-rotate)。 加载状态:点击同步时,图标会旋转,按钮文字变为“同步中”并禁用。 完成提示:同步完成后,会在按钮下方显示“同步完成”的绿色提示文字,并在3秒后自动消失。
This commit is contained in:
31
index.html
31
index.html
@@ -366,6 +366,24 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
const SideDrawer = ({ isOpen, onClose, view, setView, quality, setQuality, onClearCache, syncToken, setSyncToken, onSyncNow }) => {
|
const SideDrawer = ({ isOpen, onClose, view, setView, quality, setQuality, onClearCache, syncToken, setSyncToken, onSyncNow }) => {
|
||||||
|
const [isSyncing, setIsSyncing] = useState(false);
|
||||||
|
const [syncMsg, setSyncMsg] = useState('');
|
||||||
|
|
||||||
|
const handleSyncClick = async () => {
|
||||||
|
if (!syncToken || isSyncing) return;
|
||||||
|
setIsSyncing(true);
|
||||||
|
setSyncMsg('');
|
||||||
|
try {
|
||||||
|
await onSyncNow();
|
||||||
|
setSyncMsg('同步完成');
|
||||||
|
setTimeout(() => setSyncMsg(''), 3000);
|
||||||
|
} catch (e) {
|
||||||
|
setSyncMsg('同步失败');
|
||||||
|
} finally {
|
||||||
|
setIsSyncing(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (!isOpen) return null;
|
if (!isOpen) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -423,13 +441,18 @@
|
|||||||
className="bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-sm text-white w-full focus:outline-none focus:border-primary"
|
className="bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-sm text-white w-full focus:outline-none focus:border-primary"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={onSyncNow}
|
onClick={handleSyncClick}
|
||||||
className="bg-primary text-black px-3 py-2 rounded-lg text-sm font-bold whitespace-nowrap"
|
disabled={isSyncing}
|
||||||
|
className="bg-primary text-black px-3 py-2 rounded-lg text-sm font-bold whitespace-nowrap flex items-center gap-2 disabled:opacity-50"
|
||||||
>
|
>
|
||||||
同步
|
<Icon name="rotate" className={isSyncing ? "animate-spin" : ""} />
|
||||||
|
{isSyncing ? '同步中' : '同步'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-gray-500 mt-1">使用相同的密钥在多端同步收藏列表</p>
|
<div className="flex justify-between items-center mt-1">
|
||||||
|
<p className="text-xs text-gray-500">使用相同的密钥在多端同步收藏列表</p>
|
||||||
|
{syncMsg && <span className="text-xs text-primary font-bold animate-[fadeIn_0.3s]">{syncMsg}</span>}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="px-4 py-2 mt-2">
|
<div className="px-4 py-2 mt-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user