fix: reset spacing cannot generate correct source code (#657)

This commit is contained in:
chilingling 2024-09-03 15:02:37 +08:00 committed by GitHub
parent 76c23b767b
commit c35c34e036
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View File

@ -429,7 +429,7 @@ export default {
properties[name] = {
value,
text: value === 'auto' ? 'auto' : String(Number.parseInt(value || 0)), // box
text: value === 'auto' ? 'auto' : String(Number.parseInt(value) || 0), // box
setting: Boolean(value) //
}
})

View File

@ -61,6 +61,10 @@ export default {
props.property.value?.indexOf('px') > -1 ? Number.parseInt(props.property.value) : props.property.value
)
const updateStyle = (value) => {
emit('update', { [props.property.name]: value })
}
const sliderChange = () => {
if (sliderFlag) {
updateStyle(`${sliderValue.value}px`)
@ -83,11 +87,7 @@ export default {
const reset = () => {
sliderFlag = false
updateStyle('')
}
const updateStyle = (value) => {
emit('update', { [props.property.name]: value })
updateStyle(null)
}
const inputChange = (property) => {

View File

@ -231,7 +231,7 @@ export const stringify = (originParseList, styleObject, config = {}) => {
if (key.includes('comment')) {
str += `${value.value}\n`
} else {
str += `${key}: ${value.value};\n`
str += `${key}: ${value.value === '' ? "''" : value.value};\n`
}
}
} else {
@ -249,7 +249,7 @@ export const stringify = (originParseList, styleObject, config = {}) => {
// 在 styleObject 的,可能有改动,所以需要用 styleObject 拼接
for (const [key, value] of Object.entries(styleObject[item.selectors].rules)) {
if (![null, undefined].includes(value)) {
str += `${key}: ${value};\n`
str += `${key}: ${value === '' ? "''" : value};\n`
}
}
}
@ -266,7 +266,7 @@ export const stringify = (originParseList, styleObject, config = {}) => {
str += `${selector} {\n`
for (const [declKey, declValue] of Object.entries(value.rules)) {
str += `${declKey}: ${declValue};\n`
str += `${declKey}: ${declValue === '' ? "''" : declValue};\n`
}
str += '}\n'