App相关
typescript
import core from 'cheese-core';
const app = core.app;
用浏览器打开网站: openUrl(url: string): void
✅
参数:
- ⭐
string
(url): 网站的Url。如果不以 "http://" 或 "https://" 开头,则默认是 "http://"
用法示例:
typescript
app.openUrl("https://www.example.com")
卸载应用: uninstall(pkg: string): void
✅
参数:
- ⭐
string
(pkg): 目标包名
用法示例:
typescript
app.uninstall("com.example.package")
获取应用名称对应的已安装的应用的包名: getPackageName(appName:string): string
✅
参数:
- ⭐
string
(appName): 应用名称
返回值:
- 🟢
string
: 应用包名 - 🔴 null
用法示例:
typescript
const packageName = app.getPackageName("Cheese");
console.log("包名" , packageName);
获取应用包名对应的已安装的应用的名称: getAppName(packageName:string): string
✅
参数:
- ⭐
string
(pkg): 目标包名
返回值:
- 🟢
string
: 应用名称 - 🔴 null
用法示例:
typescript
const appName = app.getAppName("com.example.app");
console.log("应用名称", appName);
打开App设置页面: openAppSettings(packageName: string): boolean
✅
参数:
- ⭐
string
(packageName): 目标包名
返回值:
- 🟢
boolean
: true - 🔴
boolean
: false
用法示例:
typescript
if (app.openAppSettings("com.example.app")) {
console.log("成功");
}
包名打开app: openApp(pkg: string): void
✅
参数:
- ⭐
string
(pkg):包名
返回值:
- 🟢
boolean
:true - 🔴
boolean
:fasle
用法示例:
typescript
if (app.openApp("com.sm")) {
console.log("成功");
}
打开Scheme: openScheme(schemeUri: string): boolean
✅
参数:
- ⭐
string
(schemeUri): Scheme字符串
返回值:
- 🟢
boolean
: true - 🔴
boolean
: false
用法示例:
typescript
if (app.openScheme("your_scheme_here")) {
console.log("成功");
}