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:
|
||||
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):
|
||||
result = self.master.commands.execute(self.json["command"])
|
||||
if result is None:
|
||||
self.write({"result": ""})
|
||||
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):
|
||||
|
@ -84,8 +84,6 @@ export default function CommandBar() {
|
||||
const onKeyDown = (e) => {
|
||||
if (e.keyCode === Key.ENTER) {
|
||||
const body = {"command": input}
|
||||
const newHistory = Object.assign([], history)
|
||||
newHistory.splice(currentPos, 0, input)
|
||||
|
||||
fetchApi(`/commands`, {
|
||||
method: 'POST',
|
||||
@ -96,13 +94,19 @@ export default function CommandBar() {
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
setHistory(newHistory)
|
||||
setHistory(data.history)
|
||||
setCurrentPos(currentPos + 1)
|
||||
setNextArgs([])
|
||||
|
||||
setResults([...results, {"id": results.length, "result": data.result}])
|
||||
setResults([...results, {
|
||||
"id": results.length,
|
||||
"command": input,
|
||||
"result": JSON.stringify(data.result)
|
||||
}])
|
||||
})
|
||||
|
||||
setSignatureHelp("")
|
||||
setDescription("")
|
||||
|
||||
setInput("")
|
||||
setOriginalInput("")
|
||||
}
|
||||
@ -130,7 +134,6 @@ export default function CommandBar() {
|
||||
|
||||
const onKeyUp = (e) => {
|
||||
if (input == "") return
|
||||
console.log("keyup event")
|
||||
parseCommand(originalInput, input)
|
||||
e.stopPropagation()
|
||||
}
|
||||
@ -143,6 +146,7 @@ export default function CommandBar() {
|
||||
<div className="command-result">
|
||||
{results.map(result => (
|
||||
<div key={result.id}>
|
||||
<div><strong>$ {result.command}</strong></div>
|
||||
{result.result}
|
||||
</div>
|
||||
))}
|
||||
|
Loading…
Reference in New Issue
Block a user