refactor(client): typed localStorage
This commit is contained in:
		| @@ -120,10 +120,11 @@ import * as os from '@/os'; | ||||
| import { unisonReload } from '@/scripts/unison-reload'; | ||||
| import { i18n } from '@/i18n'; | ||||
| import { definePageMetadata } from '@/scripts/page-metadata'; | ||||
| import { miLocalStorage } from '@/local-storage'; | ||||
|  | ||||
| const lang = ref(localStorage.getItem('lang')); | ||||
| const fontSize = ref(localStorage.getItem('fontSize')); | ||||
| const useSystemFont = ref(localStorage.getItem('useSystemFont') != null); | ||||
| const lang = ref(miLocalStorage.getItem('lang')); | ||||
| const fontSize = ref(miLocalStorage.getItem('fontSize')); | ||||
| const useSystemFont = ref(miLocalStorage.getItem('useSystemFont') != null); | ||||
|  | ||||
| async function reloadAsk() { | ||||
| 	const { canceled } = await os.confirm({ | ||||
| @@ -157,23 +158,23 @@ const squareAvatars = computed(defaultStore.makeGetterSetter('squareAvatars')); | ||||
| const aiChanMode = computed(defaultStore.makeGetterSetter('aiChanMode')); | ||||
|  | ||||
| watch(lang, () => { | ||||
| 	localStorage.setItem('lang', lang.value as string); | ||||
| 	localStorage.removeItem('locale'); | ||||
| 	miLocalStorage.setItem('lang', lang.value as string); | ||||
| 	miLocalStorage.removeItem('locale'); | ||||
| }); | ||||
|  | ||||
| watch(fontSize, () => { | ||||
| 	if (fontSize.value == null) { | ||||
| 		localStorage.removeItem('fontSize'); | ||||
| 		miLocalStorage.removeItem('fontSize'); | ||||
| 	} else { | ||||
| 		localStorage.setItem('fontSize', fontSize.value); | ||||
| 		miLocalStorage.setItem('fontSize', fontSize.value); | ||||
| 	} | ||||
| }); | ||||
|  | ||||
| watch(useSystemFont, () => { | ||||
| 	if (useSystemFont.value) { | ||||
| 		localStorage.setItem('useSystemFont', 't'); | ||||
| 		miLocalStorage.setItem('useSystemFont', 't'); | ||||
| 	} else { | ||||
| 		localStorage.removeItem('useSystemFont'); | ||||
| 		miLocalStorage.removeItem('useSystemFont'); | ||||
| 	} | ||||
| }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 syuilo
					syuilo