<commit_before>import { Component, Input, OnChanges, SimpleChange } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser';

@Component({
  selector: 'hm-share',
  templateUrl: './share.component.html',
  styleUrls: ['./share.component.scss']
})
export class ShareComponent implements OnChanges {
  private siteName: string = 'HoneyMorning'; // Website name
  private title: string; // header title
  private url: string;
  private summary: string; //
  private desc: string = 'Share'; // default share reason
  @Input() private sharePic: string = ''; // picture url
  @Input() private shareDesc: string = ''; // desc, summary

  constructor(
    private titleService: Title,
    private metaService: Meta
  ) {
    this.title = this.titleService.getTitle();
    this.url = location.href;

    // This is used for wechat share.
    this.metaService.addTags([
      { content: this.title, property: 'og:title'},
      { content: 'article', property: 'og:type' },
      { content: this.siteName, property: 'og:site_name' }
    ]);
  }

  public ngOnChanges(changes: {[propKey: string]: SimpleChange }) {
    this.metaService.addTags([
      {content: changes['shareDesc'].currentValue, property: 'og:description'},
      {content: changes['sharePic'].currentValue, property: 'og:image'}
    ]);
  }

  /**
   * Share to Weibo
   *
   * @private
   * @memberof ShareComponent
   */
  private shareToWeibo() {
    window['sharetitle'] = this.title;
    window['shareUrl'] = this.url;

    const p = this.sharePic;
    const code = 'utf-8';
    this.doShareToWeibo(screen, document, encodeURIComponent, this.siteName, this.url, p, this.title, this.summary, code);
  }

  private doShareToWeibo(s: Screen, d: Document, e: any, r: string, l: string, pics: string, t: string, z: string, c: string) {
    const f = 'http://v.t.sina.com.cn/share/share.php?';
    let u = d.location.href;
    // tslint:disable-next-line:max-line-length
    const p = ['url=', e(u), '&title=', e(t || d.title), '&appkey=4056035540', '&source=', e(r), '&sourceUrl=', e(l), '&content=', c || 'utf-8', '&pic=', e(pics || '')].join('');

    function a() {
      // tslint:disable-next-line:max-line-length
      if (!window.open([f, p].join(''), 'mb', ['toolbar=0,status=0,resizable=1,width=620,height=450,left=', (s.width - 620) / 2, ',top=', (s.height - 450) / 2].join(''))) {
        u = [f, p].join('');
      }
    }
    if (/Firefox/.test(navigator.userAgent)) {
      setTimeout(a, 0);
    } else {
      a();
    }
  }

  /**
   * 分享到QZone
   *
   * @private
   * @memberof ShareComponent
   */
  private shareToQZone() {
    const p = {
      url: this.url.replace(location.protocol + '//', ''),
      showcount: '1', /*是否显示分享总数,显示：'1'，不显示：'0' */
      desc: this.desc, /*默认分享理由(可选)*/
      summary: this.summary, /*分享摘要(可选)*/
      title: this.title, /*分享标题(可选)*/
      site: this.siteName, /*分享来源 如：腾讯网(可选)*/
      pics: this.sharePic, /*分享图片的路径(可选)*/
      style: '201',
      width: 113,
      height: 39
    };

    const s = [];
    for (const i in p) {
      if (p.hasOwnProperty(i)) {
        s.push(i + '=' + encodeURIComponent(p[i] || ''));
      }
    }
    window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?' + s.join('&'), '_blank');
  }
}
<commit_msg>fix: share to wechat cannot show image<commit_after>import { Component, Input, OnChanges, SimpleChange } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser';

@Component({
  selector: 'hm-share',
  templateUrl: './share.component.html',
  styleUrls: ['./share.component.scss']
})
export class ShareComponent implements OnChanges {
  private siteName: string = 'HoneyMorning'; // Website name
  private title: string; // header title
  private url: string;
  private summary: string; //
  private desc: string = 'Share'; // default share reason
  @Input() private sharePic: string; // picture url
  @Input() private shareDesc: string; // desc, summary

  constructor(
    private titleService: Title,
    private metaService: Meta
  ) {
    this.title = this.titleService.getTitle();
    this.url = location.href;

    // This is used for wechat share.
    this.metaService.addTags([
      { content: 'article', property: 'og:type' },
      { content: this.title, property: 'og:title'},
      { content: this.siteName, property: 'og:site_name' }
    ]);
  }

  public ngOnChanges(changes: {
    [propKey: string]: SimpleChange
  }) {
    if (changes['shareDesc'].currentValue) {
      this.metaService.addTag({
        content: changes['shareDesc'].currentValue,
        property: 'og:description'
      }, );
    }
    if (changes['sharePic'].currentValue) {
      this.metaService.addTag({
        content: changes['sharePic'].currentValue,
        property: 'og:image'
      });
    }
  }


  /**
   * Share to Weibo
   *
   * @private
   * @memberof ShareComponent
   */
  private shareToWeibo() {
    window['sharetitle'] = this.title;
    window['shareUrl'] = this.url;

    const p = this.sharePic;
    const code = 'utf-8';
    this.doShareToWeibo(screen, document, encodeURIComponent, this.siteName, this.url, p, this.title, this.summary, code);
  }

  private doShareToWeibo(s: Screen, d: Document, e: any, r: string, l: string, pics: string, t: string, z: string, c: string) {
    const f = 'http://v.t.sina.com.cn/share/share.php?';
    let u = d.location.href;
    // tslint:disable-next-line:max-line-length
    const p = ['url=', e(u), '&title=', e(t || d.title), '&appkey=4056035540', '&source=', e(r), '&sourceUrl=', e(l), '&content=', c || 'utf-8', '&pic=', e(pics || '')].join('');

    function a() {
      // tslint:disable-next-line:max-line-length
      if (!window.open([f, p].join(''), 'mb', ['toolbar=0,status=0,resizable=1,width=620,height=450,left=', (s.width - 620) / 2, ',top=', (s.height - 450) / 2].join(''))) {
        u = [f, p].join('');
      }
    }
    if (/Firefox/.test(navigator.userAgent)) {
      setTimeout(a, 0);
    } else {
      a();
    }
  }

  /**
   * 分享到QZone
   *
   * @private
   * @memberof ShareComponent
   */
  private shareToQZone() {
    const p = {
      url: this.url.replace(location.protocol + '//', ''),
      showcount: '1', /*是否显示分享总数,显示：'1'，不显示：'0' */
      desc: this.desc, /*默认分享理由(可选)*/
      summary: this.summary, /*分享摘要(可选)*/
      title: this.title, /*分享标题(可选)*/
      site: this.siteName, /*分享来源 如：腾讯网(可选)*/
      pics: this.sharePic, /*分享图片的路径(可选)*/
      style: '201',
      width: 113,
      height: 39
    };

    const s = [];
    for (const i in p) {
      if (p.hasOwnProperty(i)) {
        s.push(i + '=' + encodeURIComponent(p[i] || ''));
      }
    }
    window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?' + s.join('&'), '_blank');
  }
}

{'fraction_non_alphanumeric': 0.18870156758355516, 'fraction_numerical': 0.012126589766341319, 'mean_word_length': 2.9228538283062644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2476669', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2462, 'n_words': 508}