Skip to content

Commit

Permalink
Merge pull request #1056 from CroatiaParanoia/refactor/modify-import-…
Browse files Browse the repository at this point in the history
…path

refactor(use-request): 修改引用路径
  • Loading branch information
brickspert authored Jul 22, 2021
2 parents b8e7542 + dac2e11 commit 23b9a74
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
25 changes: 19 additions & 6 deletions packages/use-request/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 1 addition & 13 deletions packages/use-request/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
export function isDocumentVisible(): boolean {
if (typeof document !== 'undefined' && typeof document.visibilityState !== 'undefined') {
return document.visibilityState !== 'hidden';
}
return true;
}

export function isOnline(): boolean {
if (typeof navigator.onLine !== 'undefined') {
return navigator.onLine;
}
return true;
}
export * from './utils';
13 changes: 13 additions & 0 deletions packages/use-request/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function isDocumentVisible(): boolean {
if (typeof document !== 'undefined' && typeof document.visibilityState !== 'undefined') {
return document.visibilityState !== 'hidden';
}
return true;
}

export function isOnline(): boolean {
if (typeof navigator.onLine !== 'undefined') {
return navigator.onLine;
}
return true;
}
2 changes: 1 addition & 1 deletion packages/use-request/src/utils/windowFocus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// from swr
import { isDocumentVisible, isOnline } from './index';
import { isDocumentVisible, isOnline } from './utils';

const listeners: any[] = [];

Expand Down
2 changes: 1 addition & 1 deletion packages/use-request/src/utils/windowVisible.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// from swr
import { isDocumentVisible } from './index';
import { isDocumentVisible } from './utils';

const listeners: any[] = [];

Expand Down

0 comments on commit 23b9a74

Please sign in to comment.