add method extract_story_title
				
					
				
			This commit is contained in:
		
							parent
							
								
									baeed8d332
								
							
						
					
					
						commit
						5cb8755a00
					
				
							
								
								
									
										15
									
								
								tool_core.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								tool_core.js
									
									
									
									
									
								
							@ -329,13 +329,26 @@ module.exports = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // 返回新的数组
 | 
					  // 返回新的数组
 | 
				
			||||||
  filter_story (story) {
 | 
					  filter_story (story) {
 | 
				
			||||||
    if (Array.isArray(story)) {
 | 
					    if (Array.isArray(story) && story.length) {
 | 
				
			||||||
      return story.filter((section) => Object.values(section || {}).some((val) => !this.is_empty(val))) // (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 []
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  extract_story_title (story) {
 | 
				
			||||||
 | 
					    if (Array.isArray(story) && story.length) {
 | 
				
			||||||
 | 
					      return (
 | 
				
			||||||
 | 
					        story
 | 
				
			||||||
 | 
					          .map(({ text = '' } = {}) => text.trim().replace(/\n/g, ' '))
 | 
				
			||||||
 | 
					          .join(' ')
 | 
				
			||||||
 | 
					          .substring(0, 140) || ''
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      return ''
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  is_empty (data) {
 | 
					  is_empty (data) {
 | 
				
			||||||
    // empty: undefined, null, false, 0, NaN, '', '空格,tab, \n等', [], {}
 | 
					    // empty: undefined, null, false, 0, NaN, '', '空格,tab, \n等', [], {}
 | 
				
			||||||
    if (data) {
 | 
					    if (data) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user