Skip to content

Commit a415d0b

Browse files
authored
perf(empty): 优化 image 校验 (#3129)
1 parent 139d695 commit a415d0b

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

src/packages/__VUE/empty/empty.taro.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@ const style = computed(() => {
5858
return {}
5959
})
6060
61-
const src = computed(() => {
62-
if (props.image.startsWith('https://') || props.image.startsWith('http://') || props.image.startsWith('//')) {
63-
return props.image
64-
} else {
65-
return defaultStatus[props.image]
66-
}
67-
})
61+
const src = computed(() => /^https?:\/\/|^\/\//.test(props.image) ? props.image : defaultStatus[props.image])
6862
69-
const descriptionText = computed(() => {
70-
return props.description || translate('noData')
71-
})
63+
const descriptionText = computed(() => props.description || translate('noData'))
7264
</script>

src/packages/__VUE/empty/empty.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@ const style = computed(() => {
5858
return {}
5959
})
6060
61-
const src = computed(() => {
62-
if (props.image.startsWith('https://') || props.image.startsWith('http://') || props.image.startsWith('//')) {
63-
return props.image
64-
} else {
65-
return defaultStatus[props.image]
66-
}
67-
})
61+
const src = computed(() => /^https?:\/\/|^\/\//.test(props.image) ? props.image : defaultStatus[props.image])
6862
69-
const descriptionText = computed(() => {
70-
return props.description || translate('noData')
71-
})
63+
const descriptionText = computed(() => props.description || translate('noData'))
7264
</script>

0 commit comments

Comments
 (0)