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:
@@ -1310,3 +1310,37 @@ let UI = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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"]));
|
return Future.delayed(Duration(milliseconds: message["time"]));
|
||||||
case "UI":
|
case "UI":
|
||||||
return handleUIMessage(Map.from(message));
|
return handleUIMessage(Map.from(message));
|
||||||
|
case "getLocale":
|
||||||
|
return "${App.locale.languageCode}-${App.locale.countryCode}";
|
||||||
|
case "getPlatform":
|
||||||
|
return Platform.operatingSystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user