Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
014554db
提交
014554db
authored
4月 23, 2023
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add new function: open
上级
0138d562
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
107 行增加
和
19 行删除
+107
-19
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+37
-5
main.dart
example/lib/main.dart
+1
-1
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+24
-0
fluwx.dart
lib/fluwx.dart
+1
-0
fluwx.dart
lib/src/fluwx.dart
+3
-2
fluwx_method_channel.dart
lib/src/method_channel/fluwx_method_channel.dart
+15
-3
fluwx_platform_interface.dart
lib/src/method_channel/fluwx_platform_interface.dart
+2
-2
open_command.dart
lib/src/open_command.dart
+18
-0
fluwx_test.dart
test/fluwx_test.dart
+6
-6
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
014554db
...
@@ -2,14 +2,25 @@ package com.jarvan.fluwx
...
@@ -2,14 +2,25 @@ package com.jarvan.fluwx
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.util.Log
import
androidx.annotation.NonNull
import
androidx.annotation.NonNull
import
com.jarvan.fluwx.handlers.*
import
com.jarvan.fluwx.handlers.FluwxAuthHandler
import
com.jarvan.fluwx.handlers.FluwxRequestHandler
import
com.jarvan.fluwx.handlers.FluwxShareHandler
import
com.jarvan.fluwx.handlers.FluwxShareHandlerEmbedding
import
com.jarvan.fluwx.handlers.PermissionHandler
import
com.jarvan.fluwx.handlers.WXAPiHandler
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import
com.jarvan.fluwx.utils.WXApiUtils
import
com.jarvan.fluwx.utils.WXApiUtils
import
com.tencent.mm.opensdk.modelbiz.*
import
com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage
import
com.tencent.mm.opensdk.modelbiz.OpenRankList
import
com.tencent.mm.opensdk.modelbiz.OpenWebview
import
com.tencent.mm.opensdk.modelbiz.SubscribeMessage
import
com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
import
com.tencent.mm.opensdk.modelbiz.WXOpenBusinessView
import
com.tencent.mm.opensdk.modelbiz.WXOpenBusinessWebview
import
com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat
import
com.tencent.mm.opensdk.modelpay.PayReq
import
com.tencent.mm.opensdk.modelpay.PayReq
import
com.tencent.mm.opensdk.openapi.SendReqCallback
import
io.flutter.embedding.engine.plugins.FlutterPlugin
import
io.flutter.embedding.engine.plugins.FlutterPlugin
import
io.flutter.embedding.engine.plugins.activity.ActivityAware
import
io.flutter.embedding.engine.plugins.activity.ActivityAware
import
io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import
io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
...
@@ -82,7 +93,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -82,7 +93,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
call
.
method
==
"openBusinessView"
->
openBusinessView
(
call
,
result
)
call
.
method
==
"openBusinessView"
->
openBusinessView
(
call
,
result
)
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
);
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
)
call
.
method
==
"openUrl"
->
openUrl
(
call
,
result
)
call
.
method
==
"openRankList"
->
openRankList
(
result
)
else
->
result
.
notImplemented
()
else
->
result
.
notImplemented
()
}
}
}
}
...
@@ -265,8 +278,27 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -265,8 +278,27 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
private
fun
openWXApp
(
result
:
Result
)
=
result
.
success
(
WXAPiHandler
.
wxApi
?.
openWXApp
())
private
fun
openWXApp
(
result
:
Result
)
=
result
.
success
(
WXAPiHandler
.
wxApi
?.
openWXApp
())
private
fun
openUrl
(
call
:
MethodCall
,
result
:
Result
)
{
val
req
=
OpenWebview
.
Req
()
req
.
url
=
call
.
argument
(
"url"
)
WXAPiHandler
.
wxApi
?.
sendReq
(
req
,
SendReqCallback
{
result
.
success
(
it
)
})
?:
kotlin
.
run
{
result
.
success
(
false
)
}
}
private
fun
openRankList
(
result
:
Result
)
{
val
req
=
OpenRankList
.
Req
()
WXAPiHandler
.
wxApi
?.
sendReq
(
req
,
SendReqCallback
{
result
.
success
(
it
)
})
?:
kotlin
.
run
{
result
.
success
(
false
)
}
}
override
fun
onNewIntent
(
intent
:
Intent
):
Boolean
{
override
fun
onNewIntent
(
intent
:
Intent
):
Boolean
{
handelIntent
(
intent
)
handelIntent
(
intent
)
return
false
return
false
}
}
}
}
example/lib/main.dart
浏览文件 @
014554db
...
@@ -205,7 +205,7 @@ class ShareSelectorPage extends StatelessWidget {
...
@@ -205,7 +205,7 @@ class ShareSelectorPage extends StatelessWidget {
padding:
const
EdgeInsets
.
all
(
8.0
),
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
OutlinedButton
(
child:
OutlinedButton
(
onPressed:
()
{
onPressed:
()
{
fluwx
.
open
WeChatApp
(
);
fluwx
.
open
(
OpenWeChat
()
);
},
},
child:
const
Text
(
'Open WeChat App'
),
child:
const
Text
(
'Open WeChat App'
),
),
),
...
...
ios/Classes/FluwxPlugin.m
浏览文件 @
014554db
...
@@ -94,6 +94,10 @@ FlutterMethodChannel *channel = nil;
...
@@ -94,6 +94,10 @@ FlutterMethodChannel *channel = nil;
[
self
openWeChatCustomerServiceChat
:
call
result
:
result
];
[
self
openWeChatCustomerServiceChat
:
call
result
:
result
];
}
else
if
([
@"checkSupportOpenBusinessView"
isEqualToString
:
call
.
method
])
{
}
else
if
([
@"checkSupportOpenBusinessView"
isEqualToString
:
call
.
method
])
{
[
self
checkSupportOpenBusinessView
:
call
result
:
result
];
[
self
checkSupportOpenBusinessView
:
call
result
:
result
];
}
else
if
([
@"openRankList"
isEqualToString
:
call
.
method
])
{
[
self
handleOpenRankListCall
:
call
result
:
result
];
}
else
if
([
@"openUrl"
isEqualToString
:
call
.
method
])
{
[
self
handleOpenUrlCall
:
call
result
:
result
];
}
else
if
([
@"openWeChatInvoice"
isEqualToString
:
call
.
method
])
{
}
else
if
([
@"openWeChatInvoice"
isEqualToString
:
call
.
method
])
{
[
self
openWeChatInvoice
:
call
result
:
result
];
[
self
openWeChatInvoice
:
call
result
:
result
];
}
}
...
@@ -326,6 +330,25 @@ FlutterMethodChannel *channel = nil;
...
@@ -326,6 +330,25 @@ FlutterMethodChannel *channel = nil;
[
WXApi
handleOpenUniversalLink
:
userActivity
delegate
:[
FluwxResponseHandler
defaultManager
]];
[
WXApi
handleOpenUniversalLink
:
userActivity
delegate
:[
FluwxResponseHandler
defaultManager
]];
}
}
-
(
void
)
handleOpenUrlCall
:
(
FlutterMethodCall
*
)
call
result
:
(
FlutterResult
)
result
{
OpenWebviewReq
*
req
=
[[
OpenWebviewReq
alloc
]
init
];
req
.
url
=
call
.
arguments
[
@"url"
];
[
WXApi
sendReq
:
req
completion
:
^
(
BOOL
success
){
result
(
@
(
success
));
}];
}
-
(
void
)
handleOpenRankListCall
:
(
FlutterMethodCall
*
)
call
result
:
(
FlutterResult
)
result
{
OpenRankListReq
*
req
=
[[
OpenRankListReq
alloc
]
init
];
[
WXApi
sendReq
:
req
completion
:
^
(
BOOL
success
){
result
(
@
(
success
));
}];
}
-
(
BOOL
)
handleOpenURL
:
(
NSNotification
*
)
aNotification
{
-
(
BOOL
)
handleOpenURL
:
(
NSNotification
*
)
aNotification
{
if
(
handleOpenURLByFluwx
)
{
if
(
handleOpenURLByFluwx
)
{
NSString
*
aURLString
=
[
aNotification
userInfo
][
@"url"
];
NSString
*
aURLString
=
[
aNotification
userInfo
][
@"url"
];
...
@@ -336,6 +359,7 @@ FlutterMethodChannel *channel = nil;
...
@@ -336,6 +359,7 @@ FlutterMethodChannel *channel = nil;
}
}
}
}
-
(
void
)
managerDidRecvLaunchFromWXReq
:
(
LaunchFromWXReq
*
)
request
{
-
(
void
)
managerDidRecvLaunchFromWXReq
:
(
LaunchFromWXReq
*
)
request
{
[
FluwxDelegate
defaultManager
].
extMsg
=
request
.
message
.
messageExt
;
[
FluwxDelegate
defaultManager
].
extMsg
=
request
.
message
.
messageExt
;
// LaunchFromWXReq *launchFromWXReq = (LaunchFromWXReq *)request;
// LaunchFromWXReq *launchFromWXReq = (LaunchFromWXReq *)request;
...
...
lib/fluwx.dart
浏览文件 @
014554db
...
@@ -27,4 +27,5 @@ export 'src/fluwx.dart';
...
@@ -27,4 +27,5 @@ export 'src/fluwx.dart';
export
'src/response/wechat_response.dart'
;
export
'src/response/wechat_response.dart'
;
export
'src/share/share_models.dart'
;
export
'src/share/share_models.dart'
;
export
'src/wechat_enums.dart'
;
export
'src/wechat_enums.dart'
;
export
'src/open_command.dart'
;
export
'src/wechat_file.dart'
hide
FileSchema
;
export
'src/wechat_file.dart'
hide
FileSchema
;
lib/src/fluwx.dart
浏览文件 @
014554db
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
import
'dart:async'
;
import
'dart:async'
;
import
'../fluwx.dart'
;
import
'method_channel/fluwx_platform_interface.dart'
;
import
'method_channel/fluwx_platform_interface.dart'
;
import
'response/wechat_response.dart'
;
import
'response/wechat_response.dart'
;
import
'share/share_models.dart'
;
import
'share/share_models.dart'
;
...
@@ -38,8 +39,8 @@ class Fluwx {
...
@@ -38,8 +39,8 @@ class Fluwx {
Future
<
bool
>
get
isWeChatInstalled
=>
Future
<
bool
>
get
isWeChatInstalled
=>
FluwxPlatform
.
instance
.
isWeChatInstalled
;
FluwxPlatform
.
instance
.
isWeChatInstalled
;
Future
<
bool
>
open
WeChatApp
()
async
{
Future
<
bool
>
open
(
OpenCommand
what
)
{
return
FluwxPlatform
.
instance
.
openWeChatApp
(
);
return
FluwxPlatform
.
instance
.
open
(
what
);
}
}
Future
<
bool
>
registerWxApi
({
Future
<
bool
>
registerWxApi
({
...
...
lib/src/method_channel/fluwx_method_channel.dart
浏览文件 @
014554db
...
@@ -23,6 +23,7 @@ import 'dart:io';
...
@@ -23,6 +23,7 @@ import 'dart:io';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'../open_command.dart'
;
import
'../response/wechat_response.dart'
;
import
'../response/wechat_response.dart'
;
import
'../share/share_models.dart'
;
import
'../share/share_models.dart'
;
import
'../wechat_enums.dart'
;
import
'../wechat_enums.dart'
;
...
@@ -74,10 +75,21 @@ class MethodChannelFluwx extends FluwxPlatform {
...
@@ -74,10 +75,21 @@ class MethodChannelFluwx extends FluwxPlatform {
return
await
methodChannel
.
invokeMethod
(
'isWeChatInstalled'
);
return
await
methodChannel
.
invokeMethod
(
'isWeChatInstalled'
);
}
}
/// Just open WeChat, noting to do.
@override
@override
Future
<
bool
>
openWeChatApp
()
async
{
Future
<
bool
>
open
(
OpenCommand
what
)
async
{
return
await
methodChannel
.
invokeMethod
(
'openWXApp'
);
switch
(
what
){
case
OpenWeChat
():
return
await
methodChannel
.
invokeMethod
(
'openWXApp'
);
case
OpenUrl
():
return
await
methodChannel
.
invokeMethod
(
'openUrl'
,
<
String
,
dynamic
>{
'url'
:
what
.
url
,
},
);
case
OpenRankList
():
return
await
methodChannel
.
invokeMethod
(
"openRankList"
);
}
}
}
/// It's ok if you register multi times.
/// It's ok if you register multi times.
...
...
lib/src/method_channel/fluwx_platform_interface.dart
浏览文件 @
014554db
...
@@ -50,8 +50,8 @@ abstract class FluwxPlatform extends PlatformInterface {
...
@@ -50,8 +50,8 @@ abstract class FluwxPlatform extends PlatformInterface {
throw
UnimplementedError
(
'isWeChatInstalled has not been implemented.'
);
throw
UnimplementedError
(
'isWeChatInstalled has not been implemented.'
);
}
}
Future
<
bool
>
open
WeChatApp
(
)
{
Future
<
bool
>
open
(
OpenCommand
what
)
{
throw
UnimplementedError
(
'open
WeChatApp
() has not been implemented.'
);
throw
UnimplementedError
(
'open() has not been implemented.'
);
}
}
Future
<
bool
>
registerWxApi
({
Future
<
bool
>
registerWxApi
({
...
...
lib/src/open_command.dart
0 → 100644
浏览文件 @
014554db
sealed
class
OpenCommand
{
}
class
OpenWeChat
extends
OpenCommand
{
}
class
OpenUrl
extends
OpenCommand
{
final
String
url
;
OpenUrl
(
this
.
url
);
}
class
OpenRankList
extends
OpenCommand
{
}
\ No newline at end of file
test/fluwx_test.dart
浏览文件 @
014554db
...
@@ -100,12 +100,6 @@ class MockFluwxPlatform
...
@@ -100,12 +100,6 @@ class MockFluwxPlatform
throw
UnimplementedError
();
throw
UnimplementedError
();
}
}
@override
Future
<
bool
>
openWeChatApp
()
{
// TODO: implement openWeChatApp
throw
UnimplementedError
();
}
@override
@override
Future
<
bool
>
pay
(
Future
<
bool
>
pay
(
{
required
String
appId
,
{
required
String
appId
,
...
@@ -172,6 +166,12 @@ class MockFluwxPlatform
...
@@ -172,6 +166,12 @@ class MockFluwxPlatform
// TODO: implement responseEventHandler
// TODO: implement responseEventHandler
Stream
<
WeChatResponse
>
get
responseEventHandler
=>
throw
UnimplementedError
();
Stream
<
WeChatResponse
>
get
responseEventHandler
=>
throw
UnimplementedError
();
@override
Future
<
bool
>
open
(
OpenCommand
what
)
{
// TODO: implement open
throw
UnimplementedError
();
}
}
}
void
main
(
)
{
void
main
(
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论