feat(vscode): 添加调试参数配置

为launch.json添加-debug=1参数,便于调试模式启动

docs(README): 补充zellij终端复用工具使用说明

添加x-cmd安装和zellij会话管理相关命令示例

refactor(config): 注释掉GamePort配置项

暂时注释GamePort配置项以解决配置冲突问题

refactor(xmlres): 移除未使用的gf框架依赖
This commit is contained in:
2026-01-01 22:19:00 +08:00
parent dd28d48ca4
commit 3e55b0f481
13 changed files with 72 additions and 87 deletions

1
.vscode/launch.json vendored
View File

@@ -10,6 +10,7 @@
"request": "launch",
"mode": "auto",
"cwd": "${workspaceFolder}",
"args": ["-debug=1"],
"program": "${workspaceFolder}/login"
},
// {

View File

@@ -18,3 +18,7 @@ go tool pprof -http :8081 "http://127.0.0.1:9909/debug/pprof/profile"
- [指令](./docs/command.md)
- [系统属性](./docs/properties.md)
- [登录](./docs/login.md)
eval "$(curl https://get.x-cmd.com)"
x zellij
x zellij -s bl 新建
x zellij a bl 启动

View File

@@ -40,7 +40,7 @@ func newConfig() *sConfig {
Eps: GetCfgWithDefault(ctx, "blazing.eps", g.NewVar(false)).Bool(),
Port: string(GetCfgWithDefault(ctx, "server.port", g.NewVar("8080")).String()),
RPC: GetCfgWithDefault(ctx, "server.rpc", g.NewVar("8080")).Uint16(),
GamePort: GetCfgWithDefault(ctx, "server.game", g.NewVar("8080")).Uint64s(),
//GamePort: GetCfgWithDefault(ctx, "server.game", g.NewVar("8080")).Uint64s(),
File: &file{
Mode: GetCfgWithDefault(ctx, "blazing.file.mode", g.NewVar("none")).String(),

View File

@@ -8,10 +8,6 @@ import (
"os"
"github.com/ECUST-XX/xml"
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/os/gfsnotify"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/os/gres"
"github.com/gogf/gf/v2/util/gconv"
)
@@ -140,42 +136,42 @@ func Initfile() {
}
func init() {
// func init() {
go func() {
// go func() {
if !gfile.Exists(path) {
fileHandle, _ := gfile.Create(path)
fileHandle.Close()
}
// if !gfile.Exists(path) {
// fileHandle, _ := gfile.Create(path)
// fileHandle.Close()
// }
//updatersares()
ctx := gctx.New()
_, err := gfsnotify.Add(path, func(event *gfsnotify.Event) {
if event.IsCreate() {
glog.Debug(ctx, "创建文件 : ", event.Path)
}
if event.IsWrite() {
glog.Debug(ctx, "写入文件 : ", event.Path)
//initfile() //先初始化一次
}
if event.IsRemove() {
glog.Debug(ctx, "删除文件 : ", event.Path)
}
if event.IsRename() {
glog.Debug(ctx, "重命名文件 : ", event.Path)
}
if event.IsChmod() {
glog.Debug(ctx, "修改权限 : ", event.Path)
}
glog.Debug(ctx, event)
})
// //updatersares()
// ctx := gctx.New()
// _, err := gfsnotify.Add(path, func(event *gfsnotify.Event) {
// if event.IsCreate() {
// glog.Debug(ctx, "创建文件 : ", event.Path)
// }
// if event.IsWrite() {
// glog.Debug(ctx, "写入文件 : ", event.Path)
// //initfile() //先初始化一次
// }
// if event.IsRemove() {
// glog.Debug(ctx, "删除文件 : ", event.Path)
// }
// if event.IsRename() {
// glog.Debug(ctx, "重命名文件 : ", event.Path)
// }
// if event.IsChmod() {
// glog.Debug(ctx, "修改权限 : ", event.Path)
// }
// glog.Debug(ctx, event)
// })
if err != nil {
glog.Fatal(ctx, err)
} else {
select {}
}
}()
// if err != nil {
// glog.Fatal(ctx, err)
// } else {
// select {}
// }
// }()
}
// }

File diff suppressed because one or more lines are too long

View File

@@ -51,6 +51,7 @@ func (h *ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) erro
return fmt.Errorf("no reverse client")
}
t := blservice.NewLoginServiceService().GetServerID(id)
aa, ok := cool.GetClient(t.Port)
if ok && aa != nil { //如果已经存在且这个端口已经被存过
aa.QuitSelf(0)

View File

@@ -13,6 +13,7 @@ import (
"log"
"net"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
@@ -55,6 +56,10 @@ func isPortAvailable(port uint32) bool {
func Start(serverID uint16) {
// 确定端口
r := blservice.NewLoginServiceService().GetServerID(serverID)
if r.IsVip == 1 {
g.DB().SetDebug(true)
}
port, err := determinePort(r.CanPort)
if err != nil {
log.Fatalf("Failed to determine port: %v", err)

View File

@@ -24,6 +24,9 @@ func (e *NewSel11) Skill_Use_ex() bool {
return true
}
if e.Ctx().Opp.SumDamage.IntPart() == 0 {
return true
}
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
Type: info.DamageType.Fixed,

View File

@@ -21,6 +21,10 @@ var (
Brief: "start http server",
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
// g.Dump(g.DB("test").GetConfig())
r := parser.GetArgAll()
if len(r) > 0 {
g.DB().SetDebug(true)
}
if cool.IsRedisMode {
go cool.ListenFunc(ctx)
}

View File

@@ -1,6 +1,6 @@
server:
name: "blazing server"
address: ":8080" #前台服务器地址
address: ":59480" #前台服务器地址
port: 53388 #后台服务器端口
rpc: 56409 #rpc服务端口
openapiPath: "/api.json"
@@ -23,11 +23,11 @@ database:
user: "bl"
pass: "4DD4z3T2Zh8rx8Yd"
name: "bl"
debug: true
debug: false
timezone: "Asia/Shanghai"
createdAt: "createTime"
updatedAt: "updateTime"
timeMaintainDisabled: false # (可选)是否完全关闭时间更新特性为true时CreatedAt/UpdatedAt/DeletedAt都将失效
#timeMaintainDisabled: false # (可选)是否完全关闭时间更新特性为true时CreatedAt/UpdatedAt/DeletedAt都将失效
# deletedAt: "deleteTime"
# default:
# type: "mysql"

View File

@@ -3,7 +3,6 @@ package admin
import (
"context"
"blazing/common/data/share"
"blazing/cool"
"blazing/modules/base/service"
@@ -51,11 +50,8 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq)
return &SessionRes{}, nil
}
retsid, sid, err := blazing_service.NewLoginServiceService().GetSessionId(t.UserId)
if err != nil {
return &SessionRes{}, nil
retsid := blazing_service.NewLoginServiceService().GetSessionId(t.UserId)
}
res = &SessionRes{}
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
@@ -67,10 +63,6 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq)
}
if err := share.ShareManager.SaveSession(sid, uint32(t.UserId)); err != nil {
return &SessionRes{}, nil
}
return
}

View File

@@ -1,7 +1,6 @@
package app
import (
"blazing/common/data/share"
"blazing/cool"
baseservice "blazing/modules/base/service"
"blazing/modules/blazing/service"
@@ -61,19 +60,8 @@ func (c *BlazingController) GetSession(ctx context.Context, req *SessionReq) (re
}
accountID := res1.ID
retsid, sid, err := biazing_service.GetSessionId(accountID)
if err != nil {
res.Code = 400
res.Msg = err.Error()
}
res.Session = retsid
if err := share.ShareManager.SaveSession(sid, uint32(accountID)); err != nil {
res.Code = 400
res.Msg = err.Error()
}
res.Session = biazing_service.GetSessionId(accountID)
return
}

View File

@@ -1,15 +1,14 @@
package service
import (
"blazing/common/data/share"
"blazing/cool"
"blazing/modules/config/model"
"encoding/binary"
"encoding/hex"
"strings"
"github.com/gogf/gf/v2/util/grand"
"github.com/google/uuid"
"github.com/gogf/gf/v2/util/guid"
)
type LoginService struct {
@@ -27,22 +26,14 @@ func NewLoginServiceService() *LoginService {
// 生成session
// GetSessionId 生成并返回会话ID、UUID字符串及可能的错误
// 会话ID由accountID(4字节) + UUID(16字节) + 随机数(4字节)组成,最终编码为十六进制字符串
func (s *LoginService) GetSessionId(accountID uint) (string, string, error) {
// 生成UUID v7带错误处理UUID生成失败时返回错误
uuidV7, err := uuid.NewV7()
if err != nil {
return "", "", err
}
func (s *LoginService) GetSessionId(accountID uint) string {
// // 生成UUID v7带错误处理UUID生成失败时返回错误
// uuidV7, err := uuid.NewV7()
// if err != nil {
// return "", "", err
// }
// 移除UUID中的连字符便于后续处理
uuidStr := strings.ReplaceAll(uuidV7.String(), "-", "")
// 解码UUID字符串为字节数组32位十六进制字符串对应16字节
uuidBytes, err := hex.DecodeString(uuidStr)
if err != nil {
// 理论上UUID生成的字符串不会出现解码错误此处为防御性处理
return "", "", err
}
uuidStr := guid.S()
// 将accountID转换为4字节大端序字节数组
accountBytes := make([]byte, 4)
@@ -51,13 +42,13 @@ func (s *LoginService) GetSessionId(accountID uint) (string, string, error) {
// 预分配缓冲区总长度4+16+4=24字节减少内存分配
sessionBytes := make([]byte, 0, 24)
sessionBytes = append(sessionBytes, accountBytes...)
sessionBytes = append(sessionBytes, uuidBytes...)
sessionBytes = append(sessionBytes, grand.B(4)...)
sessionBytes = append(sessionBytes, uuidStr...)
//sessionBytes = append(sessionBytes, grand.B(4)...)
// 编码为十六进制字符串作为最终会话ID
sessionID := hex.EncodeToString(sessionBytes)
return sessionID, uuidStr, nil
share.ShareManager.SaveSession(uuidStr, uint32(accountID))
return sessionID
}
func (s *LoginService) SetServerID(OnlineID uint16, Port uint16) error {