You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
/*
|
|
* @Author: BINGWU
|
|
* @Date: 2024-03-27 00:33:27
|
|
* @LastEditors: BINGWU HuJiaCheng2003@163.com
|
|
* @LastEditTime: 2024-03-27 00:37:44
|
|
* @FilePath: \bingwu-admin\src\hooks\progress.js
|
|
* @Describe:
|
|
* @Mark: ૮(˶ᵔ ᵕ ᵔ˶)ა
|
|
*/
|
|
import { ref } from 'vue'
|
|
export const useProgress = () => {
|
|
const percentage = ref(0)
|
|
const status = ref('')
|
|
const dialogVisible = ref(false)
|
|
const changePercentage = (newPercentage) => {
|
|
percentage.value = newPercentage
|
|
}
|
|
const offProgress = (newState = 'success', message = '上传成功') => {
|
|
setTimeout(() => {
|
|
dialogVisible.value = false
|
|
}, 1200)
|
|
if (newState === 'success') {
|
|
status.value = 'success'
|
|
ElMessage({
|
|
message,
|
|
type: 'success'
|
|
})
|
|
} else {
|
|
ElMessage.error(`${message}`)
|
|
status.value = 'exception'
|
|
}
|
|
}
|
|
const openProgress = () => {
|
|
status.value = ''
|
|
percentage.value = 0
|
|
dialogVisible.value = true
|
|
}
|
|
return {
|
|
percentage,
|
|
status,
|
|
dialogVisible,
|
|
changePercentage,
|
|
offProgress,
|
|
openProgress
|
|
}
|
|
}
|