mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 23:16:54 +00:00
isBrowser方法调整
This commit is contained in:
16
lib/utils.js
16
lib/utils.js
@@ -1,6 +1,12 @@
|
||||
// 封装异步加载资源的方法
|
||||
import { memo } from 'react'
|
||||
|
||||
/**
|
||||
* 判断是否客户端
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export const isBrowser = typeof window !== 'undefined'
|
||||
|
||||
/**
|
||||
* 组件持久化
|
||||
*/
|
||||
@@ -58,7 +64,7 @@ export function loadExternalResource(url, type) {
|
||||
* @returns
|
||||
*/
|
||||
export function getQueryVariable(key) {
|
||||
const query = isBrowser() ? window.location.search.substring(1) : ''
|
||||
const query = isBrowser ? window.location.search.substring(1) : ''
|
||||
const vars = query.split('&')
|
||||
for (let i = 0; i < vars.length; i++) {
|
||||
const pair = vars[i].split('=')
|
||||
@@ -143,12 +149,6 @@ export function deepClone(obj) {
|
||||
*/
|
||||
export const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||
|
||||
/**
|
||||
* 判断是否客户端
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export const isBrowser = () => typeof window !== 'undefined'
|
||||
|
||||
/**
|
||||
* 获取从第1页到指定页码的文章
|
||||
* @param pageIndex 第几页
|
||||
@@ -168,7 +168,7 @@ export const getListByPage = function (list, pageIndex, pageSize) {
|
||||
*/
|
||||
export const isMobile = () => {
|
||||
let isMobile = false
|
||||
if (!isBrowser()) {
|
||||
if (!isBrowser) {
|
||||
return isMobile
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user