mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
21 lines
476 B
TypeScript
21 lines
476 B
TypeScript
import * as NProgress from 'nprogress'
|
|
import * as React from 'react'
|
|
import { useEvent } from 'react-use'
|
|
|
|
const progressBar = {
|
|
mount() {
|
|
NProgress.start()
|
|
},
|
|
unmount() {
|
|
NProgress.done()
|
|
},
|
|
}
|
|
|
|
// use native progress bar on GitHub
|
|
export function useProgressBar() {
|
|
React.useEffect(() => {
|
|
NProgress.configure({ showSpinner: false })
|
|
}, [])
|
|
useEvent('pjax:fetch', progressBar.mount, window)
|
|
useEvent('pjax:unload', progressBar.unmount, window)
|
|
}
|