king
2023-11-03 eb0482b3fc2e91a626baa6ac73e75e0b0038f552
src/menu/stylecontroller/index.jsx
@@ -415,13 +415,105 @@
    if (res.copyType !== 'style') {
      message.warning('配置信息格式错误!', 5)
      return
    } else if (JSON.stringify(res.options) !== JSON.stringify(options)) {
      message.warning('样式选项不一致,不可粘贴!', 5)
      return
    }
    let style = res.data || {}
    if (JSON.stringify(res.options) !== JSON.stringify(options)) {
      res.options.forEach(n => {
        if (options.includes(n)) return
        if (n === 'width') {
          delete style.width
        } else if (n === 'height') {
          delete style.height
        } else if (n === 'font') {
          if (options.includes('font1')) {
            ['lineHeight', 'letterSpacing', 'fontStyle', 'textAlign', 'textDecoration'].forEach(m => {
              delete style[m]
            })
          } else if (options.includes('font2')) {
          } else {
            ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'color', 'fontStyle', 'textAlign', 'textDecoration'].forEach(m => {
              delete style[m]
            })
          }
        } else if (n === 'font1') {
          if (options.includes('font') || options.includes('font2')) {
          } else {
            ['fontSize', 'fontWeight', 'color'].forEach(m => {
              delete style[m]
            })
          }
        } else if (n === 'font2') {
          if (options.includes('font')) {
            ['textIndent', 'wordBreak'].forEach(m => {
              delete style[m]
            })
          } else if (options.includes('font1')) {
            ['lineHeight', 'letterSpacing', 'fontStyle', 'textAlign', 'textDecoration', 'textIndent', 'wordBreak'].forEach(m => {
              delete style[m]
            })
          } else {
            ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'color', 'fontStyle', 'textAlign', 'textDecoration', 'textIndent', 'wordBreak'].forEach(m => {
              delete style[m]
            })
          }
        } else if (n === 'background') {
          if (!options.includes('backgroundColor')) {
            delete style.backgroundColor
          }
          delete style.backgroundImage
          delete style.backgroundSize
          delete style.backgroundRepeat
          delete style.backgroundPosition
        } else if (n === 'backgroundColor') {
          if (!options.includes('background')) {
            delete style.backgroundColor
          }
        } else if (n === 'border') {
          Object.keys(style).forEach(key => {
            if (!/border/.test(key)) return
            delete style[key]
          })
        } else if (n === 'shadow') {
          delete style.boxShadow
          delete style.hShadow
          delete style.vShadow
          delete style.shadowBlur
          delete style.shadowColor
        } else if (n === 'margin') {
          delete style.marginTop
          delete style.marginBottom
          delete style.marginLeft
          delete style.marginRight
        } else if (n === 'padding') {
          delete style.paddingTop
          delete style.paddingBottom
          delete style.paddingLeft
          delete style.paddingRight
        } else if (n === 'float') {
          delete style.float
        } else if (n === 'minHeight') {
          delete style.minHeight
        } else if (n === 'clear') {
          delete style.clear
        } else if (n === 'display') {
          delete style.display
        } else if (n === 'position') {
          delete style.position
          delete style.top
          delete style.bottom
          delete style.left
          delete style.right
        } else if (n === 'transform') {
          delete style.transform
        }
      })
    }
    let backgroundImage = ''
    if (style.backgroundImage && /^url/ig.test(style.backgroundImage)) {
      backgroundImage = style.backgroundImage.replace(/^url\(/ig, '').replace(/\)$/ig, '')