Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync main to docs #66

Merged
merged 34 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
99eb487
upgrade the version
xxl4 Nov 11, 2023
e0ec23b
fix the build version
xxl4 Nov 11, 2023
6b5f60a
udate
xxl4 Nov 12, 2023
0d6bdaa
udate
xxl4 Nov 12, 2023
2f0a29c
udate
xxl4 Nov 12, 2023
5b74403
#61 fix when make docs report response don't found
xxl4 Nov 15, 2023
7738a0c
add docs on the makefile
xxl4 Nov 15, 2023
4cc57e3
fix the cusmenu for vue3
xxl4 Nov 15, 2023
a7dacf3
add cusmenu
xxl4 Nov 16, 2023
022f323
add cusmenu
xxl4 Nov 16, 2023
bb89132
add cusmenu
xxl4 Nov 16, 2023
569cf1f
add cus menu roles
xxl4 Nov 16, 2023
b3d2516
fix the secure
xxl4 Nov 17, 2023
df6859b
add zip support
xxl4 Nov 17, 2023
b976356
go build befor need go mod tidy
xxl4 Nov 17, 2023
688e66b
custom tls data
xxl4 Nov 17, 2023
7c9909d
default enable the secure info
xxl4 Nov 17, 2023
41485c2
fix lang
xxl4 Nov 17, 2023
7fcb2fa
upgrade gzip for easy-admin
xxl4 Nov 17, 2023
96431e4
Update README.md
xxl4 Nov 17, 2023
330fd1f
add gzip config
xxl4 Nov 17, 2023
4aeba6e
add gzip config
xxl4 Nov 17, 2023
666a1f0
Merge branch 'main' into dev-1.3.0
xxl4 Nov 17, 2023
58a73bf
upgrade 1.3.0 read me document
xxl4 Nov 17, 2023
781075c
Merge branch 'dev-1.3.0' of github.com:nicelizhi/easy-admin into dev-…
xxl4 Nov 17, 2023
b5f855f
Dev 1.3.0 (#63)
xxl4 Nov 17, 2023
2846cd6
fix the readme
xxl4 Nov 17, 2023
dfb86ec
upgrade
xxl4 Nov 17, 2023
76468e7
upgrade
xxl4 Nov 17, 2023
5610b5b
Dev 1.3.0 (#64)
xxl4 Nov 17, 2023
a773aca
document upgrade
xxl4 Nov 17, 2023
d0f68ba
upgrade docs
xxl4 Nov 17, 2023
2070f96
Dev 1.3.0 update docs (#65)
xxl4 Nov 17, 2023
b488ebb
Merge branch 'docs' into main
xxl4 Nov 17, 2023
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
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ jobs:
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: nicesteven/easy-admin

- name: Build and push Docker image version
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: nicesteven/easy-admin:1.3.0

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LDFLAGS := -s -w
# application name
PROJECT:=easy-admin
# application version
VERSION := 1.2.0
VERSION := 1.3.0
# application url
URL := https://github.com/nicelizhi/easy-admin

Expand All @@ -26,7 +26,7 @@ build-ui:

# build go application
build:
CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -a -installsuffix "" -o $(PROJECT) .
CGO_ENABLED=0 go mod tidy && go build -ldflags="$(LDFLAGS)" -a -installsuffix "" -o $(PROJECT) .

# make build-linux
build-linux:
Expand Down Expand Up @@ -55,9 +55,14 @@ start:
nohup ./$(PROJECT) server -c=config/settings.dev_steve.yml >> acc.txt &
ps aux | grep "$(PROJECT)"

.PHONY: easy-admin
stop:
pkill $(PROJECT)

# debug file
debug:
dlv debug $(file)
dlv debug $(file)

.PHONY: docs
docs:
swag init -g easy-admin.go --parseDependency --parseDepth=6 --instanceName admin -o ./docs/admin
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## About Easy-Admin

Easyadmin is a Quick, beautiful and modern admin gererator for Go VUE application.
Easyadmin is a Quick, beautiful and modern admin generator for Go VUE application.

English | [简体中文](https://nicelizhi.github.io/easy-admin/zh/)

Expand Down Expand Up @@ -48,8 +48,6 @@ English | [简体中文](https://nicelizhi.github.io/easy-admin/zh/)

- TimeZone Support

- Static packaging for vue page


## Internal

Expand Down Expand Up @@ -103,4 +101,4 @@ http://localhost:8000/swagger/admin/index.html
[https://gitee.com/nicelizhi/easy-admin/issues](https://gitee.com/nicelizhi/easy-admin/issues) (中国)

# Discussions
[https://github.com/nicelizhi/easy-admin/discussions](https://github.com/nicelizhi/easy-admin/discussions)
[https://github.com/nicelizhi/easy-admin/discussions](https://github.com/nicelizhi/easy-admin/discussions)
3 changes: 1 addition & 2 deletions app/admin/apis/captcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package apis
import (
"github.com/nicelizhi/easy-admin-core/sdk/api"
"github.com/nicelizhi/easy-admin-core/sdk/pkg/captcha"
_ "github.com/nicelizhi/easy-admin-core/sdk/pkg/response"

ginI18n "github.com/gin-contrib/i18n"
"github.com/gin-gonic/gin"
Expand All @@ -21,14 +22,12 @@ type System struct {
func (e System) GenerateCaptchaHandler(c *gin.Context) {
err := e.MakeContext(c).Errors
if err != nil {
//e.Error(500, err, "服务初始化失败!")
e.Error(500, err, ginI18n.MustGetMessage(c, "Service initialization failed"))
return
}
id, b64s, err := captcha.DriverDigitFunc()
if err != nil {
e.Logger.Errorf("DriverDigitFunc error, %s", err.Error())
//e.Error(500, err, "验证码获取失败")
e.Error(500, err, ginI18n.MustGetMessage(c, "Failed to obtain verification code"))
return
}
Expand Down
1 change: 1 addition & 0 deletions app/admin/apis/sys_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"

_ "github.com/nicelizhi/easy-admin-core/sdk/pkg/response"
"github.com/nicelizhi/easy-admin/app/admin/models"
"github.com/nicelizhi/easy-admin/app/admin/service"
"github.com/nicelizhi/easy-admin/app/admin/service/dto"
Expand Down
1 change: 1 addition & 0 deletions app/admin/apis/sys_login_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"

_ "github.com/nicelizhi/easy-admin-core/sdk/pkg/response"
"github.com/nicelizhi/easy-admin/app/admin/service"
"github.com/nicelizhi/easy-admin/app/admin/service/dto"
)
Expand Down
39 changes: 38 additions & 1 deletion app/admin/apis/sys_menu.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package apis

import (
"fmt"

"github.com/nicelizhi/easy-admin/app/admin/models"

"github.com/nicelizhi/easy-admin-core/sdk/api"
Expand All @@ -10,6 +12,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"

_ "github.com/nicelizhi/easy-admin-core/sdk/pkg/response"
"github.com/nicelizhi/easy-admin/app/admin/service"
"github.com/nicelizhi/easy-admin/app/admin/service/dto"
)
Expand Down Expand Up @@ -76,7 +79,41 @@ func (e SysMenu) CusGetPage(c *gin.Context) {
return
}

list2 := make(map[string]interface{}, 0)
list2 := make([]interface{}, 0)

for index, item := range list {
var litem = make(map[string]interface{})
var meta = make(map[string]interface{})
var children = make([]interface{}, 0)
for index1, item2 := range item.Children {
var litem2 = make(map[string]interface{})
var meta2 = make(map[string]interface{})

litem2["name"] = item2.MenuName
litem2["path"] = item2.Path
meta2["locale"] = item2.Permission
meta2["requiresAuth"] = true
meta2["hideInMenu"] = false
meta2["icon"] = item2.Icon
meta2["order"] = item2.Sort
meta2["roles"] = item2.Permission
litem2["meta"] = meta2
fmt.Println(index1)
children = append(children[:len(children)], litem2)
}

meta["locale"] = item.Permission
meta["requiresAuth"] = true
meta["hideInMenu"] = false
meta["icon"] = item.Icon
meta["order"] = item.Sort
litem["name"] = item.MenuName
litem["path"] = item.Path
litem["meta"] = meta
litem["children"] = children
fmt.Println(index, " = ", item)
list2 = append(list2[:len(list2)], litem)
}

e.OK(list2, ginI18n.MustGetMessage(c, "Query successful"))
}
Expand Down
1 change: 1 addition & 0 deletions app/admin/apis/sys_opera_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/nicelizhi/easy-admin/app/admin/service/dto"

"github.com/nicelizhi/easy-admin-core/sdk/api"
_ "github.com/nicelizhi/easy-admin-core/sdk/pkg/response"

ginI18n "github.com/gin-contrib/i18n"
"github.com/gin-gonic/gin"
Expand Down
2 changes: 1 addition & 1 deletion app/admin/apis/sys_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (e SysUser) GetInfo(c *gin.Context) {
req.Id = user.GetUserId(c)
err = s.Get(&req, p, &sysUser)
if err != nil {
e.Error(http.StatusUnauthorized, err, "登录失败")
e.Error(http.StatusUnauthorized, err, ginI18n.MustGetMessage(c, "Login failed"))
return
}
mp["introduction"] = " am a super administrator"
Expand Down
2 changes: 1 addition & 1 deletion app/admin/models/initdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func InitDb(db *gorm.DB) (err error) {
func ExecSql(db *gorm.DB, filePath string) error {
sql, err := Ioutil(filePath)
if err != nil {
fmt.Println("数据库基础数据初始化脚本读取失败!原因:", err.Error())
fmt.Println("Error Detail: ", err.Error())
return err
}
sqlList := strings.Split(sql, ";")
Expand Down
2 changes: 1 addition & 1 deletion cmd/migrate/migration/models/initdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func InitDb(db *gorm.DB) (err error) {
func ExecSql(db *gorm.DB, filePath string) error {
sql, err := Ioutil(filePath)
if err != nil {
fmt.Println("数据库基础数据初始化脚本读取失败!原因:", err.Error())
fmt.Println("Error Detail:", err.Error())
return err
}
sqlList := strings.Split(sql, ";")
Expand Down
11 changes: 9 additions & 2 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"syscall"
"time"

"github.com/gin-contrib/gzip"
"github.com/nicelizhi/easy-admin-core/config/source/file"
"github.com/nicelizhi/easy-admin-core/sdk"
"github.com/nicelizhi/easy-admin-core/sdk/api"
Expand Down Expand Up @@ -180,9 +181,14 @@ func initRouter() {
log.Fatal("not support other engine")
//os.Exit(-1)
}
if config.SslConfig.Enable {
r.Use(handler.TlsHandler())
// if config.SslConfig.Enable {
r.Use(handler.TlsHandler()) // add more secure for it
// }

if config.ApplicationConfig.Gzip {
r.Use(gzip.Gzip(config.ApplicationConfig.GzipLevel))
}

r.Use(common.Sentinel()).
Use(common.RequestId(pkg.TrafficKey)).
Use(api.SetRequestLogger).
Expand All @@ -199,6 +205,7 @@ func initRouter() {
flag := strings.Contains(accept, "text/html")
if flag {
ctx.Writer.WriteHeader(200)
ctx.Header("Content-Type", "text/html; charset=utf-8")
ctx.Writer.WriteString(string(resource.Html))
ctx.Writer.Flush()
}
Expand Down
4 changes: 2 additions & 2 deletions common/global/adm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package global

const (
// Version easy-admin version info
Version = "1.2.0"
VersionNum = 120 // version number
Version = "1.3.0"
VersionNum = 130 // version number
HomePage = "https://github.com/nicelizhi/easy-admin/" //project home page
TemplateVer = "v1"
)
Expand Down
4 changes: 2 additions & 2 deletions common/middleware/handler/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Authenticator(c *gin.Context) (interface{}, error) {
if config.ApplicationConfig.Mode != "dev" {
if !captcha.Verify(loginVals.UUID, loginVals.Code, true) {
username = loginVals.Username
msg = "验证码错误"
msg = ginI18n.MustGetMessage(c, "Verification code error")
status = "1"

return nil, jwt.ErrInvalidVerificationode
Expand All @@ -104,7 +104,7 @@ func Authenticator(c *gin.Context) (interface{}, error) {

return map[string]interface{}{"user": sysUser, "role": role}, nil
} else {
msg = "登录失败"
msg = ginI18n.MustGetMessage(c, "Login failed")
status = "1"
log.Warnf("%s login failed!", loginVals.Username)
}
Expand Down
33 changes: 26 additions & 7 deletions common/middleware/handler/httpshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,33 @@ import (

func TlsHandler() gin.HandlerFunc {
return func(c *gin.Context) {
secureMiddleware := secure.New(secure.Options{
SSLRedirect: true,
SSLHost: config.SslConfig.Domain,
})
err := secureMiddleware.Process(c.Writer, c.Request)
if err != nil {
return
if config.SslConfig.Enable {
secureMiddleware := secure.New(secure.Options{
SSLRedirect: true,
SSLHost: config.SslConfig.Domain,
IsDevelopment: true,
})
err := secureMiddleware.Process(c.Writer, c.Request)
if err != nil {
c.Abort()
return
}
} else {
secureMiddleware := secure.New(secure.Options{
IsDevelopment: true,
})
err := secureMiddleware.Process(c.Writer, c.Request)
if err != nil {
c.Abort()
return
}
}

// Avoid header rewrite if response is a redirection.
if status := c.Writer.Status(); status > 300 && status < 399 {
c.Abort()
}

c.Next()
}
}
9 changes: 9 additions & 0 deletions config/settings.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ settings:
timezone: "Africa/Cairo"
# local
local: "en"
# gzip enable
gzip: true
#gzip level
# options 1、BestCompression 1、BestSpeed 1、DefaultCompression 1、NoCompression
# NoCompression = 0
# BestSpeed = 1
# BestCompression = 9
# DefaultCompression = -1
gziplevel: 9
ssl:
# https domain
domain: localhost:8000
Expand Down
2 changes: 1 addition & 1 deletion core
Submodule core updated from 7041a9 to 18afba
13 changes: 13 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Easy Admin Change log
> All notable changes to this project will be documented in this file.

## [v1.3.0](https://github.com/nicelizhi/easy-admin/releases/tag/1.3.0)
. fix the lang support
. add gzip support and gzip config
. add acro vue support function

## [v1.2.0](https://github.com/nicelizhi/easy-admin/releases/tag/1.2.0)
. change the db deleted_at to flag.
. fix the cores bug
. fix the cores security
. fix the easy-admin ui
. add MSSQL db sql
. fix the build docker to docker hub

## [v1.1.0](https://github.com/nicelizhi/easy-admin/releases/tag/1.1.0)
. fix the redis queue client bug

Expand Down
Loading
Loading