u
This commit is contained in:
		
							parent
							
								
									0c05bfd464
								
							
						
					
					
						commit
						f9ffbb4989
					
				| @ -363,7 +363,7 @@ module.exports = { | ||||
|   summarize_story (story = []) { | ||||
|     // story is an array of objects, each object could either be {text:'some string'}, {image: url} or {video:url}. Please construct a summary object as result: { textLength, imageCount, VideoCount }
 | ||||
|     return story.reduce( | ||||
|       (summary, { text, image, video, audio, file, linkTarget } = {}) => { | ||||
|       (summary, { text, image, video, audio, file, linkTarget, _autocontent } = {}) => { | ||||
|         if (text) { | ||||
|           summary.textLength += text.length | ||||
|           summary.wordCount += text.split(/\s+/).length | ||||
| @ -377,12 +377,14 @@ module.exports = { | ||||
|           summary.fileCount++ | ||||
|         } else if (linkTarget) { | ||||
|           summary.linkCount++ | ||||
|         } else if (_autocontent) { | ||||
|           summary.emptyContent++ | ||||
|         } else { | ||||
|           summary.untypeCount++ | ||||
|         } | ||||
|         return summary | ||||
|       }, | ||||
|       { textLength: 0, wordCount: 0, imageCount: 0, videoCount: 0, audioCount: 0, fileCount: 0, linkCount: 0, untypeCount: 0 } | ||||
|       { textLength: 0, wordCount: 0, imageCount: 0, videoCount: 0, audioCount: 0, fileCount: 0, linkCount: 0, emptyContent: 0, untypeCount: 0 } | ||||
|     ) | ||||
|   }, | ||||
| 
 | ||||
|  | ||||
| @ -146,7 +146,7 @@ module.exports = { | ||||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   make_server_url (route, envar = globalThis.wo?.envar || {}) { | ||||
|   make_server_url (route, { envar = globalThis.wo?.envar, fullUrl = false } = {}) { | ||||
|     if (typeof route === 'string') route = route.replace('\\', '/') | ||||
|     else if (route?.apiWho && route?.apiTodo) { | ||||
|       const { apiVersion = 'api', apiWho, apiTodo } = route | ||||
| @ -163,22 +163,26 @@ module.exports = { | ||||
|     if (/^\/static\//.test(route)) { | ||||
|       return route | ||||
|     } | ||||
|     route = route.replace(/^\//, '') | ||||
|     // 对 route='abc.com' 这种,应当有 fullUrl===true,就直接使用,而不是组装成 pexserver.tic.cc/abc.com
 | ||||
|     // 纯数字和字母的cid
 | ||||
|     if (/^[\da-zA-Z]+$/.test(route) && envar.ipfsLens) { | ||||
|       return `${envar.ipfsLens.replace(/\/$/, '')}/${route.replace(/^\//, '')}` | ||||
|     if (/^[0-9a-zA-Z]+$/.test(route) && envar?.ipfsLens) { | ||||
|       return `${envar.ipfsLens.replace(/\/$/, '')}/${route}` | ||||
|     } | ||||
|     //// base url / 后台服务器url 需要组装。包括了 route === '_filestore/xxx' 的情况
 | ||||
|     route = route.replace(/^\//, '') | ||||
|     // 已有现成后端服务域名
 | ||||
|     if (envar.servUrl) { | ||||
|     if (fullUrl) { | ||||
|       return `http://${route}` | ||||
|     } else if (envar?.servUrl) { | ||||
|       return `${envar.servUrl.replace(/\/$/, '')}/${route}` | ||||
|     } else { | ||||
|     } else if (envar?.servHostname) { | ||||
|       // 需要组装后端服务域名
 | ||||
|       const hostname = envar.servHostname /*|| globalThis.window?.location?.hostname*/ || 'localhost' | ||||
|       const port = envar.servPort /*|| globalThis.window?.location?.port*/ || '' | ||||
|       const protocol = hostname === 'localhost' ? 'http' : envar.servProtocol || (process.env.NODE_ENV === 'production' ? 'https' : 'http') | ||||
|       return `${protocol}://${hostname}${port ? ':' : ''}${port}/${route}` | ||||
|     } | ||||
|     return route | ||||
|   }, | ||||
| 
 | ||||
|   make_bgurl (image) { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user