From 9ddf4d60685a7974e6257261be8b8a63f8296930 Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sat, 28 Nov 2020 14:20:52 +0800 Subject: [PATCH] feat: use native GitHub progress bar --- src/utils/hooks/useProgressBar.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/utils/hooks/useProgressBar.ts b/src/utils/hooks/useProgressBar.ts index 3c37110..f5c3433 100644 --- a/src/utils/hooks/useProgressBar.ts +++ b/src/utils/hooks/useProgressBar.ts @@ -1,4 +1,6 @@ import * as NProgress from 'nprogress' +import { platform } from 'platforms' +import { GitHub } from 'platforms/GitHub' import * as React from 'react' import { useEvent } from 'react-use' @@ -11,11 +13,14 @@ const progressBar = { }, } -export function useProgressBar() { - React.useEffect(() => { - NProgress.configure({ showSpinner: false }) - }, []) - - useEvent('pjax:start', progressBar.mount, window) - useEvent('pjax:unload', progressBar.unmount, window) -} +const isGitHub = platform === GitHub +// use native progress bar on GitHub +export const useProgressBar = isGitHub + ? function () {} + : function useProgressBar() { + React.useEffect(() => { + NProgress.configure({ showSpinner: false }) + }, []) + useEvent('pjax:fetch', progressBar.mount, window) + useEvent('pjax:unload', progressBar.unmount, window) + }