forked from cms/tibi-svelte-starter
yarn 4
This commit is contained in:
40
frontend/src/App.svelte
Normal file
40
frontend/src/App.svelte
Normal file
@@ -0,0 +1,40 @@
|
||||
<script lang="ts">
|
||||
import { metricCall } from "./config"
|
||||
import { location } from "./lib/store"
|
||||
export let url = ""
|
||||
|
||||
if (url) {
|
||||
// ssr
|
||||
let l = url.split("?")
|
||||
$location = {
|
||||
path: l[0],
|
||||
search: l.length > 1 ? l[1] : "",
|
||||
hash: "",
|
||||
push: false,
|
||||
pop: false,
|
||||
}
|
||||
}
|
||||
|
||||
// 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",
|
||||
},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1>Tibi Svelte Starter</h1>
|
||||
|
||||
<style lang="less" global>
|
||||
@import "./css/style.less";
|
||||
</style>
|
||||
Reference in New Issue
Block a user