mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
parent
47c26ed189
commit
42b043670e
40
packages/editor/src/layouts/sidebar/LayerNode.vue
Normal file
40
packages/editor/src/layouts/sidebar/LayerNode.vue
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
{{ `${data.name} (${data.id})` }}
|
||||||
|
</div>
|
||||||
|
<div class="layer-node-tool">
|
||||||
|
<template v-if="data.type !== 'page'">
|
||||||
|
<el-icon v-if="data.visible === false" @click.stop="setNodeVisible(true)" title="点击显示">
|
||||||
|
<Hide />
|
||||||
|
</el-icon>
|
||||||
|
<el-icon v-else @click.stop="setNodeVisible(false)" class="node-lock" title="点击隐藏">
|
||||||
|
<View />
|
||||||
|
</el-icon>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { inject } from 'vue';
|
||||||
|
import { Hide, View } from '@element-plus/icons-vue';
|
||||||
|
|
||||||
|
import { MNode } from '@tmagic/schema';
|
||||||
|
|
||||||
|
import { Services } from '@editor/type';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
data: MNode;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const services = inject<Services>('services');
|
||||||
|
const editorService = services?.editorService;
|
||||||
|
|
||||||
|
const setNodeVisible = (visible: boolean) => {
|
||||||
|
if (!editorService) return;
|
||||||
|
|
||||||
|
editorService.update({
|
||||||
|
id: props.data.id,
|
||||||
|
visible,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
@ -35,9 +35,7 @@
|
|||||||
<template #default="{ node, data }">
|
<template #default="{ node, data }">
|
||||||
<div class="cus-tree-node" :id="data.id" @mouseenter="highlightHandler(data)">
|
<div class="cus-tree-node" :id="data.id" @mouseenter="highlightHandler(data)">
|
||||||
<slot name="layer-node-content" :node="node" :data="data">
|
<slot name="layer-node-content" :node="node" :data="data">
|
||||||
<span>
|
<LayerNode :data="data"></LayerNode>
|
||||||
{{ `${data.name} (${data.id})` }}
|
|
||||||
</span>
|
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -63,6 +61,7 @@ import type { MenuButton, MenuComponent, Services } from '@editor/type';
|
|||||||
import { Layout } from '@editor/type';
|
import { Layout } from '@editor/type';
|
||||||
|
|
||||||
import LayerMenu from './LayerMenu.vue';
|
import LayerMenu from './LayerMenu.vue';
|
||||||
|
import LayerNode from './LayerNode.vue';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'MEditorLayerPanel',
|
name: 'MEditorLayerPanel',
|
||||||
|
@ -44,6 +44,12 @@
|
|||||||
.magic-editor-layer-panel .cus-tree-node {
|
.magic-editor-layer-panel .cus-tree-node {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.layer-node-tool {
|
||||||
|
margin-right: 15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.magic-editor-layer-panel .cus-tree-node-hover {
|
.magic-editor-layer-panel .cus-tree-node-hover {
|
||||||
|
@ -45,6 +45,8 @@ const Container: React.FC<ContainerProps> = ({ config, id }) => {
|
|||||||
|
|
||||||
if (!MagicUiComp) return null;
|
if (!MagicUiComp) return null;
|
||||||
|
|
||||||
|
if (item.visible === false) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MagicUiComp
|
<MagicUiComp
|
||||||
id={`${item.id || ''}`}
|
id={`${item.id || ''}`}
|
||||||
|
@ -49,6 +49,8 @@ const Page: React.FC<PageProps> = ({ config }) => {
|
|||||||
|
|
||||||
if (!MagicUiComp) return null;
|
if (!MagicUiComp) return null;
|
||||||
|
|
||||||
|
if (item.visible === false) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MagicUiComp
|
<MagicUiComp
|
||||||
id={`${item.id || ''}`}
|
id={`${item.id || ''}`}
|
||||||
|
@ -35,6 +35,8 @@ export default defineComponent({
|
|||||||
style: computed(() => app?.transformStyle(props.config.style || {})),
|
style: computed(() => app?.transformStyle(props.config.style || {})),
|
||||||
|
|
||||||
display: () => {
|
display: () => {
|
||||||
|
if (props.config.visible === false) return false;
|
||||||
|
|
||||||
const displayCfg = props.config?.display;
|
const displayCfg = props.config?.display;
|
||||||
|
|
||||||
if (typeof displayCfg === 'function') {
|
if (typeof displayCfg === 'function') {
|
||||||
|
@ -33,6 +33,8 @@ const tagName = computed(() => `magic-ui-${toLine(props.config.type)}`);
|
|||||||
const style = computed(() => app?.transformStyle(props.config.style));
|
const style = computed(() => app?.transformStyle(props.config.style));
|
||||||
|
|
||||||
const display = () => {
|
const display = () => {
|
||||||
|
if (props.config.visible === false) return false;
|
||||||
|
|
||||||
const displayCfg = props.config?.display;
|
const displayCfg = props.config?.display;
|
||||||
|
|
||||||
if (typeof displayCfg === 'function') {
|
if (typeof displayCfg === 'function') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user