npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mb-readterm

v1.0.3

Published

通用条款阅读组件 - Vue 3

Downloads

18

Readme

mb-readterm 通用条款阅读组件

简介

mb-readterm 是一个 Vue 3 条款阅读弹窗组件。

只需要传入后端返回的 productInfo(包含 prompt_section_list / qa_list / file_list 等),组件会自动:

  • 渲染条款 tab(左侧竖向导航 + 右侧内容区)
  • 支持滚动到底部校验
  • 支持倒计时等待(waiting_time
  • 支持条款 PDF 文件列表(必读/非必读)

安装

npm / pnpm

pnpm add mb-readterm

本地包(联调)

pnpm add file:../../mb-npm/mb-readterm

基础用法(Vue 3)

<template>
  <ReadTerm
    v-model="visible"
    :product-info="productInfo"
    :data-provider="dataProvider"
    @complete="onComplete"
    @close="visible = false"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ReadTerm } from 'mb-readterm'

const visible = ref(false)
const productInfo = ref<any>(null)

const dataProvider = {
  getInsuranceInfo: () => {
    return {
      // 这里返回你页面当前选项的 key/value,用于文件 condition 过滤、文本替换等
      period: '1d',
      plan_index: 0,
    }
  }
}

const onComplete = () => {
  // 用户完成阅读(满足规则后点“下一条/完成”)
}
</script>

Props

v-model

  • v-model / modelValue: boolean,控制弹窗显示/隐藏

productInfo

  • productInfo: 条款数据对象(后端返回)

dataProvider(可选)

用于提供动态数据:

  • getInsuranceInfo?: () => Record<string, any> | Promise<Record<string, any>>

Events

  • update:modelValue(visible: boolean)
  • complete() 阅读流程完成
  • close() 点击关闭
  • tab-change(index: number, key: string)
  • scroll-end(tabKey: string)
  • countdown-end(tabKey: string)

数据结构(后端字段)

核心字段:

  • prompt_section_list: tab 列表(顺序即展示顺序)
  • qa_list: 常见问题(Q/A)
  • file_list: 条款文件列表

prompt_section_list 示例

[
  { "key": "exempt_notice", "title": "责任免除" },
  { "key": "apply_notice", "title": "投保须知" },
  { "key": "claim_notice", "title": "理赔指引" },
  { "key": "qa_list", "title": "常见问题" },
  { "key": "file_list", "title": "条款文件", "type": "file_list" }
]

qa_list 示例

[
  { "q": "什么是意外伤害?", "a": "..." },
  { "q": "保单如何验真?", "a": "..." }
]

file_list 示例

[
  {
    "display_name": "保险条款",
    "file_name": "xxx.pdf",
    "file_url": "",
    "must_read": true,
    "condition": { "period": ["1d", "2d"] }
  }
]

文件 URL 规则

打开 PDF 时,URL 解析规则为:

  1. file.file_url(优先)
  2. file.url
  3. productInfo.resource_path + file.file_name

如果 file.file_name 本身是以 /http 开头,则会直接使用。

条款文件过滤规则

组件会自动过滤以下文件(不显示):

  • product_info_only
  • sign_only
  • sz_only

并支持 condition 联动过滤(依赖 dataProvider.getInsuranceInfo() 返回的 key/value)。

注意事项

  • 组件构建产物会自动注入自身 CSS,业务项目无需额外手动引入样式。
  • prompt_section_list 建议始终包含 file_list,文件明细放在 productInfo.file_list