Ftr #

Course #

Modules #

Ftr v0.7.0 Documentation


ftr/sys #

与操作系统相关的api

下面的实例均为在ios系统中运行结果

time() #

获取当前系统时间戳(毫秒)

timeMonotonic() #

获取从系统启动时开始记录的单调时间戳(毫秒),这个时间不受外部修改影响

name() #

获取系统名称,这个值包括 'iOS'|'Android'|'Linux'|'MacOSX'

info() #

获取系统信息

Example:

// Prints:
// host: Louis-iPhone
// sys: Darwin
// machine: iPhone7,2
// nodename: Louis-iPhone
// version: Darwin Kernel Version 16.6.0: Mon Apr 17 17:33:35 PDT 2017; root:xnu-3789.60.24~24/RELEASE_ARM64_T7000
// release: 16.6.0
console.log(sys.info());

version() #

获取系统版本字符串

Example:

// Prints: 10.3.2
console.log(sys.version());

brand() #

获取设备品牌名称

Example:

// Prints: Apple
console.log(sys.brand());

subsystem() #

获取子系统名称

Example:

// Prints: iPhone
console.log(sys.subsystem());

language() #

获取当前系统语言字符串,可能的值 'en-us'|'zh-cn'|'zh-tw'

Example:

// Prints: zh-Hans-CN
console.log(sys.subsystem());

isWifi() #

获取当前是否为wifi网络并且网络为有效状态,如果网络为无效状态会返回false

isMobile() #

获取当前是否为移动网络并且网络为有效状态,如果网络为无效状态会返回false

networkStatus() #

获取当前网络状态

@ret

  • 等于=0 - 无网络
  • 等于=1 - 有线网络
  • 等于=2 - 无线网络
  • 等于或大于>=3 - 移动网络

isAcPower() #

获取是否连接外部电源,连接外部电源返回true

isBattery() #

获取这个设备是否已连接电池设备,如果已连接电池返回true

batteryLevel() #

获取电池电量等级,返回为0-1的浮点值,如果没有电池返回0

memory() #

获取系统内存总量,单位为字节

usedMemory() #

获取当前应用已经使用的内存

availableMemory() #

获取当前应用可用的内存

cpuUsage() #

获取CPU占用率