u
This commit is contained in:
		
							parent
							
								
									dd3cedcd23
								
							
						
					
					
						commit
						df386d8266
					
				
							
								
								
									
										16
									
								
								tool_core.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								tool_core.js
									
									
									
									
									
								
							@ -286,7 +286,10 @@ module.exports = {
 | 
				
			|||||||
    let parent = root || globalThis || global || window || {}
 | 
					    let parent = root || globalThis || global || window || {}
 | 
				
			||||||
    let keychain = path.split('.')
 | 
					    let keychain = path.split('.')
 | 
				
			||||||
    for (let key of keychain) {
 | 
					    for (let key of keychain) {
 | 
				
			||||||
      if (typeof parent === 'object' && /^\w+\(.*\)$/.test(key)) {
 | 
					      if (!parent) {
 | 
				
			||||||
 | 
					        // 如果 parent 是 null 或 undefined,直接返回空值。
 | 
				
			||||||
 | 
					        return emptyValue
 | 
				
			||||||
 | 
					      } else if (typeof parent === 'object' && /^\w+\(.*\)$/.test(key)) {
 | 
				
			||||||
        // 支持 myfunc(param) 作为一个路径节点。
 | 
					        // 支持 myfunc(param) 作为一个路径节点。
 | 
				
			||||||
        let [all, func, param] = key.match(/^(\w+)\((.*)\)$/)
 | 
					        let [all, func, param] = key.match(/^(\w+)\((.*)\)$/)
 | 
				
			||||||
        parent = parent[func](param)
 | 
					        parent = parent[func](param)
 | 
				
			||||||
@ -352,7 +355,7 @@ module.exports = {
 | 
				
			|||||||
  summarize_story (story = []) {
 | 
					  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 }
 | 
					    // 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(
 | 
					    return story.reduce(
 | 
				
			||||||
      (summary, { text, image, video, file } = {}) => {
 | 
					      (summary, { text, image, video, file, linkTarget } = {}) => {
 | 
				
			||||||
        if (text) {
 | 
					        if (text) {
 | 
				
			||||||
          summary.textLength += text.length
 | 
					          summary.textLength += text.length
 | 
				
			||||||
          summary.wordCount += text.split(/\s+/).length
 | 
					          summary.wordCount += text.split(/\s+/).length
 | 
				
			||||||
@ -362,10 +365,14 @@ module.exports = {
 | 
				
			|||||||
          summary.videoCount++
 | 
					          summary.videoCount++
 | 
				
			||||||
        } else if (file) {
 | 
					        } else if (file) {
 | 
				
			||||||
          summary.fileCount++
 | 
					          summary.fileCount++
 | 
				
			||||||
 | 
					        } else if (linkTarget) {
 | 
				
			||||||
 | 
					          summary.linkCount++
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          summary.untype++
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return summary
 | 
					        return summary
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      { textLength: 0, wordCount: 0, imageCount: 0, videoCount: 0 }
 | 
					      { textLength: 0, wordCount: 0, imageCount: 0, videoCount: 0, file: 0, link: 0, untype: 0 }
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -462,6 +469,7 @@ module.exports = {
 | 
				
			|||||||
    })
 | 
					    })
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // 洗牌算法,随机打乱数组顺序
 | 
				
			||||||
  shuffle_array (array = []) {
 | 
					  shuffle_array (array = []) {
 | 
				
			||||||
    if (Array.isArray(array)) {
 | 
					    if (Array.isArray(array)) {
 | 
				
			||||||
      for (let i = array.length - 1; i > 0; i--) {
 | 
					      for (let i = array.length - 1; i > 0; i--) {
 | 
				
			||||||
@ -473,6 +481,6 @@ module.exports = {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  is_uuid (uuid) {
 | 
					  is_uuid (uuid) {
 | 
				
			||||||
    return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(unid)
 | 
					    return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(uuid)
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -66,9 +66,8 @@ module.exports = {
 | 
				
			|||||||
      return i18nText
 | 
					      return i18nText
 | 
				
			||||||
    } else if (typeof i18nText === 'object' && i18nText) {
 | 
					    } else if (typeof i18nText === 'object' && i18nText) {
 | 
				
			||||||
      return (
 | 
					      return (
 | 
				
			||||||
        i18nText?.[langCode] ||
 | 
					        i18nText[langCode || my.get_mylang()] ||
 | 
				
			||||||
        i18nText?.[my.get_mylang()] ||
 | 
					        (precise ? '' : i18nText.earTH || i18nText.gloBAL || i18nText.defLAN || i18nText.enUS || Object.values(i18nText)[0] || '')
 | 
				
			||||||
        (precise ? '' : i18nText?.earTH || i18nText?.defLAN || i18nText?.gloBAL || i18nText?.enUS || Object.values(i18nText)[0] || '')
 | 
					 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      return ''
 | 
					      return ''
 | 
				
			||||||
@ -97,7 +96,11 @@ module.exports = {
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    windowTitle =
 | 
					    windowTitle =
 | 
				
			||||||
      windowTitle || wo?.envar?.callnames?.[langNow] || wo?.pagesJson?.appInfo?.i18nText?.[langNow] || wo?.pagesJson?.globalStyle?.navigationBarTitleText || ''
 | 
					      windowTitle ||
 | 
				
			||||||
 | 
					      this.localizeText(wo?.envar?.callnames, { langCode: langNow }) ||
 | 
				
			||||||
 | 
					      this.localizeText(wo?.pagesJson?.appInfo?.i18nText, { langCode: langNow }) ||
 | 
				
			||||||
 | 
					      wo?.pagesJson?.globalStyle?.navigationBarTitleText ||
 | 
				
			||||||
 | 
					      ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (wo.envar._clientInfo.deviceType === 'pc') {
 | 
					    if (wo.envar._clientInfo.deviceType === 'pc') {
 | 
				
			||||||
      uni.setNavigationBarTitle({ title: windowTitle + (navibarTitle ? ` - ${navibarTitle}` : '') })
 | 
					      uni.setNavigationBarTitle({ title: windowTitle + (navibarTitle ? ` - ${navibarTitle}` : '') })
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user