login.html 9.9 KB

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