Browse Source

fix: 锁屏错误

pull/89/head
王军 3 years ago
parent
commit
fb66a38377
  1. 11
      vben28/src/views/sys/lock/useNow.ts

11
vben28/src/views/sys/lock/useNow.ts

@ -1,11 +1,8 @@
import { dateUtil } from '/@/utils/dateUtil'; import { dateUtil } from '/@/utils/dateUtil';
import { reactive, toRefs } from 'vue'; import { reactive, toRefs } from 'vue';
import { useLocaleStore } from '/@/store/modules/locale';
import { tryOnMounted, tryOnUnmounted } from '@vueuse/core'; import { tryOnMounted, tryOnUnmounted } from '@vueuse/core';
export function useNow(immediate = true) { export function useNow(immediate = true) {
const localeStore = useLocaleStore();
const localData = dateUtil.localeData(localeStore.getLocale);
let timer: IntervalHandle; let timer: IntervalHandle;
const state = reactive({ const state = reactive({
@ -28,13 +25,13 @@ export function useNow(immediate = true) {
state.year = now.get('y'); state.year = now.get('y');
state.month = now.get('M') + 1; state.month = now.get('M') + 1;
state.week = localData.weekdays()[now.day()]; state.week = '星期' + ['日', '一', '二', '三', '四', '五', '六'][now.day()];
state.day = now.get('D'); state.day = now.get('date');
state.hour = h; state.hour = h;
state.minute = m; state.minute = m;
state.second = s; state.second = s;
state.meridiem = localData.meridiem(Number(h), Number(h), true); state.meridiem = now.format('A');
}; };
function start() { function start() {
@ -60,4 +57,4 @@ export function useNow(immediate = true) {
start, start,
stop, stop,
}; };
} }
Loading…
Cancel
Save