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

jhsc-pro-common

v1.0.33

Published

jhsc-pro-common

Readme

jhsc-pro-common

jhsc-pro-common

jhsc-pro-common 基于 jhsc-ui 进行封装的业务功能及组件,主要包含通用的页面局部组件,导入导出功能,hooks 封装,http 请求封装等。

Installation

Using npm:

npm install jhsc-pro-common --save

or using yarn:

yarn add jhsc-pro-common

or using pnpm:

pnpm add jhsc-pro-common

Usage

消息处理器配置(重要)

为了避免循环依赖,HTTP 模块使用可配置的消息处理器。在使用 HTTP 功能前,建议先配置消息处理器:

// main.ts
import { setMessageHandler, setNotificationHandler } from 'jhsc-pro-common';

// 方案1: 使用 jhsc-ui (推荐)
import { JMessage, JNotification } from 'jhsc-ui';

setMessageHandler({
  error: (message) => JMessage.error(message),
  success: (message) => JMessage.success(message),
  warning: (message) => JMessage.warning(message),
  info: (message) => JMessage.info(message),
});

setNotificationHandler({
  error: (message, title) => JNotification.error(message, title),
  success: (message, title) => JNotification.success(message, title),
  warning: (message, title) => JNotification.warning(message, title),
  info: (message, title) => JNotification.info(message, title),
});

// 方案2: 不配置则使用内置弹窗
// 默认会使用自定义的弹窗组件显示消息

HTTP 请求

import { request, httpGet, httpPost } from 'jhsc-pro-common';

// 使用 axios
const response = await httpGet('/api/users');
const result = await httpPost('/api/users', { name: 'John' });

// 使用 fetch
const response = await request({
  url: '/api/users',
  method: 'GET',
  useFetch: true
});

认证工具

import { getAccessToken, setAccessToken, clearToken } from 'jhsc-pro-common';

// 获取访问令牌
const token = getAccessToken();

// 设置访问令牌
setAccessToken('your-token');

// 清除所有令牌
clearToken();

主题工具

import { generateThemeColors, toggleDarkMode } from 'jhsc-pro-common';

// 生成主题颜色
const colors = generateThemeColors('#409EFF');

// 切换暗黑模式
toggleDarkMode(true);

API Reference

HTTP 模块

  • request(config) - 通用请求函数
  • httpGet(url, params?, config?) - GET 请求
  • httpPost(url, data?, config?) - POST 请求
  • httpPut(url, data?, config?) - PUT 请求
  • httpDelete(url, params?, config?) - DELETE 请求
  • setMessageHandler(handler) - 设置消息处理器
  • setNotificationHandler(handler) - 设置通知处理器

认证模块

  • getAccessToken() - 获取访问令牌
  • setAccessToken(token) - 设置访问令牌
  • getRefreshToken() - 获取刷新令牌
  • setRefreshToken(token) - 设置刷新令牌
  • clearToken() - 清除所有令牌
  • getCurrentUser() - 获取当前用户
  • setCurrentUser(user) - 设置当前用户

主题模块

  • generateThemeColors(primary) - 生成主题颜色
  • applyTheme(colors) - 应用主题
  • toggleDarkMode(isDark) - 切换暗黑模式
  • toggleSidebarColor(isBlue) - 切换侧边栏颜色

注意事项

  1. 消息处理器配置:建议在应用启动时配置消息处理器,否则 HTTP 错误会使用内置弹窗显示
  2. 避免循环依赖:本库不再直接依赖 jhsc-ui,避免循环依赖问题
  3. 灵活性:可以使用任何 UI 库的消息组件,不限于 jhsc-ui
  4. 内置弹窗:默认提供美观的自定义弹窗,支持多种消息类型和动画效果