[+] Setting of score rounding and fix bugs

This commit is contained in:
Clansty
2024-08-08 14:49:20 +08:00
parent d0aecc76ed
commit a6a8734599
9 changed files with 106 additions and 8 deletions

View File

@@ -0,0 +1,24 @@
import { onMount } from 'svelte';
const useLocalStorage = <T>(key: string, initialValue: T) => {
let value = initialValue;
const currentValue = localStorage.getItem(key);
if (currentValue) value = JSON.parse(currentValue);
const save = () => {
localStorage.setItem(key, JSON.stringify(value));
};
return {
get value() {
return value;
},
set value(v: T) {
value = v;
save();
},
};
};
export default useLocalStorage;