Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup golang
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Start Redis
Expand All @@ -34,12 +34,28 @@ jobs:
- name: Unit Test
run: make test
- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o admin-${{ matrix.os }}-${{ matrix.arch }}
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o admin
- name: Windows
if: matrix.os == 'windows'
run: mv admin admin.exe
- name: Archive artifact
if: matrix.os != 'windows'
uses: actions/upload-artifact@v4
with:
name: admin-${{ matrix.os }}-${{ matrix.arch }}
path: admin-${{ matrix.os }}-${{ matrix.arch }}
path: |
admin
public
config/*.yml
- name: Archive artifact exe
if: matrix.os == 'windows'
uses: actions/upload-artifact@v4
with:
name: admin-${{ matrix.os }}-${{ matrix.arch }}
path: |
admin.exe
public
config/*.yml

release:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ config/application-*
temp
test
public
docs
docs
dist/*
mss-boot-admin*
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ The `mss-boot-io` project has always been developed in the GoLand integrated dev
8. [jwt-go](https://github.com/dgrijalva/jwt-go)
9. [oauth2](https://pkg.go.dev/golang.org/x/oauth2)

## 🤟 Sponsor Us

If you think this project helped you, you can buy a glass of juice for the author to show encouragement 🍹

<img class="no-margin" src="https://mss-boot-io.github.io/.github/images/sponsor-us.jpg" height="400px" alt="Sponsor Us">

## 🔑 License

[MIT](https://github.com/mss-boot-io/mss-boot-admin/blob/main/LICENSE)
Expand Down
5 changes: 5 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ npm run start
8. [jwt-go](https://github.com/dgrijalva/jwt-go)
9. [oauth2](https://pkg.go.dev/golang.org/x/oauth2)

## 🤟 打赏
如果你觉得这个项目帮助到了你,你可以帮作者买一杯果汁表示鼓励 🍹

<img class="no-margin" src="https://mss-boot-io.github.io/.github/images/sponsor-us.jpg" height="400px" alt="Sponsor Us">

## 🔑 License

[MIT](https://github.com/mss-boot-io/mss-boot-admin/blob/main/LICENSE)
Expand Down
2 changes: 1 addition & 1 deletion center/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Center interface {
}

type GRPCClientImp interface {
GetGRPCClient(string) *grpc.ClientConn
GetGRPCClient(string, ...grpc.DialOption) *grpc.ClientConn
}

type MakeRouterImp interface {
Expand Down
12 changes: 12 additions & 0 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ func setup() error {
source.WithDir("mss-boot-admin/config"),
source.WithWatch(true),
}
case source.APPConfig:
opts = []source.Option{
source.WithProvider(source.APPConfig),
source.WithProjectName(pkg.GetProjectName()),
source.WithNamespace(pkg.GetStage()),
}
case source.Local, "":
default:
slog.Error("config provider not support", "provider", configProvider)
Expand Down Expand Up @@ -187,6 +193,12 @@ func setup() error {
action.SetModel(ms[i].GetKey(), ms[i].Make())
}

// ui server init for dev
if config.Cfg.Application.Mode == config.ModeDev &&
config.Cfg.Application.UI.Enabled {
runnable = append(runnable, config.Cfg.Application.UI.Init())
}

// setup 08 add runnable to manager
center.Default.Add(runnable...)

Expand Down
24 changes: 24 additions & 0 deletions config/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ package config
*/

import (
"github.com/mss-boot-io/mss-boot/core/server"
"github.com/mss-boot-io/mss-boot/core/server/listener"
"github.com/mss-boot-io/mss-boot/pkg/config"
"path/filepath"

"github.com/gin-gonic/gin"
Expand All @@ -27,6 +30,7 @@ type Application struct {
Origin string `yaml:"origin" json:"origin"`
StaticPath map[string]string `yaml:"staticPath" json:"staticPath"`
Labels map[string]string `yaml:"labels" json:"labels"`
UI UIServer `yaml:"ui" json:"ui"`
}

func (e *Application) Init(r gin.IRouter) {
Expand Down Expand Up @@ -65,3 +69,23 @@ func (e *Application) Init(r gin.IRouter) {
// no static
}
}

type UIServer struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Path string `yaml:"path" json:"path"`
config.Listen `yaml:",inline" json:",inline"`
}

func (u *UIServer) Init() server.Runnable {
if !u.Enabled {
return nil
}

r := gin.Default()
r.Static("/", u.Path)
r.LoadHTMLFiles(filepath.Join(u.Path, "index.html"))
r.NoRoute(func(c *gin.Context) {
c.HTML(200, "index.html", nil)
})
return u.Listen.Init(listener.WithHandler(r))
}
4 changes: 4 additions & 0 deletions config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ server:
application:
mode: dev
origin: http://127.0.0.1:8080
ui:
enabled: true
addr: 0.0.0.0:8000
path: dist
staticPath:
/public: public
labels:
Expand Down
Loading