admin
2020-12-12 41f7cc6dcdca7b5ac2557558509206cc7c9c99fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var index_1 = require("../index");
Component({
    initInvoke: false,
    mixins: [],
    data: {
        show: false,
        info: [],
    },
    props: {
        name: '',
        code: '',
        ext: {},
    },
    onInit: function () {
        this.initInvoke = true;
        this.init();
    },
    didMount: function () {
        if (!this.initInvoke)
            this.init();
    },
    didUpdate: function () { },
    didUnmount: function () { },
    methods: {
        init: function () {
            return tslib_1.__awaiter(this, void 0, void 0, function () {
                var pluginMethods, info;
                return tslib_1.__generator(this, function (_a) {
                    switch (_a.label) {
                        case 0:
                            pluginMethods = index_1.getPluginMethods();
                            if (!pluginMethods) {
                                if (typeof this.props.onError === 'function')
                                    this.props.onError({ msg: 'pluginMethods is undefined', code: this.props.code, name: this.props.name });
                                throw new Error('pluginMethods is undefined');
                            }
                            return [4, pluginMethods.getComponentByCode(this.props.code, this.props.name)];
                        case 1:
                            info = _a.sent();
                            if (!info) {
                                if (typeof this.props.onError === 'function')
                                    this.props.onError({ msg: 'module not found', code: this.props.code, name: this.props.name });
                                throw new Error('module not found');
                            }
                            this.setData({ show: true, info: info });
                            return [2];
                    }
                });
            });
        },
    },
});
//# sourceMappingURL=bc-module.js.map