Skip to content

Commit

Permalink
feature: 增加上传文件组件的成功失败回调事件
Browse files Browse the repository at this point in the history
  • Loading branch information
pixel(奇淼 committed Aug 31, 2024
1 parent a155bcd commit 3c7a05b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 4 additions & 6 deletions web/src/components/selectFile/selectFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import { ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import { useUserStore } from '@/pinia/modules/user'
import { getBaseUrl } from '@/utils/format'
defineOptions({
Expand All @@ -42,14 +41,11 @@ const props = defineProps({
},
})
const path = ref(import.meta.env.VITE_BASE_API)
const userStore = useUserStore()
const fullscreenLoading = ref(false)
const fileList = ref(props.modelValue)
const emits = defineEmits(['update:modelValue'])
const emits = defineEmits(['update:modelValue', 'on-success', 'on-error'])
watch(fileList.value, (val) => {
console.log(val)
Expand All @@ -72,14 +68,16 @@ const uploadSuccess = (res) => {
})
fullscreenLoading.value = false
}
emits('on-success', res)
}
const uploadError = () => {
const uploadError = (err) => {
ElMessage({
type: 'error',
message: '上传失败'
})
fullscreenLoading.value = false
emits('on-error',err)
}
</script>
Expand Down
1 change: 0 additions & 1 deletion web/src/components/upload/common.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ defineOptions({
})
const emit = defineEmits(['on-success'])
const path = ref(import.meta.env.VITE_BASE_API)
const fullscreenLoading = ref(false)
Expand Down

0 comments on commit 3c7a05b

Please sign in to comment.