Skip to content

Commit

Permalink
feat(admin, experimental): 允许自定义页面背景图
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Jan 24, 2022
1 parent 1fe8d15 commit 1df048a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions pages/admin-api/js-config/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function get()
'title' => $page->getTitle(),
'logo' => $page->getLogo(),
'copyright' => $page->getCopyright(),
'bg' => $page->getBg(),
];

return suc(['data' => JsConfig::toArray() + ['page' => $config]]);
Expand Down
24 changes: 15 additions & 9 deletions pages/admin/login/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @layout false
*/
import { Component } from 'react';
import {Component} from 'react';
import {Form, Button, Input} from 'antd';
import {Box, Image} from '@mxjs/box';
import $ from 'miaoxing';
Expand All @@ -12,17 +12,23 @@ import nextUrl from 'next-url';
import logo from '@miaoxing/admin/images/logo.svg';
import {ConfigConsumer} from '@miaoxing/app';

const bg = 'https://image-10001577.image.myqcloud.com/uploads/3/20190602/15594729401485.jpg';

export default class extends Component {
render() {
return <Box flex>
<Global
styles={css`
body {
background: #f5f8fa url(https://image-10001577.image.myqcloud.com/uploads/3/20190602/15594729401485.jpg) no-repeat center center fixed;
background-size: cover;
}
`}
/>
<ConfigConsumer>
{({page}) => (
<Global
styles={css`
body {
background: #f5f8fa url(${page.bg || bg}) no-repeat center center fixed;
background-size: cover;
}
`}
/>
)}
</ConfigConsumer>
<Box
w={350}
mx="auto"
Expand Down
17 changes: 17 additions & 0 deletions src/Service/AdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ class AdminPage extends BaseService
*/
protected $logo = '';

/**
* 背景图片,可用于登录等简单页面
*
* @var string
* @experimental 只有特定页面有背景,可能要改为其他更合适的名称
*/
protected $bg = '';

/**
* @return string
*/
Expand All @@ -44,4 +52,13 @@ public function getLogo(): string
{
return $this->logo;
}

/**
* @return string
* @experimental
*/
public function getBg(): string
{
return $this->bg;
}
}

0 comments on commit 1df048a

Please sign in to comment.