feat: make settings typed and store "12" and "24" over "12-hour" and "24-hour" internally
This commit is contained in:
parent
eb49450756
commit
195322f3b0
5 changed files with 32 additions and 11 deletions
|
@ -1,9 +1,9 @@
|
|||
export default (): "12" | "24" => {
|
||||
const format = settingLoad("timeFormat").timeFormat ?? "auto"
|
||||
const format = settingsLoad().timeFormat?.format ?? "auto"
|
||||
|
||||
if (format == "12-hour") {
|
||||
if (format == "12") {
|
||||
return "12"
|
||||
} else if (format == "24-hour") {
|
||||
} else if (format == "24") {
|
||||
return "24"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
export default (key: string): any => {
|
||||
import type { ClientSettings } from "~/types/settings"
|
||||
|
||||
export default (): ClientSettings => {
|
||||
let clientSettingsItem: string | null = localStorage.getItem("clientSettings")
|
||||
if (typeof clientSettingsItem != "string") {
|
||||
clientSettingsItem = "{}"
|
||||
}
|
||||
|
||||
let clientSettings: { [key: string]: any } = {}
|
||||
let clientSettings: ClientSettings = {}
|
||||
try {
|
||||
clientSettings = JSON.parse(clientSettingsItem)
|
||||
} catch {
|
||||
|
@ -15,5 +17,5 @@ export default (key: string): any => {
|
|||
clientSettings = {}
|
||||
}
|
||||
|
||||
return clientSettings[key]
|
||||
return clientSettings
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue