import { AssetType } from '@/constant'
import { toggleTypeConfig } from './base'

export default {
  defaults () {
    return {
      width: 1920,
      height: 1080,
      backgroundColor: '#000000',
      backgroundImage: [],
      bgm: [],
      widgets: [],
      ...toggleTypeConfig.props
    }
  },
  transform: {
    color: ['backgroundColor']
  },
  options: [
    {
      label: '配置',
      list: [
        {
          key: 'backgroundColor',
          label: '背景色',
          type: 'color'
        },
        {
          key: 'backgroundImage',
          label: '背景图片',
          type: 'data',
          options: {
            type: [AssetType.IMAGE],
            solo: true
          }
        },
        ...toggleTypeConfig.options,
        {
          key: 'bgm',
          label: '背景音乐',
          type: 'data',
          options: {
            type: [AssetType.AUDIO],
            callback () {
              if (this.bgm.length) {
                this.widgets.forEach(widget => {
                  if (widget.mute === 0) {
                    widget.mute = 1
                  }
                })
              }
            }
          }
        }
      ]
    }
  ]
}
