Aktualisiere Metriken-Logik in App.svelte zur Verwendung von $effect und verbessere die Lesbarkeit
This commit is contained in:
@@ -16,21 +16,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// metrics
|
// metrics
|
||||||
let oldPath: string
|
let oldPath = $state("")
|
||||||
$: if (metricCall && typeof window !== "undefined" && oldPath !== $location.path) {
|
$effect(() => {
|
||||||
const ref = oldPath ? document.location.protocol + "//" + document.location.host + oldPath : document.referrer
|
if (metricCall && typeof window !== "undefined" && oldPath !== $location.path) {
|
||||||
oldPath = $location.path
|
const ref = oldPath
|
||||||
const fetchPath = oldPath + (oldPath.includes("?") ? "&" : "?") + "metrics"
|
? document.location.protocol + "//" + document.location.host + oldPath
|
||||||
fetch(fetchPath, {
|
: document.referrer
|
||||||
headers: {
|
oldPath = $location.path
|
||||||
"x-ssr-skip": "204",
|
const fetchPath = oldPath + (oldPath.includes("?") ? "&" : "?") + "metrics"
|
||||||
"x-ssr-ref": ref,
|
fetch(fetchPath, {
|
||||||
"x-ssr-res": `${window.innerWidth}x${window.innerHeight}`,
|
headers: {
|
||||||
// no cache
|
"x-ssr-skip": "204",
|
||||||
"cache-control": "no-cache, no-store, must-revalidate",
|
"x-ssr-ref": ref,
|
||||||
},
|
"x-ssr-res": `${window.innerWidth}x${window.innerHeight}`,
|
||||||
})
|
// no cache
|
||||||
}
|
"cache-control": "no-cache, no-store, must-revalidate",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>Tibi Svelte Starter</h1>
|
<h1>Tibi Svelte Starter</h1>
|
||||||
|
|||||||
Reference in New Issue
Block a user