1
0

LockPage.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div :class="prefixCls">
  3. <div :class="`${prefixCls}__unlock`" @click="handleShowForm(false)" v-show="showDate">
  4. <LockOutlined />
  5. <span>{{ t('sys.lock.unlock') }}</span>
  6. </div>
  7. <div :class="`${prefixCls}__date`">
  8. <div :class="`${prefixCls}__hour`">
  9. {{ hour }}
  10. <span class="meridiem" v-show="showDate">{{ meridiem }}</span>
  11. </div>
  12. <div :class="`${prefixCls}__minute`">{{ minute }} </div>
  13. </div>
  14. <transition name="fade-slide">
  15. <div :class="`${prefixCls}-entry`" v-show="!showDate">
  16. <div :class="`${prefixCls}-entry-content`">
  17. <div :class="`${prefixCls}-entry__header`">
  18. <img :src="headerImg" :class="`${prefixCls}-entry__header-img`" />
  19. <p :class="`${prefixCls}-entry__header-name`">{{ realName }}</p>
  20. </div>
  21. <InputPassword :placeholder="t('sys.lock.placeholder')" v-model:value="password" />
  22. <span :class="`${prefixCls}-entry__err-msg`" v-if="errMsgRef">
  23. {{ t('sys.lock.alert') }}
  24. </span>
  25. <div :class="`${prefixCls}-entry__footer`">
  26. <a-button
  27. type="link"
  28. size="small"
  29. class="mt-2 mr-2"
  30. :disabled="loadingRef"
  31. @click="handleShowForm(true)"
  32. >
  33. {{ t('common.back') }}
  34. </a-button>
  35. <a-button
  36. type="link"
  37. size="small"
  38. class="mt-2 mr-2"
  39. :disabled="loadingRef"
  40. @click="goLogin"
  41. >
  42. {{ t('sys.lock.backToLogin') }}
  43. </a-button>
  44. <a-button class="mt-2" type="link" size="small" @click="unLock()" :loading="loadingRef">
  45. {{ t('sys.lock.entry') }}
  46. </a-button>
  47. </div>
  48. </div>
  49. </div>
  50. </transition>
  51. <div :class="`${prefixCls}__footer-date`">
  52. <div class="time" v-show="!showDate">
  53. {{ hour }}:{{ minute }} <span class="meridiem">{{ meridiem }}</span>
  54. </div>
  55. <div class="date"> {{ year }}/{{ month }}/{{ day }} {{ week }} </div>
  56. </div>
  57. </div>
  58. </template>
  59. <script lang="ts">
  60. import { defineComponent, ref, computed } from 'vue';
  61. import { Alert, Input } from 'ant-design-vue';
  62. import { userStore } from '/@/store/modules/user';
  63. import { lockStore } from '/@/store/modules/lock';
  64. import { useI18n } from '/@/hooks/web/useI18n';
  65. import { useNow } from './useNow';
  66. import { useDesign } from '/@/hooks/web/useDesign';
  67. import { LockOutlined } from '@ant-design/icons-vue';
  68. import headerImg from '/@/assets/images/header.jpg';
  69. export default defineComponent({
  70. name: 'LockPage',
  71. components: { Alert, LockOutlined, InputPassword: Input.Password },
  72. setup() {
  73. const passwordRef = ref('');
  74. const loadingRef = ref(false);
  75. const errMsgRef = ref(false);
  76. const showDate = ref(true);
  77. const { prefixCls } = useDesign('lock-page');
  78. const { start, stop, ...state } = useNow(true);
  79. const { t } = useI18n();
  80. const realName = computed(() => {
  81. const { realName } = userStore.getUserInfoState || {};
  82. return realName;
  83. });
  84. /**
  85. * @description: unLock
  86. */
  87. async function unLock() {
  88. if (!passwordRef.value) {
  89. return;
  90. }
  91. let password = passwordRef.value;
  92. try {
  93. loadingRef.value = true;
  94. const res = await lockStore.unLockAction({ password });
  95. errMsgRef.value = !res;
  96. } finally {
  97. loadingRef.value = false;
  98. }
  99. }
  100. function goLogin() {
  101. userStore.loginOut(true);
  102. lockStore.resetLockInfo();
  103. }
  104. function handleShowForm(show = false) {
  105. showDate.value = show;
  106. }
  107. return {
  108. goLogin,
  109. realName,
  110. unLock,
  111. errMsgRef,
  112. loadingRef,
  113. t,
  114. prefixCls,
  115. showDate,
  116. password: passwordRef,
  117. handleShowForm,
  118. headerImg,
  119. ...state,
  120. };
  121. },
  122. });
  123. </script>
  124. <style lang="less" scoped>
  125. @prefix-cls: ~'@{namespace}-lock-page';
  126. .@{prefix-cls} {
  127. position: fixed;
  128. top: 0;
  129. right: 0;
  130. bottom: 0;
  131. left: 0;
  132. z-index: @lock-page-z-index;
  133. display: flex;
  134. width: 100vw;
  135. height: 100vh;
  136. // background: rgba(23, 27, 41);
  137. background: #000;
  138. align-items: center;
  139. justify-content: center;
  140. &__unlock {
  141. position: absolute;
  142. top: 0;
  143. left: 50%;
  144. display: flex;
  145. height: 50px;
  146. padding-top: 20px;
  147. font-size: 18px;
  148. color: #fff;
  149. cursor: pointer;
  150. transform: translate(-50%, 0);
  151. flex-direction: column;
  152. align-items: center;
  153. justify-content: space-between;
  154. transition: all 0.3s;
  155. }
  156. &__date {
  157. display: flex;
  158. width: 100vw;
  159. height: 100vh;
  160. align-items: center;
  161. justify-content: center;
  162. }
  163. &__hour {
  164. position: relative;
  165. margin-right: 80px;
  166. .meridiem {
  167. position: absolute;
  168. top: 20px;
  169. left: 20px;
  170. font-size: 26px;
  171. }
  172. @media (max-width: @screen-xs) {
  173. margin-right: 20px;
  174. }
  175. }
  176. &__hour,
  177. &__minute {
  178. display: flex;
  179. width: 40%;
  180. height: 74%;
  181. // font-size: 50em;
  182. font-weight: 700;
  183. color: #bababa;
  184. background: #141313;
  185. border-radius: 30px;
  186. justify-content: center;
  187. align-items: center;
  188. // .respond-to(large-only, { font-size: 25em;});
  189. // .respond-to(large-only, { font-size: 30em;});
  190. @media (min-width: @screen-xxxl-min) {
  191. font-size: 46em;
  192. }
  193. @media (min-width: @screen-xl-max) and (max-width: @screen-xxl-max) {
  194. font-size: 38em;
  195. }
  196. @media (min-width: @screen-lg-max) and (max-width: @screen-xl-max) {
  197. font-size: 30em;
  198. }
  199. @media (min-width: @screen-md-max) and (max-width: @screen-lg-max) {
  200. font-size: 23em;
  201. }
  202. @media (min-width: @screen-sm-max) and (max-width: @screen-md-max) {
  203. height: 50%;
  204. font-size: 12em;
  205. border-radius: 10px;
  206. .meridiem {
  207. font-size: 20px;
  208. }
  209. }
  210. @media (min-width: @screen-xs-max) and (max-width: @screen-sm-max) {
  211. font-size: 13em;
  212. }
  213. @media (max-width: @screen-xs) {
  214. height: 30%;
  215. font-size: 5em;
  216. border-radius: 10px;
  217. .meridiem {
  218. font-size: 14px;
  219. }
  220. }
  221. }
  222. &__footer-date {
  223. position: absolute;
  224. bottom: 20px;
  225. width: 100%;
  226. font-family: helvetica;
  227. color: #bababa;
  228. text-align: center;
  229. .time {
  230. font-size: 50px;
  231. .meridiem {
  232. font-size: 32px;
  233. }
  234. }
  235. .date {
  236. font-size: 26px;
  237. }
  238. }
  239. &-entry {
  240. position: absolute;
  241. top: 0;
  242. left: 0;
  243. display: flex;
  244. width: 100%;
  245. height: 100%;
  246. background: rgba(0, 0, 0, 0.5);
  247. backdrop-filter: blur(8px);
  248. justify-content: center;
  249. align-items: center;
  250. &-content {
  251. width: 260px;
  252. }
  253. &__header {
  254. text-align: center;
  255. &-img {
  256. width: 70px;
  257. border-radius: 50%;
  258. }
  259. &-name {
  260. margin-top: 5px;
  261. font-weight: 500;
  262. color: #bababa;
  263. }
  264. }
  265. &__err-msg {
  266. display: inline-block;
  267. margin-top: 10px;
  268. color: @error-color;
  269. }
  270. &__footer {
  271. display: flex;
  272. justify-content: space-between;
  273. }
  274. }
  275. }
  276. </style>