- 移除 colorMode 相关代码 - 删除全局样式文件 - 更新 nuxt 配置: - 添加 runtimeConfig - 更新 css 配置 - 优化 vite构建配置 - 新增 image 模块配置 - 更新路由配置 - 调整组件实现 - 更新环境变量加载方式
56 lines
931 B
Vue
56 lines
931 B
Vue
<script setup>
|
|
import { showImagePreview } from 'vant';
|
|
import { NuxtImg } from '#components'
|
|
const props = defineProps({
|
|
src: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
preview: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
// 用于控制图片尺寸
|
|
sizes: {
|
|
type: Array,
|
|
default: () => [320, 640, 768, 1024]
|
|
},
|
|
// 用于控制图片格式
|
|
format: {
|
|
type: String,
|
|
default: 'webp'
|
|
},
|
|
// 用于控制图片质量
|
|
quality: {
|
|
type: Number,
|
|
default: 80
|
|
}
|
|
})
|
|
|
|
const showImage = () => {
|
|
if (props.preview) {
|
|
showImagePreview([props.src]);
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<nuxt-img
|
|
loading="lazy"
|
|
v-bind="{ ...props, ...$attrs }"
|
|
style="object-fit: cover"
|
|
@click="showImage"
|
|
:src="src"
|
|
:sizes="sizes"
|
|
:format="format"
|
|
:quality="quality"
|
|
placeholder
|
|
/>
|
|
</template>
|
|
|
|
<style scoped>
|
|
:deep(img) {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style> |