mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
Merge pull request #1944 from fumiama/winres
feat(windows): add icon and metadata
This commit is contained in:
commit
8cb8428785
4
.gitignore
vendored
4
.gitignore
vendored
@ -12,6 +12,10 @@ internal/btree/*.db
|
|||||||
|
|
||||||
# binary builds
|
# binary builds
|
||||||
go-cqhttp
|
go-cqhttp
|
||||||
|
*.exe
|
||||||
|
|
||||||
# macos
|
# macos
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# windwos rc
|
||||||
|
*.syso
|
||||||
|
@ -3,6 +3,9 @@ env:
|
|||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
|
- go install github.com/tc-hib/go-winres@latest
|
||||||
|
- go generate winres/init.go
|
||||||
|
- go-winres make
|
||||||
release:
|
release:
|
||||||
draft: true
|
draft: true
|
||||||
discussion_category_name: General
|
discussion_category_name: General
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://ishkong.github.io/go-cqhttp-docs/">
|
<a href="https://ishkong.github.io/go-cqhttp-docs/">
|
||||||
<img src="https://user-images.githubusercontent.com/25968335/120111974-8abef880-c139-11eb-99cd-fa928348b198.png" width="200" height="200" alt="go-cqhttp">
|
<img src="winres/icon.png" width="200" height="200" alt="go-cqhttp">
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
1
winres/.gitignore
vendored
Normal file
1
winres/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
winres.json
|
118
winres/gen/json.go
Normal file
118
winres/gen/json.go
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
// Package main generates winres.json
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Mrs4s/go-cqhttp/internal/base"
|
||||||
|
)
|
||||||
|
|
||||||
|
const js = `{
|
||||||
|
"RT_GROUP_ICON": {
|
||||||
|
"APP": {
|
||||||
|
"0000": [
|
||||||
|
"icon.png",
|
||||||
|
"icon16.png"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RT_MANIFEST": {
|
||||||
|
"#1": {
|
||||||
|
"0409": {
|
||||||
|
"identity": {
|
||||||
|
"name": "go-cqhttp",
|
||||||
|
"version": "%s"
|
||||||
|
},
|
||||||
|
"description": "",
|
||||||
|
"minimum-os": "vista",
|
||||||
|
"execution-level": "as invoker",
|
||||||
|
"ui-access": false,
|
||||||
|
"auto-elevate": false,
|
||||||
|
"dpi-awareness": "system",
|
||||||
|
"disable-theming": false,
|
||||||
|
"disable-window-filtering": false,
|
||||||
|
"high-resolution-scrolling-aware": false,
|
||||||
|
"ultra-high-resolution-scrolling-aware": false,
|
||||||
|
"long-path-aware": false,
|
||||||
|
"printer-driver-isolation": false,
|
||||||
|
"gdi-scaling": false,
|
||||||
|
"segment-heap": false,
|
||||||
|
"use-common-controls-v6": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RT_VERSION": {
|
||||||
|
"#1": {
|
||||||
|
"0000": {
|
||||||
|
"fixed": {
|
||||||
|
"file_version": "%s",
|
||||||
|
"product_version": "%s",
|
||||||
|
"timestamp": "%s"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"0409": {
|
||||||
|
"Comments": "Golang implementation of cqhttp.",
|
||||||
|
"CompanyName": "Mrs4s",
|
||||||
|
"FileDescription": "https://github.com/Mrs4s/go-cqhttp",
|
||||||
|
"FileVersion": "%s",
|
||||||
|
"InternalName": "",
|
||||||
|
"LegalCopyright": "©️ 2020 - %d Mrs4s. All Rights Reserved.",
|
||||||
|
"LegalTrademarks": "",
|
||||||
|
"OriginalFilename": "GOCQHTTP.EXE",
|
||||||
|
"PrivateBuild": "",
|
||||||
|
"ProductName": "go-cqhttp",
|
||||||
|
"ProductVersion": "%s",
|
||||||
|
"SpecialBuild": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
const timeformat = `2006-01-02T15:04:05+08:00`
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
f, err := os.Create("winres.json")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
v := ""
|
||||||
|
if base.Version == "(devel)" {
|
||||||
|
vartag := bytes.NewBuffer(nil)
|
||||||
|
vartagcmd := exec.Command("git", "tag", "--sort=committerdate")
|
||||||
|
vartagcmd.Stdout = vartag
|
||||||
|
err = vartagcmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
s := strings.Split(vartag.String(), "\n")
|
||||||
|
v = s[len(s)-2]
|
||||||
|
} else {
|
||||||
|
v = base.Version
|
||||||
|
}
|
||||||
|
i := strings.Index(v, "-") // remove -rc / -beta
|
||||||
|
if i <= 0 {
|
||||||
|
i = len(v)
|
||||||
|
}
|
||||||
|
commitcnt := strings.Builder{}
|
||||||
|
commitcnt.WriteString(v[1:i])
|
||||||
|
commitcnt.WriteByte('.')
|
||||||
|
commitcntcmd := exec.Command("git", "rev-list", "--count", "master")
|
||||||
|
commitcntcmd.Stdout = &commitcnt
|
||||||
|
err = commitcntcmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fv := commitcnt.String()[:commitcnt.Len()-1]
|
||||||
|
_, err = fmt.Fprintf(f, js, fv, fv, v, time.Now().Format(timeformat), fv, time.Now().Year(), v)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
BIN
winres/icon.png
Normal file
BIN
winres/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
BIN
winres/icon16.png
Normal file
BIN
winres/icon16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
4
winres/init.go
Normal file
4
winres/init.go
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// Package winres 生成windows资源
|
||||||
|
package winres
|
||||||
|
|
||||||
|
//go:generate go run github.com/Mrs4s/go-cqhttp/winres/gen
|
Loading…
x
Reference in New Issue
Block a user