From 667c233d63b6de4c61e26f2c6fbf4a90c6cf42ab Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Mon, 23 Dec 2019 17:59:19 +0800 Subject: [PATCH] feat:update cli target files --- doric-cli/target/android/app/build.gradle | 2 +- .../java/pub/doric/example/MainActivity.java | 17 ++++------------- doric-cli/target/iOS/Example/AppDelegate.m | 6 ++++-- doric-cli/target/iOS/Example/SceneDelegate.m | 6 ++++-- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/doric-cli/target/android/app/build.gradle b/doric-cli/target/android/app/build.gradle index 7f5d2ffe..3554ff45 100644 --- a/doric-cli/target/android/app/build.gradle +++ b/doric-cli/target/android/app/build.gradle @@ -20,7 +20,7 @@ android { sourceSets { main { - assets.srcDirs = [project.getRootDir().getParent() + "/js/bundle/src"] + assets.srcDirs = [project.getRootDir().getParent() + "/js/bundle"] } } diff --git a/doric-cli/target/android/app/src/main/java/pub/doric/example/MainActivity.java b/doric-cli/target/android/app/src/main/java/pub/doric/example/MainActivity.java index adcd9138..46bbe75a 100644 --- a/doric-cli/target/android/app/src/main/java/pub/doric/example/MainActivity.java +++ b/doric-cli/target/android/app/src/main/java/pub/doric/example/MainActivity.java @@ -9,25 +9,16 @@ import pub.doric.DoricFragment; public class MainActivity extends AppCompatActivity { private final String BUNDLE_NAME = "__$__"; - private DoricFragment doricFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { - String scheme = "assets://" + BUNDLE_NAME + ".js"; - this.doricFragment = DoricFragment.newInstance(scheme, BUNDLE_NAME); - this.getSupportFragmentManager().beginTransaction().add(R.id.root, this.doricFragment).commit(); - } - } - - @Override - public void onBackPressed() { - if (this.doricFragment.canPop()) { - this.doricFragment.pop(); - } else { - super.onBackPressed(); + String scheme = "assets://src/" + BUNDLE_NAME + ".js"; + getIntent().putExtra("scheme", scheme); + getIntent().putExtra("alias", BUNDLE_NAME); + this.getSupportFragmentManager().beginTransaction().add(R.id.root, new DoricFragment()).commit(); } } } diff --git a/doric-cli/target/iOS/Example/AppDelegate.m b/doric-cli/target/iOS/Example/AppDelegate.m index 669bece0..ef9da07b 100644 --- a/doric-cli/target/iOS/Example/AppDelegate.m +++ b/doric-cli/target/iOS/Example/AppDelegate.m @@ -7,7 +7,7 @@ // #import "AppDelegate.h" -#import +#import @interface AppDelegate () @end @@ -17,7 +17,9 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSString *bundleName = @"__$__"; - DoricViewController *doricViewController = [[DoricViewController alloc] initWithScheme:[NSString stringWithFormat:@"assets://src/%@.js", bundleName] alias:bundleName]; + DoricViewController *doricViewController = [[DoricViewController alloc] initWithScheme:[NSString stringWithFormat:@"assets://src/%@.js", bundleName] + alias:bundleName + extra:@""]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:doricViewController]; diff --git a/doric-cli/target/iOS/Example/SceneDelegate.m b/doric-cli/target/iOS/Example/SceneDelegate.m index f00f2e90..57d201a6 100644 --- a/doric-cli/target/iOS/Example/SceneDelegate.m +++ b/doric-cli/target/iOS/Example/SceneDelegate.m @@ -1,5 +1,5 @@ #import "SceneDelegate.h" -#import +#import @interface SceneDelegate () @end @@ -8,7 +8,9 @@ @implementation SceneDelegate - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { UIWindowScene *windowScene = (UIWindowScene *) scene; NSString *bundleName = @"__$__"; - DoricViewController *doricViewController = [[DoricViewController alloc] initWithScheme:[NSString stringWithFormat:@"assets://src/%@.js", bundleName] alias:bundleName]; + DoricViewController *doricViewController = [[DoricViewController alloc] initWithScheme:[NSString stringWithFormat:@"assets://src/%@.js", bundleName] + alias:bundleName + extra:@""]; doricViewController.view.backgroundColor = [UIColor whiteColor]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:doricViewController]; self.window = [[UIWindow alloc] initWithWindowScene:windowScene];