Skip to content

Commit 098688c

Browse files
author
jack.wyb
committed
增加对微信云存储图片的支持
1 parent 8c97471 commit 098688c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

components/painter/lib/downloader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,13 @@ function transformBase64File(base64data, lru) {
174174
});
175175
}
176176

177+
//支持微信云文件fileID
177178
function downloadFile(url, lru) {
178179
return new Promise((resolve, reject) => {
179-
wx.downloadFile({
180+
const downloader = url.startsWith('cloud://')?wx.cloud.downloadFile:wx.downloadFile
181+
downloader({
180182
url: url,
183+
fileID: url,
181184
success: function (res) {
182185
if (res.statusCode !== 200) {
183186
console.error(`downloadFile ${url} failed res.statusCode is not 200`);

components/painter/lib/util.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ function isValidUrl(url) {
44
}
55

66
function isOnlineUrl(url) {
7-
return /(ht|f)tp(s?):\/\/([^ \\/]*\.)+[^ \\/]*(:[0-9]+)?\/?/.test(url)
7+
// 支持微信云文件的fileId(cloud://开头)
8+
// return /(ht|f)tp(s?):\/\/([^ \\/]*\.)+[^ \\/]*(:[0-9]+)?\/?/.test(url)
9+
return /((ht|f)tp(s?)|cloud):\/\/([^ \\/]*\.)+[^ \\/]*(:[0-9]+)?\/?/.test(url)
810
}
911

1012
function isDataUrl(url) {

0 commit comments

Comments
 (0)