"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fsExtra = require("fs-extra");
const Base_1 = require("../Base");
const VueParse_1 = require("../../generator/VueParse");
const path = require("path");
const config_1 = require("../../../config");
const _ = require("lodash");
class UploadAvatar extends Base_1.default {
    constructor(params, boxPath) {
        super(boxPath);
        this.name = 'UploadAvatar';
        if (params.initType === 'auto') {
            this.config = params;
        }
        else {
            this.config = _.cloneDeep(require('./config').default);
        }
        this.init();
    }
    init() {
        const fileStr = fsExtra.readFileSync(path.join(config_1.default.templatePath, 'component/UploadAvatar', 'comp.vue'), 'utf8');
        this.vueParse = new VueParse_1.default(this.uuid, fileStr);
    }
    fragment() {
        return `       
      <el-upload
        class="avatar-uploader"
        action="https://jsonplaceholder.typicode.com/posts/"
        :show-file-list="false"
        :on-success="handleAvatarSuccess${this.uuid}"
        :before-upload="beforeAvatarUpload${this.uuid}">
        <img v-if="imageUrl" :src="imageUrl" class="avatar" />
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
      </el-upload>
    `;
    }
}
exports.default = UploadAvatar;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvbGliL2FkYXB0ZXItdnVlL21vZHVsZXMvY29tcG9uZW50L1VwbG9hZEF2YXRhci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLG9DQUFvQztBQUNwQyxrQ0FBMkI7QUFDM0IsdURBQWdEO0FBQ2hELDZCQUE2QjtBQUM3Qiw0Q0FBcUM7QUFDckMsNEJBQTRCO0FBRTVCLE1BQXFCLFlBQWEsU0FBUSxjQUFJO0lBRzVDLFlBQWEsTUFBVyxFQUFFLE9BQWU7UUFDdkMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBSGpCLFNBQUksR0FBVyxjQUFjLENBQUM7UUFJNUI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