integrateMiuiLogin
集成小米登录到Android项目,自动配置相关文件和依赖。
前置依赖
依赖参数
| 参数名 | 类型 | 说明 |
|---|---|---|
deps.existsSync | FileSystem['existsSync'] | 检查文件是否存在 |
deps.readFileSync | FileSystem['readFileSync'] | 读取文件内容 |
deps.writeFileSync | FileSystem['writeFileSync'] | 写入文件内容 |
deps.copyFileSync | FileSystem['copyFileSync'] | 复制文件 |
deps.join | Path['join'] | 路径拼接 |
deps.xmlParser | XMLParserConstructor | XML 解析器构造函数 |
deps.xmlSerializer | XMLSerializerConstructor | XML 序列化器构造函数 |
deps.xpath | XPath | XPath 查询库 |
环境要求
- @xmldom/xmldom: XML DOM 解析库
- xpath: XPath 查询库
bash
npm install @xmldom/xmldom xpath函数签名
typescript
function integrateMiuiLogin(
projectPath: string,
moduleDir: string,
packageName: string,
config: MiuiLoginConfig,
deps: IntegrateThirdPartyModuleDeps
): Promise<{ success: boolean; message?: string; error?: string; logs: string[] }>参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
projectPath | string | 是 | Android项目路径 |
moduleDir | string | 是 | 模块目录(如 'app' 或 'HBuilder-uniPlugin') |
packageName | string | 是 | 应用包名 |
config | MiuiLoginConfig | 是 | 小米登录配置 |
deps | IntegrateThirdPartyModuleDeps | 是 | 依赖注入对象 |
返回值
| 类型 | 说明 |
|---|---|
Promise<{ success: boolean; message?: string; error?: string; logs: string[] }> | Promise,解析为集成结果对象 |
工作原理
基于 integrateThirdPartyModule 实现,自动处理库文件拷贝、Gradle依赖添加、清单文件修改等操作,确保小米登录功能正确集成。