🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

uve-utils

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uve-utils

通用工具库

latest
npmnpm
Version
1.1.26
Version published
Weekly downloads
4
33.33%
Maintainers
1
Weekly downloads
 
Created
Source

uve-utils

一个功能丰富的通用工具库,专为现代 Web 开发和政务端(浙政钉、浙里办)应用设计。

特性

  • 🚀 单文件打包:基于 Vite 构建,输出精简的 ESM 和 CJS 单文件。
  • 🛠️ 通用工具:包含正则表达式校验、日期格式化、数据类型判断、金额格式化等常用工具。
  • 🔒 加密算法:集成 AES 以及国密算法(SM2, SM3, SM4)。
  • 🏛️ 政务端支持:专门针对浙政钉浙里办环境的初始化、埋点和授权封装。
  • 📦 开箱即用:支持 TypeScript,提供完整的类型定义。

安装

npm install uve-utils
# 或者
yarn add uve-utils

快速使用

通用工具

import { utils } from 'uve-utils';

// 手机号校验
utils.checkPhoneNumber('13800138000'); // true

// 身份证校验
utils.checkIdentityId('330101199001011234');

// 日期格式化
utils.dateFormat(new Date(), 'YYYY-MM-DD HH:mm:ss');

// AES 加密
const encrypted = utils.encryptAes('Hello World');
const decrypted = utils.decryptAes(encrypted);

浙政钉/浙里办初始化

import { initZhezhengding, initZheliban } from 'uve-utils';

// 初始化浙政钉配置
initZhezhengding({
  enable: true,
  bid: 'your_bid',
  signkey: 'your_signkey',
  sapp_id: 'your_sapp_id',
  sapp_name: 'your_sapp_name'
});

// 初始化浙里办配置
initZheliban({
  enable: true,
  appTitle: '应用名称',
  bid: 'your_bid'
});

API 说明

utils (常用工具)

方法说明
checkPhoneNumber(phone)验证手机号码格式
checkIdentityId(id)验证身份证号码合法性
isNumber(val)判断是否为纯数字
numberChinese(num)数字转中文大写
dateFormat(date, format)日期格式化
getOsType()获取系统类型 (1:IOS, 2:Android, 3:Win, 4:Mac)
getBrowserType()获取浏览器环境 (浙里办, 浙政钉, 微信等)
hideString(str, start, len)字符串脱敏
uuid()生成唯一标识
moneyFormat(num)金额千分位格式化
encryptAes / decryptAesAES 加解密
encryptSm2 / decryptSm2国密 SM2 加解密
encryptSm4 / decryptSm4国密 SM4 加解密

浙政钉埋点与授权

方法说明
createBaseBurialPointZzd(config)基础埋点
createUserInfoBurialPointZzd(config)用户信息埋点
getAuthCodeZzd()获取免登授权码 (Promise)

浙里办埋点

方法说明
zwlogGlobalZlb(config)浙里办全局日志埋点

开发与构建

项目采用 Vite 进行构建,输出单文件 bundle。

# 安装依赖
yarn install

# 构建项目
yarn build

构建产物位于 dist 目录:

  • index.js: ESM 模块
  • index.cjs: CommonJS 模块
  • index.d.ts: 类型声明文件
  • zzd.html/zlb.html: 预置资产文件

License

ISC

FAQs

Package last updated on 12 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts