Skip to content

integrateQQLogin

集成QQ登录到Android项目,自动配置相关文件和依赖。

前置依赖

依赖参数

参数名类型说明
deps.existsSyncFileSystem['existsSync']检查文件是否存在
deps.readFileSyncFileSystem['readFileSync']读取文件内容
deps.writeFileSyncFileSystem['writeFileSync']写入文件内容
deps.copyFileSyncFileSystem['copyFileSync']复制文件
deps.joinPath['join']路径拼接
deps.xmlParserXMLParserConstructorXML 解析器构造函数
deps.xmlSerializerXMLSerializerConstructorXML 序列化器构造函数
deps.xpathXPathXPath 查询库

环境要求

  • @xmldom/xmldom: XML DOM 解析库
  • xpath: XPath 查询库
bash
npm install @xmldom/xmldom xpath

函数签名

typescript
function integrateQQLogin(
  projectPath: string,
  moduleDir: string,
  packageName: string,
  config: QQLoginConfig,
  deps: IntegrateThirdPartyModuleDeps
): Promise<{ success: boolean; message?: string; error?: string; logs: string[] }>

interface QQLoginConfig {
  appId: string              // QQ AppID
  oauthAarPath: string       // oauth-qq-release.aar文件路径
  openSdkJarPath: string     // open_sdk_3.5.12.2_r97423a8_lite.jar文件路径
}

参数

参数名类型必填说明
projectPathstringAndroid项目路径
moduleDirstring模块目录(如 'app' 或 'HBuilder-uniPlugin')
packageNamestring应用包名
config.appIdstringQQ AppID
config.oauthAarPathstringoauth-qq-release.aar文件路径
config.openSdkJarPathstringopen_sdk_3.5.12.2_r97423a8_lite.jar文件路径
depsIntegrateThirdPartyModuleDeps依赖注入对象

返回值

类型说明
Promise<{ success: boolean; message?: string; error?: string; logs: string[] }>Promise,解析为集成结果对象

工作原理

基于 integrateThirdPartyModule 实现,自动处理库文件拷贝、Gradle依赖添加、清单文件修改等操作,确保QQ登录功能正确集成。