支持列表全部展开/折叠功能

This commit is contained in:
qiuchengw
2025-09-24 20:38:53 +08:00
parent 7309865af0
commit 16557a260e
5 changed files with 122 additions and 0 deletions
+62
View File
@@ -20,6 +20,8 @@ const props = withDefaults(defineProps<Props>(), {
onFullscreenChange: undefined,
onSettingsConfirm: undefined,
onTimeScaleChange: undefined,
onExpandAll: undefined,
onCollapseAll: undefined,
})
const emit = defineEmits<{
@@ -32,6 +34,8 @@ const emit = defineEmits<{
'theme-change': [isDark: boolean]
'fullscreen-change': [isFullscreen: boolean]
'time-scale-change': [scale: TimelineScale]
'expand-all': []
'collapse-all': []
}>()
// LocalStorage keys
@@ -56,6 +60,8 @@ interface Props {
onThemeChange?: (isDark: boolean) => void
onFullscreenChange?: (isFullscreen: boolean) => void
onTimeScaleChange?: (scale: TimelineScale) => void
onExpandAll?: () => void
onCollapseAll?: () => void
// 外部确认接口
onSettingsConfirm?: (
type: 'theme' | 'language',
@@ -140,6 +146,23 @@ const handleExportPdf = () => {
}
}
// 展开/折叠处理函数
const handleExpandAll = () => {
if (props.onExpandAll && typeof props.onExpandAll === 'function') {
props.onExpandAll()
} else {
emit('expand-all')
}
}
const handleCollapseAll = () => {
if (props.onCollapseAll && typeof props.onCollapseAll === 'function') {
props.onCollapseAll()
} else {
emit('collapse-all')
}
}
// 语言下拉菜单控制
const toggleLanguageDropdown = () => {
showLanguageDropdown.value = !showLanguageDropdown.value
@@ -461,6 +484,45 @@ onUnmounted(() => {
</button>
</div>
<!-- 展开/折叠按钮组 -->
<div
v-if="config.showExpandCollapse !== false"
class="btn-group expand-collapse-btn-group"
>
<button
class="btn-group-item"
:title="t('expandAll')"
@click="handleExpandAll"
>
<svg
class="btn-icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
{{ t('expandAll') }}
</button>
<button
class="btn-group-item"
:title="t('collapseAll')"
@click="handleCollapseAll"
>
<svg
class="btn-icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<polyline points="18 15 12 9 6 15"></polyline>
</svg>
{{ t('collapseAll') }}
</button>
</div>
<!-- 导出按钮组 -->
<div
v-if="config.showExportCsv !== false || config.showExportPdf !== false"