fix: left collapse

This commit is contained in:
teukkk 2025-07-04 17:42:12 +08:00
parent 722776623d
commit 3ba172652a
10 changed files with 76 additions and 28 deletions

View File

@ -1,7 +1,13 @@
<template> <template>
<div class="layout-container flex h-full"> <div class="layout-container flex h-full">
<div class="layout-container__left border-r"> <div :class="`layout-container__left border-r ${isCollapse ? 'hidden' : ''}`">
<slot name="left"></slot> <div class="layout-container__left_content">
<slot name="left"></slot>
</div>
<el-tooltip :content="isCollapse ? $t('common.expand') : $t('common.collapse')" placement="right">
<el-button v-if="props.showCollapse" class="collapse" size="small" circle @click="isCollapse = !isCollapse"
:icon="isCollapse ? 'ArrowRightBold' : 'ArrowLeftBold'" />
</el-tooltip>
</div> </div>
<div class="layout-container__right"> <div class="layout-container__right">
<slot></slot> <slot></slot>
@ -10,13 +16,17 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, useSlots } from 'vue' import { computed, useSlots, ref } from 'vue'
defineOptions({ name: 'LayoutContainer' }) defineOptions({ name: 'LayoutContainer' })
const slots = useSlots() const slots = useSlots()
const props = defineProps({ const props = defineProps({
header: String || null, header: String || null,
backTo: String, backTo: String,
showCollapse: Boolean
}) })
const isCollapse = ref(false)
const showBack = computed(() => { const showBack = computed(() => {
const { backTo } = props const { backTo } = props
return backTo return backTo
@ -26,13 +36,43 @@ const showBack = computed(() => {
<style lang="scss" scoped> <style lang="scss" scoped>
.layout-container { .layout-container {
&__left { &__left {
position: relative;
box-sizing: border-box; box-sizing: border-box;
transition: width 0.28s; transition: width 0.28s;
width: var(--sidebar-width); width: var(--sidebar-width);
min-width: var(--sidebar-width); min-width: var(--sidebar-width);
box-sizing: border-box;
.collapse {
position: absolute;
top: 36px;
right: -15px;
box-shadow: 0px 5px 10px 0px #1f23291a;
z-index: 1;
}
.layout-container__left_content {
width: 100%;
height: 100%;
}
&.hidden {
width: 0;
min-width: 0;
.layout-container__left_content {
visibility: hidden;
}
.collapse {
right: -18px;
}
}
} }
&__right { &__right {
width: calc(100% - var(--sidebar-width)); flex: 1;
overflow: hidden;
} }
} }
</style> </style>

View File

@ -98,4 +98,6 @@ export default {
custom: 'Custom', custom: 'Custom',
moveTo: 'Move To', moveTo: 'Move To',
deleteConfirm: 'Confirm delete', deleteConfirm: 'Confirm delete',
expand: 'Expand',
collapse: 'Collapse',
} }

View File

@ -102,4 +102,6 @@ export default {
custom: '自定义', custom: '自定义',
moveTo: '转移到', moveTo: '转移到',
deleteConfirm: '是否删除', deleteConfirm: '是否删除',
expand: '展开',
collapse: '收起',
} }

View File

@ -98,4 +98,6 @@ export default {
custom: '自定義', custom: '自定義',
moveTo: '移動到', moveTo: '移動到',
deleteConfirm: '是否刪除', deleteConfirm: '是否刪除',
expand: '展開',
collapse: '收起',
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<LayoutContainer class="application-manage"> <LayoutContainer showCollapse class="application-manage">
<template #left> <template #left>
<h4 class="p-12-16 pb-0 mt-12">{{ $t('views.application.title') }}</h4> <h4 class="p-12-16 pb-0 mt-12">{{ $t('views.application.title') }}</h4>
<folder-tree <folder-tree

View File

@ -708,6 +708,7 @@ function closeExecutionDetail() {
top: 20px; top: 20px;
right: -15px; right: -15px;
box-shadow: 0px 5px 10px 0px #1f23291a; box-shadow: 0px 5px 10px 0px #1f23291a;
z-index: 1;
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<LayoutContainer class="knowledge-manage"> <LayoutContainer showCollapse class="knowledge-manage">
<template #left> <template #left>
<h4 class="p-12-16 pb-0 mt-12">{{ $t('views.knowledge.title') }}</h4> <h4 class="p-12-16 pb-0 mt-12">{{ $t('views.knowledge.title') }}</h4>
<folder-tree <folder-tree

View File

@ -1,5 +1,5 @@
<template> <template>
<LayoutContainer class="model-manage"> <LayoutContainer showCollapse class="model-manage">
<template #left> <template #left>
<h4 class="p-12-16 pb-0 mt-12">{{ $t('views.model.provider') }}</h4> <h4 class="p-12-16 pb-0 mt-12">{{ $t('views.model.provider') }}</h4>
<ProviderComponent <ProviderComponent

View File

@ -46,20 +46,22 @@
</template> </template>
</el-input> </el-input>
</div> </div>
<div class="flex"> <LayoutContainer showCollapse>
<div class="paragraph-sidebar p-16 border-r"> <template #left>
<el-anchor <div class="paragraph-sidebar p-16">
direction="vertical" <el-anchor
type="default" direction="vertical"
:offset="130" type="default"
container=".paragraph-scollbar" :offset="130"
@click="handleClick" container=".paragraph-scollbar"
> @click="handleClick"
<template v-for="(item, index) in paragraphDetail" :key="item.id"> >
<el-anchor-link :href="`#m${item.id}`" :title="item.title" v-if="item.title" /> <template v-for="(item, index) in paragraphDetail" :key="item.id">
</template> <el-anchor-link :href="`#m${item.id}`" :title="item.title" v-if="item.title" />
</el-anchor> </template>
</div> </el-anchor>
</div>
</template>
<div class="w-full"> <div class="w-full">
<el-empty v-if="paragraphDetail.length == 0" :description="$t('common.noData')" /> <el-empty v-if="paragraphDetail.length == 0" :description="$t('common.noData')" />
<div v-else> <div v-else>
@ -117,7 +119,7 @@
</el-scrollbar> </el-scrollbar>
</div> </div>
</div> </div>
</div> </LayoutContainer>
<div class="mul-operation border-t w-full" v-if="isBatch === true"> <div class="mul-operation border-t w-full" v-if="isBatch === true">
<el-button :disabled="multipleSelection.length === 0" @click="openGenerateDialog()"> <el-button :disabled="multipleSelection.length === 0" @click="openGenerateDialog()">
@ -343,7 +345,9 @@ onMounted(() => {
top: calc(var(--app-base-px) + 4px); top: calc(var(--app-base-px) + 4px);
} }
.paragraph-sidebar { .paragraph-sidebar {
width: 240px; width: 100%;
height: 100%;
box-sizing: border-box;
} }
.paragraph-detail { .paragraph-detail {

View File

@ -1,5 +1,5 @@
<template> <template>
<LayoutContainer class="tool-manage"> <LayoutContainer showCollapse class="tool-manage">
<template #left> <template #left>
<h4 class="p-12-16 pb-0 mt-12">{{ $t('views.tool.title') }}</h4> <h4 class="p-12-16 pb-0 mt-12">{{ $t('views.tool.title') }}</h4>
<folder-tree <folder-tree
@ -13,7 +13,7 @@
class="p-8" class="p-8"
/> />
</template> </template>
<ToolListContainer @refreshFolder="refreshFolder"> <ToolListContainer>
<template #header> <template #header>
<FolderBreadcrumb :folderList="folderList" @click="folderClickHandle" /> <FolderBreadcrumb :folderList="folderList" @click="folderClickHandle" />
</template> </template>
@ -60,9 +60,6 @@ function getFolder(bool?: boolean) {
} }
function folderClickHandle(row: any) { function folderClickHandle(row: any) {
if (row.id === folder.currentFolder?.id) {
return
}
folder.setCurrentFolder(row) folder.setCurrentFolder(row)
tool.setToolList([]) tool.setToolList([])
} }