mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Add app api
This commit is contained in:
@@ -1309,4 +1309,38 @@ let UI = {
|
||||
initialIndex: initialIndex
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* App related apis
|
||||
* @since 1.2.1
|
||||
*/
|
||||
let APP = {
|
||||
/**
|
||||
* Get the app version
|
||||
* @returns {string} - The app version
|
||||
*/
|
||||
get version() {
|
||||
return appVersion // defined in the engine
|
||||
},
|
||||
|
||||
/**
|
||||
* Get current app locale
|
||||
* @returns {string} - The app locale, in the format of [languageCode]_[countryCode]
|
||||
*/
|
||||
get locale() {
|
||||
return sendMessage({
|
||||
method: 'getLocale'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Get current running platform
|
||||
* @returns {string} - The platform name, "android", "ios", "windows", "macos", "linux"
|
||||
*/
|
||||
get platform() {
|
||||
return sendMessage({
|
||||
method: 'getPlatform'
|
||||
})
|
||||
}
|
||||
}
|
@@ -155,6 +155,10 @@ class JsEngine with _JSEngineApi, JsUiApi {
|
||||
return Future.delayed(Duration(milliseconds: message["time"]));
|
||||
case "UI":
|
||||
return handleUIMessage(Map.from(message));
|
||||
case "getLocale":
|
||||
return "${App.locale.languageCode}-${App.locale.countryCode}";
|
||||
case "getPlatform":
|
||||
return Platform.operatingSystem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user