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: add meta data for http/theme/svg plugin #509

Merged
merged 6 commits into from
May 25, 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
2 changes: 2 additions & 0 deletions packages/design-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"@babel/generator": "~7.23.2",
"@babel/parser": "~7.23.2",
"@babel/traverse": "~7.23.2",
"@opentiny/tiny-engine-layout": "workspace:~",
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@opentiny/tiny-engine-canvas": "workspace:*",
"@opentiny/tiny-engine-common": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions packages/design-core/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
*/

import i18nMeta from '@opentiny/tiny-engine-plugin-i18n'
import layoutMeta from '@opentiny/tiny-engine-layout'

export default {
layout: layoutMeta,
plugins: [i18nMeta]
}
3 changes: 2 additions & 1 deletion packages/design-core/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ const devAlias = {
'@opentiny/tiny-engine-webcomponent-core': path.resolve(__dirname, '../webcomponent/src/lib.js'),
'@opentiny/tiny-engine-i18n-host': path.resolve(__dirname, '../i18n/src/lib.js'),
'@opentiny/tiny-engine-builtin-component': path.resolve(__dirname, '../builtinComponent/index.js'),
'@opentiny/tiny-engine-entry': path.resolve(__dirname, '../entry/index.js')
'@opentiny/tiny-engine-entry': path.resolve(__dirname, '../entry/index.js'),
'@opentiny/tiny-engine-layout': path.resolve(__dirname, '../layout/index.js')
}

const prodAlias = {
Expand Down
5 changes: 5 additions & 0 deletions packages/http/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import metaData from './meta'

export default {
...metaData
}
4 changes: 4 additions & 0 deletions packages/http/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
id: 'engine.http',
type: 'http'
}
2 changes: 2 additions & 0 deletions packages/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"homepage": "https://opentiny.design/tiny-engine",
"dependencies": {
"@opentiny/tiny-engine-utils": "workspace:*",
"@opentiny/tiny-engine-entry": "workspace:*",
"@vueuse/core": "^9.6.0",
"axios": "~0.28.0",
"axios-mock-adapter": "^1.21.5"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
3 changes: 2 additions & 1 deletion packages/http/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { defineConfig } from 'vite'
import path from 'path'
hexqi marked this conversation as resolved.
Show resolved Hide resolved
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
Expand Down
7 changes: 7 additions & 0 deletions packages/layout/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import component from './src/index.vue'
import metaData from './meta'

export default {
...metaData,
component
}
4 changes: 4 additions & 0 deletions packages/layout/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
id: 'engine.layout',
type: 'layout'
}
23 changes: 23 additions & 0 deletions packages/layout/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@opentiny/tiny-engine-layout",
"version": "1.0.0",
"scripts": {
"build": "vite build"
},
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"files": [
"dist"
],
"dependencies": {
"@opentiny/tiny-engine-entry": "workspace:*",
"vue": "3.2.45"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^5.0.4",
"less": "^4.2.0",
"vite": "^5.1.6"
}
}
95 changes: 95 additions & 0 deletions packages/layout/src/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.tiny-engine-layout {
height: 100vh;
display: flex;
flex-flow: column;
}
.tiny-engine-layout-header {
height: 48px;
border-bottom: 1px solid #dfe1e6;
text-align: center;
line-height: 48px;
background: #ecf8ff;
display: flex;
justify-content: center;
& > div {
margin: 0 10px;
}
}
.tiny-engine-layout-content {
display: flex;
max-width: 100vw;
flex: 1;
position: relative;
.main-content {
flex-grow: 1;
background: #fffdec;
}
}

.left-panel {
width: 40px;
display: flex;
flex-direction: column;
justify-content: space-between;
background: #fff;
box-sizing: border-box;
z-index: 1000;
border-right: 1px solid #dfe1e6;
}
.tiny-engine-drawer {
position: absolute;
width: 500px;
height: 100%;
left: 40px;
border-right: 1px solid #dfe1e6;
background: #fff;
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}
.left-panel-top {
padding-top: 20px;
.panel-item {
text-align: center;
margin-top: 16px;
cursor: pointer;
.icon-container {
display: inline-flex;
padding: 6px;
border-radius: 6px;
&:hover {
background: #f2f2f2;
}
}
&.active {
.icon-container {
background: #f2f2f2;
}
svg {
fill: #1476ff;
}
}
}
svg {
font-size: 20px;
}
}
.main-content {
flex-grow: 1;
background: #fffdec;
font-size: 30px;
text-align: center;
}
.right-panel {
width: 272px;
height: 100%;
transition: 0.3s linear;
position: relative;
border-left: 1px solid #dfe1e6;
background: #fff;
text-align: center;
font-size: 20px;
padding-top: 10px;
box-sizing: border-box;
}
.toolbar-item {
cursor: pointer;
}
93 changes: 93 additions & 0 deletions packages/layout/src/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<template>
<div class="tiny-engine-layout">
<div class="tiny-engine-layout-header">
<div v-for="(item, index) in state.toolbars" :key="index" class="toolbar-item">
<component :is="item.component"></component>
</div>
</div>
</div>
<div class="tiny-engine-layout-content">
<div class="left-panel">
<div class="left-panel-top">
<div
v-for="(item, index) in state.plugins"
:key="index"
class="panel-item"
:class="{ active: state.active === index }"
@click="clickPanelItem(item, index)"
>
<div class="icon-container">
<component :is="item.icon"></component>
</div>
</div>
</div>
</div>
</div>
<div class="tiny-engine-drawer" v-if="state.showDrawer">
<component :is="state.showComponent"></component>
</div>
<div class="main-content">
<div>canvas</div>
</div>
<div class="right-panel">
<div>settings</div>
</div>
</template>

<script lang="jsx">
/* metaService */
import './index.less'
import { shallowRef, ref, reactive } from 'vue'

export default {
props: {
plugins: {
type: Array,
default: () => []
},
toolbars: {
type: Array,
default: () => []
},
settings: {
type: Array,
default: () => []
}
},
setup(props) {
const showDrawer = ref(false)
const showComponent = shallowRef(null)
const active = ref(null)

const state = reactive({
plugins: props.plugins,
toolbars: props.toolbars,
settings: props.settings,
showComponent,
active,
showDrawer,
drawerWidth: null
})

const clickPanelItem = (item, index) => {
if (active.value === index) {
showDrawer.value = false
active.value = null
} else {
showDrawer.value = true
showComponent.value = item.component
state.drawerWidth = item.span ? (item.span * 100) / 24 + '%' : null
active.value = index
if (item.click) {
item.click()
}
}
}

return {
state,
clickPanelItem
}
}
}
</script>
32 changes: 32 additions & 0 deletions packages/layout/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

import { defineConfig } from 'vite'
import path from 'path'
hexqi marked this conversation as resolved.
Show resolved Hide resolved
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
lib: {
entry: path.resolve(__dirname, './index.js'),
name: 'layout',
fileName: () => 'index.js',
formats: ['es']
}
}
})
3 changes: 2 additions & 1 deletion packages/svgs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
*/

import SvgIcon from './src/Main.vue'
import metaData from './meta.js'

export default (app) => {
app.component('SvgIcon', SvgIcon)
app.component('SvgIcon', { ...metaData, SvgIcon })
}
4 changes: 4 additions & 0 deletions packages/svgs/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
id: 'engine.svgs',
type: 'svgs'
}
5 changes: 4 additions & 1 deletion packages/svgs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
"author": "OpenTiny Team",
"license": "MIT",
"homepage": "https://opentiny.design/tiny-engine",
"dependencies": {},
"dependencies": {
"@opentiny/tiny-engine-entry": "workspace:*"
},
hexqi marked this conversation as resolved.
Show resolved Hide resolved
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"vite": "^4.3.7"
Expand Down
3 changes: 2 additions & 1 deletion packages/svgs/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { defineConfig } from 'vite'
import path from 'path'
hexqi marked this conversation as resolved.
Show resolved Hide resolved
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import generateComment from '@opentiny/vite-plugin-generate-comments'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
plugins: [generateComment(), vue(), vueJsx()],
publicDir: false,
resolve: {},
build: {
Expand Down
5 changes: 5 additions & 0 deletions packages/theme/dark/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import metaData from './meta'

export default {
...metaData
}
5 changes: 5 additions & 0 deletions packages/theme/dark/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
id: 'engine.theme.dark',
title: '主题',
type: 'theme'
}
4 changes: 4 additions & 0 deletions packages/theme/dark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
"author": "OpenTiny Team",
"license": "MIT",
"homepage": "https://opentiny.design/tiny-engine",
"dependencies": {
"@opentiny/tiny-engine-entry": "workspace:*"
},
"devDependencies": {
"@opentiny/vite-plugin-generate-comments": "workspace:*",
"rimraf": "^3.0.2",
"vite": "^4.3.7"
}
Expand Down
Loading