优化前端,修改返回逻辑,添加视频实时背景,音量倍速持久化

This commit is contained in:
2025-10-21 16:33:16 +08:00
parent 9d1598a5ab
commit 200283b21b
231 changed files with 744 additions and 62 deletions
+16 -8
View File
@@ -14,8 +14,8 @@ type BackButtonProps = {
/**
* BackButton
* - Primary: behaves like browser back (router.back()), preserving previous page state (e.g., scroll, filters)
* - Fallback: if no history entry exists (e.g., opened directly), navigates to '/'
* - Primary: attempts to close the current window/tab (window.close())
* - Fallback: if close fails (e.g., not opened by script), navigates to '/'
* - Uses <Link> so that Ctrl/Cmd-click or middle-click opens the fallback URL in a new tab naturally
*/
export default function BackButton({ className, ariaLabel = '返回', hrefFallback = '/', children }: BackButtonProps) {
@@ -25,13 +25,21 @@ export default function BackButton({ className, ariaLabel = '返回', hrefFallba
// Respect modifier clicks (new tab/window) and non-left clicks
if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
// Prefer SPA back when we have some history to go back to
if (typeof window !== 'undefined' && window.history.length > 1) {
e.preventDefault();
router.back();
e.preventDefault();
// Try to close the window first
if (typeof window !== 'undefined') {
window.close();
// If window.close() didn't work (window still open after a short delay),
// navigate to the fallback URL
setTimeout(() => {
if (!document.hidden) {
router.push(hrefFallback);
}
}, 80);
}
// else: allow default <Link href> to navigate to fallback
}, [router]);
}, [router, hrefFallback]);
return (
<Link
+1 -1
View File
@@ -133,7 +133,7 @@ export default function FeedMasonry({ initialItems, initialCursor }: Props) {
}, [fetchMore]);
const renderCard = useCallback((item: FeedItem) => (
<Link key={item.aweme_id} href={`/aweme/${item.aweme_id}`} className="mb-4 block group">
<Link key={item.aweme_id} href={`/aweme/${item.aweme_id}`} target="_blank" className="mb-4 block group">
<article className="relative overflow-hidden rounded-2xl shadow-sm ring-1 ring-black/5 bg-white/80 dark:bg-zinc-900/60 backdrop-blur-sm transition-transform duration-300 group-hover:-translate-y-1">
<div
className="relative w-full"