pref(common): 优化时分秒格式化函数的输出

master
钟良源 2 weeks ago
parent 1621cb920b
commit 5139400957

@ -20,13 +20,14 @@ export const getObjType = (obj) => {
'[object RegExp]': 'regExp',
'[object Undefined]': 'undefined',
'[object Null]': 'null',
'[object Object]': 'object',
'[object Object]': 'object'
};
if (obj instanceof Element) {
return 'element';
}
return map[toString.call(obj)];
};
// 新窗口打开处理函数
export function openWindow(url: string, opts?: OpenWindowOptions) {
const { target = '_blank', ...others } = opts || {};
@ -210,12 +211,12 @@ export function formatSeconds(value: string) {
if (secondTime > 0) {
result = `${parseInt(`${secondTime}`, 10)}`;
}
if (minuteTime > 0) {
result = `${parseInt(`${minuteTime}`, 10)}${result}`;
}
if (hourTime > 0) {
result = `${parseInt(`${hourTime}`, 10)}小时${result}`;
}
// if (minuteTime > 0) {
// result = `${parseInt(`${minuteTime}`, 10)}分${result}`;
// }
// if (hourTime > 0) {
// result = `${parseInt(`${hourTime}`, 10)}小时${result}`;
// }
return result;
}
@ -258,9 +259,11 @@ export const deepClone = (data) => {
let obj;
if (type === 'array') {
obj = [];
} else if (type === 'object') {
}
else if (type === 'object') {
obj = {};
} else {
}
else {
//不再具有下一层次
return data;
}
@ -268,7 +271,8 @@ export const deepClone = (data) => {
for (let i = 0, len = data.length; i < len; i++) {
obj.push(deepClone(data[i]));
}
} else if (type === 'object') {
}
else if (type === 'object') {
for (const key in data) {
obj[key] = deepClone(data[key]);
}

Loading…
Cancel
Save