feat: use native GitHub progress bar

This commit is contained in:
EnixCoda 2020-11-28 14:20:52 +08:00
parent a9ccd1703c
commit 9ddf4d6068
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

@ -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)
}