add is_empty
				
					
				
			This commit is contained in:
		
							parent
							
								
									4ff5c00560
								
							
						
					
					
						commit
						2dbd84b8d6
					
				
							
								
								
									
										18
									
								
								coretool.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								coretool.js
									
									
									
									
									
								
							@ -325,12 +325,28 @@ module.exports = {
 | 
				
			|||||||
  // 返回新的数组
 | 
					  // 返回新的数组
 | 
				
			||||||
  filter_story (story) {
 | 
					  filter_story (story) {
 | 
				
			||||||
    if (Array.isArray(story)) {
 | 
					    if (Array.isArray(story)) {
 | 
				
			||||||
      return story.filter(section => Object.values(section).some(val => val?.trim?.())) // (section.text || section.image || section.video)?.trim?.()
 | 
					      return story.filter(section => Object.values(section || {}).some(val => !this.is_empty(val))) // (section.text || section.image || section.video)?.trim?.()
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      return []
 | 
					      return []
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  is_empty (data) { // empty: undefined, null, false, 0, NaN, '', '空格,tab, \n等', [], {}
 | 
				
			||||||
 | 
					    if (data) {
 | 
				
			||||||
 | 
					      if (typeof (data) === 'string' && data.trim() === '') {
 | 
				
			||||||
 | 
					        return true
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (Array.isArray(data) && data.length === 0) {
 | 
				
			||||||
 | 
					        return true
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (typeof (data) === 'object' && Object.keys(data).length === 0) {
 | 
				
			||||||
 | 
					        return true
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return false
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return true
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * 对数组中的对象,按对象的key进行sortType排序
 | 
					   * 对数组中的对象,按对象的key进行sortType排序
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user