<commit_before><template>
    <img v-if="imgShow" 
        data-toggle="tooltip" 
        :title="type === 1 ? $t('account.membership.normal') : type === 3 ? $t('index.asset.symbol') : ''" 
        class="account-image" 
        :src="imgSrc" 
        :width="size * 2" 
        :height="size * 2" />
    <canvas v-else-if="type === 0" class="account-image" ref="canvas" 
        data-toggle="tooltip" 
        :title="type === 1 ? $t('account.membership.normal') : type === 3 ? $t('index.asset.symbol') : ''" 
        :width="size * 2"
        :height="size * 2"
        :data-jdenticon-hash="hash"></canvas>
    <div class="icon-box" v-else-if="type === 1" data-toggle="tooltip" :title="$t('account.membership.normal')">
        <svg class="account-image" :style="{width:size * 2,height:size * 2}" id="icon-account" viewBox="0 0 1024 1024" width="100%" height="100%"><path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512-229.376-512-512-512z m0 153.6c84.992 0 153.6 68.608 153.6 153.6S596.992 460.8 512 460.8s-153.6-68.608-153.6-153.6 68.608-153.6 153.6-153.6z m0 727.04a368.64 368.64 0 0 1-307.2-164.864C206.336 613.888 409.6 558.08 512 558.08c101.888 0 305.664 55.808 307.2 157.696A368.64 368.64 0 0 1 512 880.64z" fill="#ffc736"></path></svg>
    </div>
    <div class="icon-box" v-else-if="type === 2" data-toggle="tooltip" :title="$t('account.membership.contract')">
        <svg class="account-image" :style="{width:size * 2,height:size * 2}" id="icon-contract" viewBox="0 0 1024 1024" width="100%" height="100%"><path d="M512 0a512 512 0 1 1 0 1024A512 512 0 0 1 512 0z m38.115556 284.444444l-169.528889 455.111112h93.297777l169.528889-455.111112H550.115556z m108.771555 134.257778L796.444444 512l-163.271111 110.762667 50.176 34.019555L853.333333 541.809778V482.986667l-176.184889-115.825778-18.261333 51.484444zM170.666667 482.190222v58.766222l176.184889 115.825778 18.261333-51.484444L227.555556 512l163.271111-110.762667-50.232889-34.019555L170.666667 482.190222z" fill="#34CB49"></path></svg>
    </div>
    <div class="icon-box" v-else-if="type === 3" data-toggle="tooltip" :title="$t('index.asset.symbol')">
        <svg class="account-image" :style="{width:size * 2,height:size * 2}" id="icon-tokens" viewBox="0 0 1024 1024" width="100%" height="100%"><path d="M429.112889 113.777778c108.487111 0 207.644444 9.102222 280.177778 23.779555 11.889778 2.389333 23.153778 5.063111 33.792 7.964445 31.061333 8.533333 110.136889 35.555556 110.136889 76.686222l1.706666 125.610667c7.964444 1.365333 15.530667 2.844444 22.926222 4.323555 11.889778 2.389333 23.210667 5.063111 33.848889 7.964445 31.004444 8.533333 110.136889 35.555556 110.136889 76.686222L1024 595.626667c0 42.552889-55.182222 74.865778-144.270222 92.899555-9.784889 1.991111-20.081778 3.868444-30.72 5.632l1.479111 107.178667c0 42.552889-55.182222 74.922667-144.384 92.899555-72.704 14.677333-172.088889 23.779556-280.860445 23.779556-108.828444 0-208.213333-9.102222-280.917333-23.779556C55.182222 876.316444 0 843.946667 0 801.393778V642.503111c0-33.393778 53.703111-57.344 80.042667-67.128889a444.302222 444.302222 0 0 1 63.943111-17.521778c9.443556-1.877333 19.342222-3.697778 29.582222-5.404444v-73.955556c-8.362667-1.365333-16.497778-2.844444-24.348444-4.494222C60.131556 456.021333 4.949333 423.594667 4.949333 381.155556V222.208c0-33.450667 53.703111-57.457778 79.985778-67.128889a439.182222 439.182222 0 0 1 64-17.521778C221.468444 122.823111 320.568889 113.777778 429.112889 113.777778zM308.337778 686.592c-59.676444-13.084444-102.855111-32.938667-122.652445-58.140444-9.272889 1.536-18.147556 3.128889-26.567111 4.835555-27.875556 5.688889-49.834667 10.24-63.943111 13.255111a39.025778 39.025778 0 0 1-1.763555 8.078222c13.994667 3.072 36.693333 7.736889 65.706666 13.653334 40.96 8.192 91.932444 14.620444 149.219556 18.318222z m-206.620445 62.008889v58.481778c12.629333 2.616889 29.752889 6.200889 50.517334 10.353777v-56.775111a484.579556 484.579556 0 0 1-50.517334-12.060444z m617.699556 7.623111v56.888889c29.070222-5.916444 47.957333-9.955556 52.679111-11.264a38.513778 38.513778 0 0 1-1.024-8.647111v-51.768889c-15.36 5.461333-32.597333 10.467556-51.655111 14.791111z m-49.891556 66.730667v-57.287111c-19.740444 3.128889-40.96 5.859556-63.374222 8.248888v57.799112c22.755556-2.56 43.975111-5.461333 63.374222-8.760889z m-113.208889 13.255111V778.24c-28.16 2.048-57.628444 3.413333-88.064 4.152889v57.912889c30.72-0.682667 60.131556-2.104889 88.007112-4.152889z m-223.459555-55.580445v57.969778c27.306667 1.365333 55.978667 2.161778 85.447111 2.275556v-58.026667a1857.536 1857.536 0 0 1-85.447111-2.218667z m-49.948445 54.727111v-57.912888a1391.331556 1391.331556 0 0 1-80.782222-8.590223v57.457778c24.746667 3.640889 51.768889 6.656 80.782222 9.045333z m552.391112-412.785777c-23.608889 22.300444-66.844444 39.822222-124.188445 51.427555-17.635556 3.584-36.807111 6.826667-57.230222 9.671111 81.635556-2.446222 154.168889-10.069333 208.896-21.162666 30.435556-6.144 53.873778-11.036444 67.697778-14.051556a36.977778 36.977778 0 0 1-1.536-7.224889 6055.253333 6055.253333 0 0 0-66.161778-13.653333c-8.704-1.763556-17.863111-3.413333-27.477333-5.006222zM275.228444 542.890667v58.424889c12.629333 2.616889 29.809778 6.257778 50.517334 10.410666v-56.775111l-7.907556-1.536a506.538667 506.538667 0 0 1-42.609778-10.524444z m617.813334 7.566222v56.888889c29.013333-5.916444 47.786667-9.955556 52.508444-11.207111a40.732444 40.732444 0 0 1-0.910222-8.647111v-51.825778c-15.36 5.461333-32.654222 10.467556-51.655111 14.791111z m-49.948445 66.730667V559.957333c-19.797333 3.128889-40.96 5.859556-63.317333 8.248889v57.742222c22.641778-2.56 43.861333-5.461333 63.317333-8.760888z m-113.265777 13.312v-57.969778c-28.103111 2.104889-57.571556 3.413333-88.007112 4.152889v57.912889a1722.936889 1722.936889 0 0 0 88.007112-4.096zM506.311111 574.862222v57.969778c27.363556 1.365333 55.978667 2.218667 85.504 2.275556v-57.969778a1856.625778 1856.625778 0 0 1-85.504-2.275556z m-49.891555 54.784V571.733333a1394.005333 1394.005333 0 0 1-80.782223-8.647111v57.457778c24.689778 3.697778 51.768889 6.656 80.782223 9.102222z m-349.866667-301.283555v58.368c12.686222 2.673778 29.809778 6.257778 50.574222 10.410666v-56.832c-2.730667-0.455111-5.347556-1.024-7.964444-1.536a496.071111 496.071111 0 0 1-42.609778-10.410666z m617.813333 7.509333v56.888889c29.013333-5.916444 47.843556-9.955556 52.565334-11.207111a39.139556 39.139556 0 0 1-0.967112-8.647111v-51.882667c-15.36 5.518222-32.597333 10.524444-51.655111 14.848z m-49.948444 66.673778V345.372444c-19.797333 3.128889-40.96 5.859556-63.317334 8.248889V411.306667c22.641778-2.503111 43.918222-5.461333 63.317334-8.817778z m-113.265778 13.312V357.944889c-28.103111 2.048-57.571556 3.413333-88.007111 4.152889v57.912889c30.72-0.625778 60.131556-2.048 88.007111-4.152889z m-223.402667-55.523556v57.969778c27.306667 1.308444 55.921778 2.104889 85.447111 2.218667v-58.026667a1857.706667 1857.706667 0 0 1-85.447111-2.161778z m-49.948444 54.670222V357.148444c-28.615111-2.275556-55.637333-5.12-80.782222-8.647111v57.457778c24.689778 3.640889 51.768889 6.712889 80.782222 9.102222z m-187.733333-188.814222a41.073778 41.073778 0 0 1-1.763556 8.135111c13.994667 3.015111 36.693333 7.68 65.649778 13.596445 67.015111 13.539556 160.711111 21.959111 265.102222 21.959111s198.030222-8.419556 265.102222-21.959111a4925.44 4925.44 0 0 0 67.697778-14.051556 40.675556 40.675556 0 0 1-1.592889-7.224889c-13.994667-3.015111-36.807111-7.736889-66.161778-13.653333-67.015111-13.596444-160.654222-21.959111-265.102222-21.959111-104.334222 0-197.973333 8.362667-265.045333 21.902222-27.875556 5.688889-49.777778 10.24-63.943111 13.255111z" fill="#F9AD3D"></path></svg>
    </div>
</template>
<script>
    import jdenticon from 'jdenticon';
    import sha256 from 'js-sha256';
    import { mapGetters } from 'vuex';

    export default {
        props: {
            size: {
                type: Number,
                default: 30
            },
            account: {
                type: String,
                default: ''
            },
            type: { // 0-默认图标 1-普通账户 2-合约账户 3-tokens
                type: Number,
                default: 0
            }
        },
        data () {
            return {
                imgShow: false,
                imgSrc: ''
            };
        },
        updated () {
            $('[data-toggle="tooltip"]').tooltip();
        },
        computed: {
            ...mapGetters({
                symbolsMap: 'symbolsMap'
            }),
            hash: function () {
                return this.account ? sha256(this.account) : '';
            }
        },
        watch: {
            account () {
                this.drawCanvas();
            },
            size () {
                this.drawCanvas();
            }
        },
        methods: {
            drawCanvas () {
                if (this.symbolsMap[this.account]) {
                    this.imgShow = true;
                    this.imgSrc = this.symbolsMap[this.account];
                } else {
                    this.imgShow = false;
                    if (this.account) {
                        jdenticon.update(this.$refs.canvas, this.hash, 0);
                    } else {
                        let ctx = this.$refs.canvas.getContext('2d');
                        ctx.fillStyle = 'rgba(100, 100, 100, 0.5)';
                        let size = ctx.canvas.width;
                        ctx.clearRect(0, 0, size, size);
                        ctx.fillRect(0, 0, size, size);
                        ctx.clearRect(0 + 1, 0 + 1, size - 2, size - 2);
                        ctx.font = `${size}px sans-serif`;
                        ctx.fillText('?', size / 4, size - size / 6);
                    }
                }
            }
        },
        mounted () {
            this.drawCanvas();
            this.$nextTick(() => {
                $('[data-toggle="tooltip"]').tooltip();
            });
        }
    };
</script>
<style scoped>
    .icon-box {
        display: inline-block;
    }
    .account-image {
        vertical-align: middle;
    }
</style>
<commit_msg>fix: draw account image for null<commit_after><template>
    <img v-if="imgShow" 
        data-toggle="tooltip" 
        :title="type === 1 ? $t('account.membership.normal') : type === 3 ? $t('index.asset.symbol') : ''" 
        class="account-image" 
        :src="imgSrc" 
        :width="size * 2" 
        :height="size * 2" />
    <canvas v-else-if="type === 0" class="account-image" ref="canvas" 
        data-toggle="tooltip" 
        :title="type === 1 ? $t('account.membership.normal') : type === 3 ? $t('index.asset.symbol') : ''" 
        :width="size * 2"
        :height="size * 2"
        :data-jdenticon-hash="hash"></canvas>
    <div class="icon-box" v-else-if="type === 1" data-toggle="tooltip" :title="$t('account.membership.normal')">
        <svg class="account-image" :style="{width:size * 2,height:size * 2}" id="icon-account" viewBox="0 0 1024 1024" width="100%" height="100%"><path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512-229.376-512-512-512z m0 153.6c84.992 0 153.6 68.608 153.6 153.6S596.992 460.8 512 460.8s-153.6-68.608-153.6-153.6 68.608-153.6 153.6-153.6z m0 727.04a368.64 368.64 0 0 1-307.2-164.864C206.336 613.888 409.6 558.08 512 558.08c101.888 0 305.664 55.808 307.2 157.696A368.64 368.64 0 0 1 512 880.64z" fill="#ffc736"></path></svg>
    </div>
    <div class="icon-box" v-else-if="type === 2" data-toggle="tooltip" :title="$t('account.membership.contract')">
        <svg class="account-image" :style="{width:size * 2,height:size * 2}" id="icon-contract" viewBox="0 0 1024 1024" width="100%" height="100%"><path d="M512 0a512 512 0 1 1 0 1024A512 512 0 0 1 512 0z m38.115556 284.444444l-169.528889 455.111112h93.297777l169.528889-455.111112H550.115556z m108.771555 134.257778L796.444444 512l-163.271111 110.762667 50.176 34.019555L853.333333 541.809778V482.986667l-176.184889-115.825778-18.261333 51.484444zM170.666667 482.190222v58.766222l176.184889 115.825778 18.261333-51.484444L227.555556 512l163.271111-110.762667-50.232889-34.019555L170.666667 482.190222z" fill="#34CB49"></path></svg>
    </div>
    <div class="icon-box" v-else-if="type === 3" data-toggle="tooltip" :title="$t('index.asset.symbol')">
        <svg class="account-image" :style="{width:size * 2,height:size * 2}" id="icon-tokens" viewBox="0 0 1024 1024" width="100%" height="100%"><path d="M429.112889 113.777778c108.487111 0 207.644444 9.102222 280.177778 23.779555 11.889778 2.389333 23.153778 5.063111 33.792 7.964445 31.061333 8.533333 110.136889 35.555556 110.136889 76.686222l1.706666 125.610667c7.964444 1.365333 15.530667 2.844444 22.926222 4.323555 11.889778 2.389333 23.210667 5.063111 33.848889 7.964445 31.004444 8.533333 110.136889 35.555556 110.136889 76.686222L1024 595.626667c0 42.552889-55.182222 74.865778-144.270222 92.899555-9.784889 1.991111-20.081778 3.868444-30.72 5.632l1.479111 107.178667c0 42.552889-55.182222 74.922667-144.384 92.899555-72.704 14.677333-172.088889 23.779556-280.860445 23.779556-108.828444 0-208.213333-9.102222-280.917333-23.779556C55.182222 876.316444 0 843.946667 0 801.393778V642.503111c0-33.393778 53.703111-57.344 80.042667-67.128889a444.302222 444.302222 0 0 1 63.943111-17.521778c9.443556-1.877333 19.342222-3.697778 29.582222-5.404444v-73.955556c-8.362667-1.365333-16.497778-2.844444-24.348444-4.494222C60.131556 456.021333 4.949333 423.594667 4.949333 381.155556V222.208c0-33.450667 53.703111-57.457778 79.985778-67.128889a439.182222 439.182222 0 0 1 64-17.521778C221.468444 122.823111 320.568889 113.777778 429.112889 113.777778zM308.337778 686.592c-59.676444-13.084444-102.855111-32.938667-122.652445-58.140444-9.272889 1.536-18.147556 3.128889-26.567111 4.835555-27.875556 5.688889-49.834667 10.24-63.943111 13.255111a39.025778 39.025778 0 0 1-1.763555 8.078222c13.994667 3.072 36.693333 7.736889 65.706666 13.653334 40.96 8.192 91.932444 14.620444 149.219556 18.318222z m-206.620445 62.008889v58.481778c12.629333 2.616889 29.752889 6.200889 50.517334 10.353777v-56.775111a484.579556 484.579556 0 0 1-50.517334-12.060444z m617.699556 7.623111v56.888889c29.070222-5.916444 47.957333-9.955556 52.679111-11.264a38.513778 38.513778 0 0 1-1.024-8.647111v-51.768889c-15.36 5.461333-32.597333 10.467556-51.655111 14.791111z m-49.891556 66.730667v-57.287111c-19.740444 3.128889-40.96 5.859556-63.374222 8.248888v57.799112c22.755556-2.56 43.975111-5.461333 63.374222-8.760889z m-113.208889 13.255111V778.24c-28.16 2.048-57.628444 3.413333-88.064 4.152889v57.912889c30.72-0.682667 60.131556-2.104889 88.007112-4.152889z m-223.459555-55.580445v57.969778c27.306667 1.365333 55.978667 2.161778 85.447111 2.275556v-58.026667a1857.536 1857.536 0 0 1-85.447111-2.218667z m-49.948445 54.727111v-57.912888a1391.331556 1391.331556 0 0 1-80.782222-8.590223v57.457778c24.746667 3.640889 51.768889 6.656 80.782222 9.045333z m552.391112-412.785777c-23.608889 22.300444-66.844444 39.822222-124.188445 51.427555-17.635556 3.584-36.807111 6.826667-57.230222 9.671111 81.635556-2.446222 154.168889-10.069333 208.896-21.162666 30.435556-6.144 53.873778-11.036444 67.697778-14.051556a36.977778 36.977778 0 0 1-1.536-7.224889 6055.253333 6055.253333 0 0 0-66.161778-13.653333c-8.704-1.763556-17.863111-3.413333-27.477333-5.006222zM275.228444 542.890667v58.424889c12.629333 2.616889 29.809778 6.257778 50.517334 10.410666v-56.775111l-7.907556-1.536a506.538667 506.538667 0 0 1-42.609778-10.524444z m617.813334 7.566222v56.888889c29.013333-5.916444 47.786667-9.955556 52.508444-11.207111a40.732444 40.732444 0 0 1-0.910222-8.647111v-51.825778c-15.36 5.461333-32.654222 10.467556-51.655111 14.791111z m-49.948445 66.730667V559.957333c-19.797333 3.128889-40.96 5.859556-63.317333 8.248889v57.742222c22.641778-2.56 43.861333-5.461333 63.317333-8.760888z m-113.265777 13.312v-57.969778c-28.103111 2.104889-57.571556 3.413333-88.007112 4.152889v57.912889a1722.936889 1722.936889 0 0 0 88.007112-4.096zM506.311111 574.862222v57.969778c27.363556 1.365333 55.978667 2.218667 85.504 2.275556v-57.969778a1856.625778 1856.625778 0 0 1-85.504-2.275556z m-49.891555 54.784V571.733333a1394.005333 1394.005333 0 0 1-80.782223-8.647111v57.457778c24.689778 3.697778 51.768889 6.656 80.782223 9.102222z m-349.866667-301.283555v58.368c12.686222 2.673778 29.809778 6.257778 50.574222 10.410666v-56.832c-2.730667-0.455111-5.347556-1.024-7.964444-1.536a496.071111 496.071111 0 0 1-42.609778-10.410666z m617.813333 7.509333v56.888889c29.013333-5.916444 47.843556-9.955556 52.565334-11.207111a39.139556 39.139556 0 0 1-0.967112-8.647111v-51.882667c-15.36 5.518222-32.597333 10.524444-51.655111 14.848z m-49.948444 66.673778V345.372444c-19.797333 3.128889-40.96 5.859556-63.317334 8.248889V411.306667c22.641778-2.503111 43.918222-5.461333 63.317334-8.817778z m-113.265778 13.312V357.944889c-28.103111 2.048-57.571556 3.413333-88.007111 4.152889v57.912889c30.72-0.625778 60.131556-2.048 88.007111-4.152889z m-223.402667-55.523556v57.969778c27.306667 1.308444 55.921778 2.104889 85.447111 2.218667v-58.026667a1857.706667 1857.706667 0 0 1-85.447111-2.161778z m-49.948444 54.670222V357.148444c-28.615111-2.275556-55.637333-5.12-80.782222-8.647111v57.457778c24.689778 3.640889 51.768889 6.712889 80.782222 9.102222z m-187.733333-188.814222a41.073778 41.073778 0 0 1-1.763556 8.135111c13.994667 3.015111 36.693333 7.68 65.649778 13.596445 67.015111 13.539556 160.711111 21.959111 265.102222 21.959111s198.030222-8.419556 265.102222-21.959111a4925.44 4925.44 0 0 0 67.697778-14.051556 40.675556 40.675556 0 0 1-1.592889-7.224889c-13.994667-3.015111-36.807111-7.736889-66.161778-13.653333-67.015111-13.596444-160.654222-21.959111-265.102222-21.959111-104.334222 0-197.973333 8.362667-265.045333 21.902222-27.875556 5.688889-49.777778 10.24-63.943111 13.255111z" fill="#F9AD3D"></path></svg>
    </div>
</template>
<script>
    import jdenticon from 'jdenticon';
    import sha256 from 'js-sha256';
    import { mapGetters } from 'vuex';

    export default {
        props: {
            size: {
                type: Number,
                default: 30
            },
            account: {
                type: String,
                default: ''
            },
            type: { // 0-默认图标 1-普通账户 2-合约账户 3-tokens
                type: Number,
                default: 0
            }
        },
        data () {
            return {
                imgShow: false,
                imgSrc: ''
            };
        },
        updated () {
            $('[data-toggle="tooltip"]').tooltip();
        },
        computed: {
            ...mapGetters({
                symbolsMap: 'symbolsMap'
            }),
            hash: function () {
                return this.account ? sha256(this.account) : '';
            }
        },
        watch: {
            account () {
                this.drawCanvas();
            },
            size () {
                this.drawCanvas();
            }
        },
        methods: {
            drawCanvas () {
                if (this.account === null) return;
                if (this.symbolsMap[this.account]) {
                    this.imgShow = true;
                    this.imgSrc = this.symbolsMap[this.account];
                } else {
                    this.imgShow = false;
                    if (this.account) {
                        jdenticon.update(this.$refs.canvas, this.hash, 0);
                    } else {
                        let ctx = this.$refs.canvas.getContext('2d');
                        ctx.fillStyle = 'rgba(100, 100, 100, 0.5)';
                        let size = ctx.canvas.width;
                        ctx.clearRect(0, 0, size, size);
                        ctx.fillRect(0, 0, size, size);
                        ctx.clearRect(0 + 1, 0 + 1, size - 2, size - 2);
                        ctx.font = `${size}px sans-serif`;
                        ctx.fillText('?', size / 4, size - size / 6);
                    }
                }
            }
        },
        mounted () {
            this.drawCanvas();
            this.$nextTick(() => {
                $('[data-toggle="tooltip"]').tooltip();
            });
        }
    };
</script>
<style scoped>
    .icon-box {
        display: inline-block;
    }
    .account-image {
        vertical-align: middle;
    }
</style>

{'fraction_non_alphanumeric': 0.15056511056511057, 'fraction_numerical': 0.47685503685503683, 'mean_word_length': 2.54053583855254, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3385886', 'n_tokens_mistral': 14902, 'n_tokens_neox': 8662, 'n_words': 1253}