# @capacitor-community/screen-brightness 中文文档

规范地址：https://npmcn.com/package/%40capacitor-community/screen-brightness/

版本：8\.0\.0
npm 元数据更新时间：2026-10-23T21:47:58.028Z
中文译文更新时间：2026-11-09T02:21:39.086Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40capacitor-community/screen-brightness
原文对照：https://npmcn.com/package/%40capacitor-community/screen-brightness/?lang=original
项目主页：https://github.com/capacitor-community/screen-brightness#readme
源码仓库：https://github.com/capacitor-community/screen-brightness

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：22.5 kB，22 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：@capacitor/core \>=8\.0\.0
- 首次发布：2021-02-24T22:41:30.238Z
- 最新版本发布：2025-12-26T11:44:11.971Z
- 近 30 天下载量：131689（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：9（近 12 个月 1 个）

## 中文简介

ios and android上的控制屏幕亮度

## 安装

```sh
npm install @capacitor-community/screen-brightness
```

也可以使用：`pnpm add @capacitor-community/screen-brightness`、`yarn add @capacitor-community/screen-brightness`、`bun add @capacitor-community/screen-brightness`

## README

  
![](https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png)

### 屏幕亮度

**`@capacitor-community/screen-brightness`**

在iOS和Android设备上控制屏幕亮度的电容社区插件.

![](https://img.shields.io/badge/capacitor%20v8%20support-yes-brightgreen?logo=Capacitor&style=flat-square) ![](https://img.shields.io/maintenance/yes/2025?style=flat-square) [![](https://img.shields.io/github/actions/workflow/status/capacitor-community/screen-brightness/ci.yml?Test%20and%20Build%20Plugin?style=flat-square)](https://github.com/capacitor-community/screen-brightness/actions?query=workflow%3A%22Test+and+Build+Plugin%22) [![](https://img.shields.io/npm/l/@capacitor-community/screen-brightness?style=flat-square)](https://www.npmjs.com/package/@capacitor-community/screen-brightness)  
[![](https://img.shields.io/npm/dw/@capacitor-community/screen-brightness?style=flat-square)](https://www.npmjs.com/package/@capacitor-community/screen-brightness) [![](https://img.shields.io/npm/v/@capacitor-community/screen-brightness?style=flat-square)](https://www.npmjs.com/package/@capacitor-community/screen-brightness)

## 版本数

| 插件 | 电容 | 文档 |
| --- | --- | --- |
| 8.x 电话 | 8.x 电话 | [读取](https://github.com/capacitor-community/screen-brightness/blob/main/README.md) |
| 7.x 电话 | 7.x 电话 | [读取](https://github.com/capacitor-community/screen-brightness/blob/7.x/README.md) |
| 6.x (单位:千美元) | 6.x (单位:千美元) | [读取](https://github.com/capacitor-community/screen-brightness/blob/6.x/README.md) |
| 5.x 电话 | 5.x 电话 | [读取](https://github.com/capacitor-community/screen-brightness/blob/5.x/README.md) |
| 4.x (中文(简体) ) | 4.x (中文(简体) ) | [读取](https://github.com/capacitor-community/screen-brightness/blob/4.x/README.md) |
| 1.x 运算 | 3.x 运算 | [读取](https://github.com/capacitor-community/screen-brightness/blob/1.x/README.md) |

## 安装

```bash
npm install @capacitor-community/screen-brightness
npx cap sync
```

## 配置

此插件不需要配置

## 使用量

```typescript
import { ScreenBrightness } from '@capacitor-community/screen-brightness';

// Set the brightness:
const brightness = 0.5;
await ScreenBrightness.setBrightness({ brightness });

// Get the current brightness:
const {brightness: currentBrightness} = await ScreenBrightness.getBrightness();
```

## API 密码

-   [`setBrightness(...)`](https://npmcn.com/package/%40capacitor-community/screen-brightness/#readme-setbrightness)
-   [`getBrightness()`](https://npmcn.com/package/%40capacitor-community/screen-brightness/#readme-getbrightness)
-   [接口](https://npmcn.com/package/%40capacitor-community/screen-brightness/#readme-interfaces)

### 设置亮度(...)

```typescript
setBrightness(options: SetBrightnessOptions) => Promise<void>
```

设置亮度级别。 在iOS上,它设置了系统级别亮度,在Android上,它设置了当前视图的亮度.

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| **`options`** | `[SetBrightnessOptions](https://npmcn.com/package/%40capacitor-community/screen-brightness/#readme-setbrightnessoptions)` | 设置亮度的选项 |

**自:** 1.0.0 (单位:千美元)

* * *

### 获取亮度( )

```typescript
getBrightness() => Promise<GetBrightnessReturnValue>
```

返回信息而不是包含当前亮度级别

-   @ 自 1. 0

**回返情况:** `Promise<[GetBrightnessReturnValue](https://npmcn.com/package/%40capacitor-community/screen-brightness/#readme-getbrightnessreturnvalue)>`

* * *

### 接口

#### 设置亮度选项

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`brightness`** | `number` | 将亮度设置为从 0.0( 非常暗)到 1.0( 完全亮度) 的级别 在Android上,将值设置为-1恢复用户配置的亮度. | 1.0.0 (单位:千美元) |

#### 获得光速返回值

| Prop | 类型 | 说明 | 自兹 |
| --- | --- | --- | --- |
| **`brightness`** | `number` | 当前亮度水平,从0.0(非常暗)到1.0(完全亮度) 在Android上,如果该应用没有更改值,则返回 -1 . | 1.0.0 (单位:千美元) |

## 常见问题

### @capacitor-community/screen-brightness 是什么？

ios and android上的控制屏幕亮度

### 如何安装 @capacitor-community/screen-brightness？

在项目目录运行 npm install @capacitor-community/screen-brightness，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@capacitor/core（\>=8\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @capacitor-community/screen-brightness 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @capacitor-community/screen-brightness 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @capacitor-community/screen-brightness 可以商用吗？

@capacitor-community/screen-brightness 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @capacitor-community/screen-brightness 的下载量有多少？

根据 npm 官方下载统计，@capacitor-community/screen-brightness 在 2026/10/09 – 2026/11/07 这 30 天内被下载 131,689 次，日均约 4,390 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @capacitor-community/screen-brightness 还在维护吗？

最新版本 8\.0\.0 发布于 2025/12/26（10 个月前）；至今共发布 9 个版本，其中过去 12 个月发布了 1 个；首次发布于 2021/02/25。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

