mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-19 03:49:31 +08:00
style(editor): 菜单样式优化
This commit is contained in:
parent
bcbd1f5d37
commit
d1610e5ff2
@ -3,7 +3,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, inject, ref } from 'vue';
|
import { computed, defineComponent, inject, markRaw, ref } from 'vue';
|
||||||
|
import { Delete, DocumentCopy, Files, Plus } from '@element-plus/icons';
|
||||||
|
|
||||||
import { NodeType } from '@tmagic/schema';
|
import { NodeType } from '@tmagic/schema';
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ export default defineComponent({
|
|||||||
group.items.map((component) => ({
|
group.items.map((component) => ({
|
||||||
text: component.text,
|
text: component.text,
|
||||||
type: 'button',
|
type: 'button',
|
||||||
|
icon: component.icon,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
services?.editorService.add({
|
services?.editorService.add({
|
||||||
name: component.text,
|
name: component.text,
|
||||||
@ -40,6 +42,7 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
text: '标签页',
|
text: '标签页',
|
||||||
type: 'button',
|
type: 'button',
|
||||||
|
icon: Files,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
services?.editorService.add({
|
services?.editorService.add({
|
||||||
type: 'tab-pane',
|
type: 'tab-pane',
|
||||||
@ -76,12 +79,14 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
text: '新增',
|
text: '新增',
|
||||||
|
icon: markRaw(Plus),
|
||||||
display: () => node.value?.items,
|
display: () => node.value?.items,
|
||||||
items: getSubMenuData.value,
|
items: getSubMenuData.value,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
text: '复制',
|
text: '复制',
|
||||||
|
icon: markRaw(DocumentCopy),
|
||||||
display: () => !isRoot.value,
|
display: () => !isRoot.value,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
node.value && services?.editorService.copy(node.value);
|
node.value && services?.editorService.copy(node.value);
|
||||||
@ -90,6 +95,7 @@ export default defineComponent({
|
|||||||
{
|
{
|
||||||
type: 'button',
|
type: 'button',
|
||||||
text: '删除',
|
text: '删除',
|
||||||
|
icon: markRaw(Delete),
|
||||||
display: () => !isRoot.value && !isPage.value,
|
display: () => !isRoot.value && !isPage.value,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
node.value && services?.editorService.remove(node.value);
|
node.value && services?.editorService.remove(node.value);
|
||||||
|
@ -22,11 +22,25 @@
|
|||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-popover placement="top" :width="160" trigger="hover">
|
<el-popover popper-class="page-bar-popover" placement="top" :width="160" trigger="hover">
|
||||||
<div>
|
<div>
|
||||||
<slot name="page-bar-popover" :page="item">
|
<slot name="page-bar-popover" :page="item">
|
||||||
<div class="magic-editor-content-menu-item" @click="() => copy(item)">复制</div>
|
<tool-button
|
||||||
<div class="magic-editor-content-menu-item" @click="() => remove(item)">删除</div>
|
:data="{
|
||||||
|
type: 'button',
|
||||||
|
text: '复制',
|
||||||
|
icon: DocumentCopy,
|
||||||
|
handler: () => copy(item),
|
||||||
|
}"
|
||||||
|
></tool-button>
|
||||||
|
<tool-button
|
||||||
|
:data="{
|
||||||
|
type: 'button',
|
||||||
|
text: '删除',
|
||||||
|
icon: Delete,
|
||||||
|
handler: () => remove(item),
|
||||||
|
}"
|
||||||
|
></tool-button>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
@ -44,12 +58,24 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, ComputedRef, defineComponent, inject, onMounted, onUnmounted, ref, toRaw, watch } from 'vue';
|
import {
|
||||||
import { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus } from '@element-plus/icons';
|
computed,
|
||||||
|
ComputedRef,
|
||||||
|
defineComponent,
|
||||||
|
inject,
|
||||||
|
markRaw,
|
||||||
|
onMounted,
|
||||||
|
onUnmounted,
|
||||||
|
ref,
|
||||||
|
toRaw,
|
||||||
|
watch,
|
||||||
|
} from 'vue';
|
||||||
|
import { ArrowLeftBold, ArrowRightBold, CaretBottom, Delete, DocumentCopy, Plus } from '@element-plus/icons';
|
||||||
|
|
||||||
import type { MApp, MPage } from '@tmagic/schema';
|
import type { MApp, MPage } from '@tmagic/schema';
|
||||||
import { NodeType } from '@tmagic/schema';
|
import { NodeType } from '@tmagic/schema';
|
||||||
|
|
||||||
|
import ToolButton from '@editor/components/ToolButton.vue';
|
||||||
import type { Services } from '@editor/type';
|
import type { Services } from '@editor/type';
|
||||||
import { generatePageNameByApp } from '@editor/utils/editor';
|
import { generatePageNameByApp } from '@editor/utils/editor';
|
||||||
|
|
||||||
@ -138,7 +164,7 @@ const useScroll = (root: ComputedRef<MApp | undefined>) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus },
|
components: { ArrowLeftBold, ArrowRightBold, CaretBottom, Plus, ToolButton },
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const services = inject<Services>('services');
|
const services = inject<Services>('services');
|
||||||
@ -147,6 +173,9 @@ export default defineComponent({
|
|||||||
const root = computed(() => editorService?.get<MApp>('root'));
|
const root = computed(() => editorService?.get<MApp>('root'));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Delete: markRaw(Delete),
|
||||||
|
DocumentCopy: markRaw(DocumentCopy),
|
||||||
|
|
||||||
...useScroll(root),
|
...useScroll(root),
|
||||||
|
|
||||||
root,
|
root,
|
||||||
|
@ -2,6 +2,7 @@ $--theme-color: #2882e0;
|
|||||||
|
|
||||||
$--font-color: #070303;
|
$--font-color: #070303;
|
||||||
$--border-color: #d9dbdd;
|
$--border-color: #d9dbdd;
|
||||||
|
$--hover-color: #f3f5f9;
|
||||||
|
|
||||||
$--nav-height: 35px;
|
$--nav-height: 35px;
|
||||||
$--nav-color: #070303;
|
$--nav-color: #070303;
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #f3f5f9;
|
background-color: $--hover-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.magic-editor-layer-panel .cus-tree-node-hover {
|
.magic-editor-layer-panel .cus-tree-node-hover {
|
||||||
background-color: #f3f5f9;
|
background-color: $--hover-color;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-editor-page-bar-title {
|
&-title {
|
||||||
max-width: 150px;
|
max-width: 150px;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -48,3 +48,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-bar-popover {
|
||||||
|
&.el-popper.el-popover {
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item {
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease 0s;
|
||||||
|
padding: 5px 14px;
|
||||||
|
|
||||||
|
.el-button--text,
|
||||||
|
i {
|
||||||
|
color: $--font-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $--hover-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user