diff --git a/back/api/config.ts b/back/api/config.ts index 0e0a3258..6bd4bf5b 100644 --- a/back/api/config.ts +++ b/back/api/config.ts @@ -5,6 +5,7 @@ import { Logger } from 'winston'; import config from '../config'; import * as fs from 'fs'; import { celebrate, Joi } from 'celebrate'; +import { execSync } from 'child_process'; const route = Router(); export default (app: Router) => { @@ -57,6 +58,9 @@ export default (app: Router) => { const { name, content } = req.body; const path = (config.fileMap as any)[name]; fs.writeFileSync(path, content); + if (name === 'crontab.list') { + execSync(`crontab ${path}`); + } res.send({ code: 200, msg: '保存成功' }); } catch (e) { logger.error('🔥 error: %o', e); diff --git a/back/services/cookie.ts b/back/services/cookie.ts index 6b1f584b..0442827f 100644 --- a/back/services/cookie.ts +++ b/back/services/cookie.ts @@ -165,12 +165,18 @@ export default class CookieService { let ucookie = this.getCookie(res); let content = getFileContentByName(config.confFile); const regx = /.*Cookie[0-9]{1}\=\"(.+?)\"/g; - const lastCookie = oldCookie || (content.match(regx) as any[]).pop(); - const cookieRegx = /Cookie([0-9]+)\=.+?/.exec(lastCookie); - if (cookieRegx) { - const num = parseInt(cookieRegx[1]) + 1; - const newCookie = `${lastCookie}\nCookie${num}="${ucookie}"`; - const result = content.replace(lastCookie, newCookie); + if (content.match(regx)) { + const lastCookie = oldCookie || (content.match(regx) as any[]).pop(); + const cookieRegx = /Cookie([0-9]+)\=.+?/.exec(lastCookie); + if (cookieRegx) { + const num = parseInt(cookieRegx[1]) + 1; + const newCookie = `${lastCookie}\nCookie${num}="${ucookie}"`; + const result = content.replace(lastCookie, newCookie); + fs.writeFileSync(config.confFile, result); + } + } else { + const newCookie = `Cookie1="${ucookie}"`; + const result = content.replace(`Cookie1=""`, newCookie); fs.writeFileSync(config.confFile, result); } return { cookie: ucookie }; diff --git a/src/pages/login/index.less b/src/pages/login/index.less index d031b7a0..ee452a3d 100644 --- a/src/pages/login/index.less +++ b/src/pages/login/index.less @@ -1,4 +1,24 @@ -.form { +@import '~antd/es/style/themes/default.less'; + +.container { + display: flex; + flex-direction: column; + height: 100vh; + overflow: auto; + background: @layout-body-background; +} + +.lang { + width: 100%; + height: 40px; + line-height: 44px; + text-align: right; + :global(.ant-dropdown-trigger) { + margin-right: 24px; + } +} + +.content { position: absolute; top: 45%; left: 50%; @@ -6,53 +26,97 @@ width: 320px; height: 320px; padding: 36px; - box-shadow: 0 0 100px rgba(0, 0, 0, 0.08); + // box-shadow: 0 0 100px rgba(0, 0, 0, 0.08); +} - button { - width: 100%; +@media (min-width: @screen-md-min) { + .container { + background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg'); + background-repeat: no-repeat; + background-position: center 110px; + background-size: 100%; } - p { - color: rgb(204, 204, 204); - text-align: center; - margin-top: 16px; - font-size: 12px; + .content { + padding: 32px 0 24px; + } +} + +.top { + text-align: center; +} + +.header { + height: 44px; + line-height: 44px; + a { display: flex; - justify-content: space-between; + align-items: center; + justify-content: center; } } .logo { - text-align: center; - cursor: pointer; - margin-bottom: 24px; - display: flex; - justify-content: center; - align-items: center; - - img { - width: 40px; - margin-right: 8px; - } - - span { - vertical-align: text-bottom; - font-size: 16px; - text-transform: uppercase; - display: inline-block; - font-weight: 700; - // color: @primary-color; - // .text-gradient(); - } + height: 44px; + margin-right: 16px; + vertical-align: top; } -.ant-spin-container, -.ant-spin-nested-loading { - height: 100%; +.title { + position: relative; + top: 2px; + color: @heading-color; + font-weight: 600; + font-size: 33px; + font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif; } -.footer { - position: absolute; - width: 100%; - bottom: 0; -} \ No newline at end of file +.desc { + margin-top: 12px; + margin-bottom: 40px; + color: @text-color-secondary; + font-size: @font-size-base; +} + +.main { + width: 320px; + margin: 25px auto 0; + @media screen and (max-width: @screen-sm) { + width: 95%; + max-width: 320px; + } + + :global { + .@{ant-prefix}-tabs-nav-list { + margin: auto; + font-size: 16px; + } + } + + .icon { + margin-left: 16px; + color: rgba(0, 0, 0, 0.2); + font-size: 24px; + vertical-align: middle; + cursor: pointer; + transition: color 0.3s; + + &:hover { + color: @primary-color; + } + } + + .other { + margin-top: 24px; + line-height: 22px; + text-align: left; + .register { + float: right; + } + } + + .prefixIcon { + color: @primary-color; + font-size: @font-size-base; + } +} diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index eac0d084..c27fc3a1 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -1,9 +1,10 @@ import React, { Fragment, useEffect } from 'react'; import { Button, Row, Input, Form, notification } from 'antd'; import config from '@/utils/config'; -import { history } from 'umi'; +import { history, Link } from 'umi'; import styles from './index.less'; import { request } from '@/utils/http'; +import logo from '@/assets/logo.png'; const FormItem = Form.Item; @@ -39,34 +40,45 @@ const Login = () => { }, []); return ( - -
-
- {config.siteName} +
+
+
+
+ + logo + {config.siteName} + +
+
+
+
+ + + + + + + + + +
-
- - - - - - - - - -
- +
); }; diff --git a/src/utils/config.ts b/src/utils/config.ts index fa63c9ff..7763b213 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,5 +1,5 @@ export default { - siteName: '京东羊毛脚本控制面板', + siteName: '脚本控制面板', apiPrefix: '/api/', authKey: 'token',