mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 11:07:39 +08:00
Merge pull request #1943 from fumiama/title
feat: 在启动时设置标题为 `go-cqhttp 版本 版权`
This commit is contained in:
commit
95adb403e9
15
global/terminal/title.go
Normal file
15
global/terminal/title.go
Normal file
@ -0,0 +1,15 @@
|
||||
//go:build !windows
|
||||
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
)
|
||||
|
||||
// SetTitle 设置标题为 go-cqhttp `版本` `版权`
|
||||
func SetTitle() {
|
||||
fmt.Printf("\033]0;go-cqhttp "+base.Version+" © 2020 - %d Mrs4s"+"\007", time.Now().Year())
|
||||
}
|
29
global/terminal/title_windows.go
Normal file
29
global/terminal/title_windows.go
Normal file
@ -0,0 +1,29 @@
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||
)
|
||||
|
||||
func setConsoleTitle(title string) error {
|
||||
p0, err := syscall.UTF16PtrFromString(title)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r1, _, err := windows.NewLazySystemDLL("kernel32.dll").NewProc("SetConsoleTitleW").Call(uintptr(unsafe.Pointer(p0)))
|
||||
if r1 == 0 {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTitle 设置标题为 go-cqhttp `版本` `版权`
|
||||
func SetTitle() {
|
||||
_ = setConsoleTitle(fmt.Sprintf("go-cqhttp "+base.Version+" © 2020 - %d Mrs4s", time.Now().Year()))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user