Skip to content

Commit

Permalink
fix: 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Dec 18, 2023
1 parent b5e8ade commit 67f711d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/toolbars/media/src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export default {
]
const widthChange = (val) => {
const reg = '^[0-9]+$'
const reg = /^\d+$/
if (!String(val).match(reg)) {
state.width = prevWidthVal ? prevWidthVal : parseInt(dimension.value.width, 10)
Expand All @@ -331,7 +331,7 @@ export default {
const scaleChange = (val) => {
const item = mediaMap['mdx']
const reg = '^[0-9]+(\\.[0-9]+)?$'
const reg = /^\d+(\.\d+)?$/
if (!String(val).match(reg)) {
state.scaleValue = prevScaleVal ? prevScaleVal : parseInt(item.scale)
Expand All @@ -353,19 +353,21 @@ export default {
setCanvasType(value ? 'absolute' : 'normal')
}
watchEffect(() => {
const deviceType = dimension.value.deviceType
state.activeIndex = mediaMap[deviceType].index
state.readonly = dimension.value.deviceType !== 'mdx'
})
watch(
() => dimension.value.deviceType,
(deviceType) => {
state.activeIndex = mediaMap[deviceType].index
state.readonly = deviceType !== 'mdx'
}
)
watchEffect(() => {
state.scaleValue = scale.value.toFixed(2)
prevScaleVal = scale.value
})
watch(
() => useLayout().getDimension().width,
() => dimension.value.width,
(width) => {
const newWidth = parseInt(width, 10)
if (Number.isInteger(newWidth)) {
Expand Down

0 comments on commit 67f711d

Please sign in to comment.