sider menu

This commit is contained in:
zuiidea
2016-10-14 21:21:24 +08:00
parent 1a3ea0f244
commit 2a750ea65b
19 changed files with 92 additions and 534 deletions
-107
View File
@@ -1,107 +0,0 @@
import config from '../config'
class Logger {
static LOG_LEVEL_DEBUG = 1
static LOG_LEVEL_INFO = 2
static LOG_LEVEL_WARN = 3
static LOG_LEVEL_ERROR = 4
static loggerMap = new Map()
static defaultLogger = new Logger()
static getLogger(name) {
if (name && name !== '') {
if (Logger.loggerMap.has(name)) {
return Logger.loggerMap.get(name)
}
const logger = new Logger(name)
Logger.loggerMap.set(name, logger)
return logger
} else {
return Logger.defaultLogger
}
}
constructor(name) {
this.name = name
const configLogLevel = config.logLevel
if (configLogLevel === 'debug') {
this.logLevel = Logger.LOG_LEVEL_DEBUG
} else if (configLogLevel === 'info') {
this.logLevel = Logger.LOG_LEVEL_INFO
} else if (configLogLevel === 'warn') {
this.logLevel = Logger.LOG_LEVEL_WARN
} else if (configLogLevel === 'error') {
this.logLevel = Logger.LOG_LEVEL_ERROR
} else {
this.error('unsupported logLevel: %s, use INFO instead', configLogLevel)
this.logLevel = Logger.LOG_LEVEL_INFO
}
}
setLogLevel(newLogLevel) {
if (isNaN(newLogLevel)) {
this.error('setLogLevel error, not a number: %s', newLogLevel)
}
if (newLogLevel < 1 || newLogLevel > 4) {
this.error('setLogLevel error, input = %s, must between 1 and 4', newLogLevel)
}
this.logLevel = newLogLevel
}
info(pattern, ...args) {
if (this.logLevel > Logger.LOG_LEVEL_INFO) {
return
}
if (this.name) {
args.unshift(`${this.name}: ${pattern}`)
} else {
args.unshift(pattern)
console.log.apply(console, args)
}
}
error(pattern, ...args) {
if (this.logLevel > Logger.LOG_LEVEL_ERROR) {
return
}
args.unshift('background: red color: #bada55')
if (this.name) {
args.unshift(`%c${this.name}: ${pattern}`)
} else {
args.unshift(`%c${pattern}`)
console.error.apply(console, args)
}
}
debug(pattern, ...args) {
if (this.logLevel > Logger.LOG_LEVEL_DEBUG) {
return
}
args.unshift('background: black color: #bada55')
if (this.name) {
args.unshift(`%c${this.name}: ${pattern}`)
} else {
args.unshift(`%c${pattern}`)
console.debug.apply(console, args)
}
}
warn(pattern, ...args) {
if (this.logLevel > Logger.LOG_LEVEL_WARN) {
return
}
args.unshift('background: yellow color: black')
if (this.name) {
args.unshift(`%c${this.name}: ${pattern}`)
} else {
args.unshift(`%c${pattern}`)
console.warn.apply(console, args)
}
}
}
export default Logger
+7
View File
@@ -0,0 +1,7 @@
module.exports = {
name: 'Ant Design Admin',
footerText: 'Ant Design Admin 版权所有 © 2016 由 zuiidea 支持',
logoSrc:'https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg',
logoText:'Antd Admin',
needLogin:true,
};
+8 -52
View File
@@ -1,53 +1,9 @@
/** 对Date的扩展,将 Date 转化为指定格式的String * 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q)
* 可以用 1-2 个占位符 * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
* eg:
* (new Date()).format("yyyy-MM-dd hh:mm:ss.S")==> 2006-07-02 08:09:04.423
* (new Date()).format("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
* (new Date()).format("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
* (new Date()).format("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
* (new Date()).format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
*/
Date.prototype.format = function (fmt) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12,
"H+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
};
var week = {
"0": "/u65e5",
"1": "/u4e00",
"2": "/u4e8c",
"3": "/u4e09",
"4": "/u56db",
"5": "/u4e94",
"6": "/u516d"
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
if (/(E+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
};
import config from './config'
import menu from './menu'
import request from './request'
/**
* 在当前日期的基础上再增加几天
*
* @param num 要增加的天数
*/
Date.prototype.plusDays = function (num) {
var tmp = new Date();
tmp.setDate(this.getDate() + num);
return tmp;
};
module.exports = {
config,
menu,
request,
}
-58
View File
@@ -1,58 +0,0 @@
import config from 'config'
import Logger from './logger'
import reqwest from 'reqwest'
function ajax(data){
if(config.debug && data.url.indexOf('http')<0){
setTimeout(function(){
if(data.url==config.user.info){
if(localStorage.getItem("username")&&localStorage.getItem("username")=="guest"&&
localStorage.getItem("password")&&localStorage.getItem("password")=='guest'){
data.success({
message:'登录成功',
isSuccess:true,
userName:"guest"
})
}else {
data.success({
message:'获取信息成功',
isSuccess:false,
userName:"guest"
})
}
}else if (data.url==config.user.signIn) {
if(data.complete){
data.complete()
}
if(data.data.username=='guest'&&data.data.password=='guest'){
localStorage.setItem("username","guest")
localStorage.setItem("password","guest")
data.success({
message:'登录成功',
isSuccess:true,
userName:"guest"
})
}else {
data.success({
message:'密码错误',
isSuccess:false
})
}
}else if (data.url==config.user.signOut) {
localStorage.removeItem("username")
localStorage.removeItem("password")
location.reload()
}
},500)
}else {
reqwest(data)
}
}
module.exports = {
config,
ajax,
Logger
}
-52
View File
@@ -1,52 +0,0 @@
@import "./utility.less";
// table
.ant-table {
.ant-table-thead > tr > th {
text-align: center;
}
td {
text-align: center;
}
}
.ant-table-small .ant-table-body > table{
padding: 0;
}
.ant-table-pagination {
float: none;
display: table;
margin: 16px auto;
}
// scrollbar
::-webkit-scrollbar-corner {
background-color: transparent;
}
::-webkit-scrollbar-button {
width: 0;
height: 0;
display: none;
}
::-webkit-scrollbar-thumb {
width: 7px;
background-color: #b4babf;
border-radius: 7px;
}
::-webkit-scrollbar {
width: 7px;
height: 7px;
}
::-webkit-scrollbar-track {
width: 15px;
}
::-webkit-scrollbar:hover {
background-color: transparent;
}
+37
View File
@@ -0,0 +1,37 @@
module.exports = [
{
key: 'dashboard',
name: '仪表盘',
icon: 'laptop'
},
{
key: 'users',
name: '用户管理',
icon: 'user',
},
{
key: 'navigation',
name: '测试导航',
icon: 'setting',
child: [
{
key: 'navigation1',
name: '二级导航1',
},
{
key: 'navigation2',
name: '二级导航2',
child: [
{
key: 'navigation21',
name: '三级导航1',
},
{
key: 'navigation22',
name: '三级导航2',
},
],
},
],
},
];