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