login.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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,
  10. .ant-input {
  11. height: 50px;
  12. border-radius: 30px;
  13. }
  14. .ant-input-group-addon {
  15. border-radius: 0 30px 30px 0;
  16. width: 50px;
  17. font-size: 18px;
  18. }
  19. .ant-input-affix-wrapper .ant-input-prefix {
  20. left: 23px;
  21. }
  22. .ant-input-affix-wrapper .ant-input:not(:first-child) {
  23. padding-left: 50px;
  24. }
  25. .centered {
  26. display: flex;
  27. text-align: center;
  28. align-items: center;
  29. justify-content: center;
  30. width: 100%;
  31. }
  32. .title {
  33. font-size: 32px;
  34. font-weight: bold;
  35. }
  36. #app {
  37. overflow: hidden;
  38. }
  39. #login {
  40. animation: charge 0.5s both;
  41. background-color: #fff;
  42. border-radius: 2rem;
  43. padding: 3rem;
  44. transition: all 0.3s;
  45. }
  46. #login:hover {
  47. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
  48. }
  49. @keyframes charge {
  50. from {
  51. transform: translateY(5rem);
  52. opacity: 0;
  53. }
  54. to {
  55. transform: translateY(0);
  56. opacity: 1;
  57. }
  58. }
  59. .wave {
  60. opacity: 0.6;
  61. position: absolute;
  62. bottom: 40%;
  63. left: 50%;
  64. width: 6000px;
  65. height: 6000px;
  66. background-color: rgba(0, 135, 113, 0.08);
  67. margin-left: -3000px;
  68. transform-origin: 50% 48%;
  69. border-radius: 46%;
  70. pointer-events: none;
  71. rotate: 125deg;
  72. }
  73. .wave2 {
  74. opacity: 0.4;
  75. rotate: 70deg;
  76. }
  77. .wave3 {
  78. opacity: 0.2;
  79. rotate: 90deg;
  80. }
  81. .under {
  82. background-color: #dbf5ed;
  83. }
  84. .dark .wave {
  85. background: rgb(10 117 87 / 20%);
  86. }
  87. .dark .under {
  88. background-color: #101828;
  89. }
  90. .dark #login {
  91. background-color: #151f31;
  92. }
  93. .dark h1 {
  94. color: rgba(255, 255, 255, 0.85);
  95. }
  96. .ant-form-item {
  97. margin-bottom: 16px;
  98. }
  99. .ant-btn-primary-login {
  100. color: #008771;
  101. background-color: #e8f4f2;
  102. border-color: #a2d3cb;
  103. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);
  104. box-shadow: none;
  105. width: 100%;
  106. }
  107. .ant-btn-primary-login:focus,
  108. .ant-btn-primary-login:hover {
  109. color: #fff;
  110. background-color: #006655;
  111. border-color: #006655;
  112. background-image: linear-gradient(
  113. 270deg,
  114. rgba(123, 199, 77, 0) 30%,
  115. #009980,
  116. rgba(123, 199, 77, 0) 100%
  117. );
  118. background-repeat: no-repeat;
  119. animation: ma-bg-move ease-in-out 5s infinite;
  120. background-position-x: -500px;
  121. width: 95%;
  122. animation-delay: -0.5s;
  123. box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);
  124. }
  125. .ant-btn-primary-login.active,
  126. .ant-btn-primary-login:active {
  127. color: #fff;
  128. background-color: #006655;
  129. border-color: #006655;
  130. }
  131. @keyframes ma-bg-move {
  132. 0% {
  133. background-position: -500px 0;
  134. }
  135. 50% {
  136. background-position: 1000px 0;
  137. }
  138. 100% {
  139. background-position: 1000px 0;
  140. }
  141. }
  142. .wave-btn-bg {
  143. position: relative;
  144. border-radius: 25px;
  145. width: 100%;
  146. }
  147. .dark .wave-btn-bg {
  148. color: #fff;
  149. position: relative;
  150. background-color: #0a7557;
  151. border: 2px double transparent;
  152. background-origin: border-box;
  153. background-clip: padding-box, border-box;
  154. background-size: 300%;
  155. transition: all 0.5s ease;
  156. width: 100%;
  157. }
  158. .dark .wave-btn-bg:hover {animation: wave-btn-tara 4s ease infinite;}
  159. .dark .wave-btn-bg-cl {
  160. background-image: linear-gradient(rgba(13, 14, 33, 0), rgba(13, 14, 33, 0)),
  161. radial-gradient(circle at left top, #006655, #009980, #006655) !important;
  162. border-radius: 3em;
  163. }
  164. .dark .wave-btn-bg-cl:hover {
  165. width: 95%;
  166. }
  167. .dark .wave-btn-bg-cl:before {
  168. position: absolute;
  169. content: "";
  170. top: -5px;
  171. left: -5px;
  172. bottom: -5px;
  173. right: -5px;
  174. z-index: -1;
  175. background: inherit;
  176. background-size: inherit;
  177. border-radius: 4em;
  178. opacity: 0;
  179. transition: 0.5s;
  180. }
  181. .dark .wave-btn-bg-cl:hover::before {
  182. opacity: 1;
  183. filter: blur(20px);
  184. animation: wave-btn-tara 8s linear infinite;
  185. }
  186. @keyframes wave-btn-tara {
  187. to {
  188. background-position: 300%;
  189. }
  190. }
  191. .dark .ant-btn-primary-login {
  192. font-size: 14px;
  193. color: #fff;
  194. text-align: center;
  195. background-image: linear-gradient(
  196. rgba(13, 14, 33, 0.45),
  197. rgba(13, 14, 33, 0.35)
  198. );
  199. border-radius: 2rem;
  200. border: none;
  201. outline: none;
  202. background-color: transparent;
  203. height: 46px;
  204. position: relative;
  205. white-space: nowrap;
  206. cursor: pointer;
  207. touch-action: manipulation;
  208. padding: 0 15px;
  209. width: 100%;
  210. animation: none;
  211. background-position-x: 0;
  212. box-shadow: none;
  213. }
  214. </style>
  215. <body>
  216. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  217. <transition name="list" appear>
  218. <a-layout-content class="under" style="min-height: 0;">
  219. <div class='wave'></div>
  220. <div class='wave wave2'></div>
  221. <div class='wave wave3'></div>
  222. <a-row type="flex" justify="center" align="middle" style="height: 100%; overflow: auto;">
  223. <a-col :xs="22" :sm="20" :md="14" :lg="10" :xl="8" :xxl="6" id="login" style="margin: 3rem 0;">
  224. <a-row type="flex" justify="center">
  225. <a-col>
  226. <h1 class="title">{{ i18n "pages.login.title" }}</h1>
  227. </a-col>
  228. </a-row>
  229. <a-row type="flex" justify="center">
  230. <a-col span="24">
  231. <a-form>
  232. <a-form-item>
  233. <a-input v-model.trim="user.username" placeholder='{{ i18n "username" }}'
  234. @keydown.enter.native="login" autofocus>
  235. <a-icon slot="prefix" type="user" style="font-size: 16px;"/>
  236. </a-input>
  237. </a-form-item>
  238. <a-form-item>
  239. <password-input icon="lock" v-model.trim="user.password"
  240. placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
  241. </password-input>
  242. </a-form-item>
  243. <a-form-item v-if="secretEnable">
  244. <password-input icon="key" v-model.trim="user.loginSecret"
  245. placeholder='{{ i18n "secretToken" }}' @keydown.enter.native="login">
  246. </password-input>
  247. </a-input>
  248. </a-form-item>
  249. <a-form-item>
  250. <a-row justify="center" class="centered">
  251. <div class="wave-btn-bg wave-btn-bg-cl">
  252. <a-button class="ant-btn-primary-login" type="primary" :loading="loading" @click="login" :icon="loading ? 'poweroff' : undefined"
  253. :style="loading ? { width: '50px' } : { display: 'inline-block' }">
  254. [[ loading ? '' : '{{ i18n "login" }}' ]]
  255. </a-button>
  256. </div>
  257. </a-row>
  258. </a-form-item>
  259. <a-form-item>
  260. <a-row justify="center" class="centered">
  261. <a-col :span="24">
  262. <a-select ref="selectLang" v-model="lang" @change="setLang(lang)" style="width: 150px;" :dropdown-class-name="themeSwitcher.currentTheme">
  263. <a-select-option :value="l.value" label="English" v-for="l in supportLangs">
  264. <span role="img" aria-label="l.name" v-text="l.icon"></span>
  265. &nbsp;&nbsp;<span v-text="l.name"></span>
  266. </a-select-option>
  267. </a-select>
  268. </a-col>
  269. </a-row>
  270. </a-form-item>
  271. <a-form-item>
  272. <a-row justify="center" class="centered">
  273. <a-col>
  274. <a-icon type="bulb" :theme="themeSwitcher.isDarkTheme ? 'filled' : 'outlined'"></a-icon>&nbsp;
  275. </a-col>
  276. <a-col>
  277. <theme-switch />
  278. </a-col>
  279. </a-row>
  280. </a-form-item>
  281. </a-form>
  282. </a-col>
  283. </a-row>
  284. </a-col>
  285. </a-row>
  286. </a-layout-content>
  287. </transition>
  288. </a-layout>
  289. {{template "js" .}}
  290. {{template "component/themeSwitcher" .}}
  291. {{template "component/password" .}}
  292. <script>
  293. class User {
  294. constructor() {
  295. this.username = "";
  296. this.password = "";
  297. }
  298. }
  299. const app = new Vue({
  300. delimiters: ['[[', ']]'],
  301. el: '#app',
  302. data: {
  303. themeSwitcher,
  304. loading: false,
  305. user: new User(),
  306. secretEnable: false,
  307. lang: ""
  308. },
  309. async created() {
  310. this.lang = getLang();
  311. this.secretEnable = await this.getSecretStatus();
  312. },
  313. methods: {
  314. async login() {
  315. this.loading = true;
  316. const msg = await HttpUtil.post('/login', this.user);
  317. this.loading = false;
  318. if (msg.success) {
  319. location.href = basePath + 'panel/';
  320. }
  321. },
  322. async getSecretStatus() {
  323. this.loading = true;
  324. const msg = await HttpUtil.post('/getSecretStatus');
  325. this.loading = false;
  326. if (msg.success) {
  327. this.secretEnable = msg.obj;
  328. return msg.obj;
  329. }
  330. },
  331. },
  332. });
  333. </script>
  334. </body>
  335. </html>