@gm-mobile/c-cookie 3.12.12-beta.0 → 3.12.13
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 +78 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @gm-mobile/c-cookie
|
|
2
|
+
|
|
3
|
+
## 简介
|
|
4
|
+
Cookie 工具包 - 跨平台的 Cookie 读写工具,封装了 `js-cookie` 库。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @gm-mobile/c-cookie
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### peerDependencies
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"js-cookie": "^2.2.1",
|
|
17
|
+
"weapp-cookie": "^1.4.6"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 使用
|
|
22
|
+
|
|
23
|
+
### 快速开始
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
import { Cookie } from '@gm-mobile/c-cookie'
|
|
27
|
+
|
|
28
|
+
// 设置 Cookie
|
|
29
|
+
Cookie.set('name', 'value')
|
|
30
|
+
|
|
31
|
+
// 获取 Cookie
|
|
32
|
+
const value = Cookie.get('name')
|
|
33
|
+
|
|
34
|
+
// 删除 Cookie
|
|
35
|
+
Cookie.remove('name')
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### 导出列表
|
|
41
|
+
|
|
42
|
+
| 导出项 | 类型 | 说明 |
|
|
43
|
+
|--------|------|------|
|
|
44
|
+
| `Cookie` | 对象 | Cookie 操作工具 |
|
|
45
|
+
|
|
46
|
+
### Cookie 方法
|
|
47
|
+
|
|
48
|
+
| 方法 | 说明 | 参数 | 返回值 |
|
|
49
|
+
|------|------|------|--------|
|
|
50
|
+
| `Cookie.get(key)` | 获取 Cookie 值 | `key: string` | `string \| undefined` |
|
|
51
|
+
| `Cookie.set(key, value)` | 设置 Cookie 值 | `key: string, value: string \| object` | - |
|
|
52
|
+
| `Cookie.remove(key)` | 删除 Cookie | `key: string` | - |
|
|
53
|
+
|
|
54
|
+
## 示例
|
|
55
|
+
|
|
56
|
+
### 基础用法
|
|
57
|
+
|
|
58
|
+
```jsx
|
|
59
|
+
import { Cookie } from '@gm-mobile/c-cookie'
|
|
60
|
+
|
|
61
|
+
// 设置
|
|
62
|
+
Cookie.set('token', 'abc123')
|
|
63
|
+
Cookie.set('user', JSON.stringify({ name: '张三' }))
|
|
64
|
+
|
|
65
|
+
// 获取
|
|
66
|
+
const token = Cookie.get('token')
|
|
67
|
+
|
|
68
|
+
// 删除
|
|
69
|
+
Cookie.remove('token')
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 注意事项
|
|
73
|
+
- Web 端使用 `js-cookie` 实现
|
|
74
|
+
- 小程序端使用 `weapp-cookie` 实现
|
|
75
|
+
- 需要根据运行环境安装对应的 peerDependencies
|
|
76
|
+
|
|
77
|
+
## 相关包
|
|
78
|
+
- [@gm-mobile/c-tool](../c-tool) - 工具函数库
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-mobile/c-cookie",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.13",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "liyatang <liyatang@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gm-mobile#readme",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"weapp-cookie": "^1.4.6"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@gm-mobile/c-tool": "^3.12.
|
|
28
|
+
"@gm-mobile/c-tool": "^3.12.13"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f1807b01b33bb8ee331b6c713d52d85fda524bf7"
|
|
31
31
|
}
|