pixuireactcomponents 1.3.80 → 1.3.81
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/package.json
CHANGED
|
@@ -6,8 +6,15 @@ export declare namespace assetCache {
|
|
|
6
6
|
* 缓存url资源到本地
|
|
7
7
|
* @param url 资源url
|
|
8
8
|
* @param force 是否强制缓存,如果为true,会强制重新下载并覆盖本地缓存
|
|
9
|
-
* @returns
|
|
9
|
+
* @returns 返回本地缓存文件路径,成功后resolve资源的本地路径,失败后reject函数的url参数
|
|
10
10
|
*/
|
|
11
11
|
const cache: (url: string, force?: boolean, retryTimes?: number) => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param url 资源url
|
|
15
|
+
* @param responseType responseType
|
|
16
|
+
* @param retryTimes 重试次数
|
|
17
|
+
* @returns 下载成功是,返回xhr.response,否则返回空字符串
|
|
18
|
+
*/
|
|
12
19
|
const download: (url: string, responseType: 'arraybuffer' | 'json' | 'text', retryTimes?: number) => Promise<string>;
|
|
13
20
|
}
|
|
@@ -62,7 +62,7 @@ export var assetCache;
|
|
|
62
62
|
* 缓存url资源到本地
|
|
63
63
|
* @param url 资源url
|
|
64
64
|
* @param force 是否强制缓存,如果为true,会强制重新下载并覆盖本地缓存
|
|
65
|
-
* @returns
|
|
65
|
+
* @returns 返回本地缓存文件路径,成功后resolve资源的本地路径,失败后reject函数的url参数
|
|
66
66
|
*/
|
|
67
67
|
assetCache.cache = function (url, force, retryTimes) {
|
|
68
68
|
if (retryTimes === void 0) { retryTimes = 3; }
|
|
@@ -78,8 +78,7 @@ export var assetCache;
|
|
|
78
78
|
case 0:
|
|
79
79
|
if (!isJssdkEnv()) {
|
|
80
80
|
console.log('非jssdk环境');
|
|
81
|
-
reject();
|
|
82
|
-
return [2 /*return*/];
|
|
81
|
+
reject(url);
|
|
83
82
|
}
|
|
84
83
|
lib = LibMgr.getInstance().getMainLib();
|
|
85
84
|
return [4 /*yield*/, getLocalPath(url)];
|
|
@@ -89,7 +88,6 @@ export var assetCache;
|
|
|
89
88
|
if (lib.fileExists(localPath)) {
|
|
90
89
|
console.log('cacheAsset file exist', localPath);
|
|
91
90
|
resolve(localPath);
|
|
92
|
-
return [2 /*return*/];
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
xhr = new XMLHttpRequest();
|
|
@@ -110,7 +108,7 @@ export var assetCache;
|
|
|
110
108
|
assetCache.cache(url, force, retryTimes - 1).then(resolve, reject);
|
|
111
109
|
}
|
|
112
110
|
else {
|
|
113
|
-
reject();
|
|
111
|
+
reject(url);
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
return [2 /*return*/];
|
|
@@ -123,7 +121,7 @@ export var assetCache;
|
|
|
123
121
|
assetCache.cache(url, force, retryTimes - 1).then(resolve, reject);
|
|
124
122
|
}
|
|
125
123
|
else {
|
|
126
|
-
reject();
|
|
124
|
+
reject(url);
|
|
127
125
|
}
|
|
128
126
|
};
|
|
129
127
|
xhr.send();
|
|
@@ -134,6 +132,13 @@ export var assetCache;
|
|
|
134
132
|
});
|
|
135
133
|
});
|
|
136
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @param url 资源url
|
|
138
|
+
* @param responseType responseType
|
|
139
|
+
* @param retryTimes 重试次数
|
|
140
|
+
* @returns 下载成功是,返回xhr.response,否则返回空字符串
|
|
141
|
+
*/
|
|
137
142
|
assetCache.download = function (url, responseType, retryTimes) {
|
|
138
143
|
if (retryTimes === void 0) { retryTimes = 3; }
|
|
139
144
|
console.log('download---', url);
|
|
@@ -153,7 +158,7 @@ export var assetCache;
|
|
|
153
158
|
assetCache.download(url, responseType, retryTimes - 1).then(resolve, reject);
|
|
154
159
|
}
|
|
155
160
|
else {
|
|
156
|
-
reject();
|
|
161
|
+
reject('');
|
|
157
162
|
}
|
|
158
163
|
}
|
|
159
164
|
return [2 /*return*/];
|
|
@@ -166,7 +171,7 @@ export var assetCache;
|
|
|
166
171
|
assetCache.download(url, responseType, retryTimes - 1).then(resolve, reject);
|
|
167
172
|
}
|
|
168
173
|
else {
|
|
169
|
-
reject();
|
|
174
|
+
reject('');
|
|
170
175
|
}
|
|
171
176
|
};
|
|
172
177
|
xhr.send();
|