load 优化

This commit is contained in:
tangly1024.com
2023-12-01 12:50:54 +08:00
parent 23ac2195c9
commit 3b181f3069
8 changed files with 118 additions and 61 deletions

View File

@@ -7,6 +7,27 @@ import { memo } from 'react'
*/
export const isBrowser = typeof window !== 'undefined'
/**
* google机器人
* @returns
*/
export const isSearchEngineBot = () => {
if (typeof navigator === 'undefined') {
return false
}
// 获取用户代理字符串
const userAgent = navigator.userAgent;
const isEngine = /Googlebot|bingbot|Baidu/.test(userAgent);
if (isEngine) {
console.warn('爬虫', userAgent)
} else {
console.error('u-a', userAgent)
}
// 使用正则表达式检测是否包含搜索引擎爬虫关键字
return isEngine
}
/**
* 组件持久化
*/