Kaynağa Gözat

1、添加跳转原生webview方法

tags/0.0.14+3
“yanghuaxuan” 3 yıl önce
ebeveyn
işleme
da167fd67e
3 değiştirilmiş dosya ile 57 ekleme ve 29 silme
  1. +22
    -17
      .idea/workspace.xml
  2. +28
    -8
      lib/util/application.dart
  3. +7
    -4
      lib/util/router_util.dart

+ 22
- 17
.idea/workspace.xml Dosyayı Görüntüle

@@ -20,16 +20,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="0ff6f366-28dc-4efd-9bca-709f40bc6813" name="Default Changelist" comment="1、添加QQ登录">
<change afterPath="$PROJECT_DIR$/example/ios/Flutter/.last_build_id" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.dart_tool/package_config.json" beforeDir="false" afterPath="$PROJECT_DIR$/.dart_tool/package_config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/ios/Podfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Podfile.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/util/taobao/taobao_auth.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/util/taobao/taobao_auth.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/util/application.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/util/application.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/util/router_util.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/util/router_util.dart" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -464,10 +458,17 @@
<option name="LAST_COMMIT_MESSAGE" value="1、mob短信获取失败提示问题" />
</component>
<component name="WindowStateProjectService">
<state x="614" y="129" key="CommitChangelistDialog2" timestamp="1619006495179">
<screen x="52" y="23" width="1868" height="1057" />
</state>
<state x="614" y="129" key="CommitChangelistDialog2/52.23.1868.1057@52.23.1868.1057" timestamp="1619006495179" />
<state x="281" y="172" key="DiffContextDialog" timestamp="1619006513944">
<screen x="52" y="23" width="1868" height="1057" />
</state>
<state x="281" y="172" key="DiffContextDialog/52.23.1868.1057@52.23.1868.1057" timestamp="1619006513944" />
<state width="1812" height="145" key="GridCell.Tab.0.bottom" timestamp="1618577607772">
<screen x="66" y="23" width="1854" height="1057" />
</state>
<state width="1446" height="270" key="GridCell.Tab.0.bottom/0.23.1920.1012@0.23.1920.1012" timestamp="1610330822202" />
<state width="1812" height="279" key="GridCell.Tab.0.bottom/45.23.1875.1057@45.23.1875.1057" timestamp="1618552431628" />
<state width="1812" height="279" key="GridCell.Tab.0.bottom/52.23.1868.1057@52.23.1868.1057" timestamp="1618541488296" />
<state width="1812" height="279" key="GridCell.Tab.0.bottom/54.23.1866.1057@54.23.1866.1057" timestamp="1618542639632" />
@@ -478,7 +479,6 @@
<state width="1812" height="145" key="GridCell.Tab.0.center" timestamp="1618577607771">
<screen x="66" y="23" width="1854" height="1057" />
</state>
<state width="1446" height="270" key="GridCell.Tab.0.center/0.23.1920.1012@0.23.1920.1012" timestamp="1610330822202" />
<state width="1812" height="279" key="GridCell.Tab.0.center/45.23.1875.1057@45.23.1875.1057" timestamp="1618552431628" />
<state width="1812" height="279" key="GridCell.Tab.0.center/52.23.1868.1057@52.23.1868.1057" timestamp="1618541488296" />
<state width="1812" height="279" key="GridCell.Tab.0.center/54.23.1866.1057@54.23.1866.1057" timestamp="1618542639632" />
@@ -489,7 +489,6 @@
<state width="1812" height="145" key="GridCell.Tab.0.left" timestamp="1618577607771">
<screen x="66" y="23" width="1854" height="1057" />
</state>
<state width="1446" height="270" key="GridCell.Tab.0.left/0.23.1920.1012@0.23.1920.1012" timestamp="1610330822201" />
<state width="1812" height="279" key="GridCell.Tab.0.left/45.23.1875.1057@45.23.1875.1057" timestamp="1618552431628" />
<state width="1812" height="279" key="GridCell.Tab.0.left/52.23.1868.1057@52.23.1868.1057" timestamp="1618541488296" />
<state width="1812" height="279" key="GridCell.Tab.0.left/54.23.1866.1057@54.23.1866.1057" timestamp="1618542639631" />
@@ -500,7 +499,6 @@
<state width="1812" height="145" key="GridCell.Tab.0.right" timestamp="1618577607771">
<screen x="66" y="23" width="1854" height="1057" />
</state>
<state width="1446" height="270" key="GridCell.Tab.0.right/0.23.1920.1012@0.23.1920.1012" timestamp="1610330822202" />
<state width="1812" height="279" key="GridCell.Tab.0.right/45.23.1875.1057@45.23.1875.1057" timestamp="1618552431628" />
<state width="1812" height="279" key="GridCell.Tab.0.right/52.23.1868.1057@52.23.1868.1057" timestamp="1618541488296" />
<state width="1812" height="279" key="GridCell.Tab.0.right/54.23.1866.1057@54.23.1866.1057" timestamp="1618542639632" />
@@ -508,10 +506,6 @@
<state width="1812" height="94" key="GridCell.Tab.0.right/64.23.1856.1057@64.23.1856.1057" timestamp="1618567847040" />
<state width="1812" height="145" key="GridCell.Tab.0.right/66.23.1854.1057@66.23.1854.1057" timestamp="1618577607771" />
<state width="1812" height="513" key="GridCell.Tab.0.right/69.23.1851.1057@69.23.1851.1057" timestamp="1618569277891" />
<state x="396" y="121" width="1288" height="812" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1610330779542">
<screen x="0" y="23" width="1920" height="1012" />
</state>
<state x="396" y="121" width="1288" height="812" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1920.1012@0.23.1920.1012" timestamp="1610330779542" />
<state x="792" y="472" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1618486997666">
<screen x="66" y="23" width="1854" height="1057" />
</state>
@@ -519,8 +513,19 @@
<state x="663" y="308" width="1003" height="546" key="find.popup" timestamp="1618569941236">
<screen x="66" y="23" width="1854" height="1057" />
</state>
<state x="618" y="296" width="1038" height="522" key="find.popup/0.23.1920.1012@0.23.1920.1012" timestamp="1610337605973" />
<state x="663" y="308" width="1003" height="546" key="find.popup/66.23.1854.1057@66.23.1854.1057" timestamp="1618569941236" />
<state x="669" y="402" key="git4idea.merge.GitPullDialog" timestamp="1619006525045">
<screen x="52" y="23" width="1868" height="1057" />
</state>
<state x="669" y="402" key="git4idea.merge.GitPullDialog/52.23.1868.1057@52.23.1868.1057" timestamp="1619006525045" />
<state x="753" y="512" key="git4idea.ui.GitStashDialog" timestamp="1619006520501">
<screen x="52" y="23" width="1868" height="1057" />
</state>
<state x="753" y="512" key="git4idea.ui.GitStashDialog/52.23.1868.1057@52.23.1868.1057" timestamp="1619006520501" />
<state x="753" y="423" key="git4idea.ui.GitUnstashDialog" timestamp="1619006532780">
<screen x="52" y="23" width="1868" height="1057" />
</state>
<state x="753" y="423" key="git4idea.ui.GitUnstashDialog/52.23.1868.1057@52.23.1868.1057" timestamp="1619006532780" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>


+ 28
- 8
lib/util/application.dart Dosyayı Görüntüle

@@ -1,5 +1,7 @@
typedef Future InitMethod();

typedef Future StringParamsMethod(data);

class Application {
// 初始化方法
static List<InitMethod> _initMethods = List();
@@ -7,6 +9,8 @@ class Application {
///有标签的方法用于没有页面的第三模块调用
static Map<String, InitMethod> _initStringMethods = Map();

static Map<String, StringParamsMethod> _initStringParamsMethods = Map();

static Future init() async {
for (InitMethod method in _initMethods) {
await method();
@@ -20,22 +24,38 @@ class Application {
}

static addStringMethod({String type, InitMethod method}) {
if(type==null||method==null){
if (type == null || method == null) {
return;
}
_initStringMethods[type] = method;
}

static bool hasStringMethod(String type){
return _initStringMethods.containsKey(type);
static bool hasStringMethod(String type) {
return _initStringMethods.containsKey(type);
}

static doStringMethod(String type){
if(_initStringMethods.containsKey(type)){
print("存在方法"+type);
static doStringMethod(String type) {
if (_initStringMethods.containsKey(type)) {
print("存在方法" + type);
_initStringMethods[type]();
}else{
print("不存在方法"+type);
} else {
print("不存在方法" + type);
}
}

static addStringParamsMethod({String type , StringParamsMethod method}) {
if (type == null || method == null) {
return;
}
_initStringParamsMethods[type] = method;
}

static doStringParamsMethod(String type, {Map<String, dynamic> data}) {
if (_initStringParamsMethods.containsKey(type)) {
print("存在方法" + type);
_initStringParamsMethods[type](data);
} else {
print("不存在方法" + type);
}
}
}

+ 7
- 4
lib/util/router_util.dart Dosyayı Görüntüle

@@ -16,7 +16,6 @@ class RouterUtil {
* data 额外参数
* */
static Future route(SkipModel skipModel, Map<String, dynamic> data, BuildContext context) async {

if (skipModel.skipIdentifier == null || skipModel.skipIdentifier == '') {
print('skipIdentifier 参数不存在,无法跳转页面');
return Future.error('skipIdentifier 参数不存在,无法跳转页面');
@@ -37,8 +36,7 @@ class RouterUtil {
}

if (skipModel?.requiredTaobaoAuth == '1') {
UserInfoModel user =
await Provider.of<UserInfoNotifier>(context, listen: false).getUserInfoModel();
UserInfoModel user = await Provider.of<UserInfoNotifier>(context, listen: false).getUserInfoModel();
if (!user?.isTBAuth ?? false) {
TaobaoAuth.auth(context);
return;
@@ -47,7 +45,7 @@ class RouterUtil {

// webView
if (skipModel?.skipIdentifier == 'pub.flutter.url') {
this.openWebview(skipModel?.url, context);
RouterUtil.openWebview(skipModel?.url, context);
return;
}

@@ -86,9 +84,14 @@ class RouterUtil {
Logger.error('跳转链接不能为空');
return Future.error('跳转链接不能为空');
}

SkipModel model = SkipModel();
model.skipIdentifier = 'pub.flutter.url';
model.url = url;
if (Platform.isAndroid) {
Application.doStringParamsMethod("openUrl", data: {"url": model.url});
return null;
}
RouterUtil.route(model, model.toJson(), context);
}



Yükleniyor…
İptal
Kaydet