|
@@ -1,58 +1,45 @@
|
|
|
<template>
|
|
<template>
|
|
|
- <p
|
|
|
|
|
- ref="listBoxRef"
|
|
|
|
|
|
|
+ <p ref="listBoxRef"
|
|
|
class="h-32px flex items-center justify-between gap-4px px-4 py-2 m-0 overflow-hidden group/item hover:bg-bg-tertiary"
|
|
class="h-32px flex items-center justify-between gap-4px px-4 py-2 m-0 overflow-hidden group/item hover:bg-bg-tertiary"
|
|
|
- @click="handleClick"
|
|
|
|
|
- @contextmenu="handleContextmenu"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ @click="handleClick" @contextmenu="handleContextmenu">
|
|
|
<span v-if="type === 'font'" class="w-32px h-32px grid place-items-center">
|
|
<span v-if="type === 'font'" class="w-32px h-32px grid place-items-center">
|
|
|
<BsFiletypeTtf v-if="data.fielType === 'ttf'" size="16px" />
|
|
<BsFiletypeTtf v-if="data.fielType === 'ttf'" size="16px" />
|
|
|
<BsFiletypeWoff v-else-if="data.fielType === 'woff'" size="16px" />
|
|
<BsFiletypeWoff v-else-if="data.fielType === 'woff'" size="16px" />
|
|
|
<img v-else :src="fontImg" class="w-16px h-16px" />
|
|
<img v-else :src="fontImg" class="w-16px h-16px" />
|
|
|
</span>
|
|
</span>
|
|
|
- <span
|
|
|
|
|
- v-if="type === 'image'"
|
|
|
|
|
- class="w-32px h-32px rounded-4px bg-bg-tertiary grid place-items-center"
|
|
|
|
|
- >
|
|
|
|
|
- <LocalImage
|
|
|
|
|
- :src="projectStore.projectPath + data.path"
|
|
|
|
|
- class="h-full w-full object-contain"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <span v-if="type === 'image'" class="shrink-0 w-32px h-32px rounded-4px bg-bg-tertiary grid place-items-center">
|
|
|
|
|
+ <LocalImage :src="projectStore.projectPath + data.path" class="h-full w-full object-contain" />
|
|
|
</span>
|
|
</span>
|
|
|
- <span class="flex-1 truncate" :title="data.fileName">{{ data.fileName }}</span>
|
|
|
|
|
|
|
+ <span class="flex-1 flex items-center gap-4px">
|
|
|
|
|
+ <span class="truncate max-w-120px" :title="data.fileName">{{ data.fileName }}</span>
|
|
|
|
|
+ <span class="flex flex-col gap-2px w-80px text-8px text-text-secondary">
|
|
|
|
|
+ <span>分辨率:{{ imageInfo.width }}x{{ imageInfo.height }}</span>
|
|
|
|
|
+ <span>使用次数:{{ imageInfo.useCount }}</span>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </span>
|
|
|
|
|
+
|
|
|
|
|
|
|
|
<span class="items-center gap-8px shrink-0 hidden group-hover/item:flex">
|
|
<span class="items-center gap-8px shrink-0 hidden group-hover/item:flex">
|
|
|
<el-tooltip content="编辑" :append-to="listBoxRef">
|
|
<el-tooltip content="编辑" :append-to="listBoxRef">
|
|
|
- <span v-if="type !== 'other'" class="cursor-pointer" @click="handleEdit"
|
|
|
|
|
- ><LuPencilLine size="14px"
|
|
|
|
|
- /></span>
|
|
|
|
|
|
|
+ <span v-if="type !== 'other'" class="cursor-pointer" @click="handleEdit">
|
|
|
|
|
+ <LuPencilLine size="14px" />
|
|
|
|
|
+ </span>
|
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
|
<el-tooltip content="删除" :append-to="listBoxRef">
|
|
<el-tooltip content="删除" :append-to="listBoxRef">
|
|
|
<span>
|
|
<span>
|
|
|
- <el-popconfirm
|
|
|
|
|
- :append-to="listBoxRef"
|
|
|
|
|
- class="box-item"
|
|
|
|
|
- title="确认删除?"
|
|
|
|
|
- @confirm="$emit('delete')"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <el-popconfirm :append-to="listBoxRef" class="box-item" title="确认删除?" @confirm="$emit('delete')">
|
|
|
<template #reference>
|
|
<template #reference>
|
|
|
- <span class="cursor-pointer"><LuTrash2 size="14px" /></span>
|
|
|
|
|
|
|
+ <span class="cursor-pointer">
|
|
|
|
|
+ <LuTrash2 size="14px" />
|
|
|
|
|
+ </span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-popconfirm>
|
|
</el-popconfirm>
|
|
|
</span>
|
|
</span>
|
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
|
</span>
|
|
</span>
|
|
|
- <el-dropdown
|
|
|
|
|
- ref="dropdownRef"
|
|
|
|
|
- :virtual-ref="triggerRef"
|
|
|
|
|
- :show-arrow="false"
|
|
|
|
|
- :popper-options="{
|
|
|
|
|
- modifiers: [{ name: 'offset', options: { offset: [0, 0] } }]
|
|
|
|
|
- }"
|
|
|
|
|
- virtual-triggering
|
|
|
|
|
- trigger="contextmenu"
|
|
|
|
|
- placement="bottom-start"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <el-dropdown ref="dropdownRef" :virtual-ref="triggerRef" :show-arrow="false" :popper-options="{
|
|
|
|
|
+ modifiers: [{ name: 'offset', options: { offset: [0, 0] } }]
|
|
|
|
|
+ }" virtual-triggering trigger="contextmenu" placement="bottom-start">
|
|
|
<template #dropdown>
|
|
<template #dropdown>
|
|
|
<el-dropdown-menu>
|
|
<el-dropdown-menu>
|
|
|
<el-dropdown-item @click="openInExplorer">在资源管理器中打开</el-dropdown-item>
|
|
<el-dropdown-item @click="openInExplorer">在资源管理器中打开</el-dropdown-item>
|
|
@@ -70,7 +57,7 @@
|
|
|
import type { FontResource, ImageResource, Resource } from '@/types/resource'
|
|
import type { FontResource, ImageResource, Resource } from '@/types/resource'
|
|
|
import type { DropdownInstance } from 'element-plus'
|
|
import type { DropdownInstance } from 'element-plus'
|
|
|
|
|
|
|
|
-import { ref } from 'vue'
|
|
|
|
|
|
|
+import { ref, watch } from 'vue'
|
|
|
import LocalImage from '@/components/LocalImage/index.vue'
|
|
import LocalImage from '@/components/LocalImage/index.vue'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
import { LuTrash2, LuPencilLine } from 'vue-icons-plus/lu'
|
|
import { LuTrash2, LuPencilLine } from 'vue-icons-plus/lu'
|
|
@@ -78,6 +65,7 @@ import { BsFiletypeTtf, BsFiletypeWoff } from 'vue-icons-plus/bs'
|
|
|
import fontImg from '@/assets/font.svg'
|
|
import fontImg from '@/assets/font.svg'
|
|
|
import EditImageModal from './EditImageModal.vue'
|
|
import EditImageModal from './EditImageModal.vue'
|
|
|
import EditFontModal from './EditFontModal.vue'
|
|
import EditFontModal from './EditFontModal.vue'
|
|
|
|
|
+import { getImageByPath } from '@/utils'
|
|
|
|
|
|
|
|
defineEmits<{
|
|
defineEmits<{
|
|
|
delete: []
|
|
delete: []
|
|
@@ -105,6 +93,47 @@ const triggerRef = ref({
|
|
|
getBoundingClientRect: () => position.value
|
|
getBoundingClientRect: () => position.value
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const imageInfo = ref<{
|
|
|
|
|
+ width?: number
|
|
|
|
|
+ height?: number
|
|
|
|
|
+ useCount?: number
|
|
|
|
|
+}>({
|
|
|
|
|
+ width: 0,
|
|
|
|
|
+ height: 0,
|
|
|
|
|
+ useCount: 0
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.type,
|
|
|
|
|
+ async () => {
|
|
|
|
|
+ if (props.type === 'image') {
|
|
|
|
|
+ const resouce = props.data as ImageResource
|
|
|
|
|
+ const res = await getImageByPath(projectStore.projectPath + resouce.path)
|
|
|
|
|
+ imageInfo.value.width = res?.dimensions.width
|
|
|
|
|
+ imageInfo.value.height = res?.dimensions.height
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ immediate: true
|
|
|
|
|
+ }
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => projectStore.project,
|
|
|
|
|
+ async () => {
|
|
|
|
|
+ if (projectStore.project && props.type === 'image') {
|
|
|
|
|
+ const str = JSON.stringify(projectStore.project.screens)
|
|
|
|
|
+ // 判断图片id出现的次数
|
|
|
|
|
+ const count = str.split(props.data.id).length - 1
|
|
|
|
|
+ imageInfo.value.useCount = count
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ immediate: true,
|
|
|
|
|
+ deep: true
|
|
|
|
|
+ }
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
const handleClick = () => {
|
|
const handleClick = () => {
|
|
|
dropdownRef.value?.handleClose()
|
|
dropdownRef.value?.handleClose()
|
|
|
}
|
|
}
|