1
0

login.html 9.6 KB

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