From ea4bcb4aaff9fb71dc2f968c39cac48cabd457b3 Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 12:17:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20reamdme=E9=87=8C=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E6=BA=90=E7=A0=81=E5=90=AF=E5=8A=A8=E5=91=BD=E4=BB=A4=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E5=A4=B1=E6=95=88=EF=BC=8C=E5=9B=A0=E4=B8=BAui/dist?= =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E4=BB=A3=E7=A0=81=E4=BB=93=E5=BA=93=E4=B8=AD?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 +++ README.md | 3 +-- README_EN.md | 3 +-- main.go | 6 +++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7c2f0d6d..af32f777 100644 --- a/Makefile +++ b/Makefile @@ -35,3 +35,6 @@ help: @echo " make help - 显示此帮助信息" .PHONY: all build clean help + +local.run: + go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve diff --git a/README.md b/README.md index cb3b0b29..3f5ef4fc 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,7 @@ mkdir -p ~/.certimate && cd ~/.certimate && curl -O https://raw.githubuserconten ```bash git clone EMAIL:usual2970/certimate.git cd certimate -go mod vendor -go run main.go serve +make local.run ``` ## 二、使用 diff --git a/README_EN.md b/README_EN.md index d048cecb..f8923c44 100644 --- a/README_EN.md +++ b/README_EN.md @@ -54,8 +54,7 @@ mkdir -p ~/.certimate && cd ~/.certimate && curl -O https://raw.githubuserconten ```bash git clone EMAIL:usual2970/certimate.git cd certimate -go mod vendor -go run main.go serve +make local.run ``` ## Usage diff --git a/main.go b/main.go index 7a0bf641..3cd0bd06 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "github.com/usual2970/certimate/ui" "log" "os" "strings" @@ -16,6 +15,7 @@ import ( "github.com/usual2970/certimate/internal/domains" "github.com/usual2970/certimate/internal/routes" "github.com/usual2970/certimate/internal/utils/app" + "github.com/usual2970/certimate/ui" _ "time/tzdata" ) @@ -46,6 +46,10 @@ func main() { return nil }) + defer log.Println("Exit!") + go func() { + log.Println("Visit the website:", "http://127.0.0.1:8090") + }() if err := app.Start(); err != nil { log.Fatal(err) From 0c35928eee9dd653bc542c5b91e77e49a606abc7 Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 12:26:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E7=BB=88=E7=AB=AF=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 3cd0bd06..fa1d38d2 100644 --- a/main.go +++ b/main.go @@ -46,10 +46,9 @@ func main() { return nil }) + defer log.Println("Exit!") - go func() { - log.Println("Visit the website:", "http://127.0.0.1:8090") - }() + log.Println("Visit the website:", "http://127.0.0.1:8090") if err := app.Start(); err != nil { log.Fatal(err) From 265842feebcf592fb243f52352a2cd5720f5323b Mon Sep 17 00:00:00 2001 From: liburdi Date: Tue, 22 Oct 2024 13:52:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E5=8F=82=E6=95=B0=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- main.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index af32f777..d5987872 100644 --- a/Makefile +++ b/Makefile @@ -37,4 +37,4 @@ help: .PHONY: all build clean help local.run: - go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve + go mod vendor&& npm --prefix ./ui install && npm --prefix ./ui run build && go run main.go serve --http 127.0.0.1:8090 diff --git a/main.go b/main.go index fa1d38d2..39758d42 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "log" "os" "strings" @@ -25,6 +26,12 @@ func main() { isGoRun := strings.HasPrefix(os.Args[0], os.TempDir()) + // 获取启动命令中的http参数 + var httpFlag string + flag.StringVar(&httpFlag, "http", "127.0.0.1:8090", "HTTP server address") + // "serve"影响解析 + _ = flag.CommandLine.Parse(os.Args[2:]) + migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{ // enable auto creation of migration files when making collection changes in the Admin UI // (the isGoRun check is to enable it only during development) @@ -48,7 +55,7 @@ func main() { }) defer log.Println("Exit!") - log.Println("Visit the website:", "http://127.0.0.1:8090") + log.Printf("Visit the website: http://%s", httpFlag) if err := app.Start(); err != nil { log.Fatal(err)