@jnrs/shared
v1.1.34
Published
巨能(JNRS)前端工程化开发,通用工具包,与框架无关的纯逻辑、类型、常量、工具函数,完全不依赖任何 UI 框架或运行时环境。
Readme
@jnrs/shared
✨ 介绍
巨能(JNRS)前端工程化开发通用工具库,包含纯逻辑、类型、常量、工具函数等,不依赖任何 UI 框架。
功能模块
| 模块 | 路径 | 说明 |
| -------- | --------------------------- | ------------------------------------------------------------------------------------------------------ |
| 主模块 | @jnrs/shared | 类型定义(IFullResponse, IBlobItem 等)+ 工具函数(objectMatchAssign, dateFormatsToObject 等) |
| 网络请求 | @jnrs/shared/request | createAxiosInstance — 封装拦截器、错误处理、权限校验 |
| 校验器 | @jnrs/shared | 30+ 表单校验函数(verifyNumberGtZero, verifyMobile 等) |
| 日期处理 | @jnrs/shared / date-fns | 日期格式化(formatDateTime)+ date-fns 全量导出 |
| Lodash | @jnrs/shared/lodash | lodash-es 全量导出(debounce, cloneDeep 等) |
| UUID | @jnrs/shared/uuid | uuidv1, uuidv4, uuidv5 |
| 事件总线 | @jnrs/shared/mitt | mitt 事件总线 |
| 国际化 | @jnrs/shared/locales | changeLocales 语言切换 |
| 样式 | @jnrs/shared/styles | CSS 主题变量(theme.scss) |
🎨 主题变量
引入 theme.scss 后可使用以下 CSS 变量。--jnrs-color-primary 支持运行时动态修改。
| 类别 | 基础变量 | 衍生变量(level 取值:005/01/03/05/07/09) |
| ------ | --------------------------- | ---------------------------------------------------- |
| 品牌色 | --jnrs-color-primary | --jnrs-color-primary-{level} / -fade{level} |
| 字体色 | --jnrs-font-primary | --jnrs-font-primary-{level} / -fade{level} |
| 卡片色 | --jnrs-card-primary | --jnrs-card-primary-{level} / -fade{level} |
| 背景色 | --jnrs-background-primary | --jnrs-background-primary-{level} / -fade{level} |
| 状态色 | 变量 |
| ------ | ---------------------- |
| 成功 | --jnrs-color-success |
| 错误 | --jnrs-color-error |
| 警告 | --jnrs-color-warning |
| 特殊变量 | 说明 |
| --------------------------------- | ------------------------- |
| --jnrs-background-head | 表头背景色 |
| --jnrs-color-primary-light | 品牌色浅色变体(l + 0.1) |
| --jnrs-color-primary-dark | 品牌色深色变体(l - 0.1) |
| --jnrs-background-primary-light | 背景色浅色变体(l + 0.1) |
衍生变量说明:
-{level}系列:透明度叠加(如-005= 5% 透明度),适合单色模式使用-fade{level}系列:浅色/深色自适应混合,通过--jnrs-fade-anchor-l锚点自动适配主题模式- level 取值范围:
005(5%) |01(10%) |03(30%) |05(50%) |07(70%) |09(90%)
💻 技术栈
TypeScript
🧩 安装教程
pnpm add @jnrs/shared🔍 使用示例
import '@jnrs/shared/styles/theme.scss'
import type { ILocale, IFullResponse, IBusinessRequest } from '@jnrs/shared'
import { createAxiosInstance } from '@jnrs/shared/request'
import { objectMatchAssign, dateFormatsToObject, verifyNumberGtZero } from '@jnrs/shared'
import { Fullscreen, downloadByBlob } from '@jnrs/shared'
import { debounce } from '@jnrs/shared/lodash'
import { uuidv4 } from '@jnrs/shared/uuid'📋 API
详细文档请查看 AGENTS.md
📌 发版日志
详细文档请查看 CHANGELOG.md