{"size": 1692, "ext": "js", "max_stars_repo_path": "packages/core/components/smodal/main.js", "max_stars_repo_name": "yidu864/antdv-backstage-components", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/core/components/smodal/main.js", "max_issues_repo_name": "yidu864/antdv-backstage-components", "max_issues_repo_issues_event_min_datetime": "2022-03-08T10:42:20.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T10:42:22.000Z", "max_forks_repo_path": "packages/core/components/smodal/main.js", "max_forks_repo_name": "yidu864/antdv-backstage-components", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 24.8823529412, "max_line_length": 81, "alphanum_fraction": 0.5750591017}
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import ModalTemplate from './modal-template.vue'

export default {
  name: 's-modal',
  data() {
    return {
      visible: true, // 是否显示
      fullScreen: false // 全屏标识
    }
  },
  components: { ModalTemplate },
  mounted() {
    const { modalAttrs = {} } = this.$options
    const { fullScreen } = modalAttrs
    this.fullScreen = fullScreen
  },
  methods: {
    onFsc() {
      this.fullScreen = !this.fullScreen
    },
    // 给外部调用的
    _close() {
      this.listenerProxy('close')()
    },
    listenerProxy(key) {
      return () => {
        const { onComp } = this.$options
        onComp[key] && onComp[key]()
        this.visible = false
      }
    },
    _destroy() {
      this.removeIndex(this.id)
      this.$destroy()
    }
  },
  render(h) {
    const modalProps = {
      ...this.$options.modalAttrs,
      visible: this.visible,
      fullScreen: this.fullScreen,
      afterClose: this._destroy
    }
    const compProps = {
      ...this.$options.compAttrs
    }
    const onModal = {
      ...this.$options.onModal,
      close: this.listenerProxy('close'),
      ok: this.listenerProxy('ok'),
      cancel: this.listenerProxy('cancel')
    }
    const onComp = {
      ...this.$options.onComp,
      fullScreen: this.onFsc,
      close: this.listenerProxy('close'),
      ok: this.listenerProxy('ok'),
      cancel: this.listenerProxy('cancel')
    }
    // 弹窗内容
    const content = h('modal-content', { attrs: compProps, on: onComp })
    // 弹窗
    const modal = h(ModalTemplate, { attrs: modalProps, on: onModal }, [content])
    return h('a-config-provider', { attrs: { locale: zhCN } }, [modal])
  }
}
