mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-18 23:16:49 +00:00
remove package nprogress
This commit is contained in:
@@ -1,20 +1,36 @@
|
||||
import { loadExternalResource } from '@/lib/utils'
|
||||
import { useRouter } from 'next/router'
|
||||
import NProgress from 'nprogress'
|
||||
import { useEffect } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
/**
|
||||
* 出现页面加载进度条
|
||||
*/
|
||||
export default function LoadingProgress() {
|
||||
const router = useRouter()
|
||||
const [NProgress, setNProgress] = useState(null)
|
||||
// 加载进度条
|
||||
useEffect(() => {
|
||||
const handleStart = (url) => {
|
||||
NProgress.start()
|
||||
loadExternalResource(
|
||||
'https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js',
|
||||
'js'
|
||||
).then(() => {
|
||||
if (window.NProgress) {
|
||||
setNProgress(window.NProgress)
|
||||
// 调速
|
||||
window.NProgress.settings.minimun = 0.1
|
||||
loadExternalResource(
|
||||
'https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.css',
|
||||
'css'
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const handleStart = url => {
|
||||
NProgress?.start()
|
||||
}
|
||||
|
||||
const handleStop = () => {
|
||||
NProgress.done()
|
||||
NProgress?.done()
|
||||
}
|
||||
|
||||
router.events.on('routeChangeStart', handleStart)
|
||||
|
||||
Reference in New Issue
Block a user