Shorts: JS ResizeObserver syncs right panel height to left panel
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
42279394cc
commit
013b1d48a3
@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
Clock3,
|
||||
@ -110,6 +110,8 @@ export default function ShortsPage() {
|
||||
const toast = useToast();
|
||||
const [pageTab, setPageTab] = useState<"ops" | "live">("ops");
|
||||
const [status, setStatus] = useState<Record<string, any> | null>(null);
|
||||
const leftPanelRef = useRef<HTMLElement>(null);
|
||||
const rightPanelRef = useRef<HTMLElement>(null);
|
||||
const [channels, setChannels] = useState<Channel[]>([]);
|
||||
const [jobs, setJobs] = useState<Job[]>([]);
|
||||
const [jobTotal, setJobTotal] = useState(0);
|
||||
@ -203,6 +205,21 @@ export default function ShortsPage() {
|
||||
return () => clearInterval(t);
|
||||
}, [load, pageTab]);
|
||||
|
||||
// Sync right panel height to left panel
|
||||
useEffect(() => {
|
||||
const left = leftPanelRef.current;
|
||||
const right = rightPanelRef.current;
|
||||
if (!left || !right) return;
|
||||
const sync = () => {
|
||||
const h = left.getBoundingClientRect().height;
|
||||
right.style.maxHeight = `${h}px`;
|
||||
};
|
||||
sync();
|
||||
const ro = new ResizeObserver(sync);
|
||||
ro.observe(left);
|
||||
return () => ro.disconnect();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (pageTab !== "live") return;
|
||||
void loadLiveAnalytics();
|
||||
@ -889,8 +906,8 @@ export default function ShortsPage() {
|
||||
|
||||
{!loading || status ? (
|
||||
<>
|
||||
<div className="mb-6 grid gap-4 xl:grid-cols-[1.4fr_1fr] xl:items-stretch">
|
||||
<section className="flex flex-col rounded-2xl border border-white/10 bg-black/25 p-4">
|
||||
<div className="mb-6 grid gap-4 xl:grid-cols-[1.4fr_1fr] xl:items-start">
|
||||
<section ref={leftPanelRef} className="rounded-2xl border border-white/10 bg-black/25 p-4">
|
||||
<div className="mb-3 flex items-center justify-between gap-2">
|
||||
<h3 className="text-sm font-medium text-slate-100">频道配额({channels.length})</h3>
|
||||
<span className="text-[11px] text-slate-500">
|
||||
@ -1007,7 +1024,7 @@ export default function ShortsPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col overflow-hidden rounded-2xl border border-white/10 bg-black/25 p-4">
|
||||
<section ref={rightPanelRef} className="flex flex-col overflow-hidden rounded-2xl border border-white/10 bg-black/25 p-4">
|
||||
<div className="mb-3 flex items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<Clock3 className="h-4 w-4 text-amber-300" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user