调整编排的命令列表布局,适配小界面

This commit is contained in:
fofolee 2025-01-02 14:54:04 +08:00
parent 51e6e91ee1
commit 64b6a2a6d9
2 changed files with 82 additions and 11 deletions

View File

@ -33,12 +33,12 @@
header-class="category-header" header-class="category-header"
> >
<template v-slot:header> <template v-slot:header>
<div class="row items-center"> <div class="category-header-content">
<q-icon <q-icon
:name="category.icon" :name="category.icon"
color="primary" color="primary"
size="sm" size="sm"
class="q-mr-sm" class="category-icon"
/> />
<span class="text-weight-medium">{{ category.label }}</span> <span class="text-weight-medium">{{ category.label }}</span>
</div> </div>
@ -47,19 +47,19 @@
<q-item <q-item
v-for="command in getCategoryCommands(category)" v-for="command in getCategoryCommands(category)"
:key="command.value" :key="command.value"
class="command-item q-py-xs" class="command-item"
draggable="true" draggable="true"
@dragstart="onDragStart($event, command)" @dragstart="onDragStart($event, command)"
> >
<div class="drag-icon-left">
<q-icon name="drag_indicator" color="grey-6" size="16px" />
</div>
<q-item-section> <q-item-section>
<q-item-label <q-item-label
class="text-weight-medium" class="text-weight-medium"
v-html="highlightText(command.label)" v-html="highlightText(command.label)"
/> />
</q-item-section> </q-item-section>
<q-item-section side style="padding-left: 8px">
<q-icon name="drag_indicator" color="grey-6" size="16px" />
</q-item-section>
</q-item> </q-item>
</q-expansion-item> </q-expansion-item>
</template> </template>
@ -89,6 +89,13 @@ export default defineComponent({
expandedCategories: new Set(), expandedCategories: new Set(),
}; };
}, },
created() {
this.commandCategories.forEach((category) => {
if (category.defaultOpened) {
this.expandedCategories.add(category.label);
}
});
},
computed: { computed: {
filteredCategories() { filteredCategories() {
if (!this.searchQuery) return this.commandCategories; if (!this.searchQuery) return this.commandCategories;
@ -155,9 +162,7 @@ export default defineComponent({
); );
}, },
isExpanded(category) { isExpanded(category) {
return ( return this.expandedCategories.has(category.label);
category.defaultOpened || this.expandedCategories.has(category.label)
);
}, },
updateExpanded(category, value) { updateExpanded(category, value) {
if (value) { if (value) {
@ -193,6 +198,7 @@ export default defineComponent({
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
border-radius: 10px; border-radius: 10px;
padding: 4px 0;
} }
.search-input { .search-input {
@ -234,21 +240,78 @@ export default defineComponent({
} }
:deep(.q-item.category-header) { :deep(.q-item.category-header) {
min-height: 40px; min-height: 30px;
margin: 0 8px; margin: 0 8px;
padding: 0 4px; padding: 0 4px;
border-radius: 4px; border-radius: 4px;
transition: background-color 0.3s ease; transition: background-color 0.3s ease;
position: relative;
display: flex;
align-items: center;
}
:deep(.q-item.category-header .q-item__section--side) {
position: absolute;
right: 4px;
padding: 0;
height: 100%;
display: flex;
align-items: center;
}
.category-header-content {
position: absolute;
left: 0;
right: 0;
height: 100%;
display: flex;
align-items: center;
}
.category-icon {
position: absolute;
left: 4px;
height: 100%;
display: flex;
align-items: center;
}
.category-header-content span {
flex: 1;
text-align: center;
padding: 0 24px;
line-height: 1;
}
:deep(.q-expansion-item__toggle-icon) {
font-size: 1.2em;
line-height: 1;
} }
.command-item.q-item-type { .command-item.q-item-type {
border: 1px solid rgba(0, 0, 0, 0.05); border: 1px solid rgba(0, 0, 0, 0.05);
border-radius: 4px; border-radius: 4px;
margin: 4px 8px; margin: 4px 8px;
padding: 0 8px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
background: rgba(0, 0, 0, 0.02); background: rgba(0, 0, 0, 0.02);
cursor: grab; cursor: grab;
font-size: 12px; font-size: 12px;
min-height: 40px;
display: flex;
align-items: center;
position: relative;
}
.command-item.q-item-type :deep(.q-item__section) {
padding: 0;
min-height: unset;
flex: 1;
}
.command-item.q-item-type :deep(.q-item__label) {
line-height: 1;
text-align: center;
} }
.command-item.q-item-type:hover { .command-item.q-item-type:hover {
@ -282,4 +345,12 @@ export default defineComponent({
padding: 0 1px; padding: 0 1px;
border-radius: 2px; border-radius: 2px;
} }
.drag-icon-left {
position: absolute;
left: 8px;
height: 100%;
display: flex;
align-items: center;
}
</style> </style>

View File

@ -9,7 +9,7 @@
size="sm" size="sm"
@click="$emit('toggle-collapse')" @click="$emit('toggle-collapse')"
> >
<q-tooltip>折叠/展开此{{ isControlFlow ? "流程" : "命令" }}</q-tooltip> <q-tooltip>{{ isCollapsed ? "展开" : "折叠" }}</q-tooltip>
</q-btn> </q-btn>
</div> </div>
<div v-else-if="isLastCommandInChain" class="chain-icon"> <div v-else-if="isLastCommandInChain" class="chain-icon">