mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(editor): 支持控制pagebar中新增按钮显隐
This commit is contained in:
parent
bdd544e87e
commit
3e024d21ed
@ -38,7 +38,7 @@
|
||||
</div>
|
||||
<template #reference>
|
||||
<el-icon class="m-editor-page-bar-menu-icon">
|
||||
<caret-bottom></caret-bottom>
|
||||
<CaretBottom></CaretBottom>
|
||||
</el-icon>
|
||||
</template>
|
||||
</el-popover>
|
||||
|
@ -1,8 +1,14 @@
|
||||
<template>
|
||||
<div class="m-editor-page-bar" ref="pageBar">
|
||||
<div id="m-editor-page-bar-add-icon" class="m-editor-page-bar-item m-editor-page-bar-item-icon" @click="addPage">
|
||||
<div
|
||||
v-if="showAddPageButton"
|
||||
id="m-editor-page-bar-add-icon"
|
||||
class="m-editor-page-bar-item m-editor-page-bar-item-icon"
|
||||
@click="addPage"
|
||||
>
|
||||
<el-icon><plus></plus></el-icon>
|
||||
</div>
|
||||
<div v-else style="width: 21px"></div>
|
||||
<div v-if="canScroll" class="m-editor-page-bar-item m-editor-page-bar-item-icon" @click="scroll('left')">
|
||||
<el-icon><arrow-left-bold></arrow-left-bold></el-icon>
|
||||
</div>
|
||||
@ -26,13 +32,17 @@ import { generatePageNameByApp } from '../../utils/editor';
|
||||
|
||||
const services = inject<Services>('services');
|
||||
const editorService = services?.editorService;
|
||||
const uiService = services?.uiService;
|
||||
|
||||
const pageBar = ref<HTMLDivElement>();
|
||||
const itemsContainer = ref<HTMLDivElement>();
|
||||
const pageBarWidth = ref(0);
|
||||
const canScroll = ref(false);
|
||||
|
||||
const itemsContainerWidth = computed(() => pageBarWidth.value - 105);
|
||||
const showAddPageButton = computed(() => uiService?.get('showAddPageButton'));
|
||||
|
||||
// 减去新增、左移、右移三个按钮的宽度
|
||||
const itemsContainerWidth = computed(() => pageBarWidth.value - 35 * 2 - (showAddPageButton.value ? 35 : 21));
|
||||
|
||||
let translateLeft = 0;
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
@ -46,7 +56,7 @@ const resizeObserver = new ResizeObserver((entries) => {
|
||||
|
||||
const setCanScroll = () => {
|
||||
if (itemsContainer.value) {
|
||||
canScroll.value = itemsContainer.value.scrollWidth > pageBarWidth.value - 105;
|
||||
canScroll.value = itemsContainer.value.scrollWidth > itemsContainerWidth.value;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -54,6 +54,7 @@ const state = reactive<UiState>({
|
||||
showGuides: true,
|
||||
showRule: true,
|
||||
propsPanelSize: 'small',
|
||||
showAddPageButton: true,
|
||||
});
|
||||
|
||||
class Ui extends BaseService {
|
||||
|
@ -124,6 +124,8 @@ export interface UiState {
|
||||
showRule: boolean;
|
||||
/** 用于控制该属性配置表单内组件的尺寸 */
|
||||
propsPanelSize: 'large' | 'default' | 'small';
|
||||
/** 是否显示新增页面按钮 */
|
||||
showAddPageButton: boolean;
|
||||
}
|
||||
|
||||
export interface EditorNodeInfo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user