post改为json方式

main
wuyize 2023-07-01 15:01:36 +08:00
parent 069c3013e9
commit c58f251953
4 changed files with 52 additions and 22 deletions

View File

@ -92,27 +92,29 @@ AppFluWindow {
text: "登录"
onClicked: {
var param = {
username: account.text,
password: password.text
"username": account.text,
"password": password.text
}
Request.post("login",JSON.toString(param), function(result, data) {
Request.post("login",
JSON.stringify(param),
function (result, data) {
console.log(result)
console.log(data)
FluApp.navigate("/");
window.close();
}, function() {
FluApp.navigate("/");
window.close();
FluApp.navigate("/")
window.close()
}, function (p1, p2) {
console.log(p1)
console.log(p2)
//FluApp.navigate("/");
//window.close();
})
//HttpClient.doGetRequest(
// "https://quic.aiortc.org/",
// loginItem, "login")
}
}
}
}
// FluPivotItem {
@ -125,6 +127,5 @@ AppFluWindow {
}
}
}
}
}

View File

@ -122,6 +122,20 @@ FluWindow {
title_bar.maximizeButton.visible = true
// window.backgroundVisible = false
window.show()
Request.post(
"knowledge/file", "{\n"
+ " \"name\": \"特东局却热\",\n" + " \"brief\": \"fugiat occaecat\",\n"
+ " \"size\": 88,\n" + " \"sha256\": \"ea incididunt pariatur\",\n"
+ " \"tags\": [\n" + " 43,\n"
+ " 45\n" + " ],\n" + " \"parentId\": \"4\"\n" + "}",
function (p1, p2) {
console.log(p1)
console.log(p2)
}, function (p1, p2) {
console.log(p1)
console.log(p2)
})
}
}
}

View File

@ -5,7 +5,8 @@ import QtQuick
QtObject {
id: request
property string baseUrl: "http://127.0.0.1:4523/m1/2914957-0-5604d062/"
property string baseUrl: "http://127.0.0.1:4523/m1/2914957-0-default/"
//property string baseUrl: "http://192.168.156.74:8080/"
// GET
function get(url, success, failure) {
@ -20,17 +21,30 @@ QtObject {
// POST
function post(url, arg, success, failure) {
var xhr = new XMLHttpRequest
xhr.open("POST", baseUrl + url)
xhr.setRequestHeader("Content-Length", arg.length)
xhr.setRequestHeader(
"Content-Type",
"application/x-www-form-urlencoded;") //POST
xhr.open("POST", baseUrl + url, true)
xhr.setRequestHeader('Content-Type', 'application/json')
xhr.withCredentials = true
xhr.onreadystatechange = function () {
handleResponse(xhr, success, failure)
}
xhr.send(arg)
}
/* function post(url, arg, success, failure) {
var xhr = new XMLHttpRequest
xhr.open("POST", baseUrl + url)
xhr.setRequestHeader("Content-Length", arg.length)
xhr.setRequestHeader(
"Content-Type",
"application/x-www-form-urlencoded;") //POST
xhr.onreadystatechange = function () {
handleResponse(xhr, success, failure)
}
xhr.send(arg)
}*/
//
function handleResponse(xhr, success, failure) {
if (xhr.readyState === XMLHttpRequest.DONE) {

View File

@ -128,6 +128,7 @@ FluArea {
right: layout_like.left
rightMargin: 20
}
onClicked: function () {}
}
}