Skip to content

Commit

Permalink
perf: optimize progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Jun 11, 2021
1 parent 81d1651 commit 0b349db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions packages/varlet-cli/site/pc/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ const router = createRouter({
routes,
})

let isEnd = true
const { start, end } = useProgress()

router.beforeEach(() => start())
router.beforeEach(() => {
isEnd = false
setTimeout(() => {
if (!isEnd) start()
}, 200)
})

router.afterEach(() => end())
router.afterEach(() => {
isEnd = true
end()
})

window.top['router'] = router

Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-cli/site/useProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useProgress() {
},
trackColor: '#fff',
color: '#3594d9',
lineWidth: 2,
lineWidth: 3,
value: 0
})

Expand Down
2 changes: 1 addition & 1 deletion packages/varlet-ui/src/progress/progress.less
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
background-color: @progress-background;
top: 0;
left: 0;
transition: all 0.2s;
transition: all 0.2s, background-color 0.8s;
}

&__label {
Expand Down

0 comments on commit 0b349db

Please sign in to comment.