uview-pro 0.4.8 → 0.4.9
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/changelog.md +32 -8
- package/libs/request/index.ts +70 -11
- package/package.json +1 -1
- package/readme.md +1 -1
package/changelog.md
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
## 0.4.
|
|
1
|
+
## 0.4.9(2025-12-24)
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### 📝 Documentation | 文档
|
|
4
4
|
|
|
5
|
-
- **
|
|
6
|
-
- 修复 u-cell 组件中使用 u-icon 样式在微信小程序不生效问题,修复 u-upload 图片上传失败重试是否显示提示配置不生效问题 ([e591d62](https://github.com/anyup/uView-Pro/commit/e591d62befce95c207ca47158549e6fd97f1e58d))
|
|
7
|
-
- **u-cell-item:** 修复图标样式问题并优化组件结构 ([294bf4b](https://github.com/anyup/uView-Pro/commit/294bf4be88fb53a2ccd72fcc8702b09f6d736a30))
|
|
5
|
+
- **readme:** 修复捐赠页面链接 ([93323ab](https://github.com/anyup/uView-Pro/commit/93323ab414ddc5a4542604928f221a050cbe55c5))
|
|
8
6
|
|
|
9
|
-
###
|
|
7
|
+
### ✨ Features | 新功能
|
|
10
8
|
|
|
11
|
-
- **
|
|
9
|
+
- **request:** 增强http请求工具,添加请求超时配置和全局配置合并功能 ([54d4a44](https://github.com/anyup/uView-Pro/commit/54d4a448a82d76889524cc2ad0f8f08b758b73fb))
|
|
10
|
+
- **http:** 修改http请求实例和响应拦截器 ([d566496](https://github.com/anyup/uView-Pro/commit/d56649673103b519492033504aa387cd6d037721))
|
|
11
|
+
- **source:** 添加静态资源文件 ([346bce6](https://github.com/anyup/uView-Pro/commit/346bce63126c4cb2c9db1f1665568eb11e26be07))
|
|
12
|
+
- **pages:** 优化多个页面演示样式,统一布局和暗黑模式 ([da68f17](https://github.com/anyup/uView-Pro/commit/da68f17ddf3018f7f5d53a7eebfb3dc1bad550ab))
|
|
13
|
+
- **i18n:** 完善国际化支持文案 ([68accbd](https://github.com/anyup/uView-Pro/commit/68accbd1d864f190e510de380d4ed8d603f8676b))
|
|
14
|
+
- **pages:** 更新iconfont图标 ([bafd4af](https://github.com/anyup/uView-Pro/commit/bafd4af26f6d2ca4dbe6e818b31be84f57c787b0))
|
|
15
|
+
- **demo-page:** 调整演示页面样式并添加tabbar支持 ([f4c5cfc](https://github.com/anyup/uView-Pro/commit/f4c5cfc70920b50602f226220ded4690279cb331))
|
|
16
|
+
|
|
17
|
+
### 🚀 Chore | 构建/工程依赖/工具
|
|
18
|
+
|
|
19
|
+
- **harmony:** 添加调试配置并调整harmony兼容版本 ([bd18fd2](https://github.com/anyup/uView-Pro/commit/bd18fd234bf0aec9671663f5b26294b4622bae81))
|
|
12
20
|
|
|
13
21
|
### 👥 Contributors
|
|
14
22
|
|
|
15
|
-
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
|
|
23
|
+
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
|
|
16
24
|
|
|
25
|
+
## 0.4.8(2025-12-23)
|
|
26
|
+
|
|
27
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
28
|
+
|
|
29
|
+
- **u-avatar:** 修复 ios 微信小程序默认头像不显示问题 ([9e3420f](https://github.com/anyup/uView-Pro/commit/9e3420fb8d0db533ce7fb3a8e83543b43ac0c7a7))
|
|
30
|
+
- 修复 u-cell 组件中使用 u-icon 样式在微信小程序不生效问题,修复 u-upload 图片上传失败重试是否显示提示配置不生效问题 ([e591d62](https://github.com/anyup/uView-Pro/commit/e591d62befce95c207ca47158549e6fd97f1e58d))
|
|
31
|
+
- **u-cell-item:** 修复图标样式问题并优化组件结构 ([294bf4b](https://github.com/anyup/uView-Pro/commit/294bf4be88fb53a2ccd72fcc8702b09f6d736a30))
|
|
32
|
+
|
|
33
|
+
### ♻️ Code Refactoring | 代码重构
|
|
34
|
+
|
|
35
|
+
- **theme:** 修改主题默认为官方内置主题,暗黑模式默认为亮色 ([176b482](https://github.com/anyup/uView-Pro/commit/176b48210209ae362fe30e459e73dff6fc81b53e))
|
|
36
|
+
|
|
37
|
+
### 👥 Contributors
|
|
38
|
+
|
|
39
|
+
<a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a> <a href="https://github.com/lime"><img src="https://github.com/lime.png?size=40" width="40" height="40" alt="lime" title="lime"/></a>
|
|
40
|
+
|
|
17
41
|
## 0.4.7(2025-12-19)
|
|
18
42
|
|
|
19
43
|
### 🚀 Chore | 构建/工程依赖/工具
|
package/libs/request/index.ts
CHANGED
|
@@ -19,9 +19,16 @@ export interface RequestConfig {
|
|
|
19
19
|
method?: string;
|
|
20
20
|
dataType?: string;
|
|
21
21
|
responseType?: string;
|
|
22
|
+
timeout?: number;
|
|
22
23
|
meta?: RequestMeta;
|
|
24
|
+
[key: string]: any;
|
|
23
25
|
}
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* 忽略的请求参数类型定义
|
|
29
|
+
*/
|
|
30
|
+
const IGNORE_REQUEST_KEYS = ['baseUrl', 'meta'];
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* 请求拦截器类型定义
|
|
27
34
|
*/
|
|
@@ -43,6 +50,7 @@ export interface RequestOptions {
|
|
|
43
50
|
params?: Record<string, any>;
|
|
44
51
|
complete?: (response: any) => void;
|
|
45
52
|
meta?: RequestMeta;
|
|
53
|
+
[key: string]: any;
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
export class Request {
|
|
@@ -57,6 +65,7 @@ export class Request {
|
|
|
57
65
|
method: 'POST', // 请求方式
|
|
58
66
|
dataType: 'json', // 设置为json,返回后uni.request会对数据进行一次JSON.parse
|
|
59
67
|
responseType: 'text', // 此参数无需处理,因为5+和支付宝小程序不支持,默认为text即可
|
|
68
|
+
timeout: 60000,
|
|
60
69
|
meta: {
|
|
61
70
|
originalData: true, // 是否在拦截器中返回服务端的原始数据,见文档说明
|
|
62
71
|
toast: false, // 是否在请求出错时,弹出toast
|
|
@@ -68,6 +77,65 @@ export class Request {
|
|
|
68
77
|
response: null
|
|
69
78
|
};
|
|
70
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* 将全局配置合并到本次请求的 options 中
|
|
82
|
+
* - 忽略 IGNORE_REQUEST_KEYS 中的字段(如 meta)
|
|
83
|
+
* - 对 header 使用深合并(全局 header 为默认,options.header 优先)
|
|
84
|
+
* - 对对象类型的字段尝试深合并,基础类型以 options 值优先
|
|
85
|
+
* - 处理 baseUrl:若存在全局 baseUrl 且 options.url 非完整 url(非 http 开头),则合并成完整 URL
|
|
86
|
+
*/
|
|
87
|
+
private mergeGlobalConfigToOptions(options: RequestOptions): RequestOptions {
|
|
88
|
+
const mergedOptions: RequestOptions = { ...options };
|
|
89
|
+
for (const key of Object.keys(this.config)) {
|
|
90
|
+
if (IGNORE_REQUEST_KEYS.includes(key)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const cfgVal = this.config[key];
|
|
94
|
+
const optVal = options[key];
|
|
95
|
+
|
|
96
|
+
// 跳过未设置的全局配置
|
|
97
|
+
if (cfgVal === undefined) continue;
|
|
98
|
+
|
|
99
|
+
// header 需要做深合并,且以 options.header 为准覆盖同名属性
|
|
100
|
+
if (key === 'header') {
|
|
101
|
+
mergedOptions.header = deepMerge(cfgVal || {}, optVal || {});
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 针对 method 等枚举字符串,优先使用 options 中的值,否则使用全局配置
|
|
106
|
+
if (typeof cfgVal === 'string' || typeof cfgVal === 'number' || typeof cfgVal === 'boolean') {
|
|
107
|
+
mergedOptions[key] = optVal !== undefined ? optVal : cfgVal;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 对对象类型的配置(如自定义扩展)尝试做深合并
|
|
112
|
+
if (typeof cfgVal === 'object' && !Array.isArray(cfgVal)) {
|
|
113
|
+
mergedOptions[key] = deepMerge(cfgVal || {}, optVal || {});
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 其他类型,若 options 未传入则使用全局配置
|
|
118
|
+
if (optVal === undefined) {
|
|
119
|
+
mergedOptions[key] = cfgVal;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// 如果存在 baseUrl,并且 options.url 为相对地址,则拼接成完整 url
|
|
123
|
+
const baseUrl = this.config.baseUrl;
|
|
124
|
+
if (
|
|
125
|
+
baseUrl &&
|
|
126
|
+
mergedOptions.url &&
|
|
127
|
+
typeof mergedOptions.url === 'string' &&
|
|
128
|
+
mergedOptions.url.indexOf('http') !== 0
|
|
129
|
+
) {
|
|
130
|
+
mergedOptions.url =
|
|
131
|
+
baseUrl + (mergedOptions.url.indexOf('/') === 0 ? mergedOptions.url : `/${mergedOptions.url}`);
|
|
132
|
+
}
|
|
133
|
+
// 确保 url 存在,且为 string
|
|
134
|
+
if (!mergedOptions.url) {
|
|
135
|
+
mergedOptions.url = '';
|
|
136
|
+
}
|
|
137
|
+
return mergedOptions;
|
|
138
|
+
}
|
|
71
139
|
/**
|
|
72
140
|
* 设置全局默认配置
|
|
73
141
|
* @param customConfig 自定义配置
|
|
@@ -88,14 +156,10 @@ export class Request {
|
|
|
88
156
|
};
|
|
89
157
|
// 让 options.meta 传递到拦截器
|
|
90
158
|
options.meta = mergedMeta;
|
|
91
|
-
options.dataType = options.dataType || this.config.dataType;
|
|
92
|
-
options.responseType = options.responseType || this.config.responseType;
|
|
93
159
|
options.url = options.url || '';
|
|
94
160
|
options.params = options.params || {};
|
|
95
|
-
|
|
96
|
-
options
|
|
97
|
-
// 保证 url 一定为 string
|
|
98
|
-
if (!options.url) options.url = '';
|
|
161
|
+
// 将全局配置合并到本次请求 options 中(注意忽略一些特殊字段如 baseUrl/meta)
|
|
162
|
+
options = this.mergeGlobalConfigToOptions(options);
|
|
99
163
|
|
|
100
164
|
if (this.interceptor.request && typeof this.interceptor.request === 'function') {
|
|
101
165
|
const interceptorRequest = this.interceptor.request(options);
|
|
@@ -146,11 +210,6 @@ export class Request {
|
|
|
146
210
|
}
|
|
147
211
|
}
|
|
148
212
|
};
|
|
149
|
-
// 判断用户传递的URL是否http开头
|
|
150
|
-
options.url =
|
|
151
|
-
options.url && options.url.indexOf('http') !== 0
|
|
152
|
-
? this.config.baseUrl + (options.url.indexOf('/') === 0 ? options.url : `/${options.url}`)
|
|
153
|
-
: options.url;
|
|
154
213
|
uni.request(options);
|
|
155
214
|
});
|
|
156
215
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "uview-pro",
|
|
3
3
|
"name": "uview-pro",
|
|
4
4
|
"displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的80+精选UI组件库,支持多主题,暗黑模式",
|
|
5
|
-
"version": "0.4.
|
|
5
|
+
"version": "0.4.9",
|
|
6
6
|
"description": "uView Pro,是全面支持Vue3+TS的uni-app生态框架,80+精选组件,支持安卓,iOS,鸿蒙,各小程序平台,支持多主题,一键暗黑模式",
|
|
7
7
|
"main": "index.ts",
|
|
8
8
|
"module": "index.ts",
|