react-native-kookit 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG_CONTENT_URI.md +130 -0
- package/IMPLEMENTATION_SUMMARY.md +206 -0
- package/README.md +21 -1
- package/android/src/main/java/expo/modules/kookit/ReactNativeKookitModule.kt +139 -0
- package/build/ReactNativeKookitModule.d.ts +28 -0
- package/build/ReactNativeKookitModule.d.ts.map +1 -1
- package/build/ReactNativeKookitModule.js.map +1 -1
- package/package.json +1 -1
- package/ANDROID_BUILD_FIX.md +0 -117
- package/ANDROID_FTP_UPDATE.md +0 -161
- package/ANDROID_PARAMETER_FIX.md +0 -0
- package/ANDROID_SETUP.md +0 -188
- package/ANDROID_SMB_LIBRARY_COMPARISON.md +0 -170
- package/ANDROID_SMB_LISTSHARES_FIX.md +0 -100
- package/API_UNIFICATION.md +0 -180
- package/EXPO_PLUGIN_README.md +0 -136
- package/FTP_CLIENT_API.md +0 -301
- package/FTP_EXAMPLE_IMPLEMENTATION.md +0 -0
- package/FTP_FILE_LIST_ENHANCEMENT.md +0 -186
- package/FTP_FILE_OPERATIONS.md +0 -0
- package/FTP_README.md +0 -322
- package/README_NEW.md +0 -143
- package/RELEASE_CHECKLIST.md +0 -115
- package/SMB_CLIENT_STATIC_METHODS.md +0 -175
- package/SMB_COMPLETE_GUIDE.md +0 -308
- package/SMB_HYBRID_IMPLEMENTATION.md +0 -160
- package/SMB_IMPLEMENTATION_SUMMARY.md +0 -229
- package/SMB_USAGE.md +0 -275
- package/TROUBLESHOOTING.md +0 -132
|
File without changes
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
# FTP 文件列表功能增强
|
|
2
|
-
|
|
3
|
-
本文档描述了对 FTP 客户端示例应用中文件列表功能的增强。
|
|
4
|
-
|
|
5
|
-
## 新增功能
|
|
6
|
-
|
|
7
|
-
### 🗂️ 增强的文件列表显示
|
|
8
|
-
|
|
9
|
-
**文件信息显示:**
|
|
10
|
-
|
|
11
|
-
- 📁 文件夹图标 / 📄 文件图标
|
|
12
|
-
- 文件/文件夹名称
|
|
13
|
-
- 文件大小(字节)
|
|
14
|
-
- 最后修改时间
|
|
15
|
-
- 文件权限信息
|
|
16
|
-
|
|
17
|
-
**交互功能:**
|
|
18
|
-
|
|
19
|
-
- 点击文件夹:直接进入该文件夹
|
|
20
|
-
- 点击文件:显示文件操作菜单
|
|
21
|
-
- 点击菜单按钮(⋮):显示详细操作选项
|
|
22
|
-
|
|
23
|
-
### 📂 目录导航功能
|
|
24
|
-
|
|
25
|
-
**导航按钮:**
|
|
26
|
-
|
|
27
|
-
- **Refresh(刷新)**: 重新加载当前目录的文件列表
|
|
28
|
-
- **Up(向上)**: 返回父目录
|
|
29
|
-
- **Root(根目录)**: 直接跳转到根目录
|
|
30
|
-
- **New Folder(新建文件夹)**: 创建新文件夹
|
|
31
|
-
|
|
32
|
-
**当前路径显示:**
|
|
33
|
-
|
|
34
|
-
- 实时显示当前所在的目录路径
|
|
35
|
-
- 便于用户了解当前位置
|
|
36
|
-
|
|
37
|
-
### 📄 文件操作菜单
|
|
38
|
-
|
|
39
|
-
**对于文件:**
|
|
40
|
-
|
|
41
|
-
- **Download(下载)**: 下载文件到本地临时目录
|
|
42
|
-
- **Delete(删除)**: 删除远程服务器上的文件
|
|
43
|
-
- **Cancel(取消)**: 关闭操作菜单
|
|
44
|
-
|
|
45
|
-
**对于文件夹:**
|
|
46
|
-
|
|
47
|
-
- **Open Directory(打开目录)**: 进入该文件夹
|
|
48
|
-
- **Delete(删除)**: 删除整个文件夹及其内容
|
|
49
|
-
- **Cancel(取消)**: 关闭操作菜单
|
|
50
|
-
|
|
51
|
-
### 📁 新建文件夹功能
|
|
52
|
-
|
|
53
|
-
**操作流程:**
|
|
54
|
-
|
|
55
|
-
1. 点击 "New Folder" 按钮
|
|
56
|
-
2. 在弹出的对话框中输入文件夹名称
|
|
57
|
-
3. 点击 "Create" 创建文件夹
|
|
58
|
-
4. 自动刷新文件列表显示新创建的文件夹
|
|
59
|
-
|
|
60
|
-
### 🔒 安全确认
|
|
61
|
-
|
|
62
|
-
**删除确认:**
|
|
63
|
-
|
|
64
|
-
- 删除任何文件或文件夹前都会弹出确认对话框
|
|
65
|
-
- 防止误删除重要数据
|
|
66
|
-
- 显示将要删除的项目名称
|
|
67
|
-
|
|
68
|
-
## 用户界面改进
|
|
69
|
-
|
|
70
|
-
### 📱 响应式设计
|
|
71
|
-
|
|
72
|
-
**文件列表项:**
|
|
73
|
-
|
|
74
|
-
- 更大的点击区域,便于触摸操作
|
|
75
|
-
- 清晰的视觉层次,信息一目了然
|
|
76
|
-
- 文件夹和文件使用不同的颜色和样式区分
|
|
77
|
-
|
|
78
|
-
**模态对话框:**
|
|
79
|
-
|
|
80
|
-
- 半透明背景,专注于当前操作
|
|
81
|
-
- 居中显示,适合各种屏幕尺寸
|
|
82
|
-
- 清晰的按钮布局,操作直观
|
|
83
|
-
|
|
84
|
-
### 🎨 视觉优化
|
|
85
|
-
|
|
86
|
-
**图标系统:**
|
|
87
|
-
|
|
88
|
-
- 📁 文件夹图标:蓝色文本,便于识别
|
|
89
|
-
- 📄 文件图标:常规颜色
|
|
90
|
-
- ⋮ 菜单图标:灰色,表示更多操作
|
|
91
|
-
|
|
92
|
-
**信息层次:**
|
|
93
|
-
|
|
94
|
-
- 文件名:主要信息,字体较大
|
|
95
|
-
- 文件大小:次要信息,字体中等
|
|
96
|
-
- 修改时间:辅助信息,字体较小,灰色
|
|
97
|
-
|
|
98
|
-
## 操作流程示例
|
|
99
|
-
|
|
100
|
-
### 典型文件浏览流程
|
|
101
|
-
|
|
102
|
-
1. **连接 FTP 服务器**
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
创建客户端 → 输入连接信息 → 点击连接
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
2. **浏览文件**
|
|
109
|
-
|
|
110
|
-
```
|
|
111
|
-
查看文件列表 → 点击文件夹进入 → 查看文件详情
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
3. **文件操作**
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
选择文件 → 选择操作(下载/删除) → 确认操作
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
4. **目录管理**
|
|
121
|
-
```
|
|
122
|
-
新建文件夹 → 输入名称 → 创建 → 查看结果
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### 下载文件示例
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
// 用户点击文件 → 选择下载 → 自动执行下载
|
|
129
|
-
const downloadFile = async (file: any) => {
|
|
130
|
-
const localPath = `/tmp/${file.name}`;
|
|
131
|
-
await ftpClient.download(file.name, localPath);
|
|
132
|
-
// 显示成功消息和本地路径
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### 创建文件夹示例
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
// 用户输入文件夹名 → 点击创建 → 自动刷新列表
|
|
140
|
-
const createFolder = async () => {
|
|
141
|
-
await ftpClient.createDirectory(newFolderName);
|
|
142
|
-
await listFiles(); // 刷新文件列表
|
|
143
|
-
};
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## 错误处理
|
|
147
|
-
|
|
148
|
-
### 网络错误
|
|
149
|
-
|
|
150
|
-
- 连接超时:显示友好的错误消息
|
|
151
|
-
- 认证失败:提示检查用户名和密码
|
|
152
|
-
- 权限不足:显示权限相关的错误信息
|
|
153
|
-
|
|
154
|
-
### 文件操作错误
|
|
155
|
-
|
|
156
|
-
- 下载失败:显示具体的失败原因
|
|
157
|
-
- 删除失败:可能是权限问题或文件正在使用
|
|
158
|
-
- 创建文件夹失败:可能是名称冲突或权限不足
|
|
159
|
-
|
|
160
|
-
### 用户输入错误
|
|
161
|
-
|
|
162
|
-
- 空文件夹名:禁用创建按钮
|
|
163
|
-
- 无效字符:提示输入有效的文件夹名称
|
|
164
|
-
|
|
165
|
-
## 技术实现要点
|
|
166
|
-
|
|
167
|
-
### 状态管理
|
|
168
|
-
|
|
169
|
-
- `files`: 当前目录的文件列表
|
|
170
|
-
- `selectedFile`: 当前选中的文件
|
|
171
|
-
- `showFileModal`: 文件操作模态框显示状态
|
|
172
|
-
- `showCreateFolder`: 创建文件夹模态框显示状态
|
|
173
|
-
|
|
174
|
-
### 事件处理
|
|
175
|
-
|
|
176
|
-
- 文件点击:区分文件和文件夹的不同处理逻辑
|
|
177
|
-
- 模态框管理:正确的显示和隐藏逻辑
|
|
178
|
-
- 异步操作:proper async/await 处理和错误捕获
|
|
179
|
-
|
|
180
|
-
### 用户体验优化
|
|
181
|
-
|
|
182
|
-
- 操作反馈:每个操作都有相应的日志记录
|
|
183
|
-
- 进度显示:下载和上传操作显示进度
|
|
184
|
-
- 状态保持:操作完成后自动刷新相关状态
|
|
185
|
-
|
|
186
|
-
这些增强功能使得 FTP 客户端示例应用更加实用和用户友好,提供了完整的文件管理体验。
|
package/FTP_FILE_OPERATIONS.md
DELETED
|
File without changes
|
package/FTP_README.md
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
# React Native Kookit - FTP Client
|
|
2
|
-
|
|
3
|
-
A React Native Expo module that provides volume key interception and FTP client functionality for iOS and Android.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
### Volume Key Interception
|
|
8
|
-
|
|
9
|
-
- Intercept volume up/down button presses
|
|
10
|
-
- Works on both iOS and Android
|
|
11
|
-
- Prevent default volume behavior (optional)
|
|
12
|
-
|
|
13
|
-
### FTP Client
|
|
14
|
-
|
|
15
|
-
- Connect to FTP servers
|
|
16
|
-
- List files and directories
|
|
17
|
-
- Download files from FTP server
|
|
18
|
-
- Upload files to FTP server
|
|
19
|
-
- Delete files and directories
|
|
20
|
-
- Create directories
|
|
21
|
-
- Navigate directories
|
|
22
|
-
- Progress monitoring for uploads/downloads
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install react-native-kookit
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### iOS Setup
|
|
31
|
-
|
|
32
|
-
For iOS, no additional setup is required. The module works out of the box.
|
|
33
|
-
|
|
34
|
-
### Android Setup
|
|
35
|
-
|
|
36
|
-
For Android, your MainActivity must implement the `VolumeKeyInterceptActivity` interface:
|
|
37
|
-
|
|
38
|
-
```kotlin
|
|
39
|
-
import expo.modules.kookit.VolumeKeyInterceptActivity
|
|
40
|
-
|
|
41
|
-
class MainActivity : ReactActivity(), VolumeKeyInterceptActivity {
|
|
42
|
-
// ... existing code ...
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Usage
|
|
47
|
-
|
|
48
|
-
### Basic Import
|
|
49
|
-
|
|
50
|
-
```typescript
|
|
51
|
-
import ReactNativeKookitModule, {
|
|
52
|
-
FtpConnectionConfig,
|
|
53
|
-
FtpFileInfo,
|
|
54
|
-
FtpProgressInfo,
|
|
55
|
-
} from "react-native-kookit";
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Volume Key Interception
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
import { useEffect } from "react";
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
// Set up volume key listener
|
|
65
|
-
const subscription = ReactNativeKookitModule.addListener(
|
|
66
|
-
"onVolumeButtonPressed",
|
|
67
|
-
(event) => {
|
|
68
|
-
console.log("Volume button pressed:", event.key); // 'up' or 'down'
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
// Enable volume key interception
|
|
73
|
-
ReactNativeKookitModule.enableVolumeKeyInterception();
|
|
74
|
-
|
|
75
|
-
return () => {
|
|
76
|
-
// Clean up
|
|
77
|
-
ReactNativeKookitModule.disableVolumeKeyInterception();
|
|
78
|
-
subscription.remove();
|
|
79
|
-
};
|
|
80
|
-
}, []);
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### FTP Client Usage
|
|
84
|
-
|
|
85
|
-
#### 1. Connect to FTP Server
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
const config: FtpConnectionConfig = {
|
|
89
|
-
host: "ftp.example.com",
|
|
90
|
-
port: 21, // optional, defaults to 21
|
|
91
|
-
username: "your-username",
|
|
92
|
-
password: "your-password",
|
|
93
|
-
passive: true, // optional, defaults to true
|
|
94
|
-
timeout: 30000, // optional, defaults to 30000ms
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
await ReactNativeKookitModule.ftpConnect(config);
|
|
99
|
-
console.log("Connected to FTP server");
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.error("Failed to connect:", error);
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### 2. List Files and Directories
|
|
106
|
-
|
|
107
|
-
```typescript
|
|
108
|
-
try {
|
|
109
|
-
const files: FtpFileInfo[] = await ReactNativeKookitModule.ftpList();
|
|
110
|
-
files.forEach((file) => {
|
|
111
|
-
console.log(
|
|
112
|
-
`${file.isDirectory ? "DIR" : "FILE"}: ${file.name} (${file.size} bytes)`
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
} catch (error) {
|
|
116
|
-
console.error("Failed to list files:", error);
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
#### 3. Download Files
|
|
121
|
-
|
|
122
|
-
```typescript
|
|
123
|
-
try {
|
|
124
|
-
const remotePath = "remote-file.txt";
|
|
125
|
-
const localPath = "/path/to/local/file.txt";
|
|
126
|
-
|
|
127
|
-
await ReactNativeKookitModule.ftpDownload(remotePath, localPath);
|
|
128
|
-
console.log("File downloaded successfully");
|
|
129
|
-
} catch (error) {
|
|
130
|
-
console.error("Download failed:", error);
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
#### 4. Upload Files
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
try {
|
|
138
|
-
const localPath = "/path/to/local/file.txt";
|
|
139
|
-
const remotePath = "remote-file.txt";
|
|
140
|
-
|
|
141
|
-
await ReactNativeKookitModule.ftpUpload(localPath, remotePath);
|
|
142
|
-
console.log("File uploaded successfully");
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error("Upload failed:", error);
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
#### 5. Progress Monitoring
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
const progressListener = ReactNativeKookitModule.addListener(
|
|
153
|
-
"onFtpProgress",
|
|
154
|
-
(progress: FtpProgressInfo) => {
|
|
155
|
-
console.log(
|
|
156
|
-
`Progress: ${progress.percentage}% (${progress.transferred}/${progress.total} bytes)`
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const completeListener = ReactNativeKookitModule.addListener(
|
|
162
|
-
"onFtpComplete",
|
|
163
|
-
() => {
|
|
164
|
-
console.log("Operation completed");
|
|
165
|
-
}
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
const errorListener = ReactNativeKookitModule.addListener(
|
|
169
|
-
"onFtpError",
|
|
170
|
-
(error) => {
|
|
171
|
-
console.error("FTP Error:", error.error);
|
|
172
|
-
}
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
return () => {
|
|
176
|
-
progressListener.remove();
|
|
177
|
-
completeListener.remove();
|
|
178
|
-
errorListener.remove();
|
|
179
|
-
};
|
|
180
|
-
}, []);
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
#### 6. Directory Operations
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
// Create directory
|
|
187
|
-
await ReactNativeKookitModule.ftpCreateDirectory("new-directory");
|
|
188
|
-
|
|
189
|
-
// Change directory
|
|
190
|
-
await ReactNativeKookitModule.ftpChangeDirectory("some-directory");
|
|
191
|
-
|
|
192
|
-
// Get current directory
|
|
193
|
-
const currentDir = await ReactNativeKookitModule.ftpGetCurrentDirectory();
|
|
194
|
-
console.log("Current directory:", currentDir);
|
|
195
|
-
|
|
196
|
-
// Delete file or directory
|
|
197
|
-
await ReactNativeKookitModule.ftpDelete("file.txt", false); // false for file
|
|
198
|
-
await ReactNativeKookitModule.ftpDelete("directory", true); // true for directory
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
#### 7. Disconnect
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
try {
|
|
205
|
-
await ReactNativeKookitModule.ftpDisconnect();
|
|
206
|
-
console.log("Disconnected from FTP server");
|
|
207
|
-
} catch (error) {
|
|
208
|
-
console.error("Failed to disconnect:", error);
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## API Reference
|
|
213
|
-
|
|
214
|
-
### Types
|
|
215
|
-
|
|
216
|
-
```typescript
|
|
217
|
-
interface FtpConnectionConfig {
|
|
218
|
-
host: string;
|
|
219
|
-
port?: number;
|
|
220
|
-
username: string;
|
|
221
|
-
password: string;
|
|
222
|
-
passive?: boolean;
|
|
223
|
-
timeout?: number;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
interface FtpFileInfo {
|
|
227
|
-
name: string;
|
|
228
|
-
isDirectory: boolean;
|
|
229
|
-
size: number;
|
|
230
|
-
lastModified: string;
|
|
231
|
-
permissions?: string;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
interface FtpProgressInfo {
|
|
235
|
-
transferred: number;
|
|
236
|
-
total: number;
|
|
237
|
-
percentage: number;
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Methods
|
|
242
|
-
|
|
243
|
-
#### Volume Key Methods
|
|
244
|
-
|
|
245
|
-
- `enableVolumeKeyInterception()`: Enable volume key interception
|
|
246
|
-
- `disableVolumeKeyInterception()`: Disable volume key interception
|
|
247
|
-
|
|
248
|
-
#### FTP Methods
|
|
249
|
-
|
|
250
|
-
- `ftpConnect(config: FtpConnectionConfig): Promise<void>`
|
|
251
|
-
- `ftpDisconnect(): Promise<void>`
|
|
252
|
-
- `ftpList(path?: string): Promise<FtpFileInfo[]>`
|
|
253
|
-
- `ftpDownload(remotePath: string, localPath: string): Promise<void>`
|
|
254
|
-
- `ftpUpload(localPath: string, remotePath: string): Promise<void>`
|
|
255
|
-
- `ftpDelete(remotePath: string, isDirectory?: boolean): Promise<void>`
|
|
256
|
-
- `ftpCreateDirectory(remotePath: string): Promise<void>`
|
|
257
|
-
- `ftpChangeDirectory(remotePath: string): Promise<void>`
|
|
258
|
-
- `ftpGetCurrentDirectory(): Promise<string>`
|
|
259
|
-
|
|
260
|
-
### Events
|
|
261
|
-
|
|
262
|
-
#### Volume Key Events
|
|
263
|
-
|
|
264
|
-
- `onVolumeButtonPressed`: Fired when volume button is pressed
|
|
265
|
-
```typescript
|
|
266
|
-
{
|
|
267
|
-
key: "up" | "down";
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
#### FTP Events
|
|
272
|
-
|
|
273
|
-
- `onFtpProgress`: Fired during file transfer operations
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
{ transferred: number, total: number, percentage: number }
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
- `onFtpComplete`: Fired when an operation completes successfully
|
|
280
|
-
|
|
281
|
-
- `onFtpError`: Fired when an error occurs
|
|
282
|
-
```typescript
|
|
283
|
-
{
|
|
284
|
-
error: string;
|
|
285
|
-
}
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
## Platform Support
|
|
289
|
-
|
|
290
|
-
- ✅ iOS 15.1+
|
|
291
|
-
- ✅ Android API 21+
|
|
292
|
-
- ❌ Web (FTP operations are not supported due to browser security restrictions)
|
|
293
|
-
|
|
294
|
-
## Example
|
|
295
|
-
|
|
296
|
-
See the [FtpExample.tsx](./example/FtpExample.tsx) file for a complete working example.
|
|
297
|
-
|
|
298
|
-
## Security Considerations
|
|
299
|
-
|
|
300
|
-
- FTP credentials are transmitted in plain text. Use FTPS or SFTP for secure file transfers when possible.
|
|
301
|
-
- Ensure proper file path validation to prevent directory traversal attacks.
|
|
302
|
-
- Consider implementing connection pooling and timeout handling for production use.
|
|
303
|
-
|
|
304
|
-
## Troubleshooting
|
|
305
|
-
|
|
306
|
-
### Android
|
|
307
|
-
|
|
308
|
-
- Make sure your MainActivity implements `VolumeKeyInterceptActivity`
|
|
309
|
-
- Check that you have INTERNET permission in your AndroidManifest.xml
|
|
310
|
-
|
|
311
|
-
### iOS
|
|
312
|
-
|
|
313
|
-
- Ensure your app has network permissions
|
|
314
|
-
- For file operations, make sure your app has appropriate file system permissions
|
|
315
|
-
|
|
316
|
-
## Contributing
|
|
317
|
-
|
|
318
|
-
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
319
|
-
|
|
320
|
-
## License
|
|
321
|
-
|
|
322
|
-
MIT
|
package/README_NEW.md
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
# React Native Kookit - 零配置音量键拦截
|
|
2
|
-
|
|
3
|
-
🎉 **现在支持零配置安装!** 使用 Expo 插件自动处理所有原生代码修改。
|
|
4
|
-
|
|
5
|
-
## 快速开始
|
|
6
|
-
|
|
7
|
-
### 方法一:自动安装(推荐 - Expo 项目)
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# 1. 安装
|
|
11
|
-
npm install react-native-kookit
|
|
12
|
-
|
|
13
|
-
# 2. 添加到 app.json
|
|
14
|
-
{
|
|
15
|
-
"expo": {
|
|
16
|
-
"plugins": ["react-native-kookit"]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
# 3. 预构建
|
|
21
|
-
npx expo prebuild --clean
|
|
22
|
-
|
|
23
|
-
# 4. 运行
|
|
24
|
-
npx expo run:android
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### 方法二:手动安装(React Native CLI 项目)
|
|
28
|
-
|
|
29
|
-
如果不使用 Expo,请按照 [ANDROID_SETUP.md](./ANDROID_SETUP.md) 手动修改 MainActivity。
|
|
30
|
-
|
|
31
|
-
## 使用示例
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
import React, { useEffect } from "react";
|
|
35
|
-
import { View, Text, Alert } from "react-native";
|
|
36
|
-
import ReactNativeKookit from "react-native-kookit";
|
|
37
|
-
|
|
38
|
-
export default function App() {
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
// 添加音量键监听器
|
|
41
|
-
const subscription = ReactNativeKookit.addListener(
|
|
42
|
-
"onVolumeButtonPressed",
|
|
43
|
-
(event) => {
|
|
44
|
-
Alert.alert(
|
|
45
|
-
"音量键按下",
|
|
46
|
-
`按下了${event.key === "up" ? "音量+" : "音量-"}键`,
|
|
47
|
-
[{ text: "确定" }]
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// 启用音量键拦截
|
|
53
|
-
ReactNativeKookit.enableVolumeKeyInterception();
|
|
54
|
-
|
|
55
|
-
// 清理函数
|
|
56
|
-
return () => {
|
|
57
|
-
subscription.remove();
|
|
58
|
-
ReactNativeKookit.disableVolumeKeyInterception();
|
|
59
|
-
};
|
|
60
|
-
}, []);
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
|
|
64
|
-
<Text style={{ fontSize: 18, textAlign: "center", margin: 20 }}>
|
|
65
|
-
音量键拦截已启用{"\n"}
|
|
66
|
-
请按音量键测试功能
|
|
67
|
-
</Text>
|
|
68
|
-
</View>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## API 文档
|
|
74
|
-
|
|
75
|
-
### `enableVolumeKeyInterception()`
|
|
76
|
-
|
|
77
|
-
启用音量键拦截功能。
|
|
78
|
-
|
|
79
|
-
### `disableVolumeKeyInterception()`
|
|
80
|
-
|
|
81
|
-
禁用音量键拦截功能。
|
|
82
|
-
|
|
83
|
-
### `addListener(eventName, callback)`
|
|
84
|
-
|
|
85
|
-
添加事件监听器。
|
|
86
|
-
|
|
87
|
-
**参数:**
|
|
88
|
-
|
|
89
|
-
- `eventName`: `'onVolumeButtonPressed'`
|
|
90
|
-
- `callback`: `(event: {key: 'up' | 'down'}) => void`
|
|
91
|
-
|
|
92
|
-
**返回:** 订阅对象,调用 `.remove()` 方法可取消监听。
|
|
93
|
-
|
|
94
|
-
## 功能特性
|
|
95
|
-
|
|
96
|
-
- ✅ **零配置**:Expo 插件自动修改原生代码
|
|
97
|
-
- ✅ **跨平台**:支持 iOS 和 Android
|
|
98
|
-
- ✅ **高性能**:原生实现,无性能损耗
|
|
99
|
-
- ✅ **类型安全**:完整 TypeScript 支持
|
|
100
|
-
- ✅ **兼容性强**:支持新架构和旧架构
|
|
101
|
-
|
|
102
|
-
## 支持的平台
|
|
103
|
-
|
|
104
|
-
- iOS 9.0+
|
|
105
|
-
- Android API 21+
|
|
106
|
-
- Expo SDK 49+
|
|
107
|
-
- React Native 0.70+
|
|
108
|
-
|
|
109
|
-
## 常见问题
|
|
110
|
-
|
|
111
|
-
### Q: 为什么需要 `npx expo prebuild --clean`?
|
|
112
|
-
|
|
113
|
-
A: 插件需要修改原生 Android 代码,prebuild 会应用所有插件修改。
|
|
114
|
-
|
|
115
|
-
### Q: 遇到 "Plugin is an unexpected type: undefined" 错误怎么办?
|
|
116
|
-
|
|
117
|
-
A:
|
|
118
|
-
|
|
119
|
-
1. 确保已正确安装:`npm install react-native-kookit`
|
|
120
|
-
2. 清理重装:`rm -rf node_modules && npm install`
|
|
121
|
-
3. 重新预构建:`npx expo prebuild --clean`
|
|
122
|
-
|
|
123
|
-
详细故障排除请查看 [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)
|
|
124
|
-
|
|
125
|
-
### Q: 音量键无响应怎么办?
|
|
126
|
-
|
|
127
|
-
A:
|
|
128
|
-
|
|
129
|
-
1. 确认已调用 `enableVolumeKeyInterception()`
|
|
130
|
-
2. 检查是否正确添加了事件监听器
|
|
131
|
-
3. 在 Android 上确认 MainActivity 已被正确修改
|
|
132
|
-
|
|
133
|
-
### Q: 支持 React Native CLI 项目吗?
|
|
134
|
-
|
|
135
|
-
A: 支持,但需要手动修改 MainActivity,请参考 [ANDROID_SETUP.md](./ANDROID_SETUP.md)。
|
|
136
|
-
|
|
137
|
-
### Q: 会影响系统音量调节吗?
|
|
138
|
-
|
|
139
|
-
A: 当启用拦截时,会阻止系统音量调节。禁用拦截后恢复正常。
|
|
140
|
-
|
|
141
|
-
## License
|
|
142
|
-
|
|
143
|
-
MIT © [troyeguo](https://github.com/troyeguo)
|