123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- <template>
- <div v-show="state.isShowLockScreen">
- <div class="layout-lock-screen-mask"></div>
- <div class="layout-lock-screen-img" :class="{ 'layout-lock-screen-filter': state.isShowLoockLogin }"></div>
- <div class="layout-lock-screen">
- <div
- class="layout-lock-screen-date"
- ref="layoutLockScreenDateRef"
- @mousedown="onDown"
- @mousemove="onMove"
- @mouseup="onEnd"
- @touchstart.stop="onDown"
- @touchmove.stop="onMove"
- @touchend.stop="onEnd"
- >
- <div class="layout-lock-screen-date-box">
- <div class="layout-lock-screen-date-box-time">
- {{ state.time.hm }}:<span>{{ state.time.s }}</span>
- </div>
- <div class="layout-lock-screen-date-box-info">{{ state.time.mdq }}</div>
- </div>
- <div class="layout-lock-screen-date-top">
- <SvgIcon name="ele-Top" />
- <div class="layout-lock-screen-date-top-text">上滑解锁</div>
- </div>
- </div>
- <transition name="el-zoom-in-center">
- <div v-show="state.isShowLoockLogin" class="layout-lock-screen-login">
- <div class="layout-lock-screen-login-box">
- <div class="layout-lock-screen-login-box-name">{{ userInfos.name }}</div>
- <div class="layout-lock-screen-login-box-value">
- <el-input
- placeholder="请输入密码"
- ref="layoutLockScreenInputRef"
- v-model="state.lockScreenPassword"
- @keyup.enter.native.stop="onLockScreenSubmit()"
- clearable
- >
- <template #append>
- <el-button @click="onLockScreenSubmit">
- <el-icon class="el-input__icon">
- <ele-Right />
- </el-icon>
- </el-button>
- </template>
- </el-input>
- </div>
- </div>
- <div class="layout-lock-screen-login-icon">
- <!-- <SvgIcon name="ele-Microphone" :size="20" />
- <SvgIcon name="ele-AlarmClock" :size="20" /> -->
- <SvgIcon name="ele-SwitchButton" size="20px" @click="fogetPwd" />
- </div>
- </div>
- </transition>
- </div>
- </div>
- </template>
- <script setup lang="ts" name="layoutLockScreen">
- import {nextTick, onMounted, onUnmounted, reactive, ref} from 'vue';
- import {formatDate} from '/@/utils/formatTime';
- import {Cookie, Local, Session} from '/@/utils/storage';
- import {storeToRefs} from 'pinia';
- import {useThemeConfig} from '/@/stores/themeConfig';
- import {useUserInfo} from '/@/stores/userInfo';
- import {ElMessage, ElMessageBox} from 'element-plus';
- // 定义接口来定义对象的类型
- interface LockScreenState {
- transparency: number;
- downClientY: number;
- moveDifference: number;
- isShowLoockLogin: boolean;
- isFlags: boolean;
- querySelectorEl: HTMLElement | string;
- time: {
- hm: string;
- s: string;
- mdq: string;
- };
- setIntervalTime: number;
- isShowLockScreen: boolean;
- isShowLockScreenIntervalTime: number;
- lockScreenPassword: string;
- }
- // 定义变量内容
- const layoutLockScreenInputRef = ref<RefType>();
- const storesThemeConfig = useThemeConfig();
- const { themeConfig } = storeToRefs(storesThemeConfig);
- const storesUserInfo = useUserInfo();
- const {userInfos} = storeToRefs(storesUserInfo);
- const state = reactive<LockScreenState>({
- transparency: 1,
- downClientY: 0,
- moveDifference: 0,
- isShowLoockLogin: false,
- isFlags: false,
- querySelectorEl: '',
- time: {
- hm: '',
- s: '',
- mdq: '',
- },
- setIntervalTime: 0,
- isShowLockScreen: false,
- isShowLockScreenIntervalTime: 0,
- lockScreenPassword: '',
- });
- // 鼠标按下
- const onDown = (down: any) => {
- state.isFlags = true;
- state.downClientY = down.touches ? down.touches[0].clientY : down.clientY;
- };
- // 鼠标移动
- const onMove = (move: any) => {
- if (state.isFlags) {
- const el = <HTMLElement>state.querySelectorEl;
- const opacitys = (state.transparency -= 1 / 200);
- if (move.touches) {
- state.moveDifference = move.touches[0].clientY - state.downClientY;
- } else {
- state.moveDifference = move.clientY - state.downClientY;
- }
- if (state.moveDifference >= 0) return false;
- el.setAttribute('style', `top:${state.moveDifference}px;cursor:pointer;opacity:${opacitys};`);
- if (state.moveDifference < -400) {
- el.setAttribute('style', `top:${-el.clientHeight}px;cursor:pointer;transition:all 0.3s ease;`);
- state.moveDifference = -el.clientHeight;
- setTimeout(() => {
- el && el.parentNode?.removeChild(el);
- }, 300);
- }
- if (state.moveDifference === -el.clientHeight) {
- state.isShowLoockLogin = true;
- layoutLockScreenInputRef.value.focus();
- }
- }
- };
- // 鼠标松开
- const onEnd = () => {
- state.isFlags = false;
- state.transparency = 1;
- if (state.moveDifference >= -400) {
- (<HTMLElement>state.querySelectorEl).setAttribute('style', `top:0px;opacity:1;transition:all 0.3s ease;`);
- }
- };
- const layoutLockScreenDateRef = ref<RefType>();
- // 获取要拖拽的初始元素
- const initGetElement = () => {
- nextTick(() => {
- state.querySelectorEl = layoutLockScreenDateRef.value;
- });
- };
- // 时间初始化
- const initTime = () => {
- state.time.hm = formatDate(new Date(), 'HH:MM');
- state.time.s = formatDate(new Date(), 'SS');
- state.time.mdq = formatDate(new Date(), 'mm月dd日,WWW');
- };
- // 时间初始化定时器
- const initSetTime = () => {
- initTime();
- state.setIntervalTime = window.setInterval(() => {
- initTime();
- }, 1000);
- };
- // 锁屏时间定时器
- const initLockScreen = () => {
- state.isShowLockScreen = true;
- setLocalThemeConfig();
- };
- // 存储布局配置
- const setLocalThemeConfig = () => {
- themeConfig.value.isDrawer = false;
- Local.set('themeConfig', themeConfig.value);
- };
- // 密码输入点击事件
- const onLockScreenSubmit = () => {
- if (Session.get('lockPwd') != state.lockScreenPassword) {
- ElMessage({
- message: '锁屏密码错误,请重试',
- type: 'warning',
- });
- return;
- }
- themeConfig.value.isLockScreen = false;
- Local.set('themeConfig', themeConfig.value);
- };
- const fogetPwd = () => {
- ElMessageBox.confirm(`忘记密码重新进入系统,是否继续?`, '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning',
- draggable: true,
- cancelButtonClass: 'default-button',
- autofocus: false,
- })
- .then(() => {
- setLocalThemeConfig();
- // 清除缓存/token等
- Session.clear();
- Cookie.clear();
- Local.clear();
- window.location.reload();
- })
- .catch(() => {});
- };
- // 页面加载时
- onMounted(() => {
- initGetElement();
- initSetTime();
- initLockScreen();
- });
- // 页面卸载时
- onUnmounted(() => {
- window.clearInterval(state.setIntervalTime);
- window.clearInterval(state.isShowLockScreenIntervalTime);
- });
- </script>
- <style scoped lang="scss">
- .layout-lock-screen-fixed {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- }
- .layout-lock-screen-filter {
- filter: blur(3px);
- }
- .layout-lock-screen-mask {
- background: var(--el-color-white);
- @extend .layout-lock-screen-fixed;
- z-index: 9;
- }
- .layout-lock-screen-img {
- @extend .layout-lock-screen-fixed;
- //background-image: url(https://i.hd-r.cn/e4a19d84364f185266666765ac21a5db.jpg);
- background-image: url(/@/assets/images/login/bg.png);
- background-size: calc(100vw + 1px) calc(100vh + 1px);
- z-index: 99;
- }
- .layout-lock-screen {
- @extend .layout-lock-screen-fixed;
- z-index: 999;
- &-date {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 100%;
- color: var(--el-color-white);
- z-index: 9999;
- user-select: none;
- &-box {
- position: absolute;
- left: 30px;
- bottom: 50px;
- &-time {
- font-size: 100px;
- color: var(--el-color-white);
- }
- &-info {
- font-size: 40px;
- color: var(--el-color-white);
- }
- &-minutes {
- font-size: 16px;
- }
- }
- &-top {
- width: 40px;
- height: 40px;
- line-height: 40px;
- border-radius: 100%;
- border: 1px solid var(--el-border-color-light, #ebeef5);
- background: rgba(255, 255, 255, 0.1);
- color: var(--el-color-white);
- opacity: 0.8;
- position: absolute;
- right: 30px;
- bottom: 50px;
- text-align: center;
- overflow: hidden;
- transition: all 0.3s ease;
- i {
- transition: all 0.3s ease;
- }
- &-text {
- opacity: 0;
- position: absolute;
- top: 150%;
- font-size: 12px;
- color: var(--el-color-white);
- left: 50%;
- line-height: 1.2;
- transform: translate(-50%, -50%);
- transition: all 0.3s ease;
- width: 35px;
- }
- &:hover {
- border: 1px solid rgba(255, 255, 255, 0.5);
- background: rgba(255, 255, 255, 0.2);
- box-shadow: 0 0 12px 0 rgba(255, 255, 255, 0.5);
- color: var(--el-color-white);
- opacity: 1;
- transition: all 0.3s ease;
- i {
- transform: translateY(-40px);
- transition: all 0.3s ease;
- }
- .layout-lock-screen-date-top-text {
- opacity: 1;
- top: 50%;
- transition: all 0.3s ease;
- }
- }
- }
- }
- &-login {
- position: relative;
- z-index: 9999994;
- width: 100%;
- height: 100%;
- left: 0;
- top: 0;
- display: flex;
- flex-direction: column;
- justify-content: center;
- color: var(--el-color-white);
- &-box {
- text-align: center;
- margin: auto;
- &-img {
- width: 180px;
- height: 180px;
- margin: auto;
- img {
- width: 100%;
- height: 100%;
- border-radius: 100%;
- }
- }
- &-name {
- font-size: 26px;
- margin: 15px 0 30px;
- }
- }
- &-icon {
- position: absolute;
- right: 30px;
- bottom: 30px;
- i {
- font-size: 20px;
- margin-left: 15px;
- cursor: pointer;
- opacity: 0.8;
- &:hover {
- opacity: 1;
- }
- }
- }
- }
- }
- :deep(.el-input-group__append) {
- background: var(--el-color-white);
- padding: 0px 15px;
- }
- :deep(.el-input__inner) {
- border-right-color: var(--el-border-color-extra-light);
- &:hover {
- border-color: var(--el-border-color-extra-light);
- }
- }
- </style>
|