又优化了很多
This commit is contained in:
parent
20a6efe559
commit
a06bd65ce6
@ -7,6 +7,7 @@ import (
|
||||
"admin/apps/game/model"
|
||||
"admin/internal/errcode"
|
||||
"admin/internal/model/dto"
|
||||
"admin/lib/xlog"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -83,7 +84,8 @@ func (svc *ProjectService) GetAllItems(projectId int) ([]*dto.CommonDtoFieldChoi
|
||||
|
||||
handler := projects.GetProjectValueChoicesGetHook(projectEt.Po.ProjectType)
|
||||
if handler == nil {
|
||||
return nil, errcode.New(errcode.ServerError, "not found project %v items handler", projectEt.Po.ProjectType)
|
||||
xlog.Warnf("project %+v not found choices hook", projectEt.Po)
|
||||
return make([]*dto.CommonDtoFieldChoice, 0), nil
|
||||
}
|
||||
|
||||
return handler.GetItems(projectEt)
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"admin/internal/consts"
|
||||
)
|
||||
|
||||
var debugDisableAllHook = false // 调试用,关闭所有项目钩子调用,可以在没有远程游戏api服务器时,调一些gm后台本地的增删改查等逻辑
|
||||
|
||||
// 注册各个项目所有gm资源操作后的回调,例如后台添加了白名单,可以在回调里加上通知项目内的服务
|
||||
var projectsResourceHookMgr = map[string]map[string]any{
|
||||
// 神魔大陆项目注册的资源钩子回调
|
||||
@ -26,6 +28,9 @@ var projectsValueChoicesGetHook = map[string]IGetAllValueChoicesHook{
|
||||
}
|
||||
|
||||
func GetProjectResourceHook(project *entity.Project, resource string) any {
|
||||
if debugDisableAllHook {
|
||||
return nil
|
||||
}
|
||||
projectResourceHooks, find := projectsResourceHookMgr[project.Po.ProjectType]
|
||||
if !find {
|
||||
return nil
|
||||
@ -34,5 +39,8 @@ func GetProjectResourceHook(project *entity.Project, resource string) any {
|
||||
}
|
||||
|
||||
func GetProjectValueChoicesGetHook(projectId string) IGetAllValueChoicesHook {
|
||||
if debugDisableAllHook {
|
||||
return nil
|
||||
}
|
||||
return projectsValueChoicesGetHook[projectId]
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func (items *Items) GetItems(projectInfo *entity.Project) ([]*dto.CommonDtoField
|
||||
rsp := &RspData{}
|
||||
err := httpclient.Request(alisrvAddr+"/items", "get", nil, rsp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return make([]*dto.CommonDtoFieldChoice, 0), nil
|
||||
}
|
||||
return rsp.Data.List, nil
|
||||
}
|
||||
|
@ -12,6 +12,14 @@ import (
|
||||
)
|
||||
|
||||
func Request(addr string, method string, body interface{}, resData interface{}) error {
|
||||
err := request(addr, method, body, resData)
|
||||
if err != nil {
|
||||
xlog.Errorf("访问远程地址:%v 方法: %v 参数:%+v,发生错误:%v", addr, method, body, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func request(addr string, method string, body interface{}, resData interface{}) error {
|
||||
removeUrl := checkUrl(addr)
|
||||
|
||||
//xlog.Debugf("-->req url: %v", removeUrl)
|
||||
@ -22,7 +30,6 @@ func Request(addr string, method string, body interface{}, resData interface{})
|
||||
if body != nil {
|
||||
bodyBytes, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
xlog.Warnf(err)
|
||||
return errcode.New(errcode.ServerError, "数据解析失败:%v", err)
|
||||
}
|
||||
bodyReader = strings.NewReader(string(bodyBytes))
|
||||
@ -32,13 +39,11 @@ func Request(addr string, method string, body interface{}, resData interface{})
|
||||
}
|
||||
req, err := http.NewRequest(method, removeUrl, bodyReader)
|
||||
if err != nil {
|
||||
xlog.Warnf(err)
|
||||
return errcode.New(errcode.ServerError, "数据请求创建失败:%v", err)
|
||||
}
|
||||
|
||||
res, err = client.Do(req)
|
||||
if err != nil {
|
||||
xlog.Warnf(err)
|
||||
return errcode.New(errcode.ServerError, "数据请求失败:%v", err)
|
||||
}
|
||||
} else {
|
||||
@ -76,13 +81,11 @@ func Request(addr string, method string, body interface{}, resData interface{})
|
||||
|
||||
req, err := http.NewRequest("get", removeUrl, nil)
|
||||
if err != nil {
|
||||
xlog.Warnf(err)
|
||||
return errcode.New(errcode.ServerError, "数据请求创建失败:%v", err)
|
||||
}
|
||||
|
||||
res, err = client.Do(req)
|
||||
if err != nil {
|
||||
xlog.Warnf(err)
|
||||
return errcode.New(errcode.ServerError, "数据请求失败:%v", err)
|
||||
}
|
||||
}
|
||||
@ -92,7 +95,6 @@ func Request(addr string, method string, body interface{}, resData interface{})
|
||||
|
||||
resBody, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
xlog.Warnf(err)
|
||||
return errcode.New(errcode.ServerError, "数据解析失败:%v", err)
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ router.beforeEach((to, from, next) => {
|
||||
if (to.path === '/login') {
|
||||
// 有token 跳过登录
|
||||
console.log("有token走登录,跳过登录", token)
|
||||
next({path: '/'})
|
||||
next({path: '/welcome'})
|
||||
} else {
|
||||
|
||||
console.log("跳到页面:" + to.path + ",当前所有路由:", router.getRoutes())
|
||||
@ -20,17 +20,25 @@ router.beforeEach((to, from, next) => {
|
||||
if (!userStore().hasGetUserInfo()) {
|
||||
// console.log("访问页面获取用户信息。。。", to.path)
|
||||
userStore().getUserInfo().then(() => {
|
||||
// console.log("获取用户信息成功,继续:", to.path)
|
||||
next({...to, replace: true})
|
||||
console.log("获取用户信息成功,继续:", to.path)
|
||||
if (to.path === "/") {
|
||||
next({path: '/welcome'})
|
||||
} else {
|
||||
next({...to, replace: true})
|
||||
}
|
||||
}).catch(err => {
|
||||
userStore().logout().then(() => {
|
||||
ElMessage.error(err)
|
||||
next({path: '/'})
|
||||
next({path: '/login'})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
console.log("获取过用户数据,跳过获取。。。")
|
||||
next()
|
||||
if (to.path === "/") {
|
||||
next({path: '/welcome'})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -123,12 +123,12 @@ function logout() {
|
||||
<el-dropdown class="right-menu-item hover-effect" trigger="click" @command="handleCommand">
|
||||
|
||||
<!-- 头像 -->
|
||||
<div class="avatar-wrapper">
|
||||
<span style="font-size: 20px">{{ nickName }}</span>
|
||||
<el-icon color="black" size="20">
|
||||
<ArrowDownBold/>
|
||||
</el-icon>
|
||||
</div>
|
||||
<span style="font-size: 20px">
|
||||
{{ nickName }}
|
||||
<el-icon color="black" size="10">
|
||||
<arrow-down/>
|
||||
</el-icon>
|
||||
</span>
|
||||
|
||||
|
||||
<!-- 头像操作下拉菜单 -->
|
||||
|
@ -26,13 +26,13 @@
|
||||
<el-button class="theme-button" type="primary" @click="submitForm(loginForm)" @keydown.enter="keyDown()">登
|
||||
陆
|
||||
</el-button>
|
||||
<p class="forget"
|
||||
@click="
|
||||
currentModel = !currentModel;
|
||||
isForget = true;
|
||||
">
|
||||
--- Forget Passwoed----
|
||||
</p>
|
||||
<!-- <p class="forget"-->
|
||||
<!-- @click="-->
|
||||
<!-- currentModel = !currentModel;-->
|
||||
<!-- isForget = true;-->
|
||||
<!-- ">-->
|
||||
<!-- --- Forget Passwoed------>
|
||||
<!-- </p>-->
|
||||
|
||||
<!-- </el-form-item>-->
|
||||
</el-form>
|
||||
@ -80,7 +80,7 @@ const submitForm = (formEl) => {
|
||||
if (valid) {
|
||||
userStore().login(loginForm.value.user, loginForm.value.password).then(() => {
|
||||
console.log("登录成功,推送首页。。")
|
||||
router.push({path: "/"})
|
||||
router.push({path: "/welcome"})
|
||||
}, (res) => {
|
||||
|
||||
}).catch(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user