mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
change command history into mitmproxy's one
This commit is contained in:
parent
79f4cdd25c
commit
eec3c35cb1
@ -462,14 +462,14 @@ class Commands(RequestHandler):
|
|||||||
}
|
}
|
||||||
for parameter in command.parameters:
|
for parameter in command.parameters:
|
||||||
commands[name]["args"].append(parameter.name)
|
commands[name]["args"].append(parameter.name)
|
||||||
self.write({"commands": commands, "history": self.master.commands.execute("commands.history.get")})
|
self.write({"commands": commands})
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
result = self.master.commands.execute(self.json["command"])
|
result = self.master.commands.execute(self.json["command"])
|
||||||
if result is None:
|
if result is None:
|
||||||
self.write({"result": ""})
|
self.write({"result": ""})
|
||||||
return
|
return
|
||||||
self.write({"result": result, "type": type(result).__name__})
|
self.write({"result": result, "type": type(result).__name__, "history": self.master.commands.execute("commands.history.get")})
|
||||||
|
|
||||||
|
|
||||||
class Events(RequestHandler):
|
class Events(RequestHandler):
|
||||||
|
@ -84,8 +84,6 @@ export default function CommandBar() {
|
|||||||
const onKeyDown = (e) => {
|
const onKeyDown = (e) => {
|
||||||
if (e.keyCode === Key.ENTER) {
|
if (e.keyCode === Key.ENTER) {
|
||||||
const body = {"command": input}
|
const body = {"command": input}
|
||||||
const newHistory = Object.assign([], history)
|
|
||||||
newHistory.splice(currentPos, 0, input)
|
|
||||||
|
|
||||||
fetchApi(`/commands`, {
|
fetchApi(`/commands`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -96,13 +94,19 @@ export default function CommandBar() {
|
|||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
setHistory(newHistory)
|
setHistory(data.history)
|
||||||
setCurrentPos(currentPos + 1)
|
setCurrentPos(currentPos + 1)
|
||||||
setNextArgs([])
|
setNextArgs([])
|
||||||
|
setResults([...results, {
|
||||||
setResults([...results, {"id": results.length, "result": data.result}])
|
"id": results.length,
|
||||||
|
"command": input,
|
||||||
|
"result": JSON.stringify(data.result)
|
||||||
|
}])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setSignatureHelp("")
|
||||||
|
setDescription("")
|
||||||
|
|
||||||
setInput("")
|
setInput("")
|
||||||
setOriginalInput("")
|
setOriginalInput("")
|
||||||
}
|
}
|
||||||
@ -130,7 +134,6 @@ export default function CommandBar() {
|
|||||||
|
|
||||||
const onKeyUp = (e) => {
|
const onKeyUp = (e) => {
|
||||||
if (input == "") return
|
if (input == "") return
|
||||||
console.log("keyup event")
|
|
||||||
parseCommand(originalInput, input)
|
parseCommand(originalInput, input)
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
@ -143,6 +146,7 @@ export default function CommandBar() {
|
|||||||
<div className="command-result">
|
<div className="command-result">
|
||||||
{results.map(result => (
|
{results.map(result => (
|
||||||
<div key={result.id}>
|
<div key={result.id}>
|
||||||
|
<div><strong>$ {result.command}</strong></div>
|
||||||
{result.result}
|
{result.result}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
Loading…
Reference in New Issue
Block a user