login.html 15 KB

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