Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
duolabmeng6 committed Oct 17, 2023
2 parents 5b916ab + d1f2c6d commit f2da452
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
25 changes: 6 additions & 19 deletions GoEasyDesigner/Terminal/Terminal_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"bufio"
"errors"
"fmt"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"github.com/duolabmeng6/goefun/ecore"
"os/exec"
"sync"
)
Expand All @@ -35,13 +34,8 @@ func (t *Terminal) StartCommand(command string, fn func(string, error)) bool {
}

cmd := exec.Command("cmd", "/C", command)
stdout, err := cmd.StdoutPipe()
if err != nil {
fn("", err)
return false
}

stderr, err := cmd.StderrPipe()
stdout, err := cmd.StdoutPipe()
if err != nil {
fn("", err)
return false
Expand All @@ -54,11 +48,11 @@ func (t *Terminal) StartCommand(command string, fn func(string, error)) bool {
t.cmd = cmd
t.stdout = bufio.NewScanner(stdout)
t.isRunning = true
gbkDecoder := simplifiedchinese.GBK.NewDecoder()

go func() {
for t.stdout.Scan() {
output := t.stdout.Text()
output = ecore.E文本编码转换(output, "", "utf8")
fn(output, nil)
}

Expand All @@ -73,23 +67,16 @@ func (t *Terminal) StartCommand(command string, fn func(string, error)) bool {
}()

go func() {
// 读取命令的错误输出并传递给回调函数
errScanner := bufio.NewScanner(stderr)
for errScanner.Scan() {
errOutput := errScanner.Text()
errOutput, _, _ = transform.String(gbkDecoder, errOutput)

fn("", errors.New(errOutput))
}

cmd.Wait()
t.lock.Lock()
t.isRunning = false
t.lock.Unlock()
fmt.Println("命令已完成")
println("命令已完成")
fn("", errors.New("命令已完成"))

}()
return true

}

func (t *Terminal) StopCommand() {
Expand Down
5 changes: 2 additions & 3 deletions GoEasyDesigner/frontend/src/action/app9.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ appAction._打开文件加载界面 = function (filepath) {
}

// 使用 $refs 来引用滚动容器
const scrollContainer = ref(null);

try {
EventsOn("运行命令", function (data) {
console.log("运行命令", data)
store.调试信息 = store.调试信息 + "<br / >" + data
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
store.scrollContainer.scrollTop = store.scrollContainer.scrollHeight;
if (data == "命令已完成") {
store.运行按钮文本 = "运行"
store.编译按钮文本 = "编译"
Expand Down Expand Up @@ -211,7 +210,7 @@ appAction.运行 = function () {
store.运行按钮文本 = '停止'
store.调试信息 = "运行中 ..."
store.选择夹_底部现行选中项 = "1"
E运行命令(store.项目信息.项目根目录, "wails dev")
E运行命令(store.项目信息.项目根目录, "wails dev -nocolour")
} else {
store.调试信息 = "已停止 ..."
store.运行按钮文本 = '运行'
Expand Down
5 changes: 4 additions & 1 deletion GoEasyDesigner/frontend/src/app9.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<el-link href="https://github.com/duolabmeng6/GoEasyDesigner/releases">前往下载 Github Releases</el-link>
</p>

<div ref="scrollContainer" style="height: 100px;overflow-y: auto"
<div ref="" style="height: 100px;overflow-y: auto"
v-html="store.帮助信息"
></div>

Expand Down Expand Up @@ -157,7 +157,10 @@ import {BrowserOpenURL, EventsOn} from "../wailsjs/runtime";
const store = useCounterStore()
store.初始化()
const 创建组件属性默认值 = inject("创建组件属性默认值")
const scrollContainer = ref(null);
onMounted(() => {
store.scrollContainer = scrollContainer.value;
appAction.init()
appAction.新建()
store.取组件列表()
Expand Down
1 change: 1 addition & 0 deletions GoEasyDesigner/frontend/src/stores/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const useCounterStore = defineStore('counter', {

组件列表tree现行选中项: ref(""),
组件列表tree: ref([]),
scrollContainer: ref(null),
}
},

Expand Down
2 changes: 1 addition & 1 deletion GoEasyDesigner/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/duolabmeng6/goefun v1.3.6
github.com/ncruces/zenity v0.10.10
github.com/wailsapp/wails/v2 v2.6.0
golang.org/x/text v0.11.0
)

require (
Expand Down Expand Up @@ -48,4 +47,5 @@ require (
golang.org/x/image v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
)

0 comments on commit f2da452

Please sign in to comment.