处理图片引入

This commit is contained in:
MTrun 2021-12-20 18:06:08 +08:00
parent 2120e26220
commit a8de985e88
6 changed files with 26 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -20,13 +20,24 @@ export const renderIcon = (icon: any, set = {}) => {
}
/**
* * vite 使 require
* * vite 使 require utils
* @param path
* @param name
* @returns url
*/
export const requireUrl = (path: string, name: string) => {
return new URL(`${path}/${name}`, import.meta.url).href
}
/**
* * 404
* @param path
* @param name
* @returns url
*/
export const requireFallbackImg = (path?: string, name?: string) => {
const url = path && name
return new URL(url?`${path}/${name}`: '../assets/images/exception/image-404.png', import.meta.url).href
}
export const screenfullFn = (isFullscreen?: boolean, isEnabled?: boolean) => {
// 是否是全屏

View File

@ -192,7 +192,7 @@ const bgList = ref([
// url
const getImageUrl = (name: string, folder: string) => {
return requireUrl(`../assets/images/${folder}`, `${name}.png`)
return requireUrl(`../assets/images/${folder}/`, `${name}.png`)
}
//

View File

@ -16,8 +16,11 @@
object-fit="contain"
height="200"
preview-disabled
:src="requireUrl('.', '20211219181327.png')"
:src="
requireUrl('../assets/images/project', 'moke-20211219181327.png')
"
:alt="cardData.title"
:fallback-src="requireFallbackImg()"
/>
</div>
</div>
@ -76,12 +79,12 @@
<script setup lang="ts">
import { ref } from 'vue'
import { renderIcon, goDialog } from '@/utils'
import { renderIcon, goDialog, requireUrl, requireFallbackImg } from '@/utils'
import { icon } from '@/plugins'
import { AppleControlBtn } from '@/components/AppleControlBtn'
import { useMessage, useDialog } from 'naive-ui'
import { DialogEnum } from '@/enums/pluginEnum'
import { DialogReactive } from 'naive-ui'
const {
EllipsisHorizontalCircleSharpIcon,
CopyIcon,
@ -160,10 +163,6 @@ const handleSelect = (key: string) => {
console.log(key)
}
const requireUrl = (path: string, name: string) => {
return new URL(`${path}/${name}`, import.meta.url).href
}
//
const deleteHanlde = () => {
goDialog({

View File

@ -14,7 +14,12 @@
<!-- 中间 -->
<div class="list-content-img">
<img
:src="requireUrl('.', '20211219181327.png')"
:src="
requireUrl(
'../assets/images/project',
'moke-20211219181327.png'
)
"
:alt="cardData?.title"
/>
</div>
@ -58,7 +63,7 @@
</template>
<script setup lang="ts">
import { renderIcon } from '@/utils'
import { renderIcon, requireUrl, requireFallbackImg } from '@/utils'
import { icon } from '@/plugins'
import { AppleControlBtn } from '@/components/AppleControlBtn'
const { HammerIcon } = icon.ionicons5
@ -73,11 +78,6 @@ const props = defineProps({
const handleSelect = (key: string) => {
console.log(key)
}
const requireUrl = (path: string, name: string) => {
return new URL(`${path}/${name}`, import.meta.url).href
}
const fnBtnList = [
{
label: '编辑',