mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-06-05 09:38:10 +08:00
feat(editor): 新增 hideSidebar 配置支持隐藏左侧面板
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
cbc4b25072
commit
a3333e2b4e
@ -3,6 +3,7 @@
|
|||||||
:disabled-page-fragment="disabledPageFragment"
|
:disabled-page-fragment="disabledPageFragment"
|
||||||
:page-bar-sort-options="pageBarSortOptions"
|
:page-bar-sort-options="pageBarSortOptions"
|
||||||
:page-filter-function="pageFilterFunction"
|
:page-filter-function="pageFilterFunction"
|
||||||
|
:hide-sidebar="hideSidebar"
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
|
|||||||
@ -34,6 +34,8 @@ export interface EditorProps {
|
|||||||
datasourceList?: DatasourceTypeOption[];
|
datasourceList?: DatasourceTypeOption[];
|
||||||
/** 左侧面板配置 */
|
/** 左侧面板配置 */
|
||||||
sidebar?: SideBarData;
|
sidebar?: SideBarData;
|
||||||
|
/** 是否隐藏左侧面板 */
|
||||||
|
hideSidebar?: boolean;
|
||||||
/** 顶部工具栏配置 */
|
/** 顶部工具栏配置 */
|
||||||
menu?: MenuBarData;
|
menu?: MenuBarData;
|
||||||
/** 组件树右键菜单 */
|
/** 组件树右键菜单 */
|
||||||
|
|||||||
@ -23,15 +23,15 @@
|
|||||||
left-class="m-editor-framework-left"
|
left-class="m-editor-framework-left"
|
||||||
center-class="m-editor-framework-center"
|
center-class="m-editor-framework-center"
|
||||||
right-class="m-editor-framework-right"
|
right-class="m-editor-framework-right"
|
||||||
:left="columnWidth.left"
|
:left="hideSidebar ? undefined : columnWidth.left"
|
||||||
:right="columnWidth.right"
|
:right="columnWidth.right"
|
||||||
:min-left="MIN_LEFT_COLUMN_WIDTH"
|
:min-left="hideSidebar ? 0 : MIN_LEFT_COLUMN_WIDTH"
|
||||||
:min-right="MIN_RIGHT_COLUMN_WIDTH"
|
:min-right="MIN_RIGHT_COLUMN_WIDTH"
|
||||||
:min-center="MIN_CENTER_COLUMN_WIDTH"
|
:min-center="MIN_CENTER_COLUMN_WIDTH"
|
||||||
:width="frameworkRect.width"
|
:width="frameworkRect.width"
|
||||||
@change="columnWidthChange"
|
@change="columnWidthChange"
|
||||||
>
|
>
|
||||||
<template #left>
|
<template v-if="!hideSidebar" #left>
|
||||||
<slot name="sidebar"></slot>
|
<slot name="sidebar"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -94,10 +94,12 @@ defineOptions({
|
|||||||
name: 'MEditorFramework',
|
name: 'MEditorFramework',
|
||||||
});
|
});
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
disabledPageFragment: boolean;
|
disabledPageFragment: boolean;
|
||||||
pageBarSortOptions?: PageBarSortOptions;
|
pageBarSortOptions?: PageBarSortOptions;
|
||||||
pageFilterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
pageFilterFunction?: (_page: MPage | MPageFragment, _keyword: string) => boolean;
|
||||||
|
/** 是否隐藏左侧面板 */
|
||||||
|
hideSidebar?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const codeOptions = inject('codeOptions', {});
|
const codeOptions = inject('codeOptions', {});
|
||||||
@ -132,7 +134,10 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const columnWidthChange = (columnW: GetColumnWidth) => {
|
const columnWidthChange = (columnW: GetColumnWidth) => {
|
||||||
|
// 隐藏左侧面板时 left 恒为 0,不覆盖已持久化的左栏宽度,避免重新展示时丢失宽度
|
||||||
|
if (!props.hideSidebar) {
|
||||||
storageService.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, columnW.left, { protocol: Protocol.NUMBER });
|
storageService.setItem(LEFT_COLUMN_WIDTH_STORAGE_KEY, columnW.left, { protocol: Protocol.NUMBER });
|
||||||
|
}
|
||||||
storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnW.right, { protocol: Protocol.NUMBER });
|
storageService.setItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY, columnW.right, { protocol: Protocol.NUMBER });
|
||||||
|
|
||||||
uiService.set('columnWidth', columnW);
|
uiService.set('columnWidth', columnW);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user