Demo:支持设置节点背景渐变方向
This commit is contained in:
parent
fa8a80792d
commit
06fb6245b7
@ -557,3 +557,55 @@ export const numberLevelList = [
|
|||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 背景渐变方向
|
||||||
|
export const linearGradientDirList = [
|
||||||
|
{
|
||||||
|
name: 'Left to right',
|
||||||
|
value: '1',
|
||||||
|
start: [0, 0],
|
||||||
|
end: [1, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Right to left',
|
||||||
|
value: '2',
|
||||||
|
start: [1, 0],
|
||||||
|
end: [0, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Top to bottom',
|
||||||
|
value: '3',
|
||||||
|
start: [0, 0],
|
||||||
|
end: [0, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Bottom to top',
|
||||||
|
value: '4',
|
||||||
|
start: [0, 1],
|
||||||
|
end: [0, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Left top to right bottom',
|
||||||
|
value: '5',
|
||||||
|
start: [0, 0],
|
||||||
|
end: [1, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Left bottom to right top',
|
||||||
|
value: '6',
|
||||||
|
start: [0, 1],
|
||||||
|
end: [1, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Right top to left bottom',
|
||||||
|
value: '7',
|
||||||
|
start: [1, 0],
|
||||||
|
end: [0, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Right bottom to left top',
|
||||||
|
value: '8',
|
||||||
|
start: [1, 1],
|
||||||
|
end: [0, 0]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|||||||
@ -21,7 +21,8 @@ import {
|
|||||||
shapeListMap as shapeListMapZh,
|
shapeListMap as shapeListMapZh,
|
||||||
lineStyleMap as lineStyleMapZh,
|
lineStyleMap as lineStyleMapZh,
|
||||||
numberTypeList as numberTypeListZh,
|
numberTypeList as numberTypeListZh,
|
||||||
numberLevelList as numberLevelListZh
|
numberLevelList as numberLevelListZh,
|
||||||
|
linearGradientDirList as linearGradientDirListZh
|
||||||
} from './zh'
|
} from './zh'
|
||||||
import {
|
import {
|
||||||
fontFamilyList as fontFamilyListEn,
|
fontFamilyList as fontFamilyListEn,
|
||||||
@ -36,7 +37,8 @@ import {
|
|||||||
backgroundSizeList as backgroundSizeListEn,
|
backgroundSizeList as backgroundSizeListEn,
|
||||||
downTypeList as downTypeListEn,
|
downTypeList as downTypeListEn,
|
||||||
numberTypeList as numberTypeListEn,
|
numberTypeList as numberTypeListEn,
|
||||||
numberLevelList as numberLevelListEn
|
numberLevelList as numberLevelListEn,
|
||||||
|
linearGradientDirList as linearGradientDirListEn
|
||||||
} from './en'
|
} from './en'
|
||||||
|
|
||||||
const fontFamilyList = {
|
const fontFamilyList = {
|
||||||
@ -114,6 +116,11 @@ const numberLevelList = {
|
|||||||
en: numberLevelListEn
|
en: numberLevelListEn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const linearGradientDirList = {
|
||||||
|
zh: linearGradientDirListZh,
|
||||||
|
en: linearGradientDirListEn
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
fontSizeList,
|
fontSizeList,
|
||||||
lineHeightList,
|
lineHeightList,
|
||||||
@ -137,5 +144,6 @@ export {
|
|||||||
sidebarTriggerList,
|
sidebarTriggerList,
|
||||||
downTypeList,
|
downTypeList,
|
||||||
numberTypeList,
|
numberTypeList,
|
||||||
numberLevelList
|
numberLevelList,
|
||||||
|
linearGradientDirList
|
||||||
}
|
}
|
||||||
|
|||||||
@ -651,3 +651,55 @@ export const numberLevelList = [
|
|||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 背景渐变方向
|
||||||
|
export const linearGradientDirList = [
|
||||||
|
{
|
||||||
|
name: '从左到右',
|
||||||
|
value: '1',
|
||||||
|
start: [0, 0],
|
||||||
|
end: [1, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从右到左',
|
||||||
|
value: '2',
|
||||||
|
start: [1, 0],
|
||||||
|
end: [0, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从上到下',
|
||||||
|
value: '3',
|
||||||
|
start: [0, 0],
|
||||||
|
end: [0, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从下到上',
|
||||||
|
value: '4',
|
||||||
|
start: [0, 1],
|
||||||
|
end: [0, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从左上到右下',
|
||||||
|
value: '5',
|
||||||
|
start: [0, 0],
|
||||||
|
end: [1, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从左下到右上',
|
||||||
|
value: '6',
|
||||||
|
start: [0, 1],
|
||||||
|
end: [1, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从右上到左下',
|
||||||
|
value: '7',
|
||||||
|
start: [1, 0],
|
||||||
|
end: [0, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '从右下到左上',
|
||||||
|
value: '8',
|
||||||
|
start: [1, 1],
|
||||||
|
end: [0, 0]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|||||||
@ -238,7 +238,8 @@ export default {
|
|||||||
endColor: 'End',
|
endColor: 'End',
|
||||||
arrowDir: 'Arrow dir',
|
arrowDir: 'Arrow dir',
|
||||||
arrowDirStart: 'Start',
|
arrowDirStart: 'Start',
|
||||||
arrowDirEnd: 'End'
|
arrowDirEnd: 'End',
|
||||||
|
direction: 'Direction'
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
title: 'Theme',
|
title: 'Theme',
|
||||||
|
|||||||
@ -236,7 +236,8 @@ export default {
|
|||||||
endColor: '结束',
|
endColor: '结束',
|
||||||
arrowDir: '箭头位置',
|
arrowDir: '箭头位置',
|
||||||
arrowDirStart: '头部',
|
arrowDirStart: '头部',
|
||||||
arrowDirEnd: '尾部'
|
arrowDirEnd: '尾部',
|
||||||
|
direction: '方向'
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
title: '主题',
|
title: '主题',
|
||||||
|
|||||||
@ -247,16 +247,16 @@
|
|||||||
<el-popover ref="popover4" placement="bottom" trigger="hover">
|
<el-popover ref="popover4" placement="bottom" trigger="hover">
|
||||||
<Color :color="style.fillColor" @change="changeFillColor"></Color>
|
<Color :color="style.fillColor" @change="changeFillColor"></Color>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
<span class="name" style="margin-left: 20px;">{{
|
||||||
</div>
|
$t('style.gradientStyle')
|
||||||
<div class="row">
|
}}</span>
|
||||||
<div class="rowItem">
|
|
||||||
<span class="name">{{ $t('style.gradientStyle') }}</span>
|
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="style.gradientStyle"
|
v-model="style.gradientStyle"
|
||||||
@change="update('gradientStyle')"
|
@change="update('gradientStyle')"
|
||||||
></el-checkbox>
|
></el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" v-if="style.gradientStyle">
|
||||||
<div class="rowItem">
|
<div class="rowItem">
|
||||||
<span class="name">{{ $t('style.startColor') }}</span>
|
<span class="name">{{ $t('style.startColor') }}</span>
|
||||||
<span
|
<span
|
||||||
@ -282,6 +282,24 @@
|
|||||||
<Color :color="style.endColor" @change="changeEndColor"></Color>
|
<Color :color="style.endColor" @change="changeEndColor"></Color>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="rowItem">
|
||||||
|
<span class="name">{{ $t('style.direction') }}</span>
|
||||||
|
<el-select
|
||||||
|
size="mini"
|
||||||
|
style="width: 80px"
|
||||||
|
v-model="style.linearGradientDir"
|
||||||
|
placeholder=""
|
||||||
|
@change="update('linearGradientDir')"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in linearGradientDirList"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.value"
|
||||||
|
>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 形状 -->
|
<!-- 形状 -->
|
||||||
<div class="title">{{ $t('style.shape') }}</div>
|
<div class="title">{{ $t('style.shape') }}</div>
|
||||||
@ -458,7 +476,8 @@ import {
|
|||||||
borderRadiusList,
|
borderRadiusList,
|
||||||
lineHeightList,
|
lineHeightList,
|
||||||
shapeList,
|
shapeList,
|
||||||
shapeListMap
|
shapeListMap,
|
||||||
|
linearGradientDirList
|
||||||
} from '@/config'
|
} from '@/config'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
|
|
||||||
@ -502,7 +521,8 @@ export default {
|
|||||||
lineMarkerDir: '',
|
lineMarkerDir: '',
|
||||||
gradientStyle: false,
|
gradientStyle: false,
|
||||||
startColor: '',
|
startColor: '',
|
||||||
endColor: ''
|
endColor: '',
|
||||||
|
linearGradientDir: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -522,6 +542,11 @@ export default {
|
|||||||
},
|
},
|
||||||
shapeListMap() {
|
shapeListMap() {
|
||||||
return shapeListMap[this.$i18n.locale] || shapeListMap.zh
|
return shapeListMap[this.$i18n.locale] || shapeListMap.zh
|
||||||
|
},
|
||||||
|
linearGradientDirList() {
|
||||||
|
return (
|
||||||
|
linearGradientDirList[this.$i18n.locale] || linearGradientDirList.zh
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -587,6 +612,24 @@ export default {
|
|||||||
].forEach(item => {
|
].forEach(item => {
|
||||||
this.style[item] = this.activeNodes[0].getStyle(item, false)
|
this.style[item] = this.activeNodes[0].getStyle(item, false)
|
||||||
})
|
})
|
||||||
|
this.initLinearGradientDir()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 初始化渐变方向样式
|
||||||
|
initLinearGradientDir() {
|
||||||
|
const startDir = this.activeNodes[0].getStyle('startDir', false)
|
||||||
|
const endDir = this.activeNodes[0].getStyle('endDir', false)
|
||||||
|
const target = this.linearGradientDirList.find(item => {
|
||||||
|
return (
|
||||||
|
item.start[0] === startDir[0] &&
|
||||||
|
item.start[1] === startDir[1] &&
|
||||||
|
item.end[0] === endDir[0] &&
|
||||||
|
item.end[1] === endDir[1]
|
||||||
|
)
|
||||||
|
})
|
||||||
|
if (target) {
|
||||||
|
this.style.linearGradientDir = target.value
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -595,9 +638,21 @@ export default {
|
|||||||
* @Desc: 修改样式
|
* @Desc: 修改样式
|
||||||
*/
|
*/
|
||||||
update(prop) {
|
update(prop) {
|
||||||
this.activeNodes.forEach(node => {
|
if (prop === 'linearGradientDir') {
|
||||||
node.setStyle(prop, this.style[prop])
|
const target = this.linearGradientDirList.find(item => {
|
||||||
})
|
return item.value === this.style.linearGradientDir
|
||||||
|
})
|
||||||
|
this.activeNodes.forEach(node => {
|
||||||
|
node.setStyles({
|
||||||
|
startDir: [...target.start],
|
||||||
|
endDir: [...target.end]
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.activeNodes.forEach(node => {
|
||||||
|
node.setStyle(prop, this.style[prop])
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user