mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: use native GitHub progress bar
This commit is contained in:
parent
a9ccd1703c
commit
9ddf4d6068
1 changed files with 13 additions and 8 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue