mirror of
https://github.com/koho/frpmgr.git
synced 2025-10-20 16:03:47 +08:00
Add action for opening config file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,4 +2,3 @@
|
|||||||
logs
|
logs
|
||||||
bin
|
bin
|
||||||
*.syso
|
*.syso
|
||||||
icon/*.ico
|
|
BIN
icon/open.ico
Normal file
BIN
icon/open.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
@ -9,6 +9,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||||||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest.xml
|
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST manifest.xml
|
||||||
11 ICON icon/app.ico
|
11 ICON icon/app.ico
|
||||||
21 ICON icon/dot.ico
|
21 ICON icon/dot.ico
|
||||||
|
22 ICON icon/open.ico
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO \
|
VS_VERSION_INFO VERSIONINFO \
|
||||||
FILEVERSION FRPMGR_VERSION_ARRAY \
|
FILEVERSION FRPMGR_VERSION_ARRAY \
|
||||||
|
@ -103,7 +103,7 @@ func (t *AboutPage) View() TabPage {
|
|||||||
Alignment: AlignHNearVCenter,
|
Alignment: AlignHNearVCenter,
|
||||||
Text: `<a id="home" href="https://github.com/koho/frpmgr">https://github.com/koho/frpmgr</a>`,
|
Text: `<a id="home" href="https://github.com/koho/frpmgr">https://github.com/koho/frpmgr</a>`,
|
||||||
OnLinkActivated: func(link *walk.LinkLabelLink) {
|
OnLinkActivated: func(link *walk.LinkLabelLink) {
|
||||||
t.openURL(link.URL())
|
openPath(link.URL())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
VSpacer{Size: 6},
|
VSpacer{Size: 6},
|
||||||
@ -112,7 +112,7 @@ func (t *AboutPage) View() TabPage {
|
|||||||
Alignment: AlignHNearVCenter,
|
Alignment: AlignHNearVCenter,
|
||||||
Text: `<a id="frp" href="https://github.com/fatedier/frp">https://github.com/fatedier/frp</a>`,
|
Text: `<a id="frp" href="https://github.com/fatedier/frp">https://github.com/fatedier/frp</a>`,
|
||||||
OnLinkActivated: func(link *walk.LinkLabelLink) {
|
OnLinkActivated: func(link *walk.LinkLabelLink) {
|
||||||
t.openURL(link.URL())
|
openPath(link.URL())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -132,7 +132,7 @@ func (t *AboutPage) View() TabPage {
|
|||||||
Label{AssignTo: &t.newVersionTag},
|
Label{AssignTo: &t.newVersionTag},
|
||||||
Label{AssignTo: &t.newVersionDate},
|
Label{AssignTo: &t.newVersionDate},
|
||||||
PushButton{AssignTo: &t.newVersionDownloadBtn, Text: "下载", OnClicked: func() {
|
PushButton{AssignTo: &t.newVersionDownloadBtn, Text: "下载", OnClicked: func() {
|
||||||
t.openURL(t.newVersionDownloadBtn.Name())
|
openPath(t.newVersionDownloadBtn.Name())
|
||||||
}},
|
}},
|
||||||
HSpacer{},
|
HSpacer{},
|
||||||
},
|
},
|
||||||
@ -144,11 +144,11 @@ func (t *AboutPage) View() TabPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *AboutPage) openURL(url string) {
|
func openPath(path string) {
|
||||||
if url == "" {
|
if path == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openCmd := exec.Command("cmd", "/c", "start", url)
|
openCmd := exec.Command("cmd", "/c", "start", path)
|
||||||
openCmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
openCmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
|
||||||
openCmd.Start()
|
openCmd.Start()
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/lxn/walk"
|
"github.com/lxn/walk"
|
||||||
. "github.com/lxn/walk/declarative"
|
. "github.com/lxn/walk/declarative"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -225,7 +226,7 @@ func (t *ConfSectionView) View() Widget {
|
|||||||
Action{
|
Action{
|
||||||
AssignTo: &t.webAction,
|
AssignTo: &t.webAction,
|
||||||
Text: "Web",
|
Text: "Web",
|
||||||
Image: loadSysIcon("shell32", 14, 16),
|
Image: loadSysIcon("shell32", 13, 16),
|
||||||
OnTriggered: func() {
|
OnTriggered: func() {
|
||||||
t.onQuickAddSection(NewSimpleSectionDialog("Web", "web", []string{"tcp"}, 80))
|
t.onQuickAddSection(NewSimpleSectionDialog("Web", "web", []string{"tcp"}, 80))
|
||||||
},
|
},
|
||||||
@ -248,6 +249,18 @@ func (t *ConfSectionView) View() Widget {
|
|||||||
Enabled: Bind("section.Selected"),
|
Enabled: Bind("section.Selected"),
|
||||||
OnTriggered: t.onDeleteSection,
|
OnTriggered: t.onDeleteSection,
|
||||||
},
|
},
|
||||||
|
Action{
|
||||||
|
Image: loadResourceIcon(22, 16),
|
||||||
|
Text: "打开配置文件",
|
||||||
|
OnTriggered: func() {
|
||||||
|
if !t.mustSelectConf() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if path, err := filepath.Abs(t.model.conf.Path); err == nil {
|
||||||
|
openPath(path)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TableView{
|
TableView{
|
||||||
|
@ -42,7 +42,7 @@ func iconForState(state config.ServiceState, size int) (icon *walk.Icon) {
|
|||||||
case config.StateStarted:
|
case config.StateStarted:
|
||||||
icon = loadSysIcon("imageres", 101, size)
|
icon = loadSysIcon("imageres", 101, size)
|
||||||
case config.StateStopped:
|
case config.StateStopped:
|
||||||
icon, _ = walk.NewIconFromResourceIdWithSize(21, walk.Size{size, size})
|
icon = loadResourceIcon(21, size)
|
||||||
default:
|
default:
|
||||||
icon = loadSysIcon("shell32", 238, size)
|
icon = loadSysIcon("shell32", 238, size)
|
||||||
}
|
}
|
||||||
@ -71,3 +71,8 @@ func loadNewVersionIcon(size int) (icon *walk.Icon) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadResourceIcon(id int, size int) (icon *walk.Icon) {
|
||||||
|
icon, _ = walk.NewIconFromResourceIdWithSize(id, walk.Size{size, size})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user