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

lup-cache

v1.0.5

Published

获取共享缓存数据的工具包

Readme

lup-cache

获取共享缓存数据的工具包,用于在不同系统间共享用户信息、租户ID、权限信息等缓存数据。

安装

npm install lup-cache
# 或
yarn add lup-cache
# 或
pnpm install lup-cache

发布npm

npm run build

#添加npm用户
npm adduser --registry=https://registry.npmjs.org/

#检查当前登录用户
npm whoami --registry=https://registry.npmjs.org/

#发布
npm publish --registry=https://registry.npmjs.org/

使用场景

场景1:如果中台切换项目,子系统请求接口如果需要传租户id这种从localStorage中获取的参数,则需要使用本工具包;(子系统不用自己单独保存一份租户id这种数据)

使用方法

// 导入单个方法
import { getUserInfo, getTenantId } from 'lup-cache';

// 或导入整个包
import lupCache from 'lup-cache';

// 获取用户信息
const userInfo = getUserInfo();
// 或
const userInfo = lupCache.getUserInfo();

// 获取租户ID
const tenantId = getTenantId();

// 检查用户是否有特定权限
if (lupCache.hasPermission('system:user:add')) {
  // 有权限,执行相应操作
}

API

用户信息

  • getUserInfo(): 获取用户完整信息
  • getUsername(): 获取用户名
  • getUserId(): 获取用户ID
  • getUserAvatar(): 获取用户头像URL
  • getToken(): 获取用户token
  • isUserLoggedIn(): 检查用户是否已登录

租户信息

  • getTenantId(): 获取当前租户ID

权限信息

  • getPermissions(): 获取权限列表
  • hasPermission(permission): 检查是否有特定权限

项目信息

  • getProjects(): 获取项目信息列表

角色信息

  • getRoles(): 获取角色信息
  • hasRole(role): 检查是否有特定角色

语言设置

  • getCurrentLanguage(): 获取当前语言设置

注意事项

  • 本工具包依赖于浏览器的localStorage,仅适用于浏览器环境
  • 确保应用中已正确设置了相关缓存数据
  • 默认从import.meta.env.VITE_GLOB_APP_SHORT_NAME或全局变量__GLOBAL_ENV__.VITE_GLOB_APP_SHORT_NAME获取应用名称标识

许可证

MIT