| | |
| | | * @returns {string} |
| | | */ |
| | | export const getSmallImg = url => { |
| | | if (!url) return '' |
| | | const lastDotIndex = url.lastIndexOf('.') |
| | | return `${url.substring(0, lastDotIndex)}_small${url.substring(lastDotIndex)}` |
| | | if (!url) return '' |
| | | const lastDotIndex = url.lastIndexOf('.') |
| | | return `${url.substring(0, lastDotIndex)}_small${url.substring(lastDotIndex)}` |
| | | } |
| | | /** |
| | | * 浏览器判断是否全屏 |
| | |
| | | // 设置默认范围 [上个月, 当前月] |
| | | return [new Date(lastMonthYear, lastMonth, 1), new Date(currentYear, currentMonth, 1)] |
| | | } |
| | | |
| | | // key驼峰转换为下划线 |
| | | export function camelToSnake (obj) { |
| | | if (typeof obj !== 'object' || obj === null) { |
| | | return obj |
| | | } |
| | | |
| | | if (Array.isArray(obj)) { |
| | | return obj.map(item => camelToSnake(item)) |
| | | } |
| | | |
| | | const newObj = {} |
| | | for (const key in obj) { |
| | | if (Object.prototype.hasOwnProperty.call(obj, key)) { |
| | | const newKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase() |
| | | newObj[newKey] = camelToSnake(obj[key]) |
| | | } |
| | | } |
| | | return newObj |
| | | } |