login.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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" :style="{ height: '100%', overflow: 'auto', overflowX: 'hidden' }">
  402. <a-col :xs="22" :sm="12" :md="10" :lg="8" :xl="6" :xxl="5" id="login" :style="{ margin: '3rem 0' }">
  403. <div class="setting-section">
  404. <a-popover :overlay-class-name="themeSwitcher.currentTheme" title='{{ i18n "menu.settings" }}' placement="bottomRight" trigger="click">
  405. <template slot="content">
  406. <a-space direction="vertical" :size="10">
  407. <a-theme-switch-login></a-theme-switch-login>
  408. <span>{{ i18n "pages.settings.language" }}</span>
  409. <a-select ref="selectLang" :style="{ width: '100%' }" v-model="lang" @change="LanguageManager.setLanguage(lang)" :dropdown-class-name="themeSwitcher.currentTheme">
  410. <a-select-option :value="l.value" label="English" v-for="l in LanguageManager.supportedLanguages">
  411. <span role="img" aria-label="l.name" v-text="l.icon"></span>
  412. &nbsp;&nbsp;<span v-text="l.name"></span>
  413. </a-select-option>
  414. </a-select>
  415. </a-space>
  416. </template>
  417. <a-button shape="circle" icon="setting"></a-button>
  418. </a-popover>
  419. </div>
  420. <a-row type="flex" justify="center">
  421. <a-col :style="{ width: '100%' }">
  422. <h2 class="title headline zoom">
  423. <span class="words-wrapper">
  424. <b class="is-visible">{{ i18n "pages.login.hello" }}</b>
  425. <b>{{ i18n "pages.login.title" }}</b>
  426. </span>
  427. </h2>
  428. </a-col>
  429. </a-row>
  430. <a-row type="flex" justify="center">
  431. <a-col span="24">
  432. <a-form>
  433. <a-space direction="vertical" size="middle">
  434. <a-form-item>
  435. <a-input autocomplete="username" name="username" v-model.trim="user.username"
  436. placeholder='{{ i18n "username" }}' @keydown.enter.native="login" autofocus>
  437. <a-icon slot="prefix" type="user" :style="{ fontSize: '1rem' }"></a-icon>
  438. </a-input>
  439. </a-form-item>
  440. <a-form-item>
  441. <a-input-password autocomplete="password" name="password" v-model.trim="user.password"
  442. placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
  443. <a-icon slot="prefix" type="lock" :style="{ fontSize: '1rem' }"></a-icon>
  444. </a-input-password>
  445. </a-form-item>
  446. <a-form-item v-if="twoFactorEnable">
  447. <a-input autocomplete="totp" name="twoFactorCode" v-model.trim="user.twoFactorCode"
  448. placeholder='{{ i18n "twoFactorCode" }}' @keydown.enter.native="login">
  449. <a-icon slot="prefix" type="key" :style="{ fontSize: '1rem' }"></a-icon>
  450. </a-input>
  451. </a-form-item>
  452. <a-form-item>
  453. <a-row justify="center" class="centered">
  454. <div :style="{ height: '50px', marginTop: '1rem', ...loading ? { width: '52px' } : { display: 'inline-block' } }" class="wave-btn-bg wave-btn-bg-cl">
  455. <a-button class="ant-btn-primary-login" type="primary" :loading="loading" @click="login"
  456. :icon="loading ? 'poweroff' : undefined">
  457. [[ loading ? '' : '{{ i18n "login" }}' ]]
  458. </a-button>
  459. </div>
  460. </a-row>
  461. </a-form-item>
  462. </a-space>
  463. </a-form>
  464. </a-col>
  465. </a-row>
  466. </a-col>
  467. </a-row>
  468. </a-layout-content>
  469. </transition>
  470. </a-layout>
  471. {{template "page/body_scripts" .}}
  472. {{template "component/aThemeSwitch" .}}
  473. <script>
  474. const app = new Vue({
  475. delimiters: ['[[', ']]'],
  476. el: '#app',
  477. data: {
  478. themeSwitcher,
  479. loading: false,
  480. user: {
  481. username: "",
  482. password: "",
  483. twoFactorCode: ""
  484. },
  485. twoFactorEnable: false,
  486. lang: ""
  487. },
  488. async mounted() {
  489. this.lang = LanguageManager.getLanguage();
  490. this.twoFactorEnable = await this.getTwoFactorEnable();
  491. },
  492. methods: {
  493. async login() {
  494. this.loading = true;
  495. const msg = await HttpUtil.post('/login', this.user);
  496. this.loading = false;
  497. if (msg.success) {
  498. location.href = basePath + 'panel/';
  499. }
  500. },
  501. async getTwoFactorEnable() {
  502. this.loading = true;
  503. const msg = await HttpUtil.post('/getTwoFactorEnable');
  504. this.loading = false;
  505. if (msg.success) {
  506. this.twoFactorEnable = msg.obj;
  507. return msg.obj;
  508. }
  509. },
  510. },
  511. });
  512. document.addEventListener("DOMContentLoaded", function () {
  513. var animationDelay = 2000;
  514. initHeadline();
  515. function initHeadline() {
  516. animateHeadline(document.querySelectorAll('.headline'));
  517. }
  518. function animateHeadline(headlines) {
  519. var duration = animationDelay;
  520. headlines.forEach(function (headline) {
  521. setTimeout(function () {
  522. hideWord(headline.querySelector('.is-visible'));
  523. }, duration);
  524. });
  525. }
  526. function hideWord(word) {
  527. var nextWord = takeNext(word);
  528. switchWord(word, nextWord);
  529. setTimeout(function () {
  530. hideWord(nextWord);
  531. }, animationDelay);
  532. }
  533. function takeNext(word) {
  534. return word.nextElementSibling ? word.nextElementSibling : word.parentElement.firstElementChild;
  535. }
  536. function switchWord(oldWord, newWord) {
  537. oldWord.classList.remove('is-visible');
  538. oldWord.classList.add('is-hidden');
  539. newWord.classList.remove('is-hidden');
  540. newWord.classList.add('is-visible');
  541. }
  542. });
  543. </script>
  544. {{ template "page/body_end" .}}