执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import Displayable from './Displayable';
import * as zrUtil from '../core/util';
import * as textContain from '../contain/text';
import * as textHelper from './helper/text';
import {ContextCachedBy} from './constant';
 
/**
 * @alias zrender/graphic/Text
 * @extends module:zrender/graphic/Displayable
 * @constructor
 * @param {Object} opts
 */
var Text = function (opts) { // jshint ignore:line
    Displayable.call(this, opts);
};
 
Text.prototype = {
 
    constructor: Text,
 
    type: 'text',
 
    brush: function (ctx, prevEl) {
        var style = this.style;
 
        // Optimize, avoid normalize every time.
        this.__dirty && textHelper.normalizeTextStyle(style, true);
 
        // Use props with prefix 'text'.
        style.fill = style.stroke = style.shadowBlur = style.shadowColor =
            style.shadowOffsetX = style.shadowOffsetY = null;
 
        var text = style.text;
        // Convert to string
        text != null && (text += '');
 
        // Do not apply style.bind in Text node. Because the real bind job
        // is in textHelper.renderText, and performance of text render should
        // be considered.
        // style.bind(ctx, this, prevEl);
 
        if (!textHelper.needDrawText(text, style)) {
            // The current el.style is not applied
            // and should not be used as cache.
            ctx.__attrCachedBy = ContextCachedBy.NONE;
            return;
        }
 
        this.setTransform(ctx);
 
        textHelper.renderText(this, ctx, text, style, null, prevEl);
 
        this.restoreTransform(ctx);
    },
 
    getBoundingRect: function () {
        var style = this.style;
 
        // Optimize, avoid normalize every time.
        this.__dirty && textHelper.normalizeTextStyle(style, true);
 
        if (!this._rect) {
            var text = style.text;
            text != null ? (text += '') : (text = '');
 
            var rect = textContain.getBoundingRect(
                style.text + '',
                style.font,
                style.textAlign,
                style.textVerticalAlign,
                style.textPadding,
                style.textLineHeight,
                style.rich
            );
 
            rect.x += style.x || 0;
            rect.y += style.y || 0;
 
            if (textHelper.getStroke(style.textStroke, style.textStrokeWidth)) {
                var w = style.textStrokeWidth;
                rect.x -= w / 2;
                rect.y -= w / 2;
                rect.width += w;
                rect.height += w;
            }
 
            this._rect = rect;
        }
 
        return this._rect;
    }
};
 
zrUtil.inherits(Text, Displayable);
 
export default Text;