fix nav buttons
adds forward, fixes back and reload, fixes shortcut staying filled in on page change contentWindow is defined multiple times because yeah
This commit is contained in:
parent
fbe9fc4a5b
commit
054a2ab7cd
1 changed files with 17 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ declare global {
|
||||||
|
|
||||||
export default function Route({ params }: { params: { route: string[] } }) {
|
export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
const ref = useRef<HTMLIFrameElement>(null);
|
const ref = useRef<HTMLIFrameElement>(null);
|
||||||
|
const contentWindow = ref.current?.contentWindow as ContentWindow;
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const route = params.route.join("/");
|
const route = params.route.join("/");
|
||||||
|
|
||||||
|
|
@ -52,8 +53,7 @@ export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
|
|
||||||
function triggerShortcut() {
|
function triggerShortcut() {
|
||||||
store.set("shortcuts", [], false);
|
store.set("shortcuts", [], false);
|
||||||
if (!ref.current || !ref.current.contentWindow) return;
|
const contentWindow = ref.current?.contentWindow as ContentWindow;
|
||||||
const contentWindow = ref.current.contentWindow as ContentWindow;
|
|
||||||
if (!("__uv$location" in contentWindow)) return;
|
if (!("__uv$location" in contentWindow)) return;
|
||||||
const shortcuts: any[] = store("shortcuts");
|
const shortcuts: any[] = store("shortcuts");
|
||||||
|
|
||||||
|
|
@ -86,9 +86,7 @@ export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleLoad() {
|
function handleLoad() {
|
||||||
if (!ref.current || !ref.current.contentWindow) return;
|
const contentWindow = ref.current?.contentWindow as ContentWindow;
|
||||||
const contentWindow = ref.current.contentWindow as ContentWindow;
|
|
||||||
|
|
||||||
setTabName(contentWindow.document.title);
|
setTabName(contentWindow.document.title);
|
||||||
setTabIcon(
|
setTabIcon(
|
||||||
(
|
(
|
||||||
|
|
@ -104,8 +102,11 @@ export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
shortcuts.some((value) => value.url == contentWindow.__uv$location.href)
|
shortcuts.some((value) => value.url == contentWindow.__uv$location.href)
|
||||||
) {
|
) {
|
||||||
setShortcutted(true);
|
setShortcutted(true);
|
||||||
|
} else {
|
||||||
|
setShortcutted(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="w-screen fixed top-0 h-14 border-b flex items-center justify-between px-4 pr-8">
|
<div className="w-screen fixed top-0 h-14 border-b flex items-center justify-between px-4 pr-8">
|
||||||
|
|
@ -128,7 +129,7 @@ export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
<TooltipProvider delayDuration={0}>
|
<TooltipProvider delayDuration={0}>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button variant="ghost" size="icon">
|
<Button onClick={() => contentWindow.history.back()} variant="ghost" size="icon">
|
||||||
<Lucide.ArrowLeft />
|
<Lucide.ArrowLeft />
|
||||||
</Button>
|
</Button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
|
|
@ -137,7 +138,16 @@ export default function Route({ params }: { params: { route: string[] } }) {
|
||||||
|
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button variant="ghost" size="icon">
|
<Button onClick={() => contentWindow.history.forward()} variant="ghost" size="icon">
|
||||||
|
<Lucide.ArrowRight />
|
||||||
|
</Button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>Forward</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<Button onClick={() => contentWindow.location.reload()} variant="ghost" size="icon">
|
||||||
<Lucide.RotateCw />
|
<Lucide.RotateCw />
|
||||||
</Button>
|
</Button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue