网络判断

This commit is contained in:
lixiao 2025-03-18 19:05:07 +08:00
parent 23e115e89e
commit 17a52af998
3 changed files with 28 additions and 23 deletions

View File

@ -5,9 +5,9 @@
"name": "default", "name": "default",
"material": { "material": {
"certpath": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.cer", "certpath": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.cer",
"storePassword": "0000001A655821D6264A8F82501357A9E9FADD8A2D07C554ECF0BFA1241AEA1A402865E3C29B3123380E", "storePassword": "0000001B6B286329D0B89755E137765E5E3EC92AFE4D235E753CC849068623687DD2FB932E88F0E1176076",
"keyAlias": "debugKey", "keyAlias": "debugKey",
"keyPassword": "0000001AF3DBE5AAB38DC51CE559B8BDB0135E9C41C34C3727A57DAA3417D6F0D2E35469D1493F6302D3", "keyPassword": "0000001B82C966539FBC43A53702ADEAB4BC43B1A454A0645D48C22CC3BCDD977F0F98415E532D6094CF4C",
"profile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p7b", "profile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p7b",
"signAlg": "SHA256withECDSA", "signAlg": "SHA256withECDSA",
"storeFile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p12" "storeFile": "C:\\Users\\93218\\.ohos\\config\\openharmony\\auto_ohos_default_subject-two_com.oh.dts.p12"

View File

@ -90,6 +90,17 @@ export function tcpRequest<T>(req: any): Promise<T> {
}) })
} }
function getNetWorkStatus() {
connection.getDefaultNet().then(handle => {
console.log("[http request] network handle", JSON.stringify(handle))
connection.getNetCapabilities(handle).then(res => {
console.log("[http request] network result", JSON.stringify(res))
})
}).catch(err => {
console.log("[http request] network error", JSON.stringify(err))
})
}
export default async function request<T>(req: any): Promise<T> { export default async function request<T>(req: any): Promise<T> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
tempRequest(req).then((response) => { tempRequest(req).then((response) => {
@ -97,15 +108,9 @@ export default async function request<T>(req: any): Promise<T> {
resolve(response as T) resolve(response as T)
}).catch(err => { }).catch(err => {
console.log("[http request] only http request error") console.log("[http request] only http request error")
connection.getDefaultNet().then(handle => {
console.log("[http request] network handle", JSON.stringify(handle))
connection.getNetCapabilities(handle).then(res => {
console.log("[http request] network result", JSON.stringify(res))
})
}).catch(err => {
console.log("[http request] network error", JSON.stringify(err))
})
reject(err) reject(err)
}).finally(() => {
getNetWorkStatus()
}) })
}) })
} }

View File

@ -1,15 +1,15 @@
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIICFDCCAZugAwIBAgIILLIw+Om1Gu4wCgYIKoZIzj0EAwMwYzELMAkGA1UEBhMC MIICFTCCAZygAwIBAgIJAJsRE03JjrGjMAoGCCqGSM49BAMDMGMxCzAJBgNVBAYT
Q04xFDASBgNVBAoTC09wZW5IYXJtb255MRkwFwYDVQQLExBPcGVuSGFybW9ueSBU AkNOMRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkg
ZWFtMSMwIQYDVQQDExpPcGVuSGFybW9ueSBBcHBsaWNhdGlvbiBDQTAeFw0yNTAz VGVhbTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjUw
MTMwMjIyMDdaFw0zNTAzMTEwMjIyMDdaMEoxFTATBgNVBAMMDGlkZV9kZW1vX2Fw MzE4MDkyNzUwWhcNMzUwMzE2MDkyNzUwWjBKMRUwEwYDVQQDDAxpZGVfZGVtb19h
cDENMAsGA1UECxMEVW5pdDEVMBMGA1UEChMMT3JnYW5pemF0aW9uMQswCQYDVQQG cHAxDTALBgNVBAsTBFVuaXQxFTATBgNVBAoTDE9yZ2FuaXphdGlvbjELMAkGA1UE
EwJDTjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABD/XUz0Wuk0hXFbGcGSHOHZh BhMCQ04wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASjsgYkPrya0djVCUL+/VkM
8eZxGXJPRMb6O2d9Zi1pbm7upUyEKrrF0hKeokBzRLUG6ZOwhRw4bmzCCDYjthGj xCkyWvQDx9RCh6+Ao0Wy5eqz8FRyf9U488Nr+cl7e6AZXtWAFIcyVaO7fiiH3SRR
UjBQMB0GA1UdDgQWBBQDisUTnRIhYsWUI9WrlhZyP/G4ajAOBgNVHQ8BAf8EBAMC o1IwUDAdBgNVHQ4EFgQUqvy4ps0Cxq1Vc0JJApd5bGCYuaAwDgYDVR0PAQH/BAQD
B4AwHwYDVR0jBBgwFoAU24a3IhbVC6FLt90le7nxBX2iLUcwCgYIKoZIzj0EAwMD AgeAMB8GA1UdIwQYMBaAFNuGtyIW1QuhS7fdJXu58QV9oi1HMAoGCCqGSM49BAMD
ZwAwZAIwNM9ryNyDK9dNDueWY0q8qjXogHyVrNgOYW9fHSuJRk1wR2BuvIM/399z A2cAMGQCMDKcLnkiXSuvLjIQyhOq7wnWo9ObxlcqBajieyv4vZiCf90h58KQHfFN
nggoH72oAjBgvTZ5qKIJBQF81iK74oa5yylM4ig3uem9dEqaQ6BkjDQsQUCXFiU1 rvIdAFQfhwIwV3FJqf1/pNueUg5417N3Dm05QrzMtrnDOaf0gSGTuQSu9LHCaKhq
Wa95Knq/zeg= nGU1PJErkcGu
-----END CERTIFICATE----- -----END CERTIFICATE-----
4F24966DBD39F6F87309AB4A77342C262096B58EDB04A80C2528569C1CA9098D 331EC6F78C0039676593BE2FBC4BBC6BD25651900D97CDA9DC5D16C896FC9614