【React】使用react-joyride开发引导功能

【React】使用react-joyride开发引导功能

安装react-joyride

npm i react-joyride

// 引用
import Joyride, { Step } from 'react-joyride'

step数据:

 const steps: Step[] = [
    {
      target: () => uploadRef.current!,
      title: '上传文件',
     content: '点击“上传”按钮,上传会议相关文档,支持.pdf, .docx, .txt格式。',
      placement: 'bottom',
  },
    {
      target: selectAskValueRef.current!,
      title: <div className="text-left text-[16px] font-bold">选择提问范围</div>,
      content: (
        <div className="p-0 text-left text-[14px]">
          在会话栏内输入问题,即可面向整个知识库进行提问。。
        </div>
      ),
      placement: 'bottom',
      disableBeacon: true, // 隐藏小圆点
      spotlightPadding: 0, // 设置圆点大小为0,即隐藏
      styles: {
        tooltip: {
          textAlign: 'left',
          padding: '12px',
        },
        buttonNext: {
          backgroundColor: '#007bff', // 蓝色背景
          color: '#fff', // 白色字体
          border: 'none',
          fontSize: '14px',
          padding: '5px',
        },
        buttonBack: {
          color: '#007bff', // 使 "上一步" 按钮文字为蓝色
          fontSize: '14px',
          padding: '5px',
        },
      },
    },
    {
     target: messageInputRef.current!,
     title: '问答',
     content: '在会话栏内输入问题,回车或点击发送按钮,稍候即可得到答案。',
     placement: 'top',
    },
    {
      target: createNewChatRef.current!,
      title: <div className="text-left text-[16px] font-bold">创建</div>,
      content: (
        <div className="p-0 text-left text-[14px]">
          点击此处,即可创建新会话。
        </div>
      ),
      placement: 'bottom',
      styles: {
        tooltip: {
          textAlign: 'left',
        },
        buttonNext: {
          backgroundColor: '#007bff', // 蓝色背景
          color: '#fff', // 白色字体
          border: 'none',
        },
        buttonBack: {
          color: '#007bff', // 使 "上一步" 按钮文字为蓝色
        },
      },
    },
  ]

下面是使用

 <Joyride
        steps={steps}
        continuous
        scrollToFirstStep
        showSkipButton
        spotlightClicks
        spotlightPadding={0} // 去除高亮区域的填充,使弹窗直接显示
        styles={{
          options: {
            zIndex: 10000,
          },
          spotlight: {
            display: 'none', // 完全隐藏高亮区域
          },
          overlay: {
            backgroundColor: 'rgba(0, 0, 0, 0.5)', // 覆盖背景色
          },
          tooltip: {
            textAlign: 'left', // 弹窗标题和内容靠左对齐
            padding: '20px', // 可选:添加一些内边距让内容看起来更好
          },
        }}
        run={open}
        locale={{
          back: '上一步', // "Back" button text
          close: '结束引导', // "Close" button text when it's the last step
          last: '结束引导', // "Last" button text
          next: '下一步', // "Next" button text
          skip: '跳过', // "Skip" button text
        }}
      />

最后就搞定啦 ~~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郭_昊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值