# @fyelci/react-google-drive-picker 中文文档

规范地址：https://npmcn.com/package/%40fyelci/react-google-drive-picker/

版本：1\.2\.5
npm 元数据更新时间：2023-10-12T09:00:15.370Z
中文译文更新时间：2026-11-15T19:42:25.171Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40fyelci/react-google-drive-picker
原文对照：https://npmcn.com/package/%40fyelci/react-google-drive-picker/?lang=original
项目主页：https://github.com/fyelci/React-google-drive-picker#readme
源码仓库：https://github.com/fyelci/React-google-drive-picker

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

- 包体积（解压后）：34.8 kB，16 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- peer 依赖：react \>=17\.0\.0，react-dom \>=17\.0\.0
- 首次发布：2023-10-12T08:46:44.408Z
- 最新版本发布：2023-10-12T09:00:15.194Z
- 近 30 天下载量：19538（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

反弹google 驱动器拾取器 api

## 安装

```sh
npm install @fyelci/react-google-drive-picker
```

也可以使用：`pnpm add @fyelci/react-google-drive-picker`、`yarn add @fyelci/react-google-drive-picker`、`bun add @fyelci/react-google-drive-picker`

## README

# 反应- 谷歌驱动拾取器

谷歌驱动器拾取器

## 说明

Google驱动器自定义钩.

## 开始

### 安装

与 npm 关系

```
npm i @fyelci/react-google-drive-picker
```

用纱线

```
yarn add @fyelci/react-google-drive-picker
```

### 使用量

```js
import  { useEffect } from 'react';
import useDrivePicker from '@fyelci/react-google-drive-picker'


function App() {
  const [openPicker, authResponse] = useDrivePicker();  
  // const customViewsArray = [new google.picker.DocsView()]; // custom view
  const handleOpenPicker = () => {
    openPicker({
      clientId: "xxxxxxxxxxxxxxxxx",
      developerKey: "xxxxxxxxxxxx",
      viewId: "DOCS",
      // token: token, // pass oauth token in case you already have one
      showUploadView: true,
      showUploadFolders: true,
      supportDrives: true,
      multiselect: true,
      // customViews: customViewsArray, // custom view
      callbackFunction: (data) => {
        if (data.action === 'cancel') {
          console.log('User clicked cancel/close button')
        }
        console.log(data)
      },
    })
  }


  
  return (
    <div>
        <button onClick={() => handleOpenPicker()}>Open Picker</button>
    </div>
  );
}

export default App;
```

## 拾取器配置道具

## 拾取器道具

| 段落 | 价值 | 默认值 | 说明 |
| --- | --- | --- | --- |
| 回调功能 | 函数 | 需求 | 在拾取器动作上调用回调函数 |
| 客户端ID | 字符串 | 需求 | 谷歌客户端 ID |
| 开发者Key | 字符串 | 需求 | Google 开发者密钥 |
| 禁用默认查看 | 布尔 | 虚假 | 禁用默认视图 |
| 视图 | 字符串 | 医生 | 视图 |
| 视图MIME 类型 | 字符串 | 选项 | 逗号分离出 MIME 类型 。 如果您需要过滤多类文件, 请使用此选项取而代之 。 列表 : [https://developers.google.com/drive/api/v3/mime-types (英语)](https://developers.google.com/drive/api/v3/mime-types)。 。 。 . |
| 设置 | 布尔 | 虚假 | 在视图项目中显示文件夹 . |
| 设置 : | 布尔 | 虚假 | 允许用户在 Google Drive 中选择文件夹 . |
| 符号 | 字符串 | 选项 | 连接以跳过认证部分 |
| 设置 | 字符串 | 选项 | 设置 Google Picker 对话框的来源 |
| 多选择 | 布尔 | 虚假 | 启用多选取器 |
| 支持驱动程序 | 布尔 | 虚假 | 支持共享驱动器 |
| 显示载入视图 | 布尔 | 虚假 | 启用上传视图 |
| 显示装入文件夹 | 布尔 | 虚假 | 启用文件夹选择( 上载) |
| 设定父文件夹 | 字符串 | 已禁用 | 驱动文件夹 ID 上传 |
| 自定义视图 | 视图分类 \[\] | 选项 | 要添加到拾取器中的自定义视图阵列 |
| 自定义缩写 | 字符串 \[\] | \[https://www.googleapis.com/auth/drive.read only'\] (英语) | 要添加到拾取器中的自定义瞄准镜阵 |
| 语言 | 字符串 | 内 | 所支持的地盘列表 [https://developers.google.com/ pickers/docs#i18n (英语)](https://developers.google.com/picker/docs#i18n) |

## 视图

| 选项 | 说明 |
| --- | --- |
| 医生 | 所有Google Drive文档类型. |
| 医生 图像 | 谷歌驱动相片. |
| DOCS IMAGES AND 视频 | Google驱动相片和视频. |
| DOCS 视频 | 谷歌驱动视频. |
| 文件 | 谷歌驱动文档. |
| 基金会 | 谷歌驱动文件夹. |
| 拖车 | 谷歌驱动绘图. |
| 形式 | Google Drive Forms. (原始内容存档于2018-10-21). |
| PDFS 系统 | PDF文件被存储在Google Drive. |
| 碎片 | 谷歌驱动电子表格. |

## 作者

[@ Jose medina (英语)](https://www.linkedin.com/in/jos%C3%A9-medina-56479a128/)

## 承认

灵感, 代码片段

-   [斯多姆兹](https://github.com/sdoomz/react-google-picker)
-   [食肉动物](https://github.com/obonyojimmy/react-drive-picker#readme)

## 常见问题

### @fyelci/react-google-drive-picker 是什么？

反弹google 驱动器拾取器 api

### 如何安装 @fyelci/react-google-drive-picker？

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

### @fyelci/react-google-drive-picker 支持 TypeScript 吗？

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

### @fyelci/react-google-drive-picker 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @fyelci/react-google-drive-picker 可以商用吗？

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

### @fyelci/react-google-drive-picker 的下载量有多少？

根据 npm 官方下载统计，@fyelci/react-google-drive-picker 在 2026/10/16 – 2026/11/14 这 30 天内被下载 19,538 次，日均约 651 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @fyelci/react-google-drive-picker 还在维护吗？

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

