GithubHelp home page GithubHelp logo

quany / react-native-mp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 137.2 MB

React Native integration MiniProgram;Improve platform scalability.

License: MIT License

JavaScript 0.48% Java 7.12% TypeScript 1.01% Swift 0.02% C 2.26% Objective-C 70.36% Ruby 0.52% C++ 17.24% HTML 0.99%
react-native uni miniprogram

react-native-mp's Introduction

react-native-mp

为有基础能力(比如交易,通信,AI等)APP提供开放方案;用React Native实现基础业务;以小程序,H5扩展生态;

Demo

安装

需React Native 0.60以上

  • npm package
npm install react-native-mp
  • 在iOS工程的AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FB_SONARKIT_ENABLED
  InitializeFlipper(application);
#endif

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"io"
                                            initialProperties:nil];

  if (@available(iOS 13.0, *)) {
    rootView.backgroundColor = [UIColor systemBackgroundColor];
  } else {
    rootView.backgroundColor = [UIColor whiteColor];
  }

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  // 配置参数
  NSMutableDictionary *options = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
  // 设置 debug YES 会在控制台输出 js log,默认不输出 log,注:需要引入 liblibLog.a 库
  [options setObject:[NSNumber numberWithBool:NO] forKey:@"debug"];
  // 初始化引擎
  [DCUniMPSDKEngine initSDKEnvironmentWithLaunchOptions:options];
  return YES;
}

入门

import Mp from 'react-native-mp';

// 初始化
initialize({
  menus: [{title: '标题', key: 't1'}],
  capsule: true,
  fontSize: '16px',
  fontColor: '#000',
  fontWeight: 'normal',
  isFromRecents: true,
  enableBackground: true,
});
isExistsApp(appid);// 是否存在
releaseWgtToRunPathFromPath(path, appid);// 部署资源
launch({
  appid,
  params: {time: 1},
});// 打开小程序;

目标

  • 解决APP臃肿,轻量化APP,快速响应用户;
  • 解耦大而全的业务,高扩展;
  • 扩展生态共享;

欢迎交流

图片替换文本

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

react-native-mp's People

Contributors

quany avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.