<template>
    <div :class="prefixCls" :style="{width: size, height: size}">
        <span :class="extClass"></span>
    </div>
</template>
<script>
    const prefixCls = 'yy-file-logo'

    export default {
        name: 'YYFileLogo',
        props: {
            type: {
                type: String
            },
            size: {
                default: '30px'
            }
        },
        data() {
            return {
                prefixCls
            }
        },
        computed: {
            extClass() {
                let fileTypeList = [{
                    list: ['doc', 'docx'],
                    key: 'ico_doc_doc'
                }, {
                    list: ['ppt', 'pptx', 'csv'],
                    key: 'ico_doc_ppt'
                }, {
                    list: ['xls', 'xlsx'],
                    key: 'ico_doc_exl'
                }, {
                    list: ['txt'],
                    key: 'ico_doc_txt'
                }, {
                    list: ['pdf'],
                    key: 'ico_doc_pdf'
                }, {
                    list: ['zip', 'rar'],
                    key: 'ico_doc_zip'
                }, {
                    list: ['mp4', 'mpeg', 'mpg', 'rm', 'avi', 'mov', 'asf', 'wmv', '3gp', 'mkv', 'flv', 'f4v', 'rmvb'],
                    key: 'ico_doc_sp'
                }, {
                    list: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'svg'],
                    key: 'ico_doc_pic'
                }, {
                    list: ['mp3', 'wma', 'wav', 'asf', 'aac', 'mp3pro', 'vqf', 'flac', 'ape', 'mid', 'midi', 'ogg', 'au'],
                    key: 'ico_doc_yp',
                }]
                let key = 'ico_doc_def'

                fileTypeList.forEach((val) => {
                    if (val.list.indexOf(this.type) > -1) {
                        key = val.key
                    }
                })

                return [
                    prefixCls + '-item',
                    key
                ]
            }
        }
    }
</script>
