fix: language
This commit is contained in:
parent
036f8186f4
commit
9039fb1a57
|
@ -1,10 +1,9 @@
|
|||
<script setup>
|
||||
import Taskbar from '~/components/Taskbar.vue';
|
||||
import AboutMeWindow from '~/components/AboutMeWindow.vue';
|
||||
import { ref, reactive, onMounted, onUnmounted, computed, watch } from 'vue';
|
||||
import { ref, reactive, onMounted, onUnmounted, computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { locale } = useI18n();
|
||||
|
||||
// Reactive array to hold all window states
|
||||
const windows = reactive([]);
|
||||
|
|
|
@ -48,7 +48,7 @@ defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const currentTime = ref(new Date().toLocaleTimeString());
|
||||
const currentTime = ref('');
|
||||
const isMounted = ref(false);
|
||||
let timerId = null;
|
||||
const showStartMenu = ref(false);
|
||||
|
@ -79,11 +79,20 @@ const restoreMinimizedWindow = (id) => {
|
|||
emit('restore-window', id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
const updateCurrentTime = () => {
|
||||
// Map i18n locale to a specific locale for time formatting
|
||||
const timeLocale = locale.value === 'zh-tw' ? 'zh-TW' : 'en-US';
|
||||
currentTime.value = new Date().toLocaleTimeString(timeLocale);
|
||||
};
|
||||
// Watch for locale changes to update the time format immediately
|
||||
watch(locale, updateCurrentTime);
|
||||
|
||||
onMounted(() => {
|
||||
isMounted.value = true;
|
||||
timerId = setInterval(() => {
|
||||
currentTime.value = new Date().toLocaleTimeString();
|
||||
}, 1000);
|
||||
updateCurrentTime(); // Set initial time based on current locale
|
||||
timerId = setInterval(updateCurrentTime, 1000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
|
|
Loading…
Reference in New Issue