fix 插件混合排序问题

This commit is contained in:
jxxghp
2025-05-27 13:12:09 +08:00
parent ec1b756a3d
commit 1725088f05
2 changed files with 74 additions and 54 deletions

View File

@@ -1,51 +1,3 @@
<template>
<div class="mixed-sort-card-wrapper">
<!-- 文件夹卡片 -->
<div
v-if="item.type === 'folder'"
class="drop-zone cursor-move"
:data-plugin-id="item.id"
@dragover="handleDragOver"
@dragenter="handleDragEnter"
@dragleave="handleDragLeave"
@drop="handleDropToFolder"
>
<PluginFolderCard
:folder-name="item.data.name"
:plugin-count="item.data.pluginCount"
:folder-config="item.data.config"
@open="$emit('openFolder', item.id)"
@delete="$emit('deleteFolder', item.id)"
@rename="(oldName, newName) => $emit('renameFolder', oldName, newName)"
@update-config="config => $emit('updateFolderConfig', item.id, config)"
/>
</div>
<!-- 插件卡片 -->
<div v-else-if="item.type === 'plugin'" class="plugin-item-wrapper cursor-move" :data-plugin-id="item.id">
<PluginCard
:count="pluginStatistics[item.id] || 0"
:plugin="item.data"
:action="pluginActions[item.id] || false"
@remove="$emit('refreshData')"
@save="$emit('refreshData')"
@action-done="$emit('actionDone', item.id)"
/>
<!-- 移出文件夹按钮仅在文件夹内显示 -->
<VBtn
v-if="showRemoveButton"
icon="mdi-folder-remove"
variant="text"
color="warning"
size="small"
class="remove-from-folder-btn"
@click="$emit('removeFromFolder', item.id)"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import PluginCard from './PluginCard.vue'
import PluginFolderCard from './PluginFolderCard.vue'
@@ -121,14 +73,76 @@ function handleDropToFolder(event: DragEvent) {
}
</script>
<template>
<div class="mixed-sort-card-wrapper">
<!-- 文件夹卡片 -->
<div
v-if="item.type === 'folder'"
class="drop-zone cursor-move"
:data-plugin-id="item.id"
@dragover="handleDragOver"
@dragenter="handleDragEnter"
@dragleave="handleDragLeave"
@drop="handleDropToFolder"
>
<PluginFolderCard
:folder-name="item.data.name"
:plugin-count="item.data.pluginCount"
:folder-config="item.data.config"
@open="$emit('openFolder', item.id)"
@delete="$emit('deleteFolder', item.id)"
@rename="(oldName, newName) => $emit('renameFolder', oldName, newName)"
@update-config="(folderName, config) => $emit('updateFolderConfig', folderName, config)"
/>
</div>
<!-- 插件卡片 -->
<div v-else-if="item.type === 'plugin'" class="plugin-item-wrapper cursor-move" :data-plugin-id="item.id">
<PluginCard
:count="pluginStatistics[item.id] || 0"
:plugin="item.data"
:action="pluginActions[item.id] || false"
@remove="$emit('refreshData')"
@save="$emit('refreshData')"
@action-done="$emit('actionDone', item.id)"
/>
<!-- 移出文件夹按钮仅在文件夹内显示 -->
<VBtn
v-if="showRemoveButton"
icon="mdi-folder-remove"
variant="text"
color="warning"
size="small"
class="remove-from-folder-btn"
@click="$emit('removeFromFolder', item.id)"
/>
</div>
</div>
</template>
<style lang="scss" scoped>
.mixed-sort-card-wrapper {
block-size: 100%;
inline-size: 100%;
//
&.sortable-chosen {
opacity: 0.5;
}
&.sortable-ghost {
border: 2px dashed #2196f3;
border-radius: 16px;
background: rgba(33, 150, 243, 10%);
opacity: 0.3;
}
}
//
.drop-zone {
position: relative;
isolation: isolate; //
transition: all 0.3s ease;
&.drag-over {
@@ -141,6 +155,7 @@ function handleDropToFolder(event: DragEvent) {
.plugin-item-wrapper {
position: relative;
isolation: isolate; //
.remove-from-folder-btn {
position: absolute;
@@ -158,4 +173,11 @@ function handleDropToFolder(event: DragEvent) {
opacity: 1;
}
}
//
.mixed-sort-card-wrapper.sortable-drag {
.remove-from-folder-btn {
display: none !important;
}
}
</style>

View File

@@ -5,7 +5,6 @@ import api from '@/api'
import type { Plugin } from '@/api/types'
import NoDataFound from '@/components/NoDataFound.vue'
import PluginAppCard from '@/components/cards/PluginAppCard.vue'
import PluginCard from '@/components/cards/PluginCard.vue'
import noImage from '@images/logos/plugin.png'
import { useDisplay } from 'vuetify'
import { isNullOrEmptyObject } from '@/@core/utils'
@@ -13,8 +12,7 @@ import { getPluginTabs } from '@/router/i18n-menu'
import PluginMarketSettingDialog from '@/components/dialog/PluginMarketSettingDialog.vue'
import { useDynamicButton } from '@/composables/useDynamicButton'
import { useI18n } from 'vue-i18n'
import PluginFolderCard from '@/components/cards/PluginFolderCard.vue'
import MixedSortCard from '@/components/cards/MixedSortCard.vue'
import PluginMixedSortCard from '@/components/cards/PluginMixedSortCard.vue'
// 国际化
const { t } = useI18n()
@@ -1345,7 +1343,7 @@ function onDragEndPlugin(evt: any) {
group="mixed"
>
<template #item="{ element }">
<MixedSortCard
<PluginMixedSortCard
:item="element"
:plugin-statistics="PluginStatistics"
:plugin-actions="pluginActions"
@@ -1378,7 +1376,7 @@ function onDragEndPlugin(evt: any) {
group="plugins"
>
<template #item="{ element }">
<MixedSortCard
<PluginMixedSortCard
:item="{ type: 'plugin', id: element.id, data: element, order: 0 }"
:plugin-statistics="PluginStatistics"
:plugin-actions="pluginActions"
@@ -1565,5 +1563,5 @@ function onDragEndPlugin(evt: any) {
</template>
<style lang="scss" scoped>
// 样式已移至 MixedSortCard 组件
// 样式已移至 PluginMixedSortCard 组件
</style>