优化uniapp
This commit is contained in:
1 parent
4f1acaa451
commit
8fc52c574f
49 files changed
+1952
-197
No files matched your search
@@ -97,6 +97,16 @@ func (c *AppAggregateController) Home() {
|
||||
return
|
||||
}
|
||||
tid := uint64(claims.TenantId)
|
||||
// 注册即登录:新用户尚未加入企业时令牌 tid=0。
|
||||
// 此时按「原免登录功能」返回公开模块与公开菜单,其余模块由前端引导创建/挂靠企业。
|
||||
if tid == 0 {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": c.noTenantHome(claims),
|
||||
})
|
||||
return
|
||||
}
|
||||
uid := services.ResolveTenantUID(tid, uint64(claims.UserID))
|
||||
|
||||
modules := c.appModules(tid)
|
||||
@@ -125,6 +135,77 @@ func (c *AppAggregateController) Home() {
|
||||
})
|
||||
}
|
||||
|
||||
// noTenantHome tid=0(已注册、尚未加入企业)时的首屏数据。
|
||||
// 模块沿用公开宫格(保留 require_login 作为「需企业」标记),菜单只下发免登录菜单,
|
||||
// 因此新注册用户能直接使用原「免登录」功能,进入需企业模块时由端上引导申请。
|
||||
func (c *AppAggregateController) noTenantHome(claims *jwtutil.Claims) map[string]interface{} {
|
||||
var modRows []models.SystemModules
|
||||
_, _ = models.Orm.QueryTable(new(models.SystemModules)).
|
||||
Filter("delete_time__isnull", true).
|
||||
Filter("status", 1).
|
||||
Filter("is_show", 1).
|
||||
OrderBy("sort", "id").
|
||||
All(&modRows)
|
||||
modRows = services.FilterModulesByPlatform(modRows, models.PlatformApp)
|
||||
modules := make([]publicModuleItem, 0, len(modRows))
|
||||
for _, m := range modRows {
|
||||
modules = append(modules, publicModuleItem{
|
||||
ID: m.ID, Code: m.Code, Name: m.Name, Icon: m.Icon,
|
||||
Path: m.Path, Description: m.Description, RequireLogin: m.RequireLogin,
|
||||
})
|
||||
}
|
||||
|
||||
var menuRows []models.SystemMenu
|
||||
_, _ = models.Orm.QueryTable(new(models.SystemMenu)).
|
||||
Filter("status", 1).
|
||||
Filter("require_login", 0).
|
||||
All(&menuRows)
|
||||
allModules := c.allModules()
|
||||
menus := make([]appMenuItem, 0, len(menuRows))
|
||||
for _, m := range menuRows {
|
||||
if m.Type == 3 {
|
||||
continue
|
||||
}
|
||||
item := appMenuItem{
|
||||
ID: m.ID, Pid: m.Pid, Type: m.Type, Sort: m.Sort,
|
||||
Title: strings.TrimSpace(m.Title), Leaf: true,
|
||||
}
|
||||
if m.Path != nil {
|
||||
item.Path = strings.TrimSpace(*m.Path)
|
||||
}
|
||||
if m.Icon != nil {
|
||||
item.Icon = strings.TrimSpace(*m.Icon)
|
||||
}
|
||||
item.Module = appModuleCodeOfPath(item.Path, allModules)
|
||||
menus = append(menus, item)
|
||||
}
|
||||
|
||||
state := "none"
|
||||
var apply models.AuthTenantApply
|
||||
if err := models.Orm.QueryTable(new(models.AuthTenantApply)).
|
||||
Filter("identity_id", uint64(claims.UserID)).
|
||||
Filter("delete_time__isnull", true).
|
||||
OrderBy("-id").One(&apply); err == nil {
|
||||
switch apply.Status {
|
||||
case models.TenantApplyStatusPending:
|
||||
state = "pending"
|
||||
case models.TenantApplyStatusReject:
|
||||
state = "rejected"
|
||||
}
|
||||
}
|
||||
|
||||
return map[string]interface{}{
|
||||
"user": map[string]interface{}{
|
||||
"account": claims.Username, "tenant": "", "tid": 0, "need_tenant": true,
|
||||
},
|
||||
"modules": modules,
|
||||
"menus": menus,
|
||||
"stats": map[string]interface{}{},
|
||||
"quick_menu_ids": []uint64{},
|
||||
"tenant_state": state,
|
||||
}
|
||||
}
|
||||
|
||||
// publicModuleItem 移动端免登录可见的模块卡片:只暴露展示与安全开关,不含菜单/KPI。
|
||||
// 供未登录用户渲染 nav 宫格,require_login 决定点击是「进登录引导」还是「直接进入」。
|
||||
type publicModuleItem struct {
|
||||
|
||||
Reference in new issue
Block a user