77 lines
1.7 KiB
Go
77 lines
1.7 KiB
Go
package ui
|
|
|
|
import (
|
|
"go_dreamfactory/cmd/v2/lib/common"
|
|
"go_dreamfactory/cmd/v2/service/observer"
|
|
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/theme"
|
|
"fyne.io/fyne/v2/widget"
|
|
"golang.org/x/crypto/ssh"
|
|
"golang.org/x/crypto/ssh/terminal"
|
|
)
|
|
|
|
type appTerm struct {
|
|
appAdapter
|
|
|
|
obs observer.Observer
|
|
}
|
|
|
|
type termResizer struct {
|
|
widget.Icon
|
|
|
|
term *terminal.Terminal
|
|
debug bool
|
|
sess *ssh.Session
|
|
win fyne.Window
|
|
}
|
|
|
|
func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|
this.obs = obs
|
|
|
|
this.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_TERM, theme.ContentCopyIcon(), nil)
|
|
content := container.NewMax()
|
|
content.Objects = []fyne.CanvasObject{}
|
|
|
|
//cmd input
|
|
multiEntry := widget.NewMultiLineEntry()
|
|
multiEntry.PlaceHolder = "命令输入,使用;分隔"
|
|
|
|
//config
|
|
ip := widget.NewEntry()
|
|
userName := widget.NewEntry()
|
|
password := widget.NewPasswordEntry()
|
|
|
|
configForm := widget.NewForm(
|
|
&widget.FormItem{Text: "IP:", Widget: ip},
|
|
&widget.FormItem{Text: "用户名:", Widget: userName},
|
|
&widget.FormItem{Text: "密码:", Widget: password},
|
|
)
|
|
saveBtn := widget.NewButtonWithIcon("保存配置", theme.DocumentSaveIcon(), func() {
|
|
|
|
})
|
|
connBtn := widget.NewButtonWithIcon("连接", theme.ConfirmIcon(), func() {
|
|
|
|
})
|
|
btns := container.NewGridWithColumns(2, saveBtn, connBtn)
|
|
|
|
//term
|
|
t := &termResizer{win: toolWin.w}
|
|
t.ExtendBaseWidget(t)
|
|
|
|
split := container.NewVSplit(container.NewGridWithColumns(2,
|
|
multiEntry,
|
|
container.NewBorder(configForm, btns, widget.NewSeparator(), nil)), t)
|
|
split.Offset = 0.3
|
|
content.Objects = append(content.Objects, split)
|
|
|
|
this.tabItem.Content = content
|
|
|
|
return nil
|
|
}
|
|
|
|
func (a *appTerm) GetAppName() string {
|
|
return common.TOOLBAR_TERM
|
|
}
|