2023-06-25:perf: 优化锁屏组件

(cherry picked from commit d884f71d57)
This commit is contained in:
YunaiV 2024-02-29 19:34:04 +08:00 committed by shizhong
parent 14e9d56c91
commit 6a3a215768
3 changed files with 2 additions and 62 deletions

View File

@ -180,7 +180,7 @@ defineExpose({
</script> </script>
<template> <template>
<div class="z-99 border-1 border-[var(--el-border-color)] border-solid"> <div class="border-1 border-solid border-[var(--tags-view-border-color)] z-10">
<!-- 工具栏 --> <!-- 工具栏 -->
<Toolbar <Toolbar
:editor="editorRef" :editor="editorRef"

View File

@ -2,7 +2,7 @@
import { resetRouter } from '@/router' import { resetRouter } from '@/router'
import { useCache } from '@/hooks/web/useCache' import { useCache } from '@/hooks/web/useCache'
import { useLockStore } from '@/store/modules/lock' import { useLockStore } from '@/store/modules/lock'
import { useNow } from './useNow' import { useNow } from '@/hooks/web/useNow'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { useTagsViewStore } from '@/store/modules/tagsView' import { useTagsViewStore } from '@/store/modules/tagsView'
import { useUserStore } from '@/store/modules/user' import { useUserStore } from '@/store/modules/user'

View File

@ -1,60 +0,0 @@
import { dateUtil } from '@/utils/dateUtil'
import { reactive, toRefs } from 'vue'
import { tryOnMounted, tryOnUnmounted } from '@vueuse/core'
export function useNow(immediate = true) {
let timer: IntervalHandle
const state = reactive({
year: 0,
month: 0,
week: '',
day: 0,
hour: '',
minute: '',
second: 0,
meridiem: ''
})
const update = () => {
const now = dateUtil()
const h = now.format('HH')
const m = now.format('mm')
const s = now.get('s')
state.year = now.get('y')
state.month = now.get('M') + 1
state.week = '星期' + ['日', '一', '二', '三', '四', '五', '六'][now.day()]
state.day = now.get('date')
state.hour = h
state.minute = m
state.second = s
state.meridiem = now.format('A')
}
function start() {
update()
clearInterval(timer)
timer = setInterval(() => update(), 1000)
}
function stop() {
clearInterval(timer)
}
tryOnMounted(() => {
immediate && start()
})
tryOnUnmounted(() => {
stop()
})
return {
...toRefs(state),
start,
stop
}
}