oddmisc 1.1.2 → 1.1.3
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 +123 -132
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,133 +1,124 @@
|
|
|
1
|
-
# oddmisc
|
|
2
|
-
|
|
3
|
-
杂七杂八奇怪小工具 npm 包
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/oddmisc)
|
|
6
|
-
[](https://github.com/yCENzh/oddmisc/blob/main/LICENSE)
|
|
7
|
-
|
|
8
|
-
## 安装
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install oddmisc
|
|
12
|
-
# 或
|
|
13
|
-
pnpm add oddmisc
|
|
14
|
-
# 或
|
|
15
|
-
yarn add oddmisc
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## 快速开始
|
|
19
|
-
|
|
20
|
-
### 基本使用
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
import { createUmamiClient } from 'oddmisc';
|
|
24
|
-
|
|
25
|
-
// 创建客户端
|
|
26
|
-
const client = createUmamiClient({
|
|
27
|
-
shareUrl: 'https://your-umami-instance.com/share/your-share-id'
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// 获取页面访问统计
|
|
31
|
-
const stats = await client.getPageStats('/about');
|
|
32
|
-
console.log(`页面浏览量: ${stats.pageviews}, 访客数: ${stats.visitors}`);
|
|
33
|
-
|
|
34
|
-
// 获取网站整体统计
|
|
35
|
-
const siteStats = await client.getSiteStats();
|
|
36
|
-
console.log(`总浏览量: ${siteStats.pageviews}, 总访客数: ${siteStats.visitors}`);
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Astro 集成
|
|
40
|
-
|
|
41
|
-
在 `astro.config.mjs` 中配置:
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
import { defineConfig } from 'astro/config';
|
|
45
|
-
import { umami } from 'oddmisc';
|
|
46
|
-
|
|
47
|
-
export default defineConfig({
|
|
48
|
-
integrations: [
|
|
49
|
-
umami({
|
|
50
|
-
shareUrl: 'https://your-umami-instance.com/share/your-share-id'
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
##
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
MIT © yCENzh
|
|
125
|
-
|
|
126
|
-
## 贡献
|
|
127
|
-
|
|
128
|
-
欢迎提交 Issue 和 Pull Request!
|
|
129
|
-
|
|
130
|
-
## 相关链接
|
|
131
|
-
|
|
132
|
-
- [Umami 官网](https://umami.is/)
|
|
1
|
+
# oddmisc
|
|
2
|
+
|
|
3
|
+
杂七杂八奇怪小工具 npm 包
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/oddmisc)
|
|
6
|
+
[](https://github.com/yCENzh/oddmisc/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
## 安装
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install oddmisc
|
|
12
|
+
# 或
|
|
13
|
+
pnpm add oddmisc
|
|
14
|
+
# 或
|
|
15
|
+
yarn add oddmisc
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 快速开始
|
|
19
|
+
|
|
20
|
+
### 基本使用
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
import { createUmamiClient } from 'oddmisc';
|
|
24
|
+
|
|
25
|
+
// 创建客户端
|
|
26
|
+
const client = createUmamiClient({
|
|
27
|
+
shareUrl: 'https://your-umami-instance.com/share/your-share-id'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// 获取页面访问统计
|
|
31
|
+
const stats = await client.getPageStats('/about');
|
|
32
|
+
console.log(`页面浏览量: ${stats.pageviews}, 访客数: ${stats.visitors}, 访问次数: ${stats.visits}`);
|
|
33
|
+
|
|
34
|
+
// 获取网站整体统计
|
|
35
|
+
const siteStats = await client.getSiteStats();
|
|
36
|
+
console.log(`总浏览量: ${siteStats.pageviews}, 总访客数: ${siteStats.visitors}, 总访问次数: ${siteStats.visits}`);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Astro 集成
|
|
40
|
+
|
|
41
|
+
在 `astro.config.mjs` 中配置:
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { defineConfig } from 'astro/config';
|
|
45
|
+
import { umami } from 'oddmisc';
|
|
46
|
+
|
|
47
|
+
export default defineConfig({
|
|
48
|
+
integrations: [
|
|
49
|
+
umami({
|
|
50
|
+
shareUrl: 'https://your-umami-instance.com/share/your-share-id'
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
然后在前端代码中使用:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
// 全局可用
|
|
60
|
+
const stats = await window.oddmisc.getStats('/some-page');
|
|
61
|
+
const siteStats = await window.oddmisc.getSiteStats();
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## API 参考
|
|
65
|
+
|
|
66
|
+
### UmamiClient
|
|
67
|
+
|
|
68
|
+
#### 构造函数
|
|
69
|
+
```javascript
|
|
70
|
+
const client = createUmamiClient(config);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### 配置选项
|
|
74
|
+
```javascript
|
|
75
|
+
const config = {
|
|
76
|
+
shareUrl: 'https://umami.example.com/share/abc123' // 必需
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### 方法
|
|
81
|
+
|
|
82
|
+
- `getPageStats(path)` - 获取指定页面统计
|
|
83
|
+
- `getPageStatsByUrl(url)` - 通过 URL 获取页面统计
|
|
84
|
+
- `getSiteStats()` - 获取网站整体统计
|
|
85
|
+
- `clearCache()` - 清除缓存
|
|
86
|
+
- `getConfig()` - 获取当前配置
|
|
87
|
+
- `updateConfig(newConfig)` - 更新配置
|
|
88
|
+
|
|
89
|
+
### Astro 集成
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
umami(options: UmamiIntegrationOptions)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
选项:
|
|
96
|
+
```javascript
|
|
97
|
+
interface UmamiIntegrationOptions {
|
|
98
|
+
shareUrl: string; // Umami 分享链接
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 支持的 Umami URL 格式
|
|
103
|
+
|
|
104
|
+
- `https://umami.example.com/share/abc123`
|
|
105
|
+
- `https://cloud.umami.is/analytics/us/share/abc123`
|
|
106
|
+
- `https://umami.example.com/analytics/share/abc123`
|
|
107
|
+
|
|
108
|
+
## 浏览器兼容性
|
|
109
|
+
|
|
110
|
+
- 现代浏览器(Chrome 60+, Firefox 60+, Safari 12+)
|
|
111
|
+
- 支持 localStorage 的环境
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT © yCENzh
|
|
116
|
+
|
|
117
|
+
## 贡献
|
|
118
|
+
|
|
119
|
+
欢迎提交 Issue 和 Pull Request!
|
|
120
|
+
|
|
121
|
+
## 相关链接
|
|
122
|
+
|
|
123
|
+
- [Umami 官网](https://umami.is/)
|
|
133
124
|
- [GitHub 仓库](https://github.com/yCENzh/oddmisc)
|