| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { ref } from 'vue'
- /** 全局进度管理 */
- const visible = ref(false)
- const progress = ref(0)
- const text = ref('')
- export function useProgress() {
- /**
- * 显示进度
- */
- function show(t = '加载中') {
- text.value = t
- progress.value = 0
- visible.value = true
- }
- /**
- * 更新进度
- */
- function update(p: number, t?: string) {
- progress.value = Math.min(100, Math.max(0, p))
- if (t) text.value = t
- }
- /**
- * 隐藏进度
- */
- function hide() {
- visible.value = false
- progress.value = 0
- }
- return {
- visible,
- progress,
- text,
- show,
- update,
- hide
- }
- }
|