1
0

login.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <style>
  5. h1 {
  6. text-align: center;
  7. margin: 20px 0 50px 0;
  8. }
  9. .ant-btn, .ant-input {
  10. height: 50px;
  11. border-radius: 30px;
  12. }
  13. .ant-input-group-addon {
  14. border-radius: 0 30px 30px 0;
  15. width: 50px;
  16. font-size: 18px;
  17. }
  18. .ant-input-affix-wrapper .ant-input-prefix {
  19. left: 23px;
  20. }
  21. .ant-input-affix-wrapper .ant-input:not(:first-child) {
  22. padding-left: 50px;
  23. }
  24. .centered {
  25. display: flex;
  26. text-align: center;
  27. align-items: center;
  28. justify-content: center;
  29. }
  30. .title {
  31. font-size: 32px;
  32. font-weight: bold;
  33. }
  34. #app {
  35. overflow: hidden;
  36. }
  37. #login {
  38. animation: charge .5s both;
  39. background-color: #fff;
  40. border-radius: 2rem;
  41. padding: 3rem;
  42. }
  43. #login:hover {
  44. box-shadow: 0 2px 8px rgba(0,0,0,.09);
  45. }
  46. @keyframes charge {
  47. from {transform: translateY(5rem);opacity: 0}
  48. to {transform: translateY(0);opacity: 1}
  49. }
  50. @keyframes wave {
  51. from {transform: rotate(0deg);}
  52. to {transform: rotate(360deg);}
  53. }
  54. .wave {
  55. opacity: .6;
  56. position: absolute;
  57. bottom: 40%;
  58. left: 50%;
  59. width: 6000px;
  60. height: 6000px;
  61. background: #000;
  62. margin-left: -3000px;
  63. transform-origin: 50% 48%;
  64. border-radius: 46%;
  65. animation: wave 72s infinite linear;
  66. pointer-events: none;
  67. }
  68. .wave2 {
  69. animation: wave 88s infinite linear;
  70. opacity: .3;
  71. }
  72. .wave3 {
  73. animation: wave 80s infinite linear;
  74. opacity: .1;
  75. }
  76. .wave {
  77. background: #0a755715;
  78. }
  79. .under {
  80. background-color: #dbf5ed;
  81. }
  82. .dark .wave {
  83. background: rgb(10 117 87 / 20%);
  84. }
  85. .dark .under {
  86. background-color: #051510;
  87. }
  88. .dark #login {
  89. background-color: rgb(8, 22, 20);
  90. }
  91. .dark h1 {
  92. color: rgb(255 255 255 / 85%);
  93. }
  94. </style>
  95. <body>
  96. <a-layout id="app" v-cloak class="login" :class="themeSwitcher.currentTheme">
  97. <transition name="list" appear>
  98. <a-layout-content class="under">
  99. <div class='wave'></div>
  100. <div class='wave wave2'></div>
  101. <div class='wave wave3'></div>
  102. <a-row type="flex" justify="center" align="middle" style="height: 100%;">
  103. <a-col :xs="22" :sm="20" :md="14" :lg="10" :xl="6" id="login">
  104. <a-row type="flex" justify="center">
  105. <a-col>
  106. <h1 class="title">{{ i18n "pages.login.title" }}</h1>
  107. </a-col>
  108. </a-row>
  109. <a-row type="flex" justify="center">
  110. <a-col span="24">
  111. <a-form>
  112. <a-form-item>
  113. <a-input v-model.trim="user.username" placeholder='{{ i18n "username" }}'
  114. @keydown.enter.native="login" autofocus>
  115. <a-icon slot="prefix" type="user" style="font-size: 16px;" />
  116. </a-input>
  117. </a-form-item>
  118. <a-form-item>
  119. <password-input icon="lock" v-model.trim="user.password"
  120. placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
  121. </password-input>
  122. </a-form-item>
  123. <a-form-item v-if="secretEnable">
  124. <password-input icon="key" v-model.trim="user.loginSecret"
  125. placeholder='{{ i18n "secretToken" }}' @keydown.enter.native="login">
  126. </password-input>
  127. </a-input>
  128. </a-form-item>
  129. <a-form-item>
  130. <a-row justify="center" class="centered">
  131. <a-button type="primary" :loading="loading" @click="login" :icon="loading ? 'poweroff' : undefined"
  132. :style="loading ? { width: '50px' } : { display: 'block', width: '100%' }">
  133. [[ loading ? '' : '{{ i18n "login" }}' ]]
  134. </a-button>
  135. </a-row>
  136. </a-form-item>
  137. <a-form-item>
  138. <a-row justify="center" class="centered">
  139. <a-col :span="24">
  140. <a-select ref="selectLang" v-model="lang" @change="setLang(lang)" :dropdown-class-name="themeSwitcher.currentTheme">
  141. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  142. <span role="img" :aria-label="l.name" v-text="l.icon"></span>
  143. &nbsp;&nbsp;<span v-text="l.name"></span>
  144. </a-select-option>
  145. </a-select>
  146. </a-col>
  147. </a-row>
  148. </a-form-item>
  149. <a-form-item>
  150. <a-row justify="center" class="centered">
  151. <a-col>
  152. <a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon>&nbsp;
  153. </a-col>
  154. <a-col>
  155. <theme-switch />
  156. </a-col>
  157. </a-row>
  158. </a-form-item>
  159. </a-form>
  160. </a-col>
  161. </a-row>
  162. </a-col>
  163. </a-row>
  164. </a-layout-content>
  165. </transition>
  166. </a-layout>
  167. {{template "js" .}}
  168. {{template "component/themeSwitcher" .}}
  169. {{template "component/password" .}}
  170. <script>
  171. const app = new Vue({
  172. delimiters: ['[[', ']]'],
  173. el: '#app',
  174. data: {
  175. themeSwitcher,
  176. loading: false,
  177. user: new User(),
  178. secretEnable: false,
  179. lang: ""
  180. },
  181. async created() {
  182. this.lang = getLang();
  183. this.secretEnable = await this.getSecretStatus();
  184. },
  185. methods: {
  186. async login() {
  187. this.loading = true;
  188. const msg = await HttpUtil.post('/login', this.user);
  189. this.loading = false;
  190. if (msg.success) {
  191. location.href = basePath + 'panel/';
  192. }
  193. },
  194. async getSecretStatus() {
  195. this.loading = true;
  196. const msg = await HttpUtil.post('/getSecretStatus');
  197. this.loading = false;
  198. if (msg.success) {
  199. this.secretEnable = msg.obj;
  200. return msg.obj;
  201. }
  202. },
  203. },
  204. });
  205. </script>
  206. </body>
  207. </html>