Skip to content

Commit

Permalink
lesscode 0.0.3 (#228)
Browse files Browse the repository at this point in the history
* 先去掉 bk-PaaS 中的其他内容,只保留 paas-ce/lesscode 目录

* init lesscode

* add .pre-commit-config.yaml

* test

* test

* add pre-commit & update dev_install doc & add bk-PaaS doc

* typo

* up dev_install doc

* up dev_install doc

* up dev_install doc

* up dev_install doc

* up .pre-commit-config.yaml

* up comment info

* add .pre-commit-config.yaml to ignore

* feature: 组件属性配置类型提示首字母大写

* 可视化布局 => 可视化开发

* 可视化布局 => 可视化开发

* 可视化布局 => 可视化开发

* Lesscode update doc (#199)

* ignore .idea

* update bk-magic-vue version (for bk-color-picker select '')

* 组件属性提示增加 tips 配置字段

* button 按钮组件使用说明

* text 按钮组件使用说明

* image 图片组件使用说明

* input 输入框组件使用说明

* events 配置数据结构优化 ['change'] ==> [{ name: 'change', tips: ''}]

* 组件使用帮助 tips

* 帮助文档页面移除单个组件导航

* 帮助文档:栅格布局

* merge manually from #201 (#202)

* merge #201

* merge manually from #201

* 添加快捷操作功能 (#205)

* 增加chart图表 (#206)

* 增加chart图表

* fix冲突

* 删除consolelog

* 更新图标库

* merge manually from #203 (#212)

* 拖拽快捷操作支持Mac Command键 (#213)

* 添加快捷操作功能

* 拖拽快捷键支持Mac Command键

* 修改快捷操作说明

* 修复 charts-line options.tips 小问题 (#215)

* 【lesscode】修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题 (#216)

* merge #201

* merge manually from #201

* merge manually from #203

* fix some bug

* 修复 charts-line options.tips 小问题

* 修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题

* 【lesscode】修复 chart 组件样式被覆盖的问题 (#217)

* merge #201

* merge manually from #201

* merge manually from #203

* fix some bug

* 修复 charts-line options.tips 小问题

* 修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题

* 修复 chart 组件样式被覆盖的问题

* fix图表问题 (#218)

* 增加chart图表

* fix冲突

* 删除consolelog

* 更新图标库

* 同步新的lesscode-develop,fix图表bug

* 修改快捷操作 (#219)

* 添加快捷操作功能

* 拖拽快捷键支持Mac Command键

* 修改快捷操作说明

* 修复剪切快捷操作,修改快捷操作说明

* 修改快捷操作 (#220)

* 添加快捷操作功能

* 拖拽快捷键支持Mac Command键

* 修改快捷操作说明

* 修复剪切快捷操作,修改快捷操作说明

* 兼容数据为空的情况

* 兼容数据为空的情况

Co-authored-by: ielgnaw <wuji0223@gmail.com>

* 【lesscode】体验 bug 修复 (#221)

* merge #201

* merge manually from #201

* merge manually from #203

* fix some bug

* 修复 charts-line options.tips 小问题

* 修复刷新页面时,没有选中组件但右侧面板会显示 grid 属性的问题

* 修复 chart 组件样式被覆盖的问题

* 体验 bug 修复

* 修改快捷操作判断 (#222)

* 添加快捷操作功能

* 拖拽快捷键支持Mac Command键

* 修改快捷操作说明

* 修复剪切快捷操作,修改快捷操作说明

* 兼容数据为空的情况

* 兼容数据为空的情况

* 仅在选中拖拽区域触发快捷操作

* 修改判断是否在拖拽区域

* 修复体验问题 (#223)

* 增加backspace快捷删除 (#224)

* 添加快捷操作功能

* 拖拽快捷键支持Mac Command键

* 修改快捷操作说明

* 修复剪切快捷操作,修改快捷操作说明

* 兼容数据为空的情况

* 兼容数据为空的情况

* 仅在选中拖拽区域触发快捷操作

* 修改判断是否在拖拽区域

* 增加backspace快速删除
修改快捷面版样式

* 画布仅剩一个 grid 时,不允许删除;增加清空 grid 操作 (#225)

* 修复 clone grid 时,右侧面板没有默认选中的问题;更新日志 (#226)

* 文案 (#227)

Co-authored-by: hLinx <327159425@qq.com>
Co-authored-by: sundytt <30256396+sundytt@users.noreply.github.com>
Co-authored-by: Arman19941113 <35905177+Arman19941113@users.noreply.github.com>
Co-authored-by: xuzhan <xuzhan@tencent.com>
Co-authored-by: terlinhe <312592676@qq.com>
  • Loading branch information
6 people authored Jun 12, 2020
1 parent 22145fc commit ae6425f
Show file tree
Hide file tree
Showing 112 changed files with 2,374 additions and 2,673 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ open_paas_unittest

.DS_Store
.vscode/
.idea
# End of https://www.gitignore.io/api/python

# lesscode pre-commie
Expand Down
11 changes: 8 additions & 3 deletions paas-ce/lesscode/lib/client/build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ module.exports = {
source: 'src',
img: 'src',
image: 'xlink:href'
}
},
include: [
resolve(__dirname, '../../../node_modules', 'vue-echarts')
]
}
}
},
Expand All @@ -93,7 +96,9 @@ module.exports = {
include: [
resolve(__dirname, '..', 'src'),
resolve(__dirname, '../../../node_modules', 'bk-magic-vue'),
resolve(__dirname, '../../../node_modules', 'monaco-editor')
resolve(__dirname, '../../../node_modules', 'monaco-editor'),
resolve(__dirname, '../../../node_modules', 'vue-echarts'),
resolve(__dirname, '../../../node_modules', 'resize-detector')
],
cacheDirectory: resolve(__dirname, '..', '.webpack_cache'),
presets: [
Expand Down Expand Up @@ -141,7 +146,7 @@ module.exports = {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: resolve(__dirname, '../../../node_modules', 'url-loader'),
options: {
limit: 10000,
limit: true,
name: posix.join('static', 'images/[name].[hash:7].[ext]')
}
},
Expand Down
2 changes: 1 addition & 1 deletion paas-ce/lesscode/lib/client/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<link rel="icon" href="<%= htmlWebpackPlugin.options.staticUrl %>/images/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="<%= htmlWebpackPlugin.options.staticUrl %>/images/favicon.png" type="image/x-icon" />
<meta charset="utf-8">
<title>蓝鲸智云MagicBox|可视化布局</title>
<title>蓝鲸智云MagicBox|可视化开发</title>
</head>
<body>
<div id="app"></div>
Expand Down
2 changes: 1 addition & 1 deletion paas-ce/lesscode/lib/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<link rel="icon" href="<%= htmlWebpackPlugin.options.staticUrl %>/images/favicon.png" type="image/x-icon" />
<link rel="shortcut icon" href="<%= htmlWebpackPlugin.options.staticUrl %>/images/favicon.png" type="image/x-icon" />
<meta charset="utf-8">
<title>蓝鲸智云MagicBox|可视化布局</title>
<title>蓝鲸智云MagicBox|可视化开发</title>
</head>
<body>
<div id="app"></div>
Expand Down
13 changes: 10 additions & 3 deletions paas-ce/lesscode/lib/client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-->

<template>
<section v-if="emptyPage">
<section v-if="emptyPage" class="preview-page">
<router-view />
</section>
<section v-else>
Expand Down Expand Up @@ -68,11 +68,18 @@
color: #63656e;
}
.preview-page {
height: 99vh;
overflow: auto;
}
.mac {
font-family: PingFang SC, Microsoft Yahei, Helvetica, Aria;
/* font-family: PingFang SC, Microsoft Yahei, Helvetica, Aria; */
font-family: -apple-system, BlinkMacSystemFont, PingFang SC, Microsoft YaHei, Helvetica Neue, Arial;
}
.win {
font-family: Microsoft Yahei, PingFang SC, Helvetica, Aria;
/* font-family: Microsoft Yahei, PingFang SC, Helvetica, Aria; */
font-family: -apple-system, BlinkMacSystemFont, PingFang SC, Microsoft YaHei, Helvetica Neue, Arial;
}
</style>
7 changes: 6 additions & 1 deletion paas-ce/lesscode/lib/client/src/common/demand-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
bkPopover, bkProcess, bkProgress, bkRadio, bkRadioButton, bkRadioGroup, bkRoundProgress, bkRow, bkSearchSelect, bkSelect,
bkColorPicker, bkSideslider, bkSlider, bkSteps, bkSwitcher, bkTab, bkTabPanel, bkTable, bkTableColumn, bkTagInput,
bkTimePicker, bkTimeline, bkTransfer, bkTree, bkUpload, bkClickoutside, bkTooltips, bkSwiper, bkRate, bkAnimateNumber,
bkVirtualScroll, bkPopconfirm, bkZoomImage
bkVirtualScroll, bkPopconfirm, bkZoomImage, bkLink
} from 'bk-magic-vue'

// bkDiff 组件体积较大且不是很常用因此注释掉如果需要打开注释即可
Expand All @@ -29,9 +29,13 @@ import { bkDiff } from 'bk-magic-vue'
import bkText from '@/components/patch/text'
import bkImage from '@/components/patch/image'

import chart from '@/components/patch/chart'

Vue.use(bkText)
Vue.use(bkImage)

Vue.use(chart)

// components use
Vue.use(bkBadge)
Vue.use(bkButton)
Expand Down Expand Up @@ -85,6 +89,7 @@ Vue.use(bkAnimateNumber)
Vue.use(bkVirtualScroll)
Vue.use(bkPopconfirm)
Vue.use(bkZoomImage)
Vue.use(bkLink)
// bkDiff 组件体积较大且不是很常用因此注释了如果需要打开注释即可
Vue.use(bkDiff)

Expand Down
220 changes: 220 additions & 0 deletions paas-ce/lesscode/lib/client/src/common/targetData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
import store from '@/store'
import { uuid, walkGrid, findComponentParentGrid } from '@/common/util'
import cloneDeep from 'lodash.clonedeep'

class TargetData {
constructor () {
this.targetData = store.getters['drag/targetData']
}

value () {
return this.targetData
}

setTargetData (targetData) {
store.state.drag.targetData = targetData
this.targetData = store.state.drag.targetData
return this
}

find (id) {
if (typeof id !== 'undefined') {
const targetData = store.getters['drag/targetData'] || []
targetData.forEach((grid, index) => {
const callBack = (data) => {
if (data.componentId === id) this.targetData = data
}
walkGrid(targetData, grid, callBack, callBack, index)
})
}
return this
}

parent () {
const id = this.targetData.componentId
if (typeof id !== 'undefined') {
this.targetData = findComponentParentGrid(store.getters['drag/targetData'], id)
}
return this
}

remove (id) {
const targetData = store.getters['drag/targetData'] || []
targetData.forEach((grid, index) => {
const callBack = (data, parent, index, parentGrid) => {
if (data.componentId === id) {
if (parentGrid) parentGrid.renderKey = uuid()
parent.splice(index, 1)
if (id === this.targetData.componentId) this.targetData = parentGrid
const curSelectedComponentData = store.getters['drag/curSelectedComponentData'] || {}
if (id === curSelectedComponentData.componentId) store.state.drag.curSelectedComponentData = {}
}
}
walkGrid(targetData, grid, callBack, callBack, index)
})
return this
}

move (sourceParentNodeId, sourceColumnIndex, sourceChildrenIndex, targetParentNodeId, targetColumnIndex, targetChildrenIndex) {
let node
const sourceGrid = this.find(sourceParentNodeId).value()
if (typeof sourceColumnIndex === 'undefined') {
node = sourceGrid.splice(sourceChildrenIndex, 1)[0]
} else {
sourceGrid.renderKey = uuid()
const renderProps = sourceGrid.renderProps || {}
const slots = renderProps.slots || {}
const columns = slots.val || []
const column = columns[sourceColumnIndex]
node = column.children.splice(sourceChildrenIndex, 1)[0]
}
node = this.cloneNode(node)

const targetGrid = this.find(targetParentNodeId).value()
if (typeof targetColumnIndex === 'undefined') {
targetGrid.splice(targetChildrenIndex, 0, node)
} else {
targetGrid.renderKey = uuid()
const renderProps = targetGrid.renderProps || {}
const slots = renderProps.slots || {}
const columns = slots.val || []
const column = columns[targetColumnIndex]
column.children.splice(targetChildrenIndex, 0, node)
}
return this
}

update (newNode) {
const node = this.find(newNode.componentId)
const oldNode = node.value()
const parent = node.parent().value() || {}
parent.renderKey = uuid()
newNode.renderKey = uuid()
const curNode = Object.assign(oldNode, newNode)
const curSelectedComponentData = store.getters['drag/curSelectedComponentData'] || {}
if (oldNode.componentId === curSelectedComponentData.componentId) {
store.state.drag.curSelectedComponentData = curNode
}
return this
}

appendChild (node, shouldChangeId) {
node = this.cloneNode(node, shouldChangeId)
if (Array.isArray(this.targetData) && node.type === 'render-grid') {
this.targetData.push(node)
} else if (this.targetData.type === 'render-grid') {
this.targetData.renderKey = uuid()
const renderProps = this.targetData.renderProps || {}
const slots = renderProps.slots || {}
const columns = slots.val || []
for (let index = 0; index < columns.length; index++) {
const nextColumn = columns[index + 1] || { children: [] }
if (nextColumn.children.length <= 0) {
columns[index].children.push(node)
break
}
}
} else {
const targetData = store.getters['drag/targetData'] || []
targetData.forEach((grid, index) => {
const callBack = (data, parent, index, parentGrid) => {
if (data.componentId === this.targetData.componentId) {
parentGrid.renderKey = uuid()
parent.splice(index + 1, 0, node)
}
}
walkGrid(targetData, grid, callBack, callBack, index)
})
}
return this.find(node.componentId)
}

appendChildByIndex (node, parentId, columnIndex, childrenIndex, shouldChangeId) {
node = this.cloneNode(node, shouldChangeId)
const parent = this.find(parentId).value()
if (typeof columnIndex === 'undefined') {
parent.splice(childrenIndex, 0, node)
} else {
parent.renderKey = uuid()
const renderProps = parent.renderProps || {}
const slots = renderProps.slots || {}
const columns = slots.val || []
const column = columns[columnIndex]
const children = column.children
children.splice(childrenIndex, 0, node)
}
return this
}

getNodePosition (id) {
id = id || this.targetData.componentId
let res
const targetData = store.getters['drag/targetData'] || []
targetData.forEach((grid, index) => {
const callBack = (data, parent, childrenIndex, parentGrid, columnIndex) => {
if (data.componentId === id) {
res = {
parent: parentGrid,
columnIndex,
childrenIndex
}
}
}
walkGrid(targetData, grid, callBack, callBack, index)
})
return res
}

appendBefore (id, node, shouldChangeId) {
node = this.cloneNode(node, shouldChangeId)
const targetData = store.getters['drag/targetData'] || []
targetData.forEach((grid, index) => {
const callBack = (data, parent, index, parentGrid) => {
if (data.componentId === id) {
parentGrid.renderKey = uuid()
parent.splice(index, 0, node)
}
}
walkGrid(targetData, grid, callBack, callBack, index)
})
return this
}

appendAfter (id, node, shouldChangeId) {
node = this.cloneNode(node, shouldChangeId)
const targetData = store.getters['drag/targetData'] || []
targetData.forEach((grid, index) => {
const callBack = (data, parent, index, parentGrid) => {
if (data.componentId === id) {
parentGrid.renderKey = uuid()
parent.splice(index + 1, 0, node)
}
}
walkGrid(targetData, grid, callBack, callBack, index)
})
return this
}

cloneNode (node, shouldChangeId) {
node = cloneDeep(node)
const callBack = (data) => {
if (shouldChangeId) data.componentId = data.componentId.replace(/.{8}$/, uuid())
data.renderKey = uuid()
}
if (Array.isArray(node)) {
node.forEach((grid, index) => {
walkGrid(node, grid, callBack, callBack, index)
})
} else if (node.type === 'render-grid') {
walkGrid({}, node, callBack, callBack, 0)
} else {
callBack(node)
}
return node
}
}

export default (id) => {
const targetData = new TargetData()
return targetData.find(id)
}
Loading

0 comments on commit ae6425f

Please sign in to comment.