-
Notifications
You must be signed in to change notification settings - Fork 1.1k
UI route
galenlin edited this page Jan 26, 2016
·
9 revisions
Small use bundles.json file to configure UI routes.
Example:
{
"version": "1.0.0",
"bundles": [
{
"uri": "home",
"pkg": ".bundle.home",
"rules": {
"page1": ".MyPage1",
"page2": ".MyPage2"
}
}
]
}
The main route is composed of the uri and the pkg. The pkg is the package id of the bundle.
From | To |
---|---|
home home/index.html home.html |
Bundle entrance |
The default page or the principal class of the bundle.
Bundle type | Default page |
---|---|
Android | The launcher activity registered in AndroidManifest.xml |
iOS | The principal controller class defined in Info.plist |
Web | index.html |
-
Android
Small.openUri("home", context); // Turn to *.bundle.home.MainActivity (1)
-
iOS
[Small openUri:@"home" fromController:controller]; // Turn to *.bundle.home.HomeController (2)
-
Web
<a href="http://m.wequick.net/demo/home">home</a> <!-- Turn to (1) or (2) by current device -->
The sub routes is specified by the rules.
From | To |
---|---|
home/$key home/$key/index.html home/$key.html |
$valueActivity $valueController |
If the $value starts with ".", search the class in current bundle, otherwise search in global. This is just like the android:name
definition for activities in AndroidManifest.xml
.
-
Android
Small.openUri("home/page1", context); // Turn to *.bundle.home.MyPage1Activity (1)
-
iOS
[Small openUri:@"home/page1" fromController:controller]; // Turn to *.bundle.home.MyPage1Controller (2)
-
Web
<a href="http://m.wequick.net/demo/home/page1">page1</a> <!-- Turn to (1) or (2) by current device -->
Support passing parameters just like the web url way.
-
Android
Small.openUri("detail?from=app.home", context);
-
iOS
[Small openUri:@"detail?from=app.home" fromController:controller];
-
Web
<a href="http://m.wequick.net/demo/detail.html?from=web.about">Call app.detail</a>
-
Android
// app.detail/MainActivity Uri uri = Small.getUri(this); if (uri != null) { String from = uri.getQueryParameter("from"); // Do stuff by `from' }
-
iOS
// DetailController.h @property (nonatomic, strong) NSString *from; // DetailController.m NSString *from = self.from;
-
Web
var query = window.location.search.substr(1); // Do stuff by `query', something like `from=app.home'