mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
load 优化
This commit is contained in:
21
lib/utils.js
21
lib/utils.js
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件持久化
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user