fix: the console output content lacks line breaks effect #80
This commit is contained in:
parent
e7fd13d608
commit
7b18ed0b26
|
@ -21,8 +21,8 @@ type cliService struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type cliOutput struct {
|
type cliOutput struct {
|
||||||
Content string `json:"content"` // output content
|
Content []string `json:"content"` // output content
|
||||||
Prompt string `json:"prompt,omitempty"` // new line prompt, empty if not ready to input
|
Prompt string `json:"prompt,omitempty"` // new line prompt, empty if not ready to input
|
||||||
}
|
}
|
||||||
|
|
||||||
var cli *cliService
|
var cli *cliService
|
||||||
|
@ -67,7 +67,7 @@ func (c *cliService) runCommand(server, data string) {
|
||||||
|
|
||||||
func (c *cliService) echo(server, data string, newLineReady bool) {
|
func (c *cliService) echo(server, data string, newLineReady bool) {
|
||||||
output := cliOutput{
|
output := cliOutput{
|
||||||
Content: data,
|
Content: strings.Split(data, "\n"),
|
||||||
}
|
}
|
||||||
if newLineReady {
|
if newLineReady {
|
||||||
output.Prompt = fmt.Sprintf("%s:db%d> ", server, c.selectedDB[server])
|
output.Prompt = fmt.Sprintf("%s:db%d> ", server, c.selectedDB[server])
|
||||||
|
|
|
@ -351,16 +351,18 @@ const replaceTermInput = (content = '') => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process receive output content
|
* process receive output content
|
||||||
* @param {{content, prompt}} data
|
* @param {{content: string[], prompt: string}} data
|
||||||
*/
|
*/
|
||||||
const receiveTermOutput = (data) => {
|
const receiveTermOutput = (data) => {
|
||||||
if (termInst == null) {
|
if (termInst == null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { content, prompt } = data || {}
|
const { content = [], prompt } = data || {}
|
||||||
if (!isEmpty(content)) {
|
if (!isEmpty(content)) {
|
||||||
termInst.write('\r\n' + content)
|
for (const line of content) {
|
||||||
|
termInst.write('\r\n' + line)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!isEmpty(prompt)) {
|
if (!isEmpty(prompt)) {
|
||||||
promptPrefix.value = prompt
|
promptPrefix.value = prompt
|
||||||
|
|
Loading…
Reference in New Issue