|
2 | 2 | import { onMount } from 'svelte'; |
3 | 3 | import { page } from '$app/stores'; |
4 | 4 | import { getUserStore, globalMenuStore } from '$lib/helpers/store'; |
| 5 | + import { getCleanUrl } from '$lib/helpers/utils/common'; |
5 | 6 |
|
6 | 7 | let { |
7 | 8 | htmlTagId = 'embedding-page', |
|
12 | 13 | /** @type {string} */ |
13 | 14 | let curSlug = $state(''); |
14 | 15 |
|
| 16 | + /** @type {boolean} */ |
| 17 | + let fullScreen = $state(false); |
| 18 | +
|
| 19 | + $effect(() => { |
| 20 | + const footer = document.querySelector('.footer'); |
| 21 | + const pageContent = document.querySelector('.page-content'); |
| 22 | +
|
| 23 | + if (fullScreen) { |
| 24 | + if (footer instanceof HTMLElement) { |
| 25 | + footer.style.display = 'none'; |
| 26 | + } |
| 27 | + if (pageContent instanceof HTMLElement) { |
| 28 | + pageContent.style.paddingBottom = '0'; |
| 29 | + } |
| 30 | + } else { |
| 31 | + if (footer instanceof HTMLElement) { |
| 32 | + footer.style.display = ''; |
| 33 | + } |
| 34 | + if (pageContent instanceof HTMLElement) { |
| 35 | + pageContent.style.paddingBottom = ''; |
| 36 | + } |
| 37 | + } |
| 38 | +
|
| 39 | + return () => { |
| 40 | + if (footer instanceof HTMLElement) { |
| 41 | + footer.style.display = ''; |
| 42 | + } |
| 43 | + if (pageContent instanceof HTMLElement) { |
| 44 | + pageContent.style.paddingBottom = ''; |
| 45 | + } |
| 46 | + }; |
| 47 | + }); |
| 48 | +
|
15 | 49 | // @ts-ignore |
16 | 50 | let slug = $derived($page.params[slugName]); |
17 | 51 |
|
|
25 | 59 |
|
26 | 60 | onMount(() => { |
27 | 61 | const menuUnsubscribe = globalMenuStore.subscribe((/** @type {import('$pluginTypes').PluginMenuDefModel[]} */ menu) => { |
28 | | - const url = getPathUrl(); |
29 | | - let found = menu.find(x => x.link === url); |
| 62 | + const url = getCleanPath(getPathUrl()); |
| 63 | + let found = menu.find(x => getCleanPath(x.link) === url); |
30 | 64 | label = found?.label || ''; |
31 | 65 | if (!found?.embeddingInfo) { |
32 | | - const subFound = menu.find(x => !!x.subMenu?.find(y => y.link === url)); |
33 | | - found = subFound?.subMenu?.find(x => x.link === url); |
| 66 | + const subFound = menu.find(x => !!x.subMenu?.find(y => getCleanPath(y.link) === url)); |
| 67 | + found = subFound?.subMenu?.find(x => getCleanPath(x.link) === url); |
34 | 68 | label = found?.label || ''; |
35 | 69 | } |
| 70 | + fullScreen = found?.embeddingInfo?.fullScreen || false; |
36 | 71 | embed(found?.embeddingInfo || null); |
37 | 72 | }); |
38 | 73 |
|
|
77 | 112 | } |
78 | 113 | } |
79 | 114 |
|
| 115 | + /** @param {string} url */ |
| 116 | + const getCleanPath = (url) => { |
| 117 | + return getCleanUrl((url || '').split('?')[0]); |
| 118 | + }; |
| 119 | +
|
80 | 120 | const getPathUrl = () => { |
81 | | - const path = $page.url.pathname; |
82 | | - return path?.startsWith('/') ? path.substring(1) : path; |
| 121 | + return $page.url.pathname || ''; |
83 | 122 | }; |
84 | 123 | </script> |
85 | 124 |
|
|
0 commit comments