/** * * @author Ray * * @date 2023-06-20 * * @workspace ray-template * * @remark 今天也是元气满满撸代码的一天 */ /** 解锁界面 */ import { NInput, NForm, NFormItem, NButton, NSpace } from 'naive-ui' import AppAvatar from '@/app-components/app/AppAvatar/index' import dayjs from 'dayjs' import { useSetting, useSignin } from '@/store' import { rules, useCondition } from '@/app-components/app/AppLockScreen/hook' import useAppLockScreen from '@/app-components/app/AppLockScreen/appLockVar' import type { FormInst, InputInst } from 'naive-ui' const UnlockScreen = defineComponent({ name: 'UnlockScreen', setup() { const formRef = ref(null) const inputInstRef = ref(null) const { logout } = useSignin() const { changeSwitcher } = useSetting() const { setLockAppScreen } = useAppLockScreen() const HH_MM_FORMAT = 'HH:mm' const AM_PM_FORMAT = 'A' const YY_MM_DD_FORMAT = 'YY年MM月DD日' const DDD_FORMAT = 'ddd' const state = reactive({ lockCondition: useCondition(), HH_MM: dayjs().format(HH_MM_FORMAT), AM_PM: dayjs().locale('en').format(AM_PM_FORMAT), YY_MM_DD: dayjs().format(YY_MM_DD_FORMAT), DDD: dayjs().format(DDD_FORMAT), }) const dayInterval = setInterval(() => { state.HH_MM = dayjs().format(HH_MM_FORMAT) state.AM_PM = dayjs().format(AM_PM_FORMAT) }, 6_000) const yearInterval = setInterval(() => { state.YY_MM_DD = dayjs().format(YY_MM_DD_FORMAT) state.DDD = dayjs().format(DDD_FORMAT) }, 86_400_000) /** 退出登陆并且回到登陆页 */ const backToSignin = () => { window.$dialog.warning({ title: '警告', content: '是否返回到登陆页?', positiveText: '确定', negativeText: '取消', onPositiveClick: () => { logout() setTimeout(() => { changeSwitcher(false, 'lockScreenSwitch') }) }, }) } /** 解锁 */ const unlockScreen = () => { formRef.value?.validate((error) => { if (!error) { setLockAppScreen(false) changeSwitcher(false, 'lockScreenSwitch') state.lockCondition = useCondition() } }) } onBeforeUnmount(() => { clearInterval(dayInterval) clearInterval(yearInterval) }) return { ...toRefs(state), backToSignin, unlockScreen, formRef, inputInstRef, } }, render() { return (
{this.HH_MM?.split(':')[0]}
{this.HH_MM?.split(':')[1]}
返回登陆 进入系统
) }, }) export default UnlockScreen