hw-cus-ui 1.1.5 → 1.1.6

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.
@@ -85,8 +85,6 @@
85
85
 
86
86
  <script lang="ts" setup>
87
87
  import { ref, watch } from 'vue';
88
- // @ts-ignore
89
- import * as FileSaver from 'file-saver';
90
88
 
91
89
  // 导入uni-app的类型定义
92
90
  declare const uni: any;
@@ -201,12 +199,67 @@ const handleDownload = (file: any) => {
201
199
  */
202
200
  async function convertUrlToBlob(url: string, name: string) {
203
201
  try {
204
- const response = await fetch(url);
205
- if (!response.ok) {
206
- throw new Error(`HTTP错误: ${response.status}`);
207
- }
208
- const blob = await response.blob();
209
- FileSaver.saveAs(blob, name);
202
+ // 在UniApp环境中,使用 uni.downloadFile API 替代 file-saver
203
+ uni.downloadFile({
204
+ url: url,
205
+ success: (res: any) => {
206
+ if (res.statusCode === 200) {
207
+ // 下载成功后,使用 uni.saveFile 保存到本地
208
+ uni.saveFile({
209
+ tempFilePath: res.tempFilePath,
210
+ success: (saveRes: any) => {
211
+ uni.showToast({
212
+ title: '文件已保存至:' + saveRes.savedFilePath,
213
+ icon: 'none',
214
+ duration: 2000
215
+ });
216
+ },
217
+ fail: () => {
218
+ // 如果无法保存到本地,尝试使用其他方式打开文件
219
+ uni.openDocument({
220
+ filePath: res.tempFilePath,
221
+ success: () => {
222
+ console.log('打开文档成功');
223
+ },
224
+ fail: (err: any) => {
225
+ console.log('打开文档失败', err);
226
+ // 在微信小程序环境中,可能无法直接保存文件,这里提供提示
227
+ uni.showModal({
228
+ title: '提示',
229
+ content: '当前环境不支持直接保存文件,您可以点击右上角菜单选择"保存到手机"功能',
230
+ showCancel: false
231
+ });
232
+ }
233
+ });
234
+ }
235
+ });
236
+ } else {
237
+ console.log('下载失败', res);
238
+ }
239
+ },
240
+ fail: (err: any) => {
241
+ console.log('下载失败', err);
242
+ // 如果 uni.downloadFile 失败,尝试使用浏览器原生下载
243
+ if (typeof window !== 'undefined' && window.navigator && (window.navigator as any).msSaveOrOpenBlob) {
244
+ // IE浏览器
245
+ const xhr = new XMLHttpRequest();
246
+ xhr.open('GET', url, true);
247
+ xhr.responseType = 'blob';
248
+ xhr.onload = () => {
249
+ const blob = xhr.response;
250
+ (window.navigator as any).msSaveOrOpenBlob(blob, name);
251
+ };
252
+ xhr.send();
253
+ } else {
254
+ // 其他浏览器
255
+ const link = document.createElement('a');
256
+ link.href = url;
257
+ link.download = name;
258
+ link.target = '_blank';
259
+ link.click();
260
+ }
261
+ }
262
+ });
210
263
  } catch (error) {
211
264
  console.log(error);
212
265
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hw-cus-ui",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "使用该组件库需安装uniapp插件@dcloudio/uni-ui",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -11,7 +11,5 @@
11
11
  "license": "ISC",
12
12
  "type": "commonjs",
13
13
  "types": "./index.d.ts",
14
- "dependencies": {
15
- "file-saver": "^2.0.5"
16
- }
14
+ "dependencies": {}
17
15
  }
@@ -1,51 +0,0 @@
1
- ## 2.8.7(2025-05-30)
2
- 1.`新增` props:`layout-only`,支持仅使用基础布局。
3
- 2.`新增` `goF2`方法,支持手动触发进入二楼。
4
- 3.`新增` `@scrollDirectionChange`事件,支持监听列表滚动方向改变。
5
- 4.`新增` props:`paging-class`,支持直接设置`z-paging`的`class`。
6
- 5.`新增` `addKeyboardHeightChangeListener`方法,支持手动添加键盘高度变化监听。
7
- 6.`修复` `scrollIntoViewById`方法在存在`slot=top`或局部区域滚动时,滚动的位置不准确的问题。
8
- 7.`优化` 重构底部安全区域处理逻辑,修改为占位view的方式,处理方案更灵活并支持自定义底部安全区域颜色。
9
- 8.`优化` 兼容在`nvue`+`vue3`中使用`waterfall`。
10
- 9.`优化` 规范`types`中对`style`类型的约束。
11
- ## 2.8.6(2025-03-17)
12
- 1.`新增` 聊天记录模式流式输出(类似chatGPT回答)演示demo。
13
- 2.`新增` z-paging及其公共子组件支持`HBuilderX`代码文档提示。
14
- 3.`新增` props:`virtual-in-swiper-slot`,用以解决vue3+(微信小程序或QQ小程序)中,使用非内置列表写法时,若z-paging在`swiper-item`中存在的无法获取slot插入的cell高度进而导致虚拟列表失败的问题。
15
- 4.`新增` `@scrolltolower`和@`scrolltoupper`支持nvue。
16
- 5.`修复` 由`v2.8.1`引出的方法`scrollIntoViewById`在微信小程序+vue3中无效的问题。
17
- 6.`修复` 由`v2.8.1`引出的在子组件内使用z-paging虚拟列表无效的问题。
18
- 7.`修复` 在微信小程序中基础库版本较高时`wx.getSystemInfoSync is deprecated`警告。
19
- 8.`优化` 提升下拉刷新在鸿蒙Next中的性能。
20
- 9.`优化` `@scrolltolower`和`@scrolltoupper`在倒置的聊天记录模式下的触发逻辑。
21
- 10.`优化` 其他细节调整。
22
- ## 2.8.5(2025-02-09)
23
- 1.`新增` 方法`scrollToX`,支持控制x轴滚动到指定位置。
24
- 2.`修复` 快手小程序中报错`await isn't allowed in non-async function`的问题。
25
- 3.`修复` 在iOS+nvue中,设置了`:loading-more-enabled="false"`后,调用`scrollToBottom`无法滚动到底部的问题。
26
- 4.`修复` 在支付宝小程序+页面滚动中,数据为空时空数据图未居中的问题。
27
- 5.`优化` fetch types修改。
28
- ## 2.8.4(2024-12-02)
29
- 1.`修复` 在虚拟列表+vue2中,顶部占位采用transformY方案;在虚拟列表+vue3中,顶部占位采用view占位方案。以解决在vue2+微信小程序+安卓+兼容模式中,可能出现的虚拟列表闪动的问题。
30
- 2.`修复` 在列表渲染时(尤其是在虚拟列表中)偶现的【点击加载更多】闪现的问题。
31
- 3.`优化` 统一在RefresherStatus枚举中Loading取值。
32
- 4.`优化` `defaultPageNo`&`defaultPageSize`修改为只允许number类型。
33
- 5.`优化` 提升兼容性&细节优化。
34
- ## 2.8.3(2024-11-27)
35
- 1.`修复` `doInsertVirtualListItem`插入数据无效的问题。
36
- 2.`优化` 提升兼容性&细节优化。
37
- ## 2.8.2(2024-11-25)
38
- 1.`优化` types中`ZPagingRef`和`ZPagingInstance`支持泛型。
39
- ## 2.8.1(2024-11-24)
40
- 1.`新增` 完整的`props`、`slots`、`methods`、`events`的typescript types声明,可在ts中获得绝佳的代码提示体验。
41
- 2.`新增` `virtual-cell-id-prefix`:虚拟列表cell id的前缀,适用于一个页面有多个虚拟列表的情况,用以区分不同虚拟列表cell的id。
42
- 3.`修复` 在vue3+(微信小程序或QQ小程序)中,使用非内置列表写法时,若`z-paging`在`swiper-item`标签内的情况下存在的无法获取slot插入的cell高度的问题。
43
- 4.`修复` 在虚拟列表中分页数据小于1页时插入新数据,虚拟列表未生效的问题。
44
- 5.`修复` 在虚拟列表中调用`refresh`时,cell的index计算不正确的问题。
45
- 6.`修复` 在快手小程序中内容较少或空数据时`z-paging`未能铺满全屏的问题。
46
- 7.`优化` `events`中的参数涉及枚举的部分,统一由之前的number类型修改为string类型,展示更直观!涉及的events:`@query`中的`from`参数;`@refresherStatusChange`中的`status`参数;`@loadingStatusChange`中的`status`参数;`slot=refresher`中的`refresherStatus`参数;`slot=chatLoading`中的`loadingMoreStatus`参数。更新版本请特别留意!
47
- ## 2.8.0(2024-10-21)
48
- 1.`新增` 全面支持鸿蒙Next。
49
- 2.`修复` 设置了`refresher-complete-delay`后,在下拉刷新期间调用reload导致的无法再次下拉刷新的问题。
50
- 3.`优化` 废弃虚拟列表transformY顶部占位方案,修改为空view占位。解决因使用旧方案导致的vue3中可能出现的虚拟列表闪动问题。提升虚拟列表的兼容性。
51
-
@@ -1,89 +0,0 @@
1
- {
2
- "id": "z-paging",
3
- "name": "z-paging",
4
- "displayName": "【z-paging下拉刷新、上拉加载】高性能,全平台兼容。支持虚拟列表,分页全自动处理",
5
- "version": "2.8.7",
6
- "description": "超简单、低耦合!使用wxs+renderjs实现。支持自定义下拉刷新、上拉加载更多、虚拟列表、下拉进入二楼、自动管理空数据图、无闪动聊天分页、本地分页、国际化等数百项配置",
7
- "keywords": [
8
- "下拉刷新",
9
- "上拉加载",
10
- "分页器",
11
- "nvue",
12
- "虚拟列表"
13
- ],
14
- "repository": "https://github.com/SmileZXLee/uni-z-paging",
15
- "engines": {
16
- "HBuilderX": "^3.0.7"
17
- },
18
- "dcloudext": {
19
- "sale": {
20
- "regular": {
21
- "price": "0.00"
22
- },
23
- "sourcecode": {
24
- "price": "0.00"
25
- }
26
- },
27
- "contact": {
28
- "qq": "393727164"
29
- },
30
- "declaration": {
31
- "ads": "无",
32
- "data": "无",
33
- "permissions": "无"
34
- },
35
- "npmurl": "https://www.npmjs.com/package/z-paging",
36
- "type": "component-vue"
37
- },
38
- "uni_modules": {
39
- "dependencies": [],
40
- "encrypt": [],
41
- "platforms": {
42
- "cloud": {
43
- "tcb": "y",
44
- "aliyun": "y",
45
- "alipay": "n"
46
- },
47
- "client": {
48
- "App": {
49
- "app-vue": "y",
50
- "app-nvue": "y",
51
- "app-harmony": "u",
52
- "app-uvue": "u"
53
- },
54
- "H5-mobile": {
55
- "Safari": "y",
56
- "Android Browser": "y",
57
- "微信浏览器(Android)": "y",
58
- "QQ浏览器(Android)": "y"
59
- },
60
- "H5-pc": {
61
- "Chrome": "y",
62
- "IE": "y",
63
- "Edge": "y",
64
- "Firefox": "y",
65
- "Safari": "y"
66
- },
67
- "小程序": {
68
- "微信": "y",
69
- "阿里": "y",
70
- "百度": "y",
71
- "字节跳动": "y",
72
- "QQ": "y",
73
- "钉钉": "y",
74
- "快手": "y",
75
- "飞书": "y",
76
- "京东": "y"
77
- },
78
- "快应用": {
79
- "华为": "y",
80
- "联盟": "y"
81
- },
82
- "Vue": {
83
- "vue2": "y",
84
- "vue3": "y"
85
- }
86
- }
87
- }
88
- }
89
- }