update theme

This commit is contained in:
zuiidea
2017-04-14 18:55:19 +08:00
parent 4cf25852da
commit b0f790ffaf
29 changed files with 62 additions and 153 deletions
+1 -9
View File
@@ -6,16 +6,8 @@ const svgSpriteDirs = [
export default {
entry: 'src/index.js',
publicPath: "http://47.92.30.98:8000",
svgSpriteLoaderDirs: svgSpriteDirs,
"theme": "src/theme.js",
// "proxy": {
// "/api": {
// "target": "http://localhost:7001/api/v1/",
// "changeOrigin": true,
// "pathRewrite": { "^/api" : "" }
// }
// },
"theme": "./theme.config.js",
"env": {
"development": {
"extraBabelPlugins": [
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../vars.less";
@import "../../themes/vars.less";
.bread {
height: 64px;
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../vars.less";
@import "../../themes/vars.less";
.footer {
height: 48px;
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../vars.less";
@import "../../themes/vars.less";
.header {
:global .ant-menu-horizontal {
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../vars.less";
@import "../../themes/vars.less";
.layout {
position: relative;
+1 -1
View File
@@ -1 +1 @@
@import "../vars.less";
@import "../../themes/vars.less";
-16
View File
@@ -1,16 +0,0 @@
@import '~antd/lib/style/themes/default.less'; // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
/*========================*/
/*=======Antd Admin=======*/
/*========================*/
@dark-half: #494949;
@purple: #d897eb;
@shadow-1: 4px 4px 20px 0 rgba(0,0,0,0.01);
@shadow-2: 4px 4px 40px 0 rgba(0,0,0,0.05);
@transition-ease-in: all 0.3s @ease-in;
@transition-ease-out: all 0.3s @ease-out;
.text-overflow() {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
+2 -2
View File
@@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="index.css" />
<link rel="stylesheet" href="/index.css" />
<!--[if lte IE 10]>
<script
src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,media-match/2.0.2/media.match.min.js"></script>
@@ -14,7 +14,7 @@
<body>
<div id="root"></div>
<script src="index.js"></script>
<script src="/index.js"></script>
</body>
</html>
+12 -32
View File
@@ -1,6 +1,8 @@
import { getUserInfo, logout } from '../services/app'
import { routerRedux } from 'dva/router'
import { parse } from 'qs'
import { config } from '../utils'
const { prefix } = config
export default {
namespace: 'app',
@@ -8,33 +10,10 @@ export default {
user: {},
loginButtonLoading: false,
menuPopoverVisible: false,
siderFold: localStorage.getItem('antdAdminSiderFold') === 'true',
darkTheme: localStorage.getItem('antdAdminDarkTheme') !== 'false',
siderFold: localStorage.getItem(`${prefix}siderFold`) === 'true',
darkTheme: localStorage.getItem(`${prefix}darkTheme`) === 'true',
isNavbar: document.body.clientWidth < 769,
navOpenKeys: [],
permissions: {
dashboard: {
text: 'Dashboard',
route: 'dashboard',
},
users: {
text: 'User Manage',
route: 'users',
},
UIElement: {
text: 'UI Element',
route: 'UIElement',
},
UIElementIconfont: {
text: 'Iconfont',
route: 'UIElement/iconfont',
parent: 'UIElement',
},
chart: {
text: 'Rechart',
route: 'chart',
},
},
},
subscriptions: {
setup ({ dispatch }) {
@@ -59,11 +38,11 @@ export default {
}
} else {
if (location.pathname !== '/login') {
let from = location.pathname
if (location.pathname === '/dashboard') {
window.location = `${location.origin}/login?from=/dashboard`
} else {
yield put(routerRedux.push(`/login?from=${location.pathname}`))
from = '/dashboard'
}
window.location = `${location.origin}/login?from=${from}`
}
}
},
@@ -122,14 +101,14 @@ export default {
}
},
handleSwitchSider (state) {
localStorage.setItem('antdAdminSiderFold', !state.siderFold)
localStorage.setItem(`${prefix}siderFold`, !state.siderFold)
return {
...state,
siderFold: !state.siderFold,
}
},
handleChangeTheme (state) {
localStorage.setItem('antdAdminDarkTheme', !state.darkTheme)
localStorage.setItem(`${prefix}darkTheme`, !state.darkTheme)
return {
...state,
darkTheme: !state.darkTheme,
@@ -153,10 +132,11 @@ export default {
menuPopoverVisible: !state.menuPopoverVisible,
}
},
handleNavOpenKeys (state, action) {
handleNavOpenKeys (state, { payload: navOpenKeys }) {
console.log(navOpenKeys)
return {
...state,
...action.payload,
...navOpenKeys,
}
},
},
+1 -6
View File
@@ -188,12 +188,7 @@ export default {
},
},
subscriptions: {
setup ({ dispatch, history }) {
history.listen(location => {
if (location.pathname === '/dashboard') {
console.log('dashboard')
}
})
setup ({ dispatch }) {
dispatch({ type: 'query' })
dispatch({ type: 'queryWeather' })
},
-13
View File
@@ -11,14 +11,6 @@ const registerModel = (app, model) => {
}
const Routers = function ({ history, app }) {
const handleChildRoute = ({ location }) => {
console.log(location)
// const state = app._store.getState()
// if (!state.app.login && location.pathname !== '/login') {
// app._store.dispatch(routerRedux.push('/login'))
// }
}
const routes = [
{
path: '/',
@@ -136,11 +128,6 @@ const Routers = function ({ history, app }) {
},
]
routes[0].childRoutes.map(item => {
item.onEnter = handleChildRoute
return item
})
return <Router history={history} routes={routes} />
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { connect } from 'dva'
import { Layout } from '../components'
import { classnames, config } from '../utils'
import { Helmet } from 'react-helmet'
import '../components/skin.less'
import '../themes/index.less'
const { Header, Bread, Footer, Sider, styles } = Layout
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.comments {
:global .ant-table-thead > tr > th {
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.sales {
.title {
@@ -1,8 +1,7 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.numberCard {
padding: 32px;
font-family: monospace;
margin-bottom: 24px;
cursor: pointer;
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.quote {
color: #fff;
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.recentsales {
:global .ant-table-thead > tr > th {
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.sales {
.title {
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.user {
.header {
+1 -1
View File
@@ -1,4 +1,4 @@
@import "../../../components/vars.less";
@import "../../../themes/vars.less";
.weather {
color: #fff;
+1 -1
View File
@@ -29,7 +29,7 @@ const UserFilter = ({
<Search {...searchGroupProps} />
</Col>
<Col lg={{ offset: 8, span: 8 }} md={12} sm={8} xs={24} style={{ marginBottom: 16, textAlign: 'right' }}>
<Switch style={{ marginRight: 16 }} defaultChecked={isMotion} onChange={switchIsMotion} checkedChildren={'动画开'} unCheckedChildren={'动画关'} />
{/* <Switch style={{ marginRight: 16 }} defaultChecked={isMotion} onChange={switchIsMotion} checkedChildren={'动画开'} unCheckedChildren={'动画关'} /> */}
<Button size="large" type="ghost" onClick={onAdd}>添加</Button>
</Col>
</Row>
+14
View File
@@ -0,0 +1,14 @@
// 本文件是对 ant-design:
// https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
// 相应变量值的覆盖
// 注意:只需写出要覆盖的变量即可(不需要覆盖的变量不要写)
@import "../../node_modules/antd/lib/style/themes/default.less"; // // Prefix
// @border-radius-base: 3px;
// @border-radius-sm: 2px;
// @shadow-color: rgba(0,0,0,0.05);
// @shadow-1-down: 4px 4px 40px @shadow-color;
// @border-color-split: #f4f4f4;
// @border-color-base: #e5e5e5;
// @menu-dark-bg: #3e3e3e;
// @text-color: #666;
// @font-family: "AvenirNext-Regular", "Helvetica Neue", "lucida grande", "PingFangHK-Light", "STHeiti", "Heiti SC", "Hiragino Sans GB", "Microsoft JhengHei", "Microsoft Yahei", SimHei, "WenQuanYi Micro Hei", "Droid Sans", "Roboto", Helvetica, Tahoma, Arial, "sans-serif";
+14
View File
@@ -0,0 +1,14 @@
@import "./default.less"; // antd-admin
@dark-half: #494949;
@purple: #d897eb;
@shadow-1: 4px 4px 20px 0 rgba(0,0,0,0.01);
@shadow-2: 4px 4px 40px 0 rgba(0,0,0,0.05);
@transition-ease-in: all 0.3s ease-out;
@transition-ease-out: all 0.3s ease-out;
@ease-in: ease-in;
.text-overflow {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
+2
View File
@@ -0,0 +1,2 @@
@import "./default.less";
@import "./mixin.less";
-1
View File
@@ -3,7 +3,6 @@ import menu from './menu'
import request from './request'
import classnames from 'classnames'
import { color } from './theme'
// require('./mock.js')
// 连字符转驼峰
String.prototype.hyphenToHump = function () {
-43
View File
@@ -1,43 +0,0 @@
const Mock = require('mockjs')
const users = require('../../mock/users')
const app = require('../../mock/app')
const dashboard = require('../../mock/dashboard')
const mockData = [users, app, dashboard]
function serialize (str) {
let paramArray = str.split('&')
let query = {}
for (let i in paramArray) {
if (Object.prototype.hasOwnProperty.call(paramArray, i)) {
query[paramArray[i].split('=')[0]] = paramArray[i].split('=')[1]
}
}
return query
}
for (let i in mockData) {
if (Object.prototype.hasOwnProperty.call(mockData, i)) {
for (let key in mockData[i]) {
if (Object.prototype.hasOwnProperty.call(mockData[i], key)) {
Mock.mock(eval(`/${key.split(' ')[1].replace(/\//g, '\\/')}/`), key.split(' ')[0].toLowerCase(), (options) => {
if (key.split(' ')[0].toLowerCase() === 'get') {
if (options.url.split('?')[1]) {
options.query = serialize(options.url.split('?')[1])
} else {
options.query = options.body ? JSON.parse(options.body) : {}
}
}
let res = {}
let result = {}
res.json = function (data) {
result = data
}
mockData[i][key](options, res)
return result
})
}
}
}
}
Mock.setup({ timeout: '200-600' })
-14
View File
@@ -1,14 +0,0 @@
const Watch = require('watchjs')
const config = require('./config')
export default function mockStorge (name, defaultValue) {
let key = config.prefix + name
global[key] = localStorage.getItem(key)
? JSON.parse(localStorage.getItem(key))
: defaultValue
!localStorage.getItem(key) && localStorage.setItem(key, JSON.stringify(global[key]))
Watch.watch(global[key], () => {
localStorage.setItem(key, JSON.stringify(global[key]))
})
return key
}
+1 -1
View File
@@ -3,6 +3,6 @@ const path = require('path')
const lessToJs = require('less-vars-to-js')
module.exports = () => {
const themePath = path.join(__dirname, './src/components/vars.less')
const themePath = path.join(__dirname, './src/themes/default.less')
return lessToJs(fs.readFileSync(themePath, 'utf8'))
}