login.html 11 KB

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