login.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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. @media (max-width: 1024px) {
  256. .title {
  257. font-size: 1.4rem;
  258. }
  259. }
  260. .words-wrapper {
  261. width: 100%;
  262. display: inline-block;
  263. position: relative;
  264. text-align: center;
  265. }
  266. .words-wrapper b {
  267. width: 100%;
  268. display: inline-block;
  269. position: absolute;
  270. left: 0;
  271. top: 0;
  272. }
  273. .words-wrapper b.is-visible {
  274. position: relative;
  275. }
  276. .headline.zoom .words-wrapper {
  277. -webkit-perspective: 300px;
  278. -moz-perspective: 300px;
  279. perspective: 300px;
  280. }
  281. .headline {
  282. display: flex;
  283. justify-content: center;
  284. align-items: center;
  285. }
  286. .headline.zoom b {
  287. opacity: 0;
  288. }
  289. .headline.zoom b.is-visible {
  290. opacity: 1;
  291. -webkit-animation: zoom-in 0.8s;
  292. -moz-animation: zoom-in 0.8s;
  293. animation: cubic-bezier(0.215, 0.610, 0.355, 1.000) zoom-in 0.8s;
  294. }
  295. .headline.zoom b.is-hidden {
  296. -webkit-animation: zoom-out 0.8s;
  297. -moz-animation: zoom-out 0.8s;
  298. animation: cubic-bezier(0.215, 0.610, 0.355, 1.000) zoom-out 0.4s;
  299. }
  300. @-webkit-keyframes zoom-in {
  301. 0% {
  302. opacity: 0;
  303. -webkit-transform: translateZ(100px);
  304. }
  305. 100% {
  306. opacity: 1;
  307. -webkit-transform: translateZ(0);
  308. }
  309. }
  310. @-moz-keyframes zoom-in {
  311. 0% {
  312. opacity: 0;
  313. -moz-transform: translateZ(100px);
  314. }
  315. 100% {
  316. opacity: 1;
  317. -moz-transform: translateZ(0);
  318. }
  319. }
  320. @keyframes zoom-in {
  321. 0% {
  322. opacity: 0;
  323. -webkit-transform: translateZ(100px);
  324. -moz-transform: translateZ(100px);
  325. -ms-transform: translateZ(100px);
  326. -o-transform: translateZ(100px);
  327. transform: translateZ(100px);
  328. }
  329. 100% {
  330. opacity: 1;
  331. -webkit-transform: translateZ(0);
  332. -moz-transform: translateZ(0);
  333. -ms-transform: translateZ(0);
  334. -o-transform: translateZ(0);
  335. transform: translateZ(0);
  336. }
  337. }
  338. @-webkit-keyframes zoom-out {
  339. 0% {
  340. opacity: 1;
  341. -webkit-transform: translateZ(0);
  342. }
  343. 100% {
  344. opacity: 0;
  345. -webkit-transform: translateZ(-100px);
  346. }
  347. }
  348. @-moz-keyframes zoom-out {
  349. 0% {
  350. opacity: 1;
  351. -moz-transform: translateZ(0);
  352. }
  353. 100% {
  354. opacity: 0;
  355. -moz-transform: translateZ(-100px);
  356. }
  357. }
  358. @keyframes zoom-out {
  359. 0% {
  360. opacity: 1;
  361. -webkit-transform: translateZ(0);
  362. -moz-transform: translateZ(0);
  363. -ms-transform: translateZ(0);
  364. -o-transform: translateZ(0);
  365. transform: translateZ(0);
  366. }
  367. 100% {
  368. opacity: 0;
  369. -webkit-transform: translateZ(-100px);
  370. -moz-transform: translateZ(-100px);
  371. -ms-transform: translateZ(-100px);
  372. -o-transform: translateZ(-100px);
  373. transform: translateZ(-100px);
  374. }
  375. }
  376. .setting-section {
  377. position: absolute;
  378. top: 0;
  379. right: 0;
  380. padding: 22px;
  381. }
  382. .ant-space-item .ant-switch {
  383. margin: 2px 0 4px;
  384. }
  385. </style>
  386. {{ template "page/head_end" .}}
  387. {{ template "page/body_start" .}}
  388. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  389. <transition name="list" appear>
  390. <a-layout-content class="under" :style="{ minHeight: '0' }">
  391. <div class="waves-header">
  392. <div class="waves-inner-header"></div>
  393. <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  394. viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
  395. <defs>
  396. <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" />
  397. </defs>
  398. <g class="parallax">
  399. <use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(0, 135, 113, 0.08)" />
  400. <use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(0, 135, 113, 0.08)" />
  401. <use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(0, 135, 113, 0.08)" />
  402. <use xlink:href="#gentle-wave" x="48" y="7" fill="#c7ebe2" />
  403. </g>
  404. </svg>
  405. </div>
  406. <a-row type="flex" justify="center" align="middle" :style="{ height: '100%', overflow: 'auto', overflowX: 'hidden' }">
  407. <a-col :xs="22" :sm="12" :md="10" :lg="8" :xl="6" :xxl="5" id="login" :style="{ margin: '3rem 0' }">
  408. <div class="setting-section">
  409. <a-popover :overlay-class-name="themeSwitcher.currentTheme" title='{{ i18n "menu.settings" }}' placement="bottomRight" trigger="click">
  410. <template slot="content">
  411. <a-space direction="vertical" :size="10">
  412. <a-theme-switch-login></a-theme-switch-login>
  413. <span>{{ i18n "pages.settings.language" }}</span>
  414. <a-select ref="selectLang" :style="{ width: '100%' }" v-model="lang" @change="LanguageManager.setLanguage(lang)" :dropdown-class-name="themeSwitcher.currentTheme">
  415. <a-select-option :value="l.value" label="English" v-for="l in LanguageManager.supportedLanguages">
  416. <span role="img" aria-label="l.name" v-text="l.icon"></span>
  417. &nbsp;&nbsp;<span v-text="l.name"></span>
  418. </a-select-option>
  419. </a-select>
  420. </a-space>
  421. </template>
  422. <a-button shape="circle" icon="setting"></a-button>
  423. </a-popover>
  424. </div>
  425. <a-row type="flex" justify="center">
  426. <a-col :style="{ width: '100%' }">
  427. <h2 class="title headline zoom">
  428. <span class="words-wrapper">
  429. <b class="is-visible">{{ i18n "pages.login.hello" }}</b>
  430. <b>{{ i18n "pages.login.title" }}</b>
  431. </span>
  432. </h2>
  433. </a-col>
  434. </a-row>
  435. <a-row type="flex" justify="center">
  436. <a-col span="24">
  437. <a-form>
  438. <a-space direction="vertical" size="middle">
  439. <a-form-item>
  440. <a-input autocomplete="username" name="username" v-model.trim="user.username"
  441. placeholder='{{ i18n "username" }}' @keydown.enter.native="login" autofocus>
  442. <a-icon slot="prefix" type="user" :style="{ fontSize: '1rem' }"></a-icon>
  443. </a-input>
  444. </a-form-item>
  445. <a-form-item>
  446. <a-input-password autocomplete="password" name="password" v-model.trim="user.password"
  447. placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
  448. <a-icon slot="prefix" type="lock" :style="{ fontSize: '1rem' }"></a-icon>
  449. </a-input-password>
  450. </a-form-item>
  451. <a-form-item v-if="twoFactorEnable">
  452. <a-input autocomplete="totp" name="twoFactorCode" v-model.trim="user.twoFactorCode"
  453. placeholder='{{ i18n "twoFactorCode" }}' @keydown.enter.native="login">
  454. <a-icon slot="prefix" type="key" :style="{ fontSize: '1rem' }"></a-icon>
  455. </a-input>
  456. </a-form-item>
  457. <a-form-item>
  458. <a-row justify="center" class="centered">
  459. <div :style="{ height: '50px', marginTop: '1rem', ...loading ? { width: '52px' } : { display: 'inline-block' } }" class="wave-btn-bg wave-btn-bg-cl">
  460. <a-button class="ant-btn-primary-login" type="primary" :loading="loading" @click="login"
  461. :icon="loading ? 'poweroff' : undefined">
  462. [[ loading ? '' : '{{ i18n "login" }}' ]]
  463. </a-button>
  464. </div>
  465. </a-row>
  466. </a-form-item>
  467. </a-space>
  468. </a-form>
  469. </a-col>
  470. </a-row>
  471. </a-col>
  472. </a-row>
  473. </a-layout-content>
  474. </transition>
  475. </a-layout>
  476. {{template "page/body_scripts" .}}
  477. {{template "component/aThemeSwitch" .}}
  478. <script>
  479. const app = new Vue({
  480. delimiters: ['[[', ']]'],
  481. el: '#app',
  482. data: {
  483. themeSwitcher,
  484. loading: false,
  485. user: {
  486. username: "",
  487. password: "",
  488. twoFactorCode: ""
  489. },
  490. twoFactorEnable: false,
  491. lang: ""
  492. },
  493. async mounted() {
  494. this.lang = LanguageManager.getLanguage();
  495. this.twoFactorEnable = await this.getTwoFactorEnable();
  496. },
  497. methods: {
  498. async login() {
  499. this.loading = true;
  500. const msg = await HttpUtil.post('/login', this.user);
  501. this.loading = false;
  502. if (msg.success) {
  503. location.href = basePath + 'panel/';
  504. }
  505. },
  506. async getTwoFactorEnable() {
  507. this.loading = true;
  508. const msg = await HttpUtil.post('/getTwoFactorEnable');
  509. this.loading = false;
  510. if (msg.success) {
  511. this.twoFactorEnable = msg.obj;
  512. return msg.obj;
  513. }
  514. },
  515. },
  516. });
  517. document.addEventListener("DOMContentLoaded", function () {
  518. var animationDelay = 2000;
  519. initHeadline();
  520. function initHeadline() {
  521. animateHeadline(document.querySelectorAll('.headline'));
  522. }
  523. function animateHeadline(headlines) {
  524. var duration = animationDelay;
  525. headlines.forEach(function (headline) {
  526. setTimeout(function () {
  527. hideWord(headline.querySelector('.is-visible'));
  528. }, duration);
  529. });
  530. }
  531. function hideWord(word) {
  532. var nextWord = takeNext(word);
  533. switchWord(word, nextWord);
  534. setTimeout(function () {
  535. hideWord(nextWord);
  536. }, animationDelay);
  537. }
  538. function takeNext(word) {
  539. return word.nextElementSibling ? word.nextElementSibling : word.parentElement.firstElementChild;
  540. }
  541. function switchWord(oldWord, newWord) {
  542. oldWord.classList.remove('is-visible');
  543. oldWord.classList.add('is-hidden');
  544. newWord.classList.remove('is-hidden');
  545. newWord.classList.add('is-visible');
  546. }
  547. });
  548. </script>
  549. {{ template "page/body_end" .}}