native.js 630 B

12345678910111213141516171819202122232425262728
  1. export default function ({ $userAgent }, i) {
  2. const before = () => {
  3. if ($userAgent.isApp) {
  4. return;
  5. }
  6. // else if ($userAgent.isMiniProgram) {
  7. // throw new Error('小程序环境不支持');
  8. // }
  9. throw new Error('非App环境');
  10. };
  11. i('native', {
  12. share({ title, content, gotoUrl, shareImg }) {
  13. before();
  14. if ($userAgent.isIos) {
  15. window.webkit.messageHandlers.share.postMessage({
  16. title,
  17. content,
  18. gotoUrl,
  19. shareImg,
  20. });
  21. } else {
  22. window.native.share(title, content, gotoUrl, shareImg);
  23. }
  24. },
  25. });
  26. }