提交 229346a4 编写于 作者: Q qiang

fix: storage 接口支持 Date 对象 fixed #1661

上级 0b86fd87
......@@ -12,9 +12,16 @@ function parseValue (value) {
const type = object.type
if (types.indexOf(type) >= 0) {
const keys = Object.keys(object)
// eslint-disable-next-line valid-typeof
if (keys.length === 2 && 'data' in object && typeof object.data === type) {
return object.data
if (keys.length === 2 && 'data' in object) {
// eslint-disable-next-line valid-typeof
if (typeof object.data === type) {
return object.data
}
// eslint-disable-next-line no-useless-escape
if (type === 'object' && /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{3}Z$/.test(object.data)) {
// ISO 8601 格式返回 Date
return new Date(object.data)
}
} else if (keys.length === 1) {
return ''
}
......
......@@ -7,9 +7,16 @@ function parseValue (value) {
const type = object.type
if (types.indexOf(type) >= 0) {
const keys = Object.keys(object)
// eslint-disable-next-line valid-typeof
if (keys.length === 2 && 'data' in object && typeof object.data === type) {
return object.data
if (keys.length === 2 && 'data' in object) {
// eslint-disable-next-line valid-typeof
if (typeof object.data === type) {
return object.data
}
// eslint-disable-next-line no-useless-escape
if (type === 'object' && /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{3}Z$/.test(object.data)) {
// ISO 8601 格式返回 Date
return new Date(object.data)
}
} else if (keys.length === 1) {
return ''
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册