-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from miserydx/dev-miserydx
[fix] 解决iOS 14不能正常加载fair_extension中的js plugin
- Loading branch information
Showing
4 changed files
with
190 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,55 @@ | ||
let FairImagePickerCallback = {}; | ||
let FairImagePickerId = 1; | ||
class FairImagePicker { | ||
|
||
static photo = 'photo'; | ||
static album = 'album'; | ||
|
||
static getImage(req) { | ||
let selectorId = 'FairImagePickerId' + FairImagePickerId++; | ||
// 设置回调 | ||
let reqFunc = {}; | ||
if (req.success) { | ||
reqFunc['success'] = req.success; | ||
} | ||
if (req.failure) { | ||
reqFunc['failure'] = req.failure; | ||
} | ||
FairImagePickerCallback[selectorId] = reqFunc; | ||
let typeP = ''; | ||
if (req.type) { | ||
typeP = req.type; | ||
} | ||
let reqMap = { | ||
pageName: '#FairKey#', | ||
funcName: 'invokePlugin', | ||
'className':'FairImagePicker#getImage', | ||
args: { | ||
callId: selectorId, | ||
type: typeP, | ||
} | ||
}; | ||
invokeFlutterCommonChannel(JSON.stringify(reqMap), function (resp) { | ||
//处理dart端返回的请求结果 | ||
let respMap = JSON.parse(resp); | ||
let respArgs = respMap['args']; | ||
let respCallId = respArgs['callId']; | ||
let imagePath = respArgs['imagePath']; | ||
//处理需要返回的结果值 | ||
let callback = FairImagePickerCallback[respCallId]; | ||
if (callback == null) { | ||
return | ||
} | ||
let successCallback = callback['success']; | ||
let failureCallback = callback['failure']; | ||
if (imagePath != null && successCallback != null) { | ||
successCallback(imagePath); | ||
} else { | ||
if (failureCallback != null) { | ||
failureCallback(''); | ||
} | ||
} | ||
//移除回调 | ||
FairImagePickerCallback[respCallId] = null; | ||
}); | ||
const FairImagePicker = { | ||
photo: 'photo', | ||
album: 'album', | ||
getImage: function (req) { | ||
let selectorId = 'FairImagePickerId' + FairImagePickerId++; | ||
// 设置回调 | ||
let reqFunc = {}; | ||
if (req.success) { | ||
reqFunc['success'] = req.success; | ||
} | ||
if (req.failure) { | ||
reqFunc['failure'] = req.failure; | ||
} | ||
FairImagePickerCallback[selectorId] = reqFunc; | ||
let typeP = ''; | ||
if (req.type) { | ||
typeP = req.type; | ||
} | ||
let reqMap = { | ||
pageName: '#FairKey#', | ||
funcName: 'invokePlugin', | ||
'className': 'FairImagePicker#getImage', | ||
args: { | ||
callId: selectorId, | ||
type: typeP, | ||
} | ||
}; | ||
invokeFlutterCommonChannel(JSON.stringify(reqMap), function (resp) { | ||
//处理dart端返回的请求结果 | ||
let respMap = JSON.parse(resp); | ||
let respArgs = respMap['args']; | ||
let respCallId = respArgs['callId']; | ||
let imagePath = respArgs['imagePath']; | ||
//处理需要返回的结果值 | ||
let callback = FairImagePickerCallback[respCallId]; | ||
if (callback == null) { | ||
return | ||
} | ||
let successCallback = callback['success']; | ||
let failureCallback = callback['failure']; | ||
if (imagePath != null && successCallback != null) { | ||
successCallback(imagePath); | ||
} else { | ||
if (failureCallback != null) { | ||
failureCallback(''); | ||
} | ||
} | ||
//移除回调 | ||
FairImagePickerCallback[respCallId] = null; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,76 @@ | ||
let FairNetCallBack = {}; | ||
let callBackId = 0; | ||
|
||
class FairNet { | ||
|
||
static GET = 'GET'; | ||
static POST = 'POST'; | ||
|
||
static requestData(req) { | ||
let respMap = {}; | ||
let id = 'FairNet$' + (callBackId++); | ||
// 设置回调 | ||
let reqFunc = {}; | ||
if (req.complete) { | ||
reqFunc['complete'] = req.complete; | ||
} | ||
if (req.success) { | ||
reqFunc['success'] = req.success; | ||
} | ||
if (req.failure) { | ||
reqFunc['failure'] = req.failure; | ||
} | ||
FairNetCallBack[id] = reqFunc; | ||
// 处理参数 | ||
let method = ''; | ||
if (req.method) { | ||
method = req.method; | ||
} | ||
let url = ''; | ||
if (req.url) { | ||
url = req.url; | ||
} | ||
let data = {}; | ||
if (req.data) { | ||
data = mapOrSetToObject(req.data); | ||
} | ||
let reqMap = { | ||
pageName: '#FairKey#', | ||
funcName: 'invokePlugin', | ||
'className': 'FairNet#requestData', | ||
args: { | ||
callId: id, | ||
method: method, | ||
url: url, | ||
data: data | ||
} | ||
}; | ||
invokeFlutterCommonChannel(JSON.stringify(reqMap), (resultStr) =>{ | ||
let responseMap = JSON.parse(resultStr); | ||
let data = responseMap['data']; | ||
responseMap['data'] = data.data; | ||
let id = responseMap['callId']; | ||
//处理需要返回的结果值 | ||
let callback = FairNetCallBack[id]; | ||
if (callback == null) { | ||
return | ||
} | ||
let complete = callback['complete']; | ||
let failure = callback['failure']; | ||
let success = callback['success']; | ||
if (responseMap['statusCode'] === 200) { | ||
if (complete != null) { | ||
complete(); | ||
} | ||
if (success != null) { | ||
success(convertObjectLiteralToSetOrMap(responseMap)); | ||
} | ||
} else { | ||
if (complete != null) { | ||
complete(); | ||
} | ||
if (failure != null) { | ||
failure(responseMap['statusMessage']); | ||
} | ||
} | ||
}) | ||
} | ||
const FairNet = { | ||
GET: 'GET', | ||
POST: 'POST', | ||
requestData: function (req) { | ||
let respMap = {}; | ||
let id = 'FairNet$' + (callBackId++); | ||
// 设置回调 | ||
let reqFunc = {}; | ||
if (req.complete) { | ||
reqFunc['complete'] = req.complete; | ||
} | ||
if (req.success) { | ||
reqFunc['success'] = req.success; | ||
} | ||
if (req.failure) { | ||
reqFunc['failure'] = req.failure; | ||
} | ||
FairNetCallBack[id] = reqFunc; | ||
// 处理参数 | ||
let method = ''; | ||
if (req.method) { | ||
method = req.method; | ||
} | ||
let url = ''; | ||
if (req.url) { | ||
url = req.url; | ||
} | ||
let data = {}; | ||
if (req.data) { | ||
data = mapOrSetToObject(req.data); | ||
} | ||
let reqMap = { | ||
pageName: '#FairKey#', | ||
funcName: 'invokePlugin', | ||
'className': 'FairNet#requestData', | ||
args: { | ||
callId: id, | ||
method: method, | ||
url: url, | ||
data: data | ||
} | ||
}; | ||
invokeFlutterCommonChannel(JSON.stringify(reqMap), (resultStr) => { | ||
let responseMap = JSON.parse(resultStr); | ||
let data = responseMap['data']; | ||
responseMap['data'] = data.data; | ||
let id = responseMap['callId']; | ||
//处理需要返回的结果值 | ||
let callback = FairNetCallBack[id]; | ||
if (callback == null) { | ||
return | ||
} | ||
let complete = callback['complete']; | ||
let failure = callback['failure']; | ||
let success = callback['success']; | ||
if (responseMap['statusCode'] === 200) { | ||
if (complete != null) { | ||
complete(); | ||
} | ||
if (success != null) { | ||
success(convertObjectLiteralToSetOrMap(responseMap)); | ||
} | ||
} else { | ||
if (complete != null) { | ||
complete(); | ||
} | ||
if (failure != null) { | ||
failure(responseMap['statusMessage']); | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,55 @@ | ||
let FairPermissionCallback = {}; | ||
let FairPermissionId = 1; | ||
class FairPermission { | ||
|
||
static permissionPhoto = "Permission_Photo"; | ||
static permissionPhone = "Permission_Phone"; | ||
static permissionAudio = "Permission_Audio"; | ||
|
||
static requestPermission(req) { | ||
let selectorId = 'FairPermissionId' + FairPermissionId++; | ||
// 设置回调 | ||
let reqFunc = {}; | ||
if (req.granted) { | ||
reqFunc['granted'] = req.granted; | ||
} | ||
if (req.restricted) { | ||
reqFunc['restricted'] = req.restricted; | ||
} | ||
FairPermissionCallback[selectorId] = reqFunc; | ||
let typeP = ''; | ||
if (req.type) { | ||
typeP = req.type; | ||
} | ||
let reqMap = { | ||
pageName: '#FairKey#', | ||
funcName: 'invokePlugin', | ||
'className':'FairPermission#requestPermission', | ||
args: { | ||
callId: selectorId, | ||
type: typeP | ||
} | ||
}; | ||
invokeFlutterCommonChannel(JSON.stringify(reqMap), function (resp) { | ||
//处理dart端返回的请求结果 | ||
let respMap = JSON.parse(resp); | ||
let respArgs = respMap['args']; | ||
let respCallId = respArgs['callId']; | ||
let isGranted = respArgs['isGranted']; | ||
//处理需要返回的结果值 | ||
let callback = FairPermissionCallback[respCallId]; | ||
if (callback == null) { | ||
return | ||
} | ||
let grantedCallback = callback['granted']; | ||
let restrictedCallback = callback['restricted']; | ||
if (isGranted && grantedCallback != null) { | ||
grantedCallback(); | ||
} else { | ||
if (restrictedCallback != null) { | ||
restrictedCallback(); | ||
} | ||
} | ||
//移除回调 | ||
FairPermissionCallback[respCallId] = null; | ||
}); | ||
const FairPermission = { | ||
permissionPhoto: "Permission_Photo", | ||
permissionPhone: "Permission_Phone", | ||
permissionAudio: "permissionAudio", | ||
requestPermission: function (req) { | ||
let selectorId = 'FairPermissionId' + FairPermissionId++; | ||
// 设置回调 | ||
let reqFunc = {}; | ||
if (req.granted) { | ||
reqFunc['granted'] = req.granted; | ||
} | ||
if (req.restricted) { | ||
reqFunc['restricted'] = req.restricted; | ||
} | ||
FairPermissionCallback[selectorId] = reqFunc; | ||
let typeP = ''; | ||
if (req.type) { | ||
typeP = req.type; | ||
} | ||
let reqMap = { | ||
pageName: '#FairKey#', | ||
funcName: 'invokePlugin', | ||
'className': 'FairPermission#requestPermission', | ||
args: { | ||
callId: selectorId, | ||
type: typeP | ||
} | ||
}; | ||
invokeFlutterCommonChannel(JSON.stringify(reqMap), function (resp) { | ||
//处理dart端返回的请求结果 | ||
let respMap = JSON.parse(resp); | ||
let respArgs = respMap['args']; | ||
let respCallId = respArgs['callId']; | ||
let isGranted = respArgs['isGranted']; | ||
//处理需要返回的结果值 | ||
let callback = FairPermissionCallback[respCallId]; | ||
if (callback == null) { | ||
return | ||
} | ||
let grantedCallback = callback['granted']; | ||
let restrictedCallback = callback['restricted']; | ||
if (isGranted && grantedCallback != null) { | ||
grantedCallback(); | ||
} else { | ||
if (restrictedCallback != null) { | ||
restrictedCallback(); | ||
} | ||
} | ||
//移除回调 | ||
FairPermissionCallback[respCallId] = null; | ||
}); | ||
} | ||
} |
Oops, something went wrong.