zhl-methods 1.0.5 → 1.1.0

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
@@ -46,20 +46,25 @@ isPhone(123)
46
46
 
47
47
  ##### 获取导航栏高度
48
48
 
49
+ - @example getNavBarHeight() => 100
49
50
  - @returns {number}
50
51
 
51
52
  ##### 弹窗二次确认
52
53
 
54
+ - @example showModal(query,callback)
53
55
  - @param {Function} callback
54
56
 
55
57
  ##### 获取当前环境
56
58
 
59
+ - @example getEnv()
57
60
  - @returns {string} release 线上 trial 测试 develop 开发
58
61
 
59
62
  ##### 获取 appId
60
63
 
64
+ - @example getAppId()
61
65
  - @returns {string}
62
66
 
63
67
  ##### 获取底部安全距离
64
68
 
69
+ - @example getSafeBottom()
65
70
  - @returns {string}
package/VERSION.md ADDED
@@ -0,0 +1,14 @@
1
+ # zhl-methods
2
+
3
+ 版本更新日志
4
+
5
+ #### 1.0.5
6
+
7
+ - 增加 css 文件
8
+ - 单/多行文本溢出省略号 nowrap/manyWrap
9
+ - 滚动条样式 scrollbar
10
+
11
+ ### 1.1.0
12
+
13
+ - 删除 wx 'requestApi' 方法 使用 'showModal' 代替
14
+ - 小程序 兼容 uin 和 wx 方法
package/index.css CHANGED
@@ -1,3 +1,4 @@
1
+ /* npm publish 发布命令 */
1
2
  /* 单行溢出省略号 */
2
3
  .nowrap {
3
4
  /*溢出部分隐藏*/
package/package.json CHANGED
@@ -1,8 +1,6 @@
1
1
  {
2
2
  "name": "zhl-methods",
3
- "version": "1.0.5",
4
- "description": "",
5
- "main": "index.js",
3
+ "version": "1.1.0",
6
4
  "license": "ISC",
7
5
  "dependencies": {
8
6
  "vue": "^3.5.12"
package/wx/index.js CHANGED
@@ -1,12 +1,11 @@
1
- if (!wx) {
2
- wx = uni;
3
- }
1
+ const thit = uni ? uni : wx;
4
2
  /**
5
3
  * 获取导航栏高度
4
+ * @example getNavBarHeight() => 100
6
5
  * @returns {number}
7
6
  */
8
7
  export const getNavBarHeight = () => {
9
- let res = wx.getSystemInfoSync();
8
+ let res = thit.getSystemInfoSync();
10
9
  let nav = 48;
11
10
  if (res.system.indexOf("iOS") > -1) {
12
11
  nav = 44;
@@ -18,7 +17,7 @@ export const getNavBarHeight = () => {
18
17
  * @param {Function} callback
19
18
  */
20
19
  export const requestApi = (callback) => {
21
- wx.showModal({
20
+ thit.showModal({
22
21
  title: "确认该操作吗?",
23
22
  confirmText: "确认",
24
23
  cancelText: "取消",
@@ -35,7 +34,7 @@ export const requestApi = (callback) => {
35
34
  * @param {Function} callback
36
35
  */
37
36
  export const showModal = (query = {}, callback) => {
38
- wx.showModal({
37
+ thit.showModal({
39
38
  title: query.title ? query.title : "确认该操作吗?",
40
39
  content: query.content ? query.content : "",
41
40
  confirmText: "确认",
@@ -52,21 +51,21 @@ export const showModal = (query = {}, callback) => {
52
51
  * @returns {string} release线上 trial测试 develop开发
53
52
  */
54
53
  export const getEnv = () => {
55
- return wx.getAccountInfoSync().miniProgram.envVersion;
54
+ return thit.getAccountInfoSync().miniProgram.envVersion;
56
55
  };
57
56
  /**
58
57
  * 获取appId
59
58
  * @returns {string}
60
59
  */
61
60
  export const getAppId = () => {
62
- return wx.getAccountInfoSync().miniProgram.appId;
61
+ return thit.getAccountInfoSync().miniProgram.appId;
63
62
  };
64
63
  /**
65
64
  * 获取底部安全距离
66
65
  * @returns {string}
67
66
  */
68
67
  export const getSafeBottom = () => {
69
- let winInfo = wx.getWindowInfo();
68
+ let winInfo = thit.getWindowInfo();
70
69
  return winInfo.safeArea.bottom - winInfo.safeArea.height;
71
70
  };
72
71
  /**
@@ -74,13 +73,13 @@ export const getSafeBottom = () => {
74
73
  * @param {string|number} 要复制的数据
75
74
  */
76
75
  export const copyText = (val) => {
77
- wx.setClipboardData({
76
+ thit.setClipboardData({
78
77
  data: val,
79
78
  success: () => {
80
- wx.showToast({ title: "复制成功", icon: "none" });
79
+ thit.showToast({ title: "复制成功", icon: "none" });
81
80
  },
82
81
  fail: (res) => {
83
- wx.showToast({ title: "复制失败", icon: "none" });
82
+ thit.showToast({ title: "复制失败", icon: "none" });
84
83
  },
85
84
  });
86
85
  };