Skip to content

Commit

Permalink
feat: 优化Mappop和LPImage组件,处理图片加载错误;更新eslint配置,忽略lottie资源目录
Browse files Browse the repository at this point in the history
  • Loading branch information
IceyWu committed Nov 16, 2024
1 parent 104d199 commit 6205928
Show file tree
Hide file tree
Showing 6 changed files with 628 additions and 644 deletions.
125 changes: 63 additions & 62 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,63 @@
import antfu from '@antfu/eslint-config'

export default antfu(
{},
{
ignores: [
'dist',
'node_modules',
'.output',
'.nuxt',
'content/posts',
'data',
'uno.config.ts',
],
},
{
rules: {
'node/prefer-global/process': 'off',
'no-console': 'off',
'style/no-tabs': 'off',
'style/quote-props': 'off',
'vue/html-indent': 'off',
'style/indent': 'off',
'node/prefer-global/process': 'off',
'node/prefer-global/buffer': 'off',
'unused-imports/no-unused-vars': 'off',
'vue/singleline-html-element-content-newline': 'off',
'ts/no-use-before-define': 'off',
'no-empty-pattern': 'off',
'vue/eqeqeq': 'off',
'ts/no-unsafe-function-type': 'off',
'unicorn/no-new-array': 'off',
'ts/no-unused-expressions': 'off',
'regexp/no-unused-capturing-group': 'off',
'regexp/no-legacy-features': 'off',
'eqeqeq': 'off',
'no-empty': 'off',
'node/handle-callback-err': 'off',
'no-case-declarations': 'off',
'style/no-mixed-spaces-and-tabs': 'off',
'no-dupe-keys': 'off',
'regexp/no-dupe-disjunctions': 'off',
'sort-imports': 'off',
'unicorn/prefer-dom-node-text-content': 'off',
'vue/no-use-v-if-with-v-for': 'off',
'vue/no-unused-refs': 'off',
'array-callback-return': 'off',
'regexp/no-dupe-disjunctions': 'off',
'vue/require-v-for-key': 'off',
'import/order': 'off',
},
},
{
files: [
'*.d.ts',
],
rules: {
'unused-imports/no-unused-vars': 'off',
'eslint-comments/no-unlimited-disable': 'off',
},
},
)
import antfu from '@antfu/eslint-config'

export default antfu(
{},
{
ignores: [
'dist',
'node_modules',
'.output',
'.nuxt',
'content/posts',
'data',
'uno.config.ts',
'src/assets/lottie',
],
},
{
rules: {
'node/prefer-global/process': 'off',
'no-console': 'off',
'style/no-tabs': 'off',
'style/quote-props': 'off',
'vue/html-indent': 'off',
'style/indent': 'off',
'node/prefer-global/process': 'off',
'node/prefer-global/buffer': 'off',
'unused-imports/no-unused-vars': 'off',
'vue/singleline-html-element-content-newline': 'off',
'ts/no-use-before-define': 'off',
'no-empty-pattern': 'off',
'vue/eqeqeq': 'off',
'ts/no-unsafe-function-type': 'off',
'unicorn/no-new-array': 'off',
'ts/no-unused-expressions': 'off',
'regexp/no-unused-capturing-group': 'off',
'regexp/no-legacy-features': 'off',
'eqeqeq': 'off',
'no-empty': 'off',
'node/handle-callback-err': 'off',
'no-case-declarations': 'off',
'style/no-mixed-spaces-and-tabs': 'off',
'no-dupe-keys': 'off',
'regexp/no-dupe-disjunctions': 'off',
'sort-imports': 'off',
'unicorn/prefer-dom-node-text-content': 'off',
'vue/no-use-v-if-with-v-for': 'off',
'vue/no-unused-refs': 'off',
'array-callback-return': 'off',
'regexp/no-dupe-disjunctions': 'off',
'vue/require-v-for-key': 'off',
'import/order': 'off',
},
},
{
files: [
'*.d.ts',
],
rules: {
'unused-imports/no-unused-vars': 'off',
'eslint-comments/no-unlimited-disable': 'off',
},
},
)
1 change: 1 addition & 0 deletions src/assets/lottie/img_err.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/components/LPImage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { isEmpty } from '@iceywu/utils'
import { decode } from 'blurhash'
import * as LivePhotosKit from 'livephotoskit'
import loadErrorData from '~/assets/lottie/img_err.json'
import { getDataUrlFromArr } from '~/utils/blurhash'
interface LPImageProps {
Expand Down Expand Up @@ -166,6 +167,11 @@ const loadingImgSrc = computed(() => {
const showImgSrc = computed(() => {
return isShowBase ? imgInfo.value.baseSrc : imgInfo.value.src
})
const loadError = ref(false)
function onLoadErrorPreImg(e: any) {
console.log('💗onLoadErrorPreImg---------->', e)
loadError.value = true
}
</script>

<template>
Expand All @@ -191,6 +197,7 @@ const showImgSrc = computed(() => {
:src="loadingImgSrc"
:loading="lazyload"
@load="onLoadPreImg"
@error="onLoadErrorPreImg"
>

<img
Expand All @@ -205,6 +212,9 @@ const showImgSrc = computed(() => {
:src="showImgSrc"
@load="onLoad"
>
<div v-if="loadError" class="leff-0 absolute top-0 z-9 h-full w-full fcc">
<Lottie width="20em" height="20em" :json-data="loadErrorData" />
</div>
</div>
</template>

Expand Down
1 change: 0 additions & 1 deletion src/components/Mappop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ function handleClosePop() {
emit('closePop')
}
function showImgs(index: number) {
// eslint-disable-next-line array-callback-return
const images = fileList.value.map((item: any) => {
const { fileType, file, cover } = item || {}
if (fileType === 'IMAGE') {
Expand Down
Loading

0 comments on commit 6205928

Please sign in to comment.