nuxt3网站文章分享微信 ,QQ功能

news2025/3/31 9:45:22

1.安装
npm install qrcode --save-dev
2.组件使用

  
          <div class="share">
            <div style="line-height: 69px; color: #fff;width: 100px;">
              <p style="text-align: center;">分享:</p>
            </div>

            <div @click="shareToMicroblog()" class="BJ_WB">
              <a class="weibo" />
              <a>微博</a>
            </div>

            <!-- <div @click="shareToQQ()" class="BJ_QQ">
                <a class="qq"></a>
                <a>QQ好友</a>
              </div> -->

            <div
              class="BJ_WX"
              @mouseover="showQR = true"
              @mouseleave="showQR = false"
            >
              <div class="weixinall">
                <a class="weixin" />
                <a>微信</a>
              </div>
              <div
                class="weixincode"
                :class="{ 'qrcode-visible': showQR }"
                style="
                  position: absolute;
                  top: -220px;

                  opacity: 0;
                  transition: opacity 0.3s ease;
                  width: 200px;
                  height: 200px;
                  background-color: #fff;
                "
              >
                <canvas
                  id="QRCode_header"
                  style="width: 165px; height: 165px; margin: auto"
                />
                <p
                  style="
                    color: #818181;
                    font-size: 12px;
                    line-height: 16px;
                    margin-left: 15px;
                  "
                >
                  打开微信扫一扫<br />将您喜欢的内容分享微信朋友圈
                </p>
              </div>
            </div>

            <div class="BJ" @click="shareToQQRom()">
              <a class="qqkj"></a>
              <a>QQ</a>
            </div>
          </div>
<script setup lang="ts">
import QRCode from "qrcode";
const route = useRoute();
const id = ref(route.params.id);
const showQR = ref(false);
const shareUrl = `https://XXXXXXX.COM/XXXXXXXXXX/${id.value}`;
//分享到QQ
// const shareToQQ= function() {
//   window.open(
//       `https://connect.qq.com/widget/shareqq/index.html?url=${shareUrl}&title=${sysInfo}&source=${shareUrl}&desc=${sysInfo}&pics=`)
// }
//分享到微信
onMounted(() => {
  const QR_OPTIONS = {
    errorCorrectionLevel: "H",
    width: 165,
    height: 165,
    margin: 3,
    color: {
      dark: "#000",
      light: "#fff",
    },
    
  };

  QRCode.toCanvas(
    document.querySelector("#QRCode_header"),
    shareUrl,
    QR_OPTIONS,
    (error: any) => {
      if (error) console.error("二维码生成失败:", error);
    }
  );
});

//分享到微博
const shareToMicroblog = function () {
  window.open(
    `https://service.weibo.com/share/share.php?url=${shareUrl}&title=${details.value.productBackground}`
  );
};

//分享到qq空间
const shareToQQRom = function () {
  const pics = encodeURIComponent(details.value.productBackgroundImage);
  const desc = encodeURIComponent(details.value.productBackground);
  window.open(
    `https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=${shareUrl}&title=${details.value.productBackground}&summary=${details.value.productBackground}&desc=${desc}&pics=${pics}`
  );
};
</script>
<style scoped lang="scss">
.share {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  justify-content: center;
  .weibo {
    display: block;
    width: 24px;
    height: 21px;
    background-image: url("/assets/img/wb.png") !important;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
  }

  .BJ_WB {
    background-color: #e6162d;
    width: 110px;
    height: 40px;
    margin-top: 15px;
    margin-right: 15px;
    display: flex;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    color: #fff;
    cursor: pointer;
    &:hover {
      background-color: #f75567;

      transform: translateY(-2px);
    }
  }

  .BJ_QQ {
    background-color: #2384cc;
    width: 110px;
    height: 40px;
    margin-top: 15px;
    margin-right: 15px;
    display: flex;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    color: #fff;
    cursor: pointer;
    &:hover {
      background-color: #5faae2;
      transform: translateY(-2px);
    }
  }

  .BJ_WX {
    background-color: #3cb034;
    width: 110px;
    height: 40px;
    margin-top: 15px;
    border-radius: 8px;
    /* position: relative; */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s;
    color: #fff;
    cursor: pointer;
    &:hover {
      background-color: #7dd377;
      transform: translateY(-2px);
    }
  }

  .BJ {
    background-color: rgb(255, 206, 0);
    width: 110px;
    height: 40px;
    display: flex;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    color: #fff;
    margin: 15px;
    cursor: pointer;
    &:hover {
      background-color: #ffde52;
      transform: translateY(-2px);
    }
  }

  .qq {
    display: block;
    width: 28px;
    height: 28px;
    background-image: url("/assets/img/qq.png");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
  }
  .qqkj {
    display: block;
    width: 28px;
    height: 28px;
    background-image: url("/assets/img/qqkj.png");

    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
  }

  .weixinall {
    position: relative;
    display: flex;
    justify-content: center;
    .weixin {
      display: block;
      width: 28px;
      height: 28px;
      background-image: url("/assets/img/wx.png");
      background-size: cover;
      background-repeat: no-repeat;
      background-position: 50% 50%;
    }
    .weixincode {
      position: absolute;
      left: -60px;
      z-index: 1000 !important;
    }
  }
}

.qrcode-visible {
  opacity: 1 !important;
  pointer-events: auto;
}
</style>

效果
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2323244.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

STM32F103_LL库+寄存器学习笔记07 - 串口接收缓冲区非空中断

导言 上一章节《STM32F103_LL库寄存器学习笔记06 - 梳理串口与串行发送“Hello,World"》梳理完USART的基本设置与发送字符串“Hello,World"&#xff0c;接着梳理接收缓冲区非空中断。 实用的串口接收程序都会使用中断方式&#xff0c;不会使用轮询方式。最主要的原因…

生物中心论

Robert Lanza的“生物中心论”&#xff08;Biocentrism&#xff09;是一种以生命和意识为核心的宇宙观&#xff0c;试图颠覆传统科学对时间、空间和物质的理解。 一、核心观点 意识创造宇宙 生物中心论认为&#xff0c;宇宙的存在依赖于观察者的意识。传统科学将宇宙视为独立实…

Spring AOP:面向切面编程的探索之旅

目录 1. AOP 2. Spring AOP 快速入门 2.1 引入 Spring AOP 依赖 2.2 Spring AOP 简单使用 3. Spring AOP 核心概念 3.1 切点 3.1.1 Pointcut 定义切点 3.1.2 切点表达式 3.1.2.1 execution 表达式 3.1.2.2 annotation 表达式 3.2 连接点 3.3 通知(Advice) 3.3.1 通…

使用QT画带有透明效果的图

分辨率&#xff1a;24X24 最大圆 代码: #include <QApplication> #include <QImage> #include <QPainter>int main(int argc, char *argv[]) {QImage image(QSize(24,24),QImage::Format_ARGB32);image.fill(QColor(0,0,0,0));QPainter paint(&image);…

RocketMQ可视化工具使用 - Dashboard(保姆级教程)

1、github拉取代码&#xff0c;地址&#xff1a; https://github.com/apache/rocketmq-dashboard 2、指定Program arguments&#xff0c;本地启动工程 勾上这个Program arguments&#xff0c;会出现多一个对应的框 写入参数 --server.port1280 --rocketmq.config.namesrvAddr…

用Unity实现UDP客户端同步通信

制作UDPNetMgr网络管理模块 这段代码定义了一个名为UDPNetMgr的 Unity 脚本类&#xff0c;用于管理 UDP 网络通信&#xff0c;它作为单例存在&#xff0c;在Awake方法中创建收发消息的线程&#xff0c;Update方法处理接收到的消息&#xff1b;StartClient方法启动客户端连接&a…

pandoc安装及基础使用

pandoc安装 访问pandoc tags,切换至想要安装的版本&#xff0c;本次安装3.6.4 下载windows版本 下载texlive镜像&#xff0c;将文件转换成pdf需要用到 点开后会进入最近的镜像网站 下载完成后解压iso文件&#xff0c;以管理员身份运行install-tl-windows.bat&#xff…

3.27学习总结 算法题

自己用c语言做的&#xff0c;不尽如意 后面看了题解&#xff0c;用的是c&#xff0c;其中string 变量和字符串拼接感觉比c方便好多&#xff0c;可以用更少的代码实现更好的效果&#xff0c;打算之后去学习c&#xff0c;用c写算法。 递归&#xff0c;不断输入字符&#xff0c;…

案例分享|树莓派媒体播放器,重构商场广告的“黄金三秒”

研究显示&#xff0c;与传统户外广告相比&#xff0c;数字户外广告在消费者心中的记忆率提高了17%&#xff0c;而动态户外广告更是能提升16%的销售业绩&#xff0c;整体广告效率提升了17%。这一显著优势&#xff0c;使得越来越多资源和技术流入数字广告行业。 户外裸眼3D广告 无…

Redisson - 分布式锁和同步器

文章目录 锁&#xff08;Lock&#xff09;公平锁&#xff08;Fair Lock&#xff09;联锁&#xff08;MultiLock&#xff09;红锁&#xff08;RedLock&#xff09; 【已废弃】读写锁&#xff08;ReadWriteLock&#xff09;信号量&#xff08;Semaphore&#xff09;可过期许可信号…

Zustand 状态管理:从入门到实践

Zustand 状态管理&#xff1a;从入门到实践 Zustand 是一个轻量、快速且灵活的 React 状态管理库。它基于 Hooks API&#xff0c;提供了简洁的接口来创建和使用状态&#xff0c;同时易于扩展和优化。本文将通过一个 TODO 应用实例带你快速入门 Zustand&#xff0c;并探讨其核心…

PGP实现简单加密教程

模拟情景&#xff1a; 假设001和002两位同学的电脑上都安装了PGP&#xff0c;现在两人需要进行加密通讯。 一、创建密钥 1.新建密钥&#xff0c;输入名称和邮箱&#xff0c;输入8位口令&#xff0c;根据指示完成。 2.将其添加到主密钥&#xff0c;鼠标右击出现选项。 这里出…

7.8 窗体间传递数据

版权声明&#xff1a;本文为博主原创文章&#xff0c;转载请在显著位置标明本文出处以及作者网名&#xff0c;未经作者允许不得用于商业目的 当项目中有多个窗体时&#xff08;在本节中为两个窗体&#xff1a;Form1和Form2&#xff09;&#xff0c;窗体间传递数据有以下几种方…

【redis】集群 数据分片算法:哈希求余、一致性哈希、哈希槽分区算法

文章目录 什么是集群数据分片算法哈希求余分片搬运 一致性哈希扩容 哈希槽分区算法扩容相关问题 什么是集群 广义的集群&#xff0c;只要你是多个机器&#xff0c;构成了分布式系统&#xff0c;都可以称为是一个“集群” 前面的“主从结构”和“哨兵模式”可以称为是“广义的…

基于Springboot的网上订餐系统 【源码】+【PPT】+【开题报告】+【论文】

网上订餐系统是一个基于Java语言和Spring Boot框架开发的Web应用&#xff0c;旨在为用户和管理员提供一个便捷的订餐平台。该系统通过简化餐饮订购和管理流程&#xff0c;为用户提供快速、高效的在线订餐体验&#xff0c;同时也为管理员提供完善的后台管理功能&#xff0c;帮助…

【redis】集群 如何搭建集群详解

文章目录 集群搭建1. 创建目录和配置2. 编写 docker-compose.yml完整配置文件 3. 启动容器4. 构建集群超时 集群搭建 基于 docker 在我们云服务器上搭建出一个 redis 集群出来 当前节点&#xff0c;主要是因为我们只有一个云服务器&#xff0c;搞分布式系统&#xff0c;就比较…

飞牛NAS本地部署小雅Alist结合内网穿透实现跨地域远程在线访问观影

文章目录 前言1. VMware安装飞牛云&#xff08;fnOS&#xff09;1.1 打开VMware创建虚拟机1.3 初始化系统 2. 飞牛云搭建小雅Alist3. 公网远程访问小雅Alist3.1 安装Cpolar内网穿透3.2 创建远程连接公网地址 4. 固定Alist小雅公网地址 前言 嘿&#xff0c;小伙伴们&#xff0c…

Linux版本控制器Git【Ubuntu系统】

文章目录 **前言**一、版本控制器二、Git 简史三、安装 Git四、 在 Gitee/Github 创建项目五、三板斧1、git add 命令2、git commit 命令3、git push 命令 六、其他1、git pull 命令2、git log 命令3、git reflog 命令4、git stash 命令 七、.ignore 文件1、为什么使用 .gitign…

browser-use 库网页元素点击测试工具

目录 代码代码解释输出结果 代码 import asyncio import jsonfrom browser_use.browser.browser import Browser, BrowserConfig from browser_use.dom.views import DOMBaseNode, DOMElementNode, DOMTextNode from browser_use.utils import time_execution_syncclass Eleme…

解决GitLab无法拉取项目

1、验证 SSH 密钥是否已生成 ls ~/.ssh/ 如果看到类似 id_rsa 和 id_rsa.pub 的文件&#xff0c;则说明已存在 SSH 密钥。 避免麻烦&#xff0c;铲掉重来最方便。 如果没有&#xff0c;请生成新的 SSH 密钥&#xff1a; ssh-keygen -t rsa -b 4096 -C "your_emailexam…