update 解决项目列表卡片按钮下拉问题

This commit is contained in:
2026-02-14 14:08:54 +08:00
parent 32a7e34e64
commit 7f779e021d
2 changed files with 50 additions and 16 deletions

View File

@@ -20,16 +20,19 @@
</span> </span>
</div> </div>
<el-dropdown class="options-dropdown" :teleported="false"> <el-dropdown
class="options-dropdown"
:class="{ 'is-visible': isDropdownVisible }"
@command="handleCommand"
@visible-change="handleVisibleChange"
>
<div class="options-btn" @click.stop> <div class="options-btn" @click.stop>
<el-icon :size="18"><MoreFilled /></el-icon> <el-icon :size="18"><MoreFilled /></el-icon>
</div> </div>
<template #dropdown> <template #dropdown>
<el-dropdown-menu @click.stop> <el-dropdown-menu>
<el-dropdown-item v-for="(action, aIndex) in actionList" :key="aIndex"> <el-dropdown-item v-for="(action, aIndex) in actionList" :key="aIndex" :command="action">
<el-link :type="action.type" @click.stop="actionClickFun(action)"> <el-link :type="action.type">{{ action.title }}</el-link>
{{ action.title }}
</el-link>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
@@ -38,7 +41,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { computed, ref } from 'vue';
import { MoreFilled } from '@element-plus/icons-vue'; import { MoreFilled } from '@element-plus/icons-vue';
import { useDict } from '@/utils/useDict'; import { useDict } from '@/utils/useDict';
import { PROJECT_EXE_STATUS_CODE } from '@/utils/enum/project'; import { PROJECT_EXE_STATUS_CODE } from '@/utils/enum/project';
@@ -79,8 +82,15 @@ const cardClickFun = () => {
emit('cardClick', props.project); emit('cardClick', props.project);
}; };
const actionClickFun = (action: any) => { // const actionClickFun = (action: any) => {
emit('actionClick', props.project, action); // emit('actionClick', props.project, action);
// };
const handleCommand = (command: any) => {
emit('actionClick', props.project, command);
};
const isDropdownVisible = ref(false);
const handleVisibleChange = (visible: boolean) => {
isDropdownVisible.value = visible;
}; };
</script> </script>
@@ -101,6 +111,10 @@ const actionClickFun = (action: any) => {
transform: scale(1.1); transform: scale(1.1);
} }
} }
&:hover .options-dropdown,
.options-dropdown.is-visible {
opacity: 1;
}
.cover-img { .cover-img {
transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);

View File

@@ -1,13 +1,18 @@
<template> <template>
<div class="project-card" @click="cardClickFun"> <div class="project-card" @click="cardClickFun">
<el-dropdown class="options-dropdown" :teleported="false"> <el-dropdown
class="options-dropdown"
:class="{ 'is-visible': isDropdownVisible }"
@command="handleCommand"
@visible-change="handleVisibleChange"
>
<div class="options-btn" @click.stop> <div class="options-btn" @click.stop>
<el-icon :size="18"><MoreFilled /></el-icon> <el-icon :size="18"><MoreFilled /></el-icon>
</div> </div>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item v-for="(action, aIndex) in actionList" :key="aIndex"> <el-dropdown-item v-for="(action, aIndex) in actionList" :key="aIndex" :command="action">
<el-link :type="action.type" @click.stop="actionClickFun(action)"> <el-link :type="action.type">
{{ action.title }} {{ action.title }}
</el-link> </el-link>
</el-dropdown-item> </el-dropdown-item>
@@ -15,7 +20,11 @@
</template> </template>
</el-dropdown> </el-dropdown>
<img class="gl-pointer-class cover-img" :src="coverImgMap[project.detailImgUrl ? 'custom' : (index % 2 !== 0 ? 'blue' : 'green')]" alt="" /> <img
class="gl-pointer-class cover-img"
:src="coverImgMap[project.detailImgUrl ? 'custom' : index % 2 !== 0 ? 'blue' : 'green']"
alt=""
/>
<div class="bottom-box"> <div class="bottom-box">
<span class="gl-text-ellipsis gl-pointer-class" :title="project.nodeName"> <span class="gl-text-ellipsis gl-pointer-class" :title="project.nodeName">
@@ -29,7 +38,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue'; import { computed, ref } from 'vue';
import { MoreFilled } from '@element-plus/icons-vue'; import { MoreFilled } from '@element-plus/icons-vue';
import { useDict } from '@/utils/useDict'; import { useDict } from '@/utils/useDict';
import { PROJECT_EXE_STATUS_CODE } from '@/utils/enum/project'; import { PROJECT_EXE_STATUS_CODE } from '@/utils/enum/project';
@@ -70,8 +79,15 @@ const cardClickFun = () => {
emit('cardClick', props.project); emit('cardClick', props.project);
}; };
const actionClickFun = (action: any) => { // const actionClickFun = (action: any) => {
emit('actionClick', props.project, action); // emit('actionClick', props.project, action);
// };
const handleCommand = (command: any) => {
emit('actionClick', props.project, command);
};
const isDropdownVisible = ref(false);
const handleVisibleChange = (visible: boolean) => {
isDropdownVisible.value = visible;
}; };
</script> </script>
@@ -80,5 +96,9 @@ const actionClickFun = (action: any) => {
.project-card { .project-card {
@extend .project-card-base; @extend .project-card-base;
&:hover .options-dropdown,
.options-dropdown.is-visible {
opacity: 1;
}
} }
</style> </style>