Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 增加了toolbar 示例 #133

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions examples/src/components/ToolBar/ToolBar.vue

This file was deleted.

48 changes: 0 additions & 48 deletions examples/src/components/ToolBar/ToolBarItem.vue

This file was deleted.

6 changes: 0 additions & 6 deletions examples/src/components/ToolBar/index.ts

This file was deleted.

19 changes: 0 additions & 19 deletions examples/src/components/ToolBar/type.ts

This file was deleted.

6 changes: 3 additions & 3 deletions examples/src/pages/ApiView/ToolBar/Toolbar.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<ToolBar :bars="toolBars" />
<ToolBar :bars="toolBars" class="w-full h-14 align-middle" />
</template>

<script setup lang="ts">
import type { ToolBarItemType } from '@open-data-v/designer'
import { ToolBar } from '@open-data-v/designer'
import { h } from 'vue'
import { useRouter } from 'vue-router'

import LogoView from '@/components/LogoView'
import type { ToolBarItemType } from '@/components/ToolBar'
import { ToolBar } from '@/components/ToolBar'

import { toggleTheme } from './modules/actions'
import ThemeIcon from './modules/themeSwitch/ThemeIcon.vue'
Expand Down
16 changes: 14 additions & 2 deletions examples/src/pages/DesignerView/View.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
<template>
<Designer ref="designer" :toolbars="toolBars" />
<Designer ref="designer">
<template #top>
<ToolBar :bars="toolBars" class="w-full h-14 align-middle">
<div class="tool-bar-title">{{ canvasState.name }}</div>
</ToolBar>
</template>
</Designer>
</template>

<script setup lang="ts">
import { StaticKey, useEventBus } from '@open-data-v/base'
import { StaticDataPlugin, SubDataPlugin, WebsocketDataPlugin } from '@open-data-v/data'
/* eslint-disable-next-line @typescript-eslint/consistent-type-imports */
import { Designer, useCanvasState, useDataState, useScriptState } from '@open-data-v/designer'
import {
Designer,
ToolBar,
useCanvasState,
useDataState,
useScriptState
} from '@open-data-v/designer'
import { CustomScriptPlugin, SystemScriptPlugin } from '@open-data-v/scripts'
import { onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
Expand Down
4 changes: 2 additions & 2 deletions examples/src/pages/UIView.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<n-layout class="home">
<n-layout-header class="h-16">
<ToolBar />
<n-layout-header class="h-14">
<ToolBar class="w-full h-14" />
</n-layout-header>
<!-- 左侧组件列表 -->
<n-layout class="main">
Expand Down
2 changes: 1 addition & 1 deletion packages/base/src/components/RenderSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineComponent({
},
// @ts-ignore
setup(props) {
return () => [h('div', {}, props.slots)]
return () => [h('template', {}, props.slots)]
}
})
3 changes: 0 additions & 3 deletions packages/designer/src/components/ToolBar/ToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const props = withDefaults(
bars: () => []
}
)

const leftToolBars = computed<ToolBarItemType[]>(() =>
props.bars.filter((el) => el.location === 'left' || el.location === undefined)
)
Expand All @@ -55,11 +54,9 @@ const rightToolBars = computed<ToolBarItemType[]>(() =>
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
height: inherit;
border-bottom: 1px var(--n-text-color) solid;
}
.tool-bar-item {
height: inherit;
display: flex;
align-items: center;
}
Expand Down
1 change: 0 additions & 1 deletion packages/designer/src/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ const canvasStyleData = computed(() => canvasState.canvasStyleData)
const curComponent = computed(() => canvasState.activeComponent)

const bgStyle = computed<Record<string, string>>(() => {
debugger
const backgroundStyle = backgroundToCss(canvasStyleData.value.background)
const style = {
...canvasStyleData.value,
Expand Down
7 changes: 5 additions & 2 deletions packages/designer/src/pages/designer/Designer.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<template>
<div class="h-full flex-col flex flex-nowrap overflow-hidden">
<div class="w-full h-14 align-middle">
<template v-if="slots?.top">
<RenderSlot :slots="slots?.top()" />
</template>
<template v-else>
<ToolBar :toolbars="toolbars" />
</div>
</template>
<div class="content flex flex-1 flex-nowrap flex-row overflow-auto">
<template v-if="slots?.left">
<RenderSlot :slots="slots?.left()" />
Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/pane/Toolsbar/Toolbar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<ToolBar v-if="toolbars.length > 0" :bars="toolbars" class="w-full">
<ToolBar v-if="toolbars.length > 0" :bars="toolbars" class="w-full h-14 align-middle">
<div class="tool-bar-title">{{ canvasState.name }}</div>
</ToolBar>
</template>
Expand Down
Loading