login.html 9.9 KB

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