mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 08:12:49 +08:00
处理图片引入
This commit is contained in:
parent
2120e26220
commit
a8de985e88
BIN
src/assets/images/exception/image-404.png
Normal file
BIN
src/assets/images/exception/image-404.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/images/project/moke-20211219181327.png
Normal file
BIN
src/assets/images/project/moke-20211219181327.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
@ -20,13 +20,24 @@ export const renderIcon = (icon: any, set = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 处理 vite 中无法使用 require 的问题
|
* * 处理 vite 中无法使用 require 的问题,utils 文件为根路径
|
||||||
|
* @param path
|
||||||
* @param name
|
* @param name
|
||||||
* @returns url
|
* @returns url
|
||||||
*/
|
*/
|
||||||
export const requireUrl = (path: string, name: string) => {
|
export const requireUrl = (path: string, name: string) => {
|
||||||
return new URL(`${path}/${name}`, import.meta.url).href
|
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) => {
|
export const screenfullFn = (isFullscreen?: boolean, isEnabled?: boolean) => {
|
||||||
// 是否是全屏
|
// 是否是全屏
|
||||||
|
@ -192,7 +192,7 @@ const bgList = ref([
|
|||||||
|
|
||||||
// 处理url获取
|
// 处理url获取
|
||||||
const getImageUrl = (name: string, folder: string) => {
|
const getImageUrl = (name: string, folder: string) => {
|
||||||
return requireUrl(`../assets/images/${folder}`, `${name}.png`)
|
return requireUrl(`../assets/images/${folder}/`, `${name}.png`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打乱
|
// 打乱
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
object-fit="contain"
|
object-fit="contain"
|
||||||
height="200"
|
height="200"
|
||||||
preview-disabled
|
preview-disabled
|
||||||
:src="requireUrl('.', '20211219181327.png')"
|
:src="
|
||||||
|
requireUrl('../assets/images/project', 'moke-20211219181327.png')
|
||||||
|
"
|
||||||
:alt="cardData.title"
|
:alt="cardData.title"
|
||||||
|
:fallback-src="requireFallbackImg()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -76,12 +79,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { renderIcon, goDialog } from '@/utils'
|
import { renderIcon, goDialog, requireUrl, requireFallbackImg } from '@/utils'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { AppleControlBtn } from '@/components/AppleControlBtn'
|
import { AppleControlBtn } from '@/components/AppleControlBtn'
|
||||||
import { useMessage, useDialog } from 'naive-ui'
|
import { useMessage, useDialog } from 'naive-ui'
|
||||||
import { DialogEnum } from '@/enums/pluginEnum'
|
import { DialogEnum } from '@/enums/pluginEnum'
|
||||||
import { DialogReactive } from 'naive-ui'
|
|
||||||
const {
|
const {
|
||||||
EllipsisHorizontalCircleSharpIcon,
|
EllipsisHorizontalCircleSharpIcon,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
@ -160,10 +163,6 @@ const handleSelect = (key: string) => {
|
|||||||
console.log(key)
|
console.log(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
const requireUrl = (path: string, name: string) => {
|
|
||||||
return new URL(`${path}/${name}`, import.meta.url).href
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除处理
|
// 删除处理
|
||||||
const deleteHanlde = () => {
|
const deleteHanlde = () => {
|
||||||
goDialog({
|
goDialog({
|
||||||
|
@ -14,7 +14,12 @@
|
|||||||
<!-- 中间 -->
|
<!-- 中间 -->
|
||||||
<div class="list-content-img">
|
<div class="list-content-img">
|
||||||
<img
|
<img
|
||||||
:src="requireUrl('.', '20211219181327.png')"
|
:src="
|
||||||
|
requireUrl(
|
||||||
|
'../assets/images/project',
|
||||||
|
'moke-20211219181327.png'
|
||||||
|
)
|
||||||
|
"
|
||||||
:alt="cardData?.title"
|
:alt="cardData?.title"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -58,7 +63,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { renderIcon } from '@/utils'
|
import { renderIcon, requireUrl, requireFallbackImg } from '@/utils'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { AppleControlBtn } from '@/components/AppleControlBtn'
|
import { AppleControlBtn } from '@/components/AppleControlBtn'
|
||||||
const { HammerIcon } = icon.ionicons5
|
const { HammerIcon } = icon.ionicons5
|
||||||
@ -73,11 +78,6 @@ const props = defineProps({
|
|||||||
const handleSelect = (key: string) => {
|
const handleSelect = (key: string) => {
|
||||||
console.log(key)
|
console.log(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
const requireUrl = (path: string, name: string) => {
|
|
||||||
return new URL(`${path}/${name}`, import.meta.url).href
|
|
||||||
}
|
|
||||||
|
|
||||||
const fnBtnList = [
|
const fnBtnList = [
|
||||||
{
|
{
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
|
Loading…
Reference in New Issue
Block a user