更新PlatformUtil

This commit is contained in:
dgflash
2024-08-05 21:31:01 +08:00
parent 45ac750ebd
commit 1ae3231a02

View File

@@ -3,7 +3,7 @@
* @LastEditors: dgflash
* @LastEditTime: 2022-09-02 14:39:03
*/
import { native, sys } from "cc";
import { __private, native, sys } from "cc";
/** 平台数据 */
export class PlatformUtil {
@@ -42,4 +42,27 @@ export class PlatformUtil {
// else
// return false
// }
/** 获取当前设备的网络类型, 如果网络类型无法获取,默认将返回 `sys.NetworkType.LAN` */
getNetworkType(): __private._pal_system_info_enum_type_network_type__NetworkType {
return sys.getNetworkType();
}
/**
* 获取当前设备的电池电量,如果电量无法获取,默认将返回 1
* @return - 0.0 ~ 1.0
*/
getBatteryLevel(): number {
return sys.getBatteryLevel();
}
/** 尝试打开一个 web 页面,并非在所有平台都有效 */
openURL(url: string) {
sys.openURL(url);
}
/** 拷贝字符串到剪切板 */
copyText(text: string) {
native.copyTextToClipboard(text);
}
}