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

pharma-report-visit

v0.0.6

Published

记录项目/模块访问情况,自动执行上报操作

Readme

pharma-report-visit

项目/模块访问上报工具,支持 Vue、React、小程序、等前端项目,内置项目编码校验,自动完成访问上报。(目前后端并未返回是否首次上报等字段,前端在 路由变化时根据路由地址区分项目或模块进行上报,以减轻服务器压力。)

📌 核心功能

  • ✅ 内置所有项目枚举清单,调用时自动校验项目合法性

  • ✅ 可根据项目编码清单以及上报方法,随时进行上报操作

  • ✅ 无框架依赖,支持 Vue、React、小程序、原生 JS

📦 安装

npm 安装

npm install @your-scope/pharma-report-visit --save

yarn 安装

yarn add @your-scope/pharma-report-visit

pnpm 安装

pnpm add @your-scope/pharma-report-visit

🔧 快速使用

所有平台使用流程一致,仅需 2 步:初始化配置 + 调用检测方法。

1. 初始化配置(全局仅需执行一次)

在项目入口文件(如 main.ts、app.tsx、app.js)中初始化,配置后端接口基础地址。

import { initVisit } from '@your-scope/pharma-report-visit';

// 初始化:传入后端接口基础地址
initVisit({
  baseUrl: 'https://api.your-domain.com', // 替换为你的后端接口域名
  token: 'xxxx', // baseUrl依赖的token
});

2. 调用首次访问检测方法

1.在需要检测的页面/组件中调用,传入「项目编码」(需与内置清单一致)。

import { reportVisit, PROJECT_CODE_ENUM } from '@your-scope/pharma-report-visit';

const report = async () => {
  await reportVisit(PROJECT_CODE_ENUM.PHARMA_CLOUD_ENTERPRISE);
};

2.在需要检测的路由上调用,传入「项目编码」和「模块编码」(需与内置清单一致)。

import { reportVisit, PROJECT_CODE_ENUM } from '@your-scope/pharma-report-visit';

if (to.path === '/dataTable') {
  reportVisit(PROJECT_CODE_ENUM.PHARMA_CLOUD_ENTERPRISE, 'dataTable');
}

📋 内置项目清单

插件内置所有项目清单,调用 reportVisit 时会自动校验「项目编码」的合法性,非法编码会抛出明确错误。

内置清单示例(可在 npm 包更新时同步更新):

// 内置项目清单(src/types.ts)
export enum PROJECT_CODE_ENUM {
  /** 药融云企业版 */
  PHARMA_CLOUD_ENTERPRISE = 'Lbpizt0h',
  /** 原料药独立版 */
  API_STANDALONE = 'OKE3SneZ',
  /** BioXfinder */
  BIO_X_FINDER = 'cT6lPVpU',
  /** 医疗器械 */
  MEDICAL_DEVICE = 'sZENYI2y',
  /** 生物项目 */
  BIOLOGICAL_PROJECT = 'BnxeDslJ',
  /** 循证医学 */
  EVIDENCE_BASED_MEDICINE = 'yWPlAP1F',
  /** IntSynth */
  INT_SYNTH = 'LtEolTiV',
  /** 医多维 */
  MEDICAL_DIMENSION = 'ohLtDrZs',
  /** 专利独立版 */
  PATENT_STANDALONE = 'qx2JY9YG',
  /** 投资版 */
  INVESTMENT_EDITION = 'pc7Jwb7l',
  /** 摩熵医药小程序 */
  MOMED_PHARMA_MINI = 'LkdJdgSm',
  /** 院销智策 */
  HOSPITAL_SALES_STRATEGY = 'ngospmbe',
  /** 摩熵药筛小程序 */
  MOMED_DRUG_SCREEN_MINI = 'HFhegElJ',
}

清单导出

可导出内置清单,用于业务中展示项目/模块列表:

import { PROJECT_CODE_ENUM } from '@your-scope/pharma-report-visit';

// 打印所有项目
console.log('所有项目:', PROJECT_CODE_ENUM);

🔍 核心 API 说明

1. initVisit(config)

初始化插件,全局仅需调用一次,传入后端接口基础配置。

参数

|参数名|类型|必填|说明| |---|---|---|---| |config|VisitConfig|是|初始化配置对象,包含 token、baseUrl|

VisitConfig 类型

interface VisitConfig {
  token: string; // 后端接口地址依赖Token(必填)
  baseUrl: string; // 后端接口基础地址(必填)
}

2. reportVisit(project, module)

上报指定项目的访问情况,异步返回结果。

参数

|参数名|类型|必填|说明| |---|---|---|---| |project|string|是|项目编码(需与内置 ALL_PROJECTS 中的 code 一致)| |module|string|否|模块编码(与后端约定后填写)|

返回值

Promise:true = 上报成功,false = 上报失败

📈 版本更新日志

  • v0.0.1:初始版本,支持全平台通用、内置项目模块清单、自动上报标记。