OronBox

OS 系统信息

宿主环境信息:平台、语言、时区等

获取宿主操作系统信息,不需要权限

方法

const arch       = await OronBox.os.arch();       // 'x64' | 'arm64' | 'x86' | 'riscv64' | 'arm' | 'unknown'
const hostname   = await OronBox.os.hostname();    // 仅桌面端
const locale     = await OronBox.os.locale();      // 'en_US' | 'zh_CN' | ...
const platform   = await OronBox.os.platform();    // 'linux' | 'macos' | 'windows' | 'android' | 'ios'
const version    = await OronBox.os.version();     // 仅桌面端
const language   = await OronBox.os.language();    // 'en' | 'zh' | ...
const appearance = await OronBox.os.appearance();  // 'light' | 'dark'
const timezone   = await OronBox.os.timezone();    // UTC 偏移分钟数,如 480 = UTC+8

完整示例

globalThis.activate = async (plugin) => {
  const lines = [
    `Platform: ${await OronBox.os.platform()}`,
    `Arch: ${await OronBox.os.arch()}`,
    `Language: ${await OronBox.os.language()}`,
    `Locale: ${await OronBox.os.locale()}`,
    `Appearance: ${await OronBox.os.appearance()}`,
    `Timezone: UTC${await OronBox.os.timezone() >= 0 ? '+' : ''}${await OronBox.os.timezone() / 60}h`
  ];

  await OronBox.ui.render(OronBox.ui.Text(lines.join('\n')));
};

On this page