-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dba4e7d
Showing
299 changed files
with
22,844 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/node_modules | ||
/oh_modules | ||
/local.properties | ||
/.idea | ||
**/build | ||
/.hvigor | ||
.cxx | ||
/.clangd | ||
/.clang-format | ||
/.clang-tidy | ||
**/.test | ||
entry/patch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"app": { | ||
"bundleName": "cn.wildfirechat.messenger", | ||
"vendor": "example", | ||
"versionCode": 1000000, | ||
"versionName": "1.0.0", | ||
"icon": "$media:app_icon", | ||
"label": "$string:app_name" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"string": [ | ||
{ | ||
"name": "app_name", | ||
"value": "Messenger" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"app": { | ||
"signingConfigs": [], | ||
"compileSdkVersion": 9, | ||
"compatibleSdkVersion": 9, | ||
"products": [ | ||
{ | ||
"name": "default", | ||
"signingConfig": "default", | ||
} | ||
] | ||
}, | ||
"modules": [ | ||
{ | ||
"name": "entry", | ||
"srcPath": "./entry", | ||
"targets": [ | ||
{ | ||
"name": "default", | ||
"applyToProducts": [ | ||
"default" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "marswrapper", | ||
"srcPath": "./marswrapper", | ||
"targets": [ | ||
{ | ||
"name": "default", | ||
"applyToProducts": [ | ||
"default" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/node_modules | ||
/oh_modules | ||
/.preview | ||
/build | ||
/.cxx | ||
/.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"apiType": 'stageMode', | ||
"buildOption": { | ||
}, | ||
"targets": [ | ||
{ | ||
"name": "default", | ||
"runtimeOS": "HarmonyOS" | ||
}, | ||
{ | ||
"name": "ohosTest", | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. | ||
export { hapTasks } from '@ohos/hvigor-ohos-plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "entry", | ||
"version": "1.0.0", | ||
"description": "Please describe the basic information.", | ||
"main": "", | ||
"author": "", | ||
"license": "", | ||
"dependencies": { | ||
"marswrapper": "file:../marswrapper" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// @ts-nocheck | ||
// 引入包名 | ||
import http from '@ohos.net.http'; | ||
import data_preferences from '@ohos.data.preferences'; | ||
import wfc from 'marswrapper' | ||
|
||
class AppServer { | ||
baseUrl = 'https://app.wildfirechat.net' | ||
authToken = '' | ||
|
||
requestAuthCode(mobile: string) { | ||
return this._post('/send_code', { mobile }) | ||
} | ||
|
||
loginWithAuthCode(phone: string, authCode: string) { | ||
let obj = { | ||
'mobile': phone, | ||
'code': authCode, | ||
'platform': 2, | ||
'clientId': wfc.getClientId(), | ||
} | ||
return this._post('/login', obj) | ||
} | ||
|
||
_post(path: string, data: string | object): Promise<object> { | ||
return new Promise((resolve, reject) => { | ||
let httpRequest = http.createHttp(); | ||
// 用于订阅HTTP响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息 | ||
// 从API 8开始,使用on('headersReceive', Callback)替代on('headerReceive', AsyncCallback)。 8+ | ||
httpRequest.on('headersReceive', (header) => { | ||
console.info('header: ' + JSON.stringify(header)); | ||
// if (header.toString() === 'authToken') { | ||
// this.authToken = header.toString(); | ||
// } | ||
}); | ||
console.log('request', path, data) | ||
httpRequest.request( | ||
// 填写HTTP请求的URL地址,可以带参数也可以不带参数。URL地址需要开发者自定义。请求的参数可以在extraData中指定 | ||
this.baseUrl + path, | ||
{ | ||
method: http.RequestMethod.POST, // 可选,默认为http.RequestMethod.GET | ||
// 开发者根据自身业务需要添加header字段 | ||
header: { | ||
'Content-Type': 'application/json' | ||
}, | ||
// 当使用POST请求时此字段用于传递内容 | ||
extraData: data, | ||
expectDataType: http.HttpDataType.OBJECT, // 可选,指定返回数据的类型 | ||
usingCache: true, // 可选,默认为true | ||
priority: 1, // 可选,默认为1 | ||
connectTimeout: 60000, // 可选,默认为60000ms | ||
readTimeout: 60000, // 可选,默认为60000ms | ||
usingProtocol: http.HttpProtocol.HTTP1_1, // 可选,协议类型默认值由系统自动指定 | ||
}, (err, data) => { | ||
if (!err) { | ||
// data.result为HTTP响应内容,可根据业务需要进行解析 | ||
console.info('Result:' + JSON.stringify(data.result)); | ||
console.info('code:' + JSON.stringify(data.responseCode)); | ||
// data.header为HTTP响应头,可根据业务需要进行解析 | ||
console.info('header:' + JSON.stringify(data.header)); | ||
console.info('cookies:' + JSON.stringify(data.cookies)); // 8+ | ||
// 取消订阅HTTP响应头事件 | ||
httpRequest.off('headersReceive'); | ||
// 当该请求使用完毕时,调用destroy方法主动销毁 | ||
httpRequest.destroy(); | ||
console.log('response', data) | ||
if (data.result.code === 0) { | ||
resolve(data.result.result) | ||
} else { | ||
reject(data.result.code) | ||
} | ||
} else { | ||
console.info('error:' + JSON.stringify(err)); | ||
// 取消订阅HTTP响应头事件 | ||
httpRequest.off('headersReceive'); | ||
// 当该请求使用完毕时,调用destroy方法主动销毁。 | ||
httpRequest.destroy(); | ||
console.error('err', err) | ||
reject(err) | ||
} | ||
} | ||
) | ||
}) | ||
} | ||
} | ||
|
||
let self = new AppServer(); | ||
|
||
export default self | ||
|
||
|
Oops, something went wrong.