@jnrs/shared 1.1.9 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,8 +29,6 @@ import { createAxiosInstance } from '@jnrs/shared/request'
29
29
  import { Fullscreen } from '@jnrs/shared'
30
30
  import { debounce } from '@jnrs/shared/lodash'
31
31
  import { uuidv4 } from '@jnrs/shared/uuid'
32
- import { uuidv4 } from '@jnrs/shared/uuid'
33
- ...
34
32
  ```
35
33
 
36
34
  ## 📋 API
@@ -61,15 +59,78 @@ import { uuidv4 } from '@jnrs/shared/uuid'
61
59
  #### @jnrs/shared/request 模块
62
60
  接口
63
61
  - Options
62
+
63
+ | 属性名 | 类型 | 说明 |
64
+ |--------|------|------|
65
+ | baseURL | `string` | 请求的根路径 |
66
+ | timeout | `number` | 请求超时时间(ms) |
67
+ | showErrorMsg | `boolean` | 是否显示错误信息 |
68
+ | headers | `Record<string, string>` | 请求头 |
69
+
70
+
64
71
  - MessageOptions
72
+
73
+ | 属性名 | 类型 | 说明 |
74
+ |--------|------|------|
75
+ | message | `string` | 消息内容 |
76
+ | type | `'success' \| 'error' \| 'warning'` | 消息类型 |
77
+ | grouping | `boolean` | 是否开启消息分组 |
78
+ | duration | `number` | 消息显示持续时间(ms) |
79
+ | showClose | `boolean` | 是否显示关闭按钮 |
80
+
81
+
65
82
  - CreateRequestOptions
66
- - BusinessRequest
67
- - BusinessResponse
83
+
84
+ | 属性名 | 类型 | 说明 |
85
+ |--------|------|------|
86
+ | options | `Options` | 请求配置项 |
87
+ | responseMap | `Record<number, string>` | HTTP 状态码与提示信息的映射 |
88
+ | handleMessageFn | `(opts: MessageOptions) => void` | 自定义消息处理函数 |
89
+ | handleGetTokenFn | `() => string \| null \| undefined` | 获取 token 的函数 |
90
+ | handleNoAuthFn | `() => void` | 未授权时的处理函数 |
91
+
92
+
93
+ - BusinessRequest(泛型 D 默认为 Data)
94
+
95
+ | 属性名 | 类型 | 说明 |
96
+ |--------|------|------|
97
+ | url | `string` | 请求地址 |
98
+ | mockUrl | `string` | MOCK 请求地址 |
99
+ | method | `'get' \| 'post' \| 'put' \| 'delete' \| 'patch' \| 'head' \| 'options'` | 请求方法 |
100
+ | headers | `Record<string, string>` | 请求头 |
101
+ | params | `Record<string, unknown>` | URL 查询参数 |
102
+ | data | `D` | 请求体数据 |
103
+ | showErrorMsg | `boolean` | 是否显示错误信息 |
104
+ | noAuth | `boolean` | 是否跳过授权验证 |
105
+ | responseType | `'json' \| 'blob' \| 'arraybuffer' \| 'text' \| 'stream'` | 响应数据类型 |
106
+
107
+
108
+ - BusinessResponse(泛型 T 默认为 unknown)
109
+
110
+ | 属性名 | 类型 | 说明 |
111
+ |--------|------|------|
112
+ | code | `number` | 业务状态码 |
113
+ | msg | `string` | 提示信息 |
114
+ | data | `T` | 业务数据 |
115
+
116
+
68
117
 
69
118
  函数
70
119
  - createAxiosInstance
120
+ ```typescript
121
+ /**
122
+ * 创建带默认配置的 axios 实例(已将副作用抽离为可配置项函数)
123
+ * @param options - 实例的配置项
124
+ * @param responseMap - 响应代码映射表
125
+ * @param handleMessageFn - 提示信息函数
126
+ * @param handleGetTokenFn - 获取 token 函数
127
+ * @param handleNoAuthFn - 登录失败处理函数
128
+ * @returns axiosInstance
129
+ */
130
+ ```
71
131
 
72
132
 
133
+ #### @jnrs/shared/date-fns 模块
73
134
  #### @jnrs/shared/lodash 模块
74
135
  #### @jnrs/shared/uuid 模块
75
136
  #### @jnrs/shared/mitt 模块
@@ -48,11 +48,13 @@
48
48
  /* 主题样式衍生 */
49
49
 
50
50
  // 字体
51
+ --jnrs-font-primary-01: oklch(from var(--jnrs-font-primary) l c h / 0.1);
51
52
  --jnrs-font-primary-03: oklch(from var(--jnrs-font-primary) l c h / 0.3);
52
53
  --jnrs-font-primary-06: oklch(from var(--jnrs-font-primary) l c h / 0.6);
53
54
 
54
55
  // 背景
55
56
  --jnrs-card-primary-03: oklch(from var(--jnrs-background-primary) l c h / 0.3);
57
+ --jnrs-card-primary-06: oklch(from var(--jnrs-background-primary) l c h / 0.6);
56
58
  --jnrs-background-primary-06: oklch(from var(--jnrs-background-primary) l c h / 0.6);
57
59
  --jnrs-background-primary-light: oklch(from var(--jnrs-background-primary) calc(l + 0.1) c h);
58
60
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@jnrs/shared",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "巨能前端工程化开发,通用工具包,与框架无关的纯逻辑、类型、常量、工具函数,完全不依赖任何 UI 框架或运行时环境。",
5
5
  "keywords": [
6
6
  "jnrs",
7
7
  "shared"
8
8
  ],
9
- "author": "Talia-Tan",
9
+ "author": "talia_tan",
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",