1
0

login.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. {{ template "page/head_start" .}}
  2. {{ template "page/head_end" .}}
  3. {{ template "page/body_start" .}}
  4. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme + ' login-app'">
  5. <transition name="list" appear>
  6. <a-layout-content class="under min-h-100vh">
  7. <div class="waves-header">
  8. <div class="waves-inner-header"></div>
  9. <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  10. viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
  11. <defs>
  12. <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" />
  13. </defs>
  14. <g class="parallax">
  15. <use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(0, 135, 113, 0.08)" />
  16. <use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(0, 135, 113, 0.08)" />
  17. <use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(0, 135, 113, 0.08)" />
  18. <use xlink:href="#gentle-wave" x="48" y="7" fill="#c7ebe2" />
  19. </g>
  20. </svg>
  21. </div>
  22. <a-row type="flex" justify="center" align="middle" class="h-100 overflow-hidden-auto">
  23. <a-col :xs="22" :sm="12" :md="10" :lg="8" :xl="6" :xxl="5" id="login" class="my-3rem">
  24. <template v-if="!loadingStates.fetched">
  25. <div class="text-center">
  26. <a-spin size="large" />
  27. </div>
  28. </template>
  29. <template v-else>
  30. <div class="setting-section">
  31. <a-popover :overlay-class-name="themeSwitcher.currentTheme" title='{{ i18n "menu.settings" }}'
  32. placement="bottomRight" trigger="click">
  33. <template slot="content">
  34. <a-space direction="vertical" :size="10">
  35. <a-theme-switch-login></a-theme-switch-login>
  36. <span>{{ i18n "pages.settings.language" }}</span>
  37. <a-select ref="selectLang" class="w-100" v-model="lang"
  38. @change="LanguageManager.setLanguage(lang)" :dropdown-class-name="themeSwitcher.currentTheme">
  39. <a-select-option :value="l.value" label="English" v-for="l in LanguageManager.supportedLanguages">
  40. <span role="img" aria-label="l.name" v-text="l.icon"></span>
  41. &nbsp;&nbsp;<span v-text="l.name"></span>
  42. </a-select-option>
  43. </a-select>
  44. </a-space>
  45. </template>
  46. <a-button shape="circle" icon="setting"></a-button>
  47. </a-popover>
  48. </div>
  49. <a-row type="flex" justify="center">
  50. <a-col :style="{ width: '100%' }">
  51. <h2 class="title headline zoom">
  52. <span class="words-wrapper">
  53. <b class="is-visible">{{ i18n "pages.login.hello" }}</b>
  54. <b>{{ i18n "pages.login.title" }}</b>
  55. </span>
  56. </h2>
  57. </a-col>
  58. </a-row>
  59. <a-row type="flex" justify="center">
  60. <a-col span="24">
  61. <a-form @submit.prevent="login">
  62. <a-space direction="vertical" size="middle">
  63. <a-form-item>
  64. <a-input autocomplete="username" name="username" v-model.trim="user.username"
  65. placeholder='{{ i18n "username" }}' autofocus required>
  66. <a-icon slot="prefix" type="user" class="fs-1rem"></a-icon>
  67. </a-input>
  68. </a-form-item>
  69. <a-form-item>
  70. <a-input-password autocomplete="password" name="password" v-model.trim="user.password"
  71. placeholder='{{ i18n "password" }}' required>
  72. <a-icon slot="prefix" type="lock" class="fs-1rem"></a-icon>
  73. </a-input-password>
  74. </a-form-item>
  75. <a-form-item v-if="twoFactorEnable">
  76. <a-input autocomplete="one-time-code" name="twoFactorCode" v-model.trim="user.twoFactorCode"
  77. placeholder='{{ i18n "twoFactorCode" }}' required>
  78. <a-icon slot="prefix" type="key" class="fs-1rem"></a-icon>
  79. </a-input>
  80. </a-form-item>
  81. <a-form-item>
  82. <a-row justify="center" class="centered">
  83. <div class="wave-btn-bg wave-btn-bg-cl h-50px mt-1rem" :style="loadingStates.spinning ? 'width: 52px' : 'display: inline-block'">
  84. <a-button class="ant-btn-primary-login" type="primary" :loading="loadingStates.spinning"
  85. :icon="loadingStates.spinning ? 'poweroff' : undefined" html-type="submit">
  86. [[ loadingStates.spinning ? '' : '{{ i18n "login" }}' ]]
  87. </a-button>
  88. </div>
  89. </a-row>
  90. </a-form-item>
  91. </a-space>
  92. </a-form>
  93. </a-col>
  94. </a-row>
  95. </template>
  96. </a-col>
  97. </a-row>
  98. </a-layout-content>
  99. </transition>
  100. </a-layout>
  101. {{template "page/body_scripts" .}}
  102. {{template "component/aThemeSwitch" .}}
  103. <script>
  104. const app = new Vue({
  105. delimiters: ['[[', ']]'],
  106. el: '#app',
  107. data: {
  108. themeSwitcher,
  109. loadingStates: {
  110. fetched: false,
  111. spinning: false
  112. },
  113. user: {
  114. username: "",
  115. password: "",
  116. twoFactorCode: ""
  117. },
  118. twoFactorEnable: false,
  119. lang: ""
  120. },
  121. async mounted() {
  122. this.lang = LanguageManager.getLanguage();
  123. this.twoFactorEnable = await this.getTwoFactorEnable();
  124. },
  125. methods: {
  126. async login() {
  127. this.loadingStates.spinning = true;
  128. const msg = await HttpUtil.post('/login', this.user);
  129. if (msg.success) {
  130. location.href = basePath + 'panel/';
  131. }
  132. this.loadingStates.spinning = false;
  133. },
  134. async getTwoFactorEnable() {
  135. const msg = await HttpUtil.post('/getTwoFactorEnable');
  136. if (msg.success) {
  137. this.twoFactorEnable = msg.obj;
  138. this.loadingStates.fetched = true;
  139. return msg.obj;
  140. }
  141. },
  142. },
  143. });
  144. document.addEventListener("DOMContentLoaded", function () {
  145. var animationDelay = 2000;
  146. initHeadline();
  147. function initHeadline() {
  148. animateHeadline(document.querySelectorAll('.headline'));
  149. }
  150. function animateHeadline(headlines) {
  151. var duration = animationDelay;
  152. headlines.forEach(function (headline) {
  153. setTimeout(function () {
  154. hideWord(headline.querySelector('.is-visible'));
  155. }, duration);
  156. });
  157. }
  158. function hideWord(word) {
  159. var nextWord = takeNext(word);
  160. switchWord(word, nextWord);
  161. setTimeout(function () {
  162. hideWord(nextWord);
  163. }, animationDelay);
  164. }
  165. function takeNext(word) {
  166. return word.nextElementSibling ? word.nextElementSibling : word.parentElement.firstElementChild;
  167. }
  168. function switchWord(oldWord, newWord) {
  169. oldWord.classList.remove('is-visible');
  170. oldWord.classList.add('is-hidden');
  171. newWord.classList.remove('is-hidden');
  172. newWord.classList.add('is-visible');
  173. }
  174. });
  175. </script>
  176. {{ template "page/body_end" .}}