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 } }