No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Others.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { shareToQQ, shareToQZone, shareToWeibo4Web } from './specifyShare'
  2. import { qqFriend, qZone, weibo } from './command'
  3. import Share from './Share'
  4. export default class Others extends Share {
  5. constructor(config) {
  6. super(config)
  7. }
  8. call(command = 'default', options) {
  9. this.setShareData(options)
  10. if (!navigator.share) {
  11. command = String(command).toLowerCase()
  12. if (command === weibo) {
  13. shareToWeibo4Web()
  14. } else {
  15. if (command === qqFriend) {
  16. shareToQQ()
  17. } else if (command === qZone) {
  18. shareToQZone()
  19. }
  20. throw new Error(`the browser may not support command ${command}!`)
  21. }
  22. return
  23. }
  24. const shareData = this.getShareData()
  25. const queryObj = {
  26. url: shareData.link,
  27. title: shareData.title,
  28. text: shareData.desc,
  29. }
  30. navigator
  31. .share(queryObj)
  32. .then(shareData.success)
  33. .catch(shareData.fail)
  34. }
  35. }