Use Chinese
This commit is contained in:
parent
75ac1466c7
commit
5186e3a5fb
15
main.go
15
main.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"fmt"
|
||||||
"github.com/pkg/browser"
|
"github.com/pkg/browser"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
@ -15,19 +16,25 @@ import (
|
|||||||
//go:generate go run ./builder
|
//go:generate go run ./builder
|
||||||
//go:embed build/for-build
|
//go:embed build/for-build
|
||||||
var asset embed.FS
|
var asset embed.FS
|
||||||
|
var listen = "localhost:8086"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if tmp := os.Getenv("UM_LISTEN"); tmp != "" {
|
||||||
|
listen = tmp
|
||||||
|
}
|
||||||
pfxFs := WithPrefix(asset, "build/for-build")
|
pfxFs := WithPrefix(asset, "build/for-build")
|
||||||
go func() {
|
go func() {
|
||||||
err := http.ListenAndServe("localhost:6280", http.FileServer(http.FS(pfxFs)))
|
err := http.ListenAndServe(listen, http.FileServer(http.FS(pfxFs)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("启动出错,请检查是否有其他程序占用了端口:" + listen)
|
||||||
|
_, _ = fmt.Scanln()
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
log.Println("you can now open browser with: http://localhost:6280 to access this tool.")
|
log.Printf("使用浏览器打开: %s 即可访问。", listen)
|
||||||
err := browser.OpenURL("http://localhost:6280")
|
err := browser.OpenURL("http://" + listen)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error while opening browser:", err)
|
log.Println("自动打开浏览器错误,需要手动打开: "+listen, err)
|
||||||
}
|
}
|
||||||
sign := make(chan os.Signal, 1)
|
sign := make(chan os.Signal, 1)
|
||||||
signal.Notify(sign, os.Interrupt, os.Kill)
|
signal.Notify(sign, os.Interrupt, os.Kill)
|
||||||
|
Reference in New Issue
Block a user