mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-12 10:05:07 +08:00
feat: add vue3(element-plus)
This commit is contained in:
34
yudao-ui-admin-vue3/src/hooks/web/useNProgress.ts
Normal file
34
yudao-ui-admin-vue3/src/hooks/web/useNProgress.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { nextTick, unref } from 'vue'
|
||||
import type { NProgressOptions } from 'nprogress'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { useCssVar } from '@vueuse/core'
|
||||
|
||||
const primaryColor = useCssVar('--el-color-primary', document.documentElement)
|
||||
|
||||
export const useNProgress = () => {
|
||||
NProgress.configure({ showSpinner: false } as NProgressOptions)
|
||||
|
||||
const initColor = async () => {
|
||||
await nextTick()
|
||||
const bar = document.getElementById('nprogress')?.getElementsByClassName('bar')[0] as ElRef
|
||||
if (bar) {
|
||||
bar.style.background = unref(primaryColor.value)
|
||||
}
|
||||
}
|
||||
|
||||
initColor()
|
||||
|
||||
const start = () => {
|
||||
NProgress.start()
|
||||
}
|
||||
|
||||
const done = () => {
|
||||
NProgress.done()
|
||||
}
|
||||
|
||||
return {
|
||||
start,
|
||||
done
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user