Compare commits
2 commits
eb49450756
...
885fc5f906
Author | SHA1 | Date | |
---|---|---|---|
885fc5f906 | |||
195322f3b0 |
7 changed files with 35 additions and 14 deletions
3
app.vue
3
app.vue
|
@ -8,7 +8,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ContextMenu from '~/components/ContextMenu.vue';
|
import ContextMenu from '~/components/ContextMenu.vue';
|
||||||
import { render } from 'vue';
|
import { render } from 'vue';
|
||||||
import settingLoad from './utils/settingLoad';
|
|
||||||
|
|
||||||
const banner = useState("banner", () => false);
|
const banner = useState("banner", () => false);
|
||||||
|
|
||||||
|
@ -44,7 +43,7 @@ function contextMenuHandler(e: MouseEvent) {
|
||||||
//]);
|
//]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentTheme = settingLoad("selectedThemeUrl") ?? "dark"
|
const currentTheme = settingsLoad().selectedThemeId ?? "dark"
|
||||||
const baseURL = useRuntimeConfig().app.baseURL;
|
const baseURL = useRuntimeConfig().app.baseURL;
|
||||||
|
|
||||||
useHead({
|
useHead({
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<span v-if="getDayDifference(date, currentDate) === 1">Yesterday at</span>
|
<span v-if="getDayDifference(date, currentDate) === 1">Yesterday at</span>
|
||||||
<span v-else-if="getDayDifference(date, currentDate) > 1 ">{{ date.toLocaleDateString(undefined) }},</span>
|
<span v-else-if="getDayDifference(date, currentDate) > 1 ">{{ date.toLocaleDateString(undefined) }},</span>
|
||||||
|
|
||||||
{{ date.toLocaleTimeString(undefined, { hour12: props.format=="12", timeStyle: "short" }) }}
|
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-text" v-html="sanitized" tabindex="0"></div>
|
<div class="message-text" v-html="sanitized" tabindex="0"></div>
|
||||||
|
|
|
@ -24,14 +24,14 @@
|
||||||
<p class="subtitle">TIME FORMAT</p>
|
<p class="subtitle">TIME FORMAT</p>
|
||||||
<div class="icons">
|
<div class="icons">
|
||||||
<RadioButtons :button-count="3" :text-strings="timeFormatTextStrings"
|
<RadioButtons :button-count="3" :text-strings="timeFormatTextStrings"
|
||||||
:default-button-index="settingLoad('timeFormat')?.index ?? 0" :callback="onTimeFormatClicked"></RadioButtons>
|
:default-button-index="settingsLoad().timeFormat?.index ?? 0" :callback="onTimeFormatClicked"></RadioButtons>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import RadioButtons from '~/components/UserInterface/RadioButtons.vue';
|
import RadioButtons from '~/components/UserInterface/RadioButtons.vue';
|
||||||
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
import type { TimeFormat } from '~/types/settings';
|
||||||
import settingSave from '~/utils/settingSave';
|
import settingSave from '~/utils/settingSave';
|
||||||
|
|
||||||
const runtimeConfig = useRuntimeConfig()
|
const runtimeConfig = useRuntimeConfig()
|
||||||
|
@ -79,7 +79,18 @@ async function fetchThemes() {
|
||||||
await fetchThemes()
|
await fetchThemes()
|
||||||
|
|
||||||
async function onTimeFormatClicked(index: number) {
|
async function onTimeFormatClicked(index: number) {
|
||||||
settingSave("timeFormat", {index, timeFormat: timeFormatTextStrings[index].toLowerCase()})
|
let format: "auto" | "12" | "24" = "auto"
|
||||||
|
|
||||||
|
if (index == 0) {
|
||||||
|
format = "auto"
|
||||||
|
} else if (index == 1) {
|
||||||
|
format = "12"
|
||||||
|
} else if (index == 2) {
|
||||||
|
format = "24"
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeFormat: TimeFormat = {index, format}
|
||||||
|
settingSave("timeFormat", timeFormat)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="radio-buttons-container" ref="radioButtonsContainer">
|
<div class="radio-buttons-container" ref="radioButtonsContainer">
|
||||||
<div v-for="index in incidies" :key="index" class="radio-button" @click="onClick(index)">
|
<div v-for="index in indices" :key="index" class="radio-button" @click="onClick(index)">
|
||||||
<span class="radio-button-radio"></span>
|
<span class="radio-button-radio"></span>
|
||||||
<span class="radio-button-text">{{ textStrings[index] }}</span>
|
<span class="radio-button-text">{{ textStrings[index] }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,7 +19,7 @@ const props = defineProps<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// makes an array from 0 to buttonCount - 1
|
// makes an array from 0 to buttonCount - 1
|
||||||
const incidies = Array.from({ length: props.buttonCount }, (_, i) => i)
|
const indices = Array.from({ length: props.buttonCount }, (_, i) => i)
|
||||||
|
|
||||||
// select default selected button
|
// select default selected button
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
9
types/settings.ts
Normal file
9
types/settings.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export interface ClientSettings {
|
||||||
|
selectedThemeId?: string, // the ID of the theme, not the URL, for example "dark"
|
||||||
|
timeFormat?: TimeFormat
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TimeFormat {
|
||||||
|
index: number,
|
||||||
|
format: "auto" | "12" | "24"
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
export default (): "12" | "24" => {
|
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"
|
return "12"
|
||||||
} else if (format == "24-hour") {
|
} else if (format == "24") {
|
||||||
return "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")
|
let clientSettingsItem: string | null = localStorage.getItem("clientSettings")
|
||||||
if (typeof clientSettingsItem != "string") {
|
if (typeof clientSettingsItem != "string") {
|
||||||
clientSettingsItem = "{}"
|
clientSettingsItem = "{}"
|
||||||
}
|
}
|
||||||
|
|
||||||
let clientSettings: { [key: string]: any } = {}
|
let clientSettings: ClientSettings = {}
|
||||||
try {
|
try {
|
||||||
clientSettings = JSON.parse(clientSettingsItem)
|
clientSettings = JSON.parse(clientSettingsItem)
|
||||||
} catch {
|
} catch {
|
||||||
|
@ -15,5 +17,5 @@ export default (key: string): any => {
|
||||||
clientSettings = {}
|
clientSettings = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientSettings[key]
|
return clientSettings
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue