my-uniapp-tools 3.0.2 → 4.0.1
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 +189 -232
- package/dist/index.d.ts +17 -3
- package/dist/my-uniapp-tools.cjs.js +1 -1
- package/dist/my-uniapp-tools.esm.js +1 -1
- package/dist/navigation/index.d.ts +208 -44
- package/dist/system/index.d.ts +48 -23
- package/package.json +1 -5
package/dist/system/index.d.ts
CHANGED
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 系统信息相关工具函数
|
|
3
|
+
* 核心原则:简单、清晰、零破坏性
|
|
3
4
|
*/
|
|
4
|
-
/**
|
|
5
|
-
* 获取窗口信息(优化版本)
|
|
6
|
-
* @param useCache 是否使用缓存,默认true
|
|
7
|
-
* @returns 窗口信息对象,包含窗口尺寸、像素比等信息
|
|
8
|
-
* @description 调用 uni.getWindowInfo() 获取当前设备的窗口相关信息,支持缓存
|
|
9
|
-
*/
|
|
10
|
-
export declare const useWindowInfo: (useCache?: boolean) => any;
|
|
11
5
|
/**
|
|
12
6
|
* 平台类型定义
|
|
13
7
|
*/
|
|
14
8
|
type PlatformType = "weixin" | "web" | "app" | "alipay" | "h5" | "unknown";
|
|
9
|
+
/**
|
|
10
|
+
* 顶部区域高度度量
|
|
11
|
+
* @description
|
|
12
|
+
* - `statusBarHeight`: 状态栏高度
|
|
13
|
+
* - `navigationBarHeight`: 导航栏高度(不包含状态栏)
|
|
14
|
+
* - `totalTopHeight`: statusBarHeight + navigationBarHeight
|
|
15
|
+
*/
|
|
16
|
+
export interface TopBarMetrics {
|
|
17
|
+
statusBarHeight: number;
|
|
18
|
+
navigationBarHeight: number;
|
|
19
|
+
totalTopHeight: number;
|
|
20
|
+
platform: PlatformType;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 清除系统缓存(横竖屏切换时调用)
|
|
24
|
+
*/
|
|
25
|
+
export declare const clearSystemCache: () => void;
|
|
15
26
|
/**
|
|
16
27
|
* 获取当前运行平台
|
|
17
28
|
* @returns 平台类型字符串 ('weixin' | 'web' | 'app' | 'alipay' | 'h5' | 'unknown')
|
|
18
|
-
* @description
|
|
29
|
+
* @description 通过条件编译判断当前代码运行的平台环境
|
|
19
30
|
*/
|
|
20
31
|
export declare const getPlatform: () => PlatformType;
|
|
32
|
+
/**
|
|
33
|
+
* 获取窗口信息
|
|
34
|
+
* @param useCache 是否使用缓存,默认true
|
|
35
|
+
* @returns 窗口信息对象,包含窗口尺寸、像素比等信息
|
|
36
|
+
* @description 调用 uni.getWindowInfo() 获取当前设备的窗口相关信息,支持缓存
|
|
37
|
+
*/
|
|
38
|
+
export declare const useWindowInfo: (useCache?: boolean) => UniNamespace.GetWindowInfoResult | null;
|
|
21
39
|
/**
|
|
22
40
|
* 获取小程序账户信息
|
|
23
41
|
* @returns 小程序账户信息对象,包含appId、版本、环境等信息
|
|
24
42
|
* @description 调用 uni.getAccountInfoSync() 获取当前小程序的账户相关信息
|
|
25
43
|
*/
|
|
26
44
|
export declare const getCurrentEnv: () => {
|
|
27
|
-
appId: string;
|
|
28
|
-
version: string;
|
|
29
|
-
envVersion: "develop" | "trial" | "release";
|
|
30
|
-
accountInfo: UniApp.AccountInfo;
|
|
31
|
-
} | {
|
|
32
45
|
appId: string;
|
|
33
46
|
version: string;
|
|
34
47
|
envVersion: string;
|
|
35
|
-
accountInfo:
|
|
48
|
+
accountInfo: any;
|
|
36
49
|
};
|
|
37
50
|
/**
|
|
38
51
|
* 检查小程序版本更新
|
|
@@ -48,27 +61,39 @@ export declare const onCheckForUpdate: () => void;
|
|
|
48
61
|
* @returns 状态栏高度(单位:px)
|
|
49
62
|
* @description 获取设备状态栏的高度,用于适配不同设备的状态栏
|
|
50
63
|
*/
|
|
51
|
-
export declare const getStatusBarHeight: () =>
|
|
64
|
+
export declare const getStatusBarHeight: () => number;
|
|
52
65
|
/**
|
|
53
66
|
* 获取菜单按钮边界信息
|
|
54
67
|
* @returns 菜单按钮边界信息对象或null
|
|
55
68
|
* @description 获取小程序右上角菜单按钮的边界信息,仅在小程序平台有效
|
|
56
69
|
*/
|
|
57
|
-
export declare const getMenuButtonBoundingClientRect: () =>
|
|
70
|
+
export declare const getMenuButtonBoundingClientRect: () => UniNamespace.GetMenuButtonBoundingClientRectRes | null;
|
|
58
71
|
/**
|
|
59
|
-
*
|
|
72
|
+
* 获取导航栏高度(不含状态栏)
|
|
60
73
|
* @returns 导航栏高度(单位:px)
|
|
61
|
-
* @description
|
|
74
|
+
* @description 获取导航栏的高度,不包含状态栏高度
|
|
75
|
+
*/
|
|
76
|
+
export declare const getNavigationBarHeight: () => number;
|
|
77
|
+
/**
|
|
78
|
+
* 获取顶部区域高度度量(推荐使用)
|
|
79
|
+
* @description 返回结构化的顶部区域高度信息,避免重复计算
|
|
62
80
|
*/
|
|
63
|
-
export declare const
|
|
81
|
+
export declare const getTopBarMetrics: () => TopBarMetrics;
|
|
64
82
|
/**
|
|
65
|
-
* @
|
|
83
|
+
* @deprecated 请使用 getTopBarMetrics() 获取结构化数据,或使用 getStatusBarHeight() + getNavigationBarHeight()
|
|
84
|
+
* @returns 包含状态栏高度和导航栏总高度的配置对象
|
|
66
85
|
* @description 一次性获取应用所需的状态栏和导航栏高度配置信息
|
|
67
86
|
*/
|
|
68
87
|
export declare const getTopNavBarHeight: () => {
|
|
69
|
-
statusBarHeight:
|
|
70
|
-
navHeight:
|
|
88
|
+
statusBarHeight: number;
|
|
89
|
+
navHeight: number;
|
|
71
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated 请使用 getTopBarMetrics().totalTopHeight
|
|
93
|
+
* @returns 导航栏总高度(包含状态栏,单位:px)
|
|
94
|
+
* @description 获取导航栏的总高度,包含状态栏高度
|
|
95
|
+
*/
|
|
96
|
+
export declare const getNavHeight: () => number;
|
|
72
97
|
/**
|
|
73
98
|
* 修改页面标题
|
|
74
99
|
* @param title 新的页面标题
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-uniapp-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "一个功能强大、性能优化的 uni-app 开发工具库,提供剪贴板、本地存储、导航、系统信息等常用功能",
|
|
6
6
|
"main": "dist/my-uniapp-tools.cjs.js",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"storage",
|
|
38
38
|
"navigation",
|
|
39
39
|
"system",
|
|
40
|
-
"performance",
|
|
41
40
|
"typescript",
|
|
42
41
|
"微信小程序",
|
|
43
42
|
"支付宝小程序",
|
|
@@ -77,8 +76,5 @@
|
|
|
77
76
|
"sass-embedded": "^1.89.2",
|
|
78
77
|
"typescript": "^5.8.3",
|
|
79
78
|
"vuepress": "^2.0.0-rc.24"
|
|
80
|
-
},
|
|
81
|
-
"directories": {
|
|
82
|
-
"example": "examples"
|
|
83
79
|
}
|
|
84
80
|
}
|