提交 c8dec887 作者: 方治民

合并分支 '3.x' 到 'main'

3.x

查看合并请求 !21
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js", "lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
"log": "conventional-changelog -p angular -i CHANGELOG.md -s", "log": "conventional-changelog -p angular -i CHANGELOG.md -s",
"up": "pnpx @dcloudio/uvm alpha", "u": "pnpx @dcloudio/uvm vue3",
"prepare": "husky install" "prepare": "husky install"
}, },
"config": { "config": {
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
"@dcloudio/uni-helper-json": "^1.0.13", "@dcloudio/uni-helper-json": "^1.0.13",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-3071220230324001", "@dcloudio/uni-stacktracey": "3.0.0-alpha-3071220230324001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3071220230324001", "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3071220230324001",
"@iconify/json": "^2.2.41", "@iconify/json": "^2.2.42",
"@types/crypto-js": "^4.1.1", "@types/crypto-js": "^4.1.1",
"@types/lodash-es": "^4.17.7", "@types/lodash-es": "^4.17.7",
"@types/node": "^18.15.11", "@types/node": "^18.15.11",
...@@ -150,13 +150,13 @@ ...@@ -150,13 +150,13 @@
"stylelint-config-standard": "^29.0.0", "stylelint-config-standard": "^29.0.0",
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
"terser": "^5.16.8", "terser": "^5.16.8",
"typescript": "^5.0.2", "typescript": "^5.0.3",
"unocss": "^0.50.6", "unocss": "^0.50.6",
"unocss-preset-weapp": "^0.5.2", "unocss-preset-weapp": "^0.5.2",
"unplugin-auto-import": "^0.15.2", "unplugin-auto-import": "^0.15.2",
"unplugin-vue-components": "^0.24.1", "unplugin-vue-components": "^0.24.1",
"vite": "^4.2.1", "vite": "^4.2.1",
"vue-eslint-parser": "^9.1.0" "vue-eslint-parser": "^9.1.1"
}, },
"engines": { "engines": {
"node": ">=16" "node": ">=16"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
type: String, type: String,
default: 'scaleToFill', default: 'scaleToFill',
}, },
background: {
type: String,
default: '#F7F7F7',
},
src: { src: {
type: String, type: String,
required: true, required: true,
...@@ -38,10 +42,10 @@ ...@@ -38,10 +42,10 @@
const hash = md5(url).toString() const hash = md5(url).toString()
hashCacheKey.value = `G_CACHE_IMAGE_${hash}` hashCacheKey.value = `G_CACHE_IMAGE_${hash}`
if (uni.getStorageSync(hashCacheKey.value)) { if (uni.getStorageSync(hashCacheKey.value)) {
console.log('CacheImage cache hit') console.debug('CacheImage cache hit')
url = uni.getStorageSync(hashCacheKey.value) url = uni.getStorageSync(hashCacheKey.value)
} else { } else {
console.log('CacheImage cache miss') console.debug('CacheImage cache miss')
try { try {
const res = await uni.downloadFile({ url }) const res = await uni.downloadFile({ url })
if (res.statusCode === 200) { if (res.statusCode === 200) {
...@@ -61,7 +65,7 @@ ...@@ -61,7 +65,7 @@
console.error(e) console.error(e)
} }
} }
console.log(props.src, '=>', url, hash, hashCacheKey.value) console.debug(props.src, '=>', url, hash, hashCacheKey.value)
// #endif // #endif
src.value = url src.value = url
...@@ -87,7 +91,10 @@ ...@@ -87,7 +91,10 @@
:width="props.width" :width="props.width"
:height="props.height" :height="props.height"
:radius="props.radius" :radius="props.radius"
:background="props.background"
:src="src" :src="src"
@error="onError" @error="onError"
/> >
<slot></slot>
</fui-lazyload>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from 'vue' import type { PropType } from 'vue'
import md5 from 'crypto-js/md5'
import { nanoid } from 'nanoid' import { nanoid } from 'nanoid'
import { getPoster, isImage, isVideo } from './utils' import { getPoster, isImage, isVideo } from './utils'
import CacheImage from '@/components/CacheImage/index.vue'
type Asset = Recordable & { url: string } type Asset = Recordable & { url: string }
const props = defineProps({ const props = defineProps({
...@@ -35,7 +37,17 @@ ...@@ -35,7 +37,17 @@
// 预览图片 // 预览图片
const preview = (index: number) => { const preview = (index: number) => {
uni.previewImage({ uni.previewImage({
urls: images.value.map((item) => item.url), urls: images.value.map((item) => {
// #ifdef APP-PLUS
const hash = md5(item.url).toString()
const key = `G_CACHE_IMAGE_${hash}`
if (uni.getStorageSync(key)) {
return uni.getStorageSync(key)
}
// #endif
return item.url
}),
current: index, current: index,
}) })
} }
...@@ -67,7 +79,7 @@ ...@@ -67,7 +79,7 @@
<template> <template>
<view class="preview-wrap"> <view class="preview-wrap">
<!-- 视频预览 --> <!-- 视频预览 -->
<fui-lazyload <CacheImage
class="preview-video" class="preview-video"
:background="props.background" :background="props.background"
:mode="props.mode" :mode="props.mode"
...@@ -82,10 +94,10 @@ ...@@ -82,10 +94,10 @@
<view class="icon-wrap" :style="{ width: props.width, height: props.height }"> <view class="icon-wrap" :style="{ width: props.width, height: props.height }">
<fui-icon class="video-play-icon" name="suspend" size="40" color="#fff" /> <fui-icon class="video-play-icon" name="suspend" size="40" color="#fff" />
</view> </view>
</fui-lazyload> </CacheImage>
<!-- 图片预览 --> <!-- 图片预览 -->
<fui-lazyload <CacheImage
class="preview-image" class="preview-image"
:background="props.background" :background="props.background"
:mode="props.mode" :mode="props.mode"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论