mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-19 11:55:23 +00:00
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import config from './config'
|
|
import menu from './menu'
|
|
import request from './request'
|
|
import classnames from 'classnames'
|
|
import {color} from './theme'
|
|
require('./mock.js')
|
|
|
|
// 连字符转驼峰
|
|
String.prototype.hyphenToHump = function () {
|
|
return this.replace(/-(\w)/g, function () {
|
|
return arguments[1].toUpperCase()
|
|
})
|
|
}
|
|
|
|
// 驼峰转连字符
|
|
String.prototype.humpToHyphen = function () {
|
|
return this.replace(/([A-Z])/g, '-$1').toLowerCase()
|
|
}
|
|
|
|
// 日期格式化
|
|
Date.prototype.format = function (format) {
|
|
var o = {
|
|
'M+': this.getMonth() + 1,
|
|
'd+': this.getDate(),
|
|
'h+': this.getHours(),
|
|
'H+': this.getHours(),
|
|
'm+': this.getMinutes(),
|
|
's+': this.getSeconds(),
|
|
'q+': Math.floor((this.getMonth() + 3) / 3),
|
|
'S': this.getMilliseconds()
|
|
}
|
|
if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) }
|
|
for (var k in o) {
|
|
if (new RegExp('(' + k + ')').test(format)) {
|
|
format = format.replace(RegExp.$1, RegExp.$1.length === 1
|
|
? o[k]
|
|
: ('00' + o[k]).substr(('' + o[k]).length))
|
|
}
|
|
}
|
|
return format
|
|
}
|
|
|
|
module.exports = {
|
|
config,
|
|
menu,
|
|
request,
|
|
color,
|
|
classnames
|
|
}
|