login.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. {{ template "page/head_start" .}}
  2. <style>
  3. html * {
  4. -webkit-font-smoothing: antialiased;
  5. -moz-osx-font-smoothing: grayscale;
  6. }
  7. h1 {
  8. text-align: center;
  9. /*margin: 20px 0 50px 0;*/
  10. height: 110px;
  11. }
  12. .ant-form-item-children .ant-btn,
  13. .ant-input {
  14. height: 50px;
  15. border-radius: 30px;
  16. }
  17. .ant-input-group-addon {
  18. border-radius: 0 30px 30px 0;
  19. width: 50px;
  20. font-size: 18px;
  21. }
  22. .ant-input-affix-wrapper .ant-input-prefix {
  23. left: 23px;
  24. }
  25. .ant-input-affix-wrapper .ant-input:not(:first-child) {
  26. padding-left: 50px;
  27. }
  28. .centered {
  29. display: flex;
  30. text-align: center;
  31. align-items: center;
  32. justify-content: center;
  33. width: 100%;
  34. }
  35. .title {
  36. font-size: 2rem;
  37. margin-block-end: 2rem;
  38. }
  39. .title b {
  40. font-weight: bold !important;
  41. }
  42. #app {
  43. overflow: hidden;
  44. }
  45. #login {
  46. animation: charge 0.5s both;
  47. background-color: #fff;
  48. border-radius: 2rem;
  49. padding: 4rem 3rem;
  50. transition: all 0.3s;
  51. user-select: none;
  52. -webkit-user-select: none;
  53. -moz-user-select: none;
  54. }
  55. #login:hover {
  56. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
  57. }
  58. @keyframes charge {
  59. from {
  60. transform: translateY(5rem);
  61. opacity: 0;
  62. }
  63. to {
  64. transform: translateY(0);
  65. opacity: 1;
  66. }
  67. }
  68. .under {
  69. background-color: #c7ebe2;
  70. z-index: 0;
  71. }
  72. .dark .under {
  73. background-color: var(--dark-color-login-wave);
  74. }
  75. .dark #login {
  76. background-color: var(--dark-color-surface-100);
  77. }
  78. .dark h1 {
  79. color: rgba(255, 255, 255);
  80. }
  81. .ant-btn-primary-login {
  82. width: 100%;
  83. }
  84. .ant-btn-primary-login:focus,
  85. .ant-btn-primary-login:hover {
  86. color: #fff;
  87. background-color: #006655;
  88. border-color: #006655;
  89. background-image: linear-gradient(270deg,
  90. rgba(123, 199, 77, 0) 30%,
  91. #009980,
  92. rgba(123, 199, 77, 0) 100%);
  93. background-repeat: no-repeat;
  94. animation: ma-bg-move ease-in-out 5s infinite;
  95. background-position-x: -500px;
  96. width: 95%;
  97. animation-delay: -0.5s;
  98. box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);
  99. }
  100. .ant-btn-primary-login.active,
  101. .ant-btn-primary-login:active {
  102. color: #fff;
  103. background-color: #006655;
  104. border-color: #006655;
  105. }
  106. @keyframes ma-bg-move {
  107. 0% {
  108. background-position: -500px 0;
  109. }
  110. 50% {
  111. background-position: 1000px 0;
  112. }
  113. 100% {
  114. background-position: 1000px 0;
  115. }
  116. }
  117. .wave-btn-bg {
  118. position: relative;
  119. border-radius: 25px;
  120. width: 100%;
  121. transition: all 0.3s cubic-bezier(.645, .045, .355, 1);
  122. }
  123. .dark .wave-btn-bg {
  124. color: #fff;
  125. position: relative;
  126. background-color: #0a7557;
  127. border: 2px double transparent;
  128. background-origin: border-box;
  129. background-clip: padding-box, border-box;
  130. background-size: 300%;
  131. width: 100%;
  132. z-index: 1;
  133. }
  134. .dark .wave-btn-bg:hover {
  135. animation: wave-btn-tara 4s ease infinite;
  136. }
  137. .dark .wave-btn-bg-cl {
  138. background-image: linear-gradient(rgba(13, 14, 33, 0), rgba(13, 14, 33, 0)),
  139. radial-gradient(circle at left top, #006655, #009980, #006655) !important;
  140. border-radius: 3em;
  141. }
  142. .dark .wave-btn-bg-cl:hover {
  143. width: 95%;
  144. }
  145. .dark .wave-btn-bg-cl:before {
  146. position: absolute;
  147. content: "";
  148. top: -5px;
  149. left: -5px;
  150. bottom: -5px;
  151. right: -5px;
  152. z-index: -1;
  153. background: inherit;
  154. background-size: inherit;
  155. border-radius: 4em;
  156. opacity: 0;
  157. transition: 0.5s;
  158. }
  159. .dark .wave-btn-bg-cl:hover::before {
  160. opacity: 1;
  161. filter: blur(20px);
  162. animation: wave-btn-tara 8s linear infinite;
  163. }
  164. @keyframes wave-btn-tara {
  165. to {
  166. background-position: 300%;
  167. }
  168. }
  169. .dark .ant-btn-primary-login {
  170. font-size: 14px;
  171. color: #fff;
  172. text-align: center;
  173. background-image: linear-gradient(rgba(13, 14, 33, 0.45),
  174. rgba(13, 14, 33, 0.35));
  175. border-radius: 2rem;
  176. border: none;
  177. outline: none;
  178. background-color: transparent;
  179. height: 46px;
  180. position: relative;
  181. white-space: nowrap;
  182. cursor: pointer;
  183. touch-action: manipulation;
  184. padding: 0 15px;
  185. width: 100%;
  186. animation: none;
  187. background-position-x: 0;
  188. box-shadow: none;
  189. }
  190. .waves-header {
  191. position: fixed;
  192. width: 100%;
  193. text-align: center;
  194. background-color: #dbf5ed;
  195. color: white;
  196. z-index: -1;
  197. }
  198. .dark .waves-header {
  199. background-color: var(--dark-color-login-background);
  200. }
  201. .waves-inner-header {
  202. height: 50vh;
  203. width: 100%;
  204. margin: 0;
  205. padding: 0;
  206. }
  207. .waves {
  208. position: relative;
  209. width: 100%;
  210. height: 15vh;
  211. margin-bottom: -8px;
  212. /*Fix for safari gap*/
  213. min-height: 100px;
  214. max-height: 150px;
  215. }
  216. .parallax>use {
  217. animation: move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
  218. }
  219. .dark .parallax>use {
  220. fill: var(--dark-color-login-wave);
  221. }
  222. .parallax>use:nth-child(1) {
  223. animation-delay: -2s;
  224. animation-duration: 4s;
  225. opacity: 0.2;
  226. }
  227. .parallax>use:nth-child(2) {
  228. animation-delay: -3s;
  229. animation-duration: 7s;
  230. opacity: 0.4;
  231. }
  232. .parallax>use:nth-child(3) {
  233. animation-delay: -4s;
  234. animation-duration: 10s;
  235. opacity: 0.6;
  236. }
  237. .parallax>use:nth-child(4) {
  238. animation-delay: -5s;
  239. animation-duration: 13s;
  240. }
  241. @keyframes move-forever {
  242. 0% {
  243. transform: translate3d(-90px, 0, 0);
  244. }
  245. 100% {
  246. transform: translate3d(85px, 0, 0);
  247. }
  248. }
  249. @media (max-width: 768px) {
  250. .waves {
  251. height: 40px;
  252. min-height: 40px;
  253. }
  254. }
  255. .words-wrapper {
  256. width: 100%;
  257. display: inline-block;
  258. position: relative;
  259. text-align: center;
  260. }
  261. .words-wrapper b {
  262. width: 100%;
  263. display: inline-block;
  264. position: absolute;
  265. left: 0;
  266. top: 0;
  267. }
  268. .words-wrapper b.is-visible {
  269. position: relative;
  270. }
  271. .headline.zoom .words-wrapper {
  272. -webkit-perspective: 300px;
  273. -moz-perspective: 300px;
  274. perspective: 300px;
  275. }
  276. .headline {
  277. display: flex;
  278. justify-content: center;
  279. align-items: center;
  280. }
  281. .headline.zoom b {
  282. opacity: 0;
  283. }
  284. .headline.zoom b.is-visible {
  285. opacity: 1;
  286. -webkit-animation: zoom-in 0.8s;
  287. -moz-animation: zoom-in 0.8s;
  288. animation: cubic-bezier(0.215, 0.610, 0.355, 1.000) zoom-in 0.8s;
  289. }
  290. .headline.zoom b.is-hidden {
  291. -webkit-animation: zoom-out 0.8s;
  292. -moz-animation: zoom-out 0.8s;
  293. animation: cubic-bezier(0.215, 0.610, 0.355, 1.000) zoom-out 0.4s;
  294. }
  295. @-webkit-keyframes zoom-in {
  296. 0% {
  297. opacity: 0;
  298. -webkit-transform: translateZ(100px);
  299. }
  300. 100% {
  301. opacity: 1;
  302. -webkit-transform: translateZ(0);
  303. }
  304. }
  305. @-moz-keyframes zoom-in {
  306. 0% {
  307. opacity: 0;
  308. -moz-transform: translateZ(100px);
  309. }
  310. 100% {
  311. opacity: 1;
  312. -moz-transform: translateZ(0);
  313. }
  314. }
  315. @keyframes zoom-in {
  316. 0% {
  317. opacity: 0;
  318. -webkit-transform: translateZ(100px);
  319. -moz-transform: translateZ(100px);
  320. -ms-transform: translateZ(100px);
  321. -o-transform: translateZ(100px);
  322. transform: translateZ(100px);
  323. }
  324. 100% {
  325. opacity: 1;
  326. -webkit-transform: translateZ(0);
  327. -moz-transform: translateZ(0);
  328. -ms-transform: translateZ(0);
  329. -o-transform: translateZ(0);
  330. transform: translateZ(0);
  331. }
  332. }
  333. @-webkit-keyframes zoom-out {
  334. 0% {
  335. opacity: 1;
  336. -webkit-transform: translateZ(0);
  337. }
  338. 100% {
  339. opacity: 0;
  340. -webkit-transform: translateZ(-100px);
  341. }
  342. }
  343. @-moz-keyframes zoom-out {
  344. 0% {
  345. opacity: 1;
  346. -moz-transform: translateZ(0);
  347. }
  348. 100% {
  349. opacity: 0;
  350. -moz-transform: translateZ(-100px);
  351. }
  352. }
  353. @keyframes zoom-out {
  354. 0% {
  355. opacity: 1;
  356. -webkit-transform: translateZ(0);
  357. -moz-transform: translateZ(0);
  358. -ms-transform: translateZ(0);
  359. -o-transform: translateZ(0);
  360. transform: translateZ(0);
  361. }
  362. 100% {
  363. opacity: 0;
  364. -webkit-transform: translateZ(-100px);
  365. -moz-transform: translateZ(-100px);
  366. -ms-transform: translateZ(-100px);
  367. -o-transform: translateZ(-100px);
  368. transform: translateZ(-100px);
  369. }
  370. }
  371. .setting-section {
  372. position: absolute;
  373. top: 0;
  374. right: 0;
  375. padding: 22px;
  376. }
  377. .ant-space-item .ant-switch {
  378. margin: 2px 0 4px;
  379. }
  380. </style>
  381. {{ template "page/head_end" .}}
  382. {{ template "page/body_start" .}}
  383. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  384. <transition name="list" appear>
  385. <a-layout-content class="under" :style="{ minHeight: '0' }">
  386. <div class="waves-header">
  387. <div class="waves-inner-header"></div>
  388. <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  389. viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
  390. <defs>
  391. <path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
  392. </defs>
  393. <g class="parallax">
  394. <use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(0, 135, 113, 0.08)" />
  395. <use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(0, 135, 113, 0.08)" />
  396. <use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(0, 135, 113, 0.08)" />
  397. <use xlink:href="#gentle-wave" x="48" y="7" fill="#c7ebe2" />
  398. </g>
  399. </svg>
  400. </div>
  401. <a-row type="flex" justify="center" align="middle"
  402. :style="{ height: '100%', overflow: 'auto', overflowX: 'hidden' }">
  403. <a-col :xs="22" :sm="12" :md="10" :lg="8" :xl="6" :xxl="5" id="login" :style="{ margin: '3rem 0' }">
  404. <template v-if="!loadingStates.fetched">
  405. <div :style="{ textAlign: 'center' }">
  406. <a-spin size="large" />
  407. </div>
  408. </template>
  409. <template v-else>
  410. <div class="setting-section">
  411. <a-popover :overlay-class-name="themeSwitcher.currentTheme" title='{{ i18n "menu.settings" }}'
  412. placement="bottomRight" trigger="click">
  413. <template slot="content">
  414. <a-space direction="vertical" :size="10">
  415. <a-theme-switch-login></a-theme-switch-login>
  416. <span>{{ i18n "pages.settings.language" }}</span>
  417. <a-select ref="selectLang" :style="{ width: '100%' }" v-model="lang"
  418. @change="LanguageManager.setLanguage(lang)" :dropdown-class-name="themeSwitcher.currentTheme">
  419. <a-select-option :value="l.value" label="English" v-for="l in LanguageManager.supportedLanguages">
  420. <span role="img" aria-label="l.name" v-text="l.icon"></span>
  421. &nbsp;&nbsp;<span v-text="l.name"></span>
  422. </a-select-option>
  423. </a-select>
  424. </a-space>
  425. </template>
  426. <a-button shape="circle" icon="setting"></a-button>
  427. </a-popover>
  428. </div>
  429. <a-row type="flex" justify="center">
  430. <a-col :style="{ width: '100%' }">
  431. <h2 class="title headline zoom">
  432. <span class="words-wrapper">
  433. <b class="is-visible">{{ i18n "pages.login.hello" }}</b>
  434. <b>{{ i18n "pages.login.title" }}</b>
  435. </span>
  436. </h2>
  437. </a-col>
  438. </a-row>
  439. <a-row type="flex" justify="center">
  440. <a-col span="24">
  441. <a-form @submit.prevent="login">
  442. <a-space direction="vertical" size="middle">
  443. <a-form-item>
  444. <a-input autocomplete="username" name="username" v-model.trim="user.username"
  445. placeholder='{{ i18n "username" }}' autofocus required>
  446. <a-icon slot="prefix" type="user" :style="{ fontSize: '1rem' }"></a-icon>
  447. </a-input>
  448. </a-form-item>
  449. <a-form-item>
  450. <a-input-password autocomplete="password" name="password" v-model.trim="user.password"
  451. placeholder='{{ i18n "password" }}' required>
  452. <a-icon slot="prefix" type="lock" :style="{ fontSize: '1rem' }"></a-icon>
  453. </a-input-password>
  454. </a-form-item>
  455. <a-form-item v-if="twoFactorEnable">
  456. <a-input autocomplete="one-time-code" name="twoFactorCode" v-model.trim="user.twoFactorCode"
  457. placeholder='{{ i18n "twoFactorCode" }}' required>
  458. <a-icon slot="prefix" type="key" :style="{ fontSize: '1rem' }"></a-icon>
  459. </a-input>
  460. </a-form-item>
  461. <a-form-item>
  462. <a-row justify="center" class="centered">
  463. <div
  464. :style="{ height: '50px', marginTop: '1rem', ...loadingStates.spinning ? { width: '52px' } : { display: 'inline-block' } }"
  465. class="wave-btn-bg wave-btn-bg-cl">
  466. <a-button class="ant-btn-primary-login" type="primary" :loading="loadingStates.spinning"
  467. :icon="loadingStates.spinning ? 'poweroff' : undefined" html-type="submit">
  468. [[ loadingStates.spinning ? '' : '{{ i18n "login" }}' ]]
  469. </a-button>
  470. </div>
  471. </a-row>
  472. </a-form-item>
  473. </a-space>
  474. </a-form>
  475. </a-col>
  476. </a-row>
  477. </template>
  478. </a-col>
  479. </a-row>
  480. </a-layout-content>
  481. </transition>
  482. </a-layout>
  483. {{template "page/body_scripts" .}}
  484. {{template "component/aThemeSwitch" .}}
  485. <script>
  486. const app = new Vue({
  487. delimiters: ['[[', ']]'],
  488. el: '#app',
  489. data: {
  490. themeSwitcher,
  491. loadingStates: {
  492. fetched: false,
  493. spinning: false
  494. },
  495. user: {
  496. username: "",
  497. password: "",
  498. twoFactorCode: ""
  499. },
  500. twoFactorEnable: false,
  501. lang: ""
  502. },
  503. async mounted() {
  504. this.lang = LanguageManager.getLanguage();
  505. this.twoFactorEnable = await this.getTwoFactorEnable();
  506. },
  507. methods: {
  508. async login() {
  509. this.loadingStates.spinning = true;
  510. const msg = await HttpUtil.post('/login', this.user);
  511. if (msg.success) {
  512. location.href = basePath + 'panel/';
  513. }
  514. this.loadingStates.spinning = false;
  515. },
  516. async getTwoFactorEnable() {
  517. const msg = await HttpUtil.post('/getTwoFactorEnable');
  518. if (msg.success) {
  519. this.twoFactorEnable = msg.obj;
  520. this.loadingStates.fetched = true;
  521. return msg.obj;
  522. }
  523. },
  524. },
  525. });
  526. document.addEventListener("DOMContentLoaded", function () {
  527. var animationDelay = 2000;
  528. initHeadline();
  529. function initHeadline() {
  530. animateHeadline(document.querySelectorAll('.headline'));
  531. }
  532. function animateHeadline(headlines) {
  533. var duration = animationDelay;
  534. headlines.forEach(function (headline) {
  535. setTimeout(function () {
  536. hideWord(headline.querySelector('.is-visible'));
  537. }, duration);
  538. });
  539. }
  540. function hideWord(word) {
  541. var nextWord = takeNext(word);
  542. switchWord(word, nextWord);
  543. setTimeout(function () {
  544. hideWord(nextWord);
  545. }, animationDelay);
  546. }
  547. function takeNext(word) {
  548. return word.nextElementSibling ? word.nextElementSibling : word.parentElement.firstElementChild;
  549. }
  550. function switchWord(oldWord, newWord) {
  551. oldWord.classList.remove('is-visible');
  552. oldWord.classList.add('is-hidden');
  553. newWord.classList.remove('is-hidden');
  554. newWord.classList.add('is-visible');
  555. }
  556. });
  557. </script>
  558. {{ template "page/body_end" .}}