Merge branch 'master' into dev

This commit is contained in:
akrike
2025-02-08 01:14:44 +08:00
38 changed files with 32 additions and 32 deletions

View File

@@ -1,6 +1,8 @@
package api
import (
"slices"
"github.com/lzh-1625/go_process_manager/internal/app/constants"
"github.com/lzh-1625/go_process_manager/internal/app/model"
"github.com/lzh-1625/go_process_manager/internal/app/repository"
@@ -14,22 +16,19 @@ type logApi struct{}
var LogApi = new(logApi)
func (a *logApi) GetLog(ctx *gin.Context, req model.GetLogReq) {
filterName := make([]string, 0, len(req.FilterName))
processNameList := repository.PermissionRepository.GetProcessNameByPermission(getUserName(ctx), constants.OPERATION_LOG)
if len(filterName) != 0 {
for _, v := range processNameList {
for _, m := range req.FilterName {
if v == m {
filterName = append(filterName, m)
break
}
}
}
if isAdmin(ctx) {
rOk(ctx, "Query successful!", service.LogServiceImpl.Search(req, req.FilterName...))
} else {
filterName = append(filterName, processNameList...)
processNameList := repository.PermissionRepository.GetProcessNameByPermission(getUserName(ctx), constants.OPERATION_LOG)
filterName := slices.DeleteFunc(req.FilterName, func(s string) bool {
return !slices.Contains(processNameList, s)
})
if len(filterName) == 0 {
filterName = processNameList
}
errCheck(ctx, len(filterName) == 0, "No information found!")
rOk(ctx, "Query successful!", service.LogServiceImpl.Search(req, filterName...))
}
errCheck(ctx, !isAdmin(ctx) && len(filterName) == 0, "No information found!")
rOk(ctx, "Query successful!", service.LogServiceImpl.Search(req, filterName...))
}
func (a *logApi) GetRunningLog(ctx *gin.Context) {

View File

@@ -91,7 +91,7 @@ type ProcessLog struct {
Id int `json:"id,omitempty" gorm:"primaryKey;autoIncrement;column:id" `
Log string `json:"log" gorm:"column:log" type:"text"`
Time int64 `json:"time" gorm:"column:time" type:"long"`
Name string `json:"name" gorm:"column:name" type:"keyword"`
Name string `json:"name" gorm:"column:name" type:"text"`
Using string `json:"using" gorm:"column:using" type:"keyword"`
}

View File

@@ -1,7 +1,6 @@
package route
import (
"embed"
"io/fs"
"net/http"
@@ -10,6 +9,7 @@ import (
"github.com/lzh-1625/go_process_manager/internal/app/constants"
"github.com/lzh-1625/go_process_manager/internal/app/middle"
"github.com/lzh-1625/go_process_manager/log"
"github.com/lzh-1625/go_process_manager/resources"
"github.com/lzh-1625/go_process_manager/utils"
"github.com/gin-contrib/pprof"
@@ -29,20 +29,17 @@ func Route() {
log.Logger.Fatalw("服务器启动失败", "err", err)
}
//go:embed templates
var f embed.FS
func staticInit(r *gin.Engine) {
r.NoRoute(func(c *gin.Context) {
b, _ := f.ReadFile("templates/index.html")
b, _ := resources.Templates.ReadFile("templates/index.html")
c.Data(http.StatusOK, "text/html; charset=utf-8", b)
})
r.StaticFS("/js", http.FS(utils.UnwarpIgnore(fs.Sub(f, "templates/js"))))
r.StaticFS("/css", http.FS(utils.UnwarpIgnore(fs.Sub(f, "templates/css"))))
r.StaticFS("/media", http.FS(utils.UnwarpIgnore(fs.Sub(f, "templates/media"))))
r.StaticFS("/fonts", http.FS(utils.UnwarpIgnore(fs.Sub(f, "templates/fonts"))))
r.StaticFS("/js", http.FS(utils.UnwarpIgnore(fs.Sub(resources.Templates, "templates/js"))))
r.StaticFS("/css", http.FS(utils.UnwarpIgnore(fs.Sub(resources.Templates, "templates/css"))))
r.StaticFS("/media", http.FS(utils.UnwarpIgnore(fs.Sub(resources.Templates, "templates/media"))))
r.StaticFS("/fonts", http.FS(utils.UnwarpIgnore(fs.Sub(resources.Templates, "templates/fonts"))))
r.GET("/favicon.ico", func(ctx *gin.Context) {
ctx.Data(200, "image/x-icon", utils.UnwarpIgnore(f.ReadFile("templates/favicon.ico")))
ctx.Data(200, "image/x-icon", utils.UnwarpIgnore(resources.Templates.ReadFile("templates/favicon.ico")))
})
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -78,13 +78,11 @@ func (p *ProcessPty) SetTerminalSize(cols, rows int) {
}
func (p *ProcessPty) WriteBytes(input []byte) (err error) {
p.logReportHandler(config.CF.ProcessInputPrefix + string(input))
_, err = p.pty.Write(input)
return
}
func (p *ProcessPty) Write(input string) (err error) {
p.logReportHandler(config.CF.ProcessInputPrefix + input)
_, err = p.pty.Write([]byte(input))
return
}

6
resources/resources.go Normal file
View File

@@ -0,0 +1,6 @@
package resources
import "embed"
//go:embed templates
var Templates embed.FS

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 730 KiB

After

Width:  |  Height:  |  Size: 730 KiB

View File

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 141 KiB

View File

Before

Width:  |  Height:  |  Size: 898 KiB

After

Width:  |  Height:  |  Size: 898 KiB

View File

@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>login</title><script defer="defer" src="/js/chunk-vendors.5b52f07b.js"></script><script defer="defer" src="/js/app.35a813b1.js"></script><link href="/css/chunk-vendors.965b2fe9.css" rel="stylesheet"><link href="/css/app.254f733a.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but login doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>login</title><script defer="defer" src="/js/chunk-vendors.c371f7f2.js"></script><script defer="defer" src="/js/app.5b64d7f6.js"></script><link href="/css/chunk-vendors.965b2fe9.css" rel="stylesheet"><link href="/css/app.254f733a.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but login doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long