fix: missing navigator object in server-side
This commit is contained in:
parent
5a112aeaee
commit
a31f702499
@ -2,10 +2,9 @@
|
||||
import {N_ARRAY} from "src/const";
|
||||
import {fade} from "svelte/transition";
|
||||
import {UAParser} from 'ua-parser-js';
|
||||
import {onMount} from "svelte";
|
||||
|
||||
const ua = navigator ? navigator.userAgent : "";
|
||||
|
||||
const { browser } = UAParser(ua);
|
||||
let browserInfo: null | string = null;
|
||||
|
||||
let bigintSupported = typeof BigInt !== 'undefined';
|
||||
|
||||
@ -163,6 +162,12 @@
|
||||
}
|
||||
return Number(speedSample.difficulty) / speedSample.time * 1000;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const ua = navigator ? navigator.userAgent : "";
|
||||
const {browser} = UAParser(ua);
|
||||
browserInfo = browser.name + " " + browser.version;
|
||||
})
|
||||
</script>
|
||||
|
||||
<div
|
||||
@ -216,7 +221,9 @@
|
||||
速度是在 N = {speedSample.N.toString(2).length} bits, T = {speedSample.difficulty} 的测试中测量的.
|
||||
</span>
|
||||
<br/>
|
||||
浏览器版本:{browser}
|
||||
{#if browserInfo}
|
||||
浏览器版本:{browserInfo}
|
||||
{/if}
|
||||
</p>
|
||||
<table class="w-full text-sm text-left rtl:text-right mt-4">
|
||||
<thead class="text-sm uppercase font-medium border-b border-outline dark:border-dark-outline">
|
||||
|
Loading…
Reference in New Issue
Block a user