移除没实现的限制多端登录

This commit is contained in:
xiangheng
2024-03-15 02:01:23 +08:00
parent a047a8592c
commit f3436ec298
9 changed files with 31 additions and 64 deletions

View File

@@ -42,7 +42,7 @@
"devDependencies": { "devDependencies": {
"@rushstack/eslint-patch": "^1.7.2", "@rushstack/eslint-patch": "^1.7.2",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^20.11.25", "@types/node": "^20.11.27",
"@types/nprogress": "^0.2.3", "@types/nprogress": "^0.2.3",
"@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0", "@vitejs/plugin-vue-jsx": "^3.1.0",
@@ -51,18 +51,18 @@
"@vue/tsconfig": "^0.5.1", "@vue/tsconfig": "^0.5.1",
"autoprefixer": "^10.4.18", "autoprefixer": "^10.4.18",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-plugin-vue": "^9.22.0", "eslint-plugin-vue": "^9.23.0",
"execa": "^8.0.1", "execa": "^8.0.1",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"postcss": "^8.4.35", "postcss": "^8.4.35",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"rollup-plugin-visualizer": "^5.12.0", "rollup-plugin-visualizer": "^5.12.0",
"sass": "^1.71.1", "sass": "^1.72.0",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",
"typescript": "~5.4.2", "typescript": "~5.4.2",
"unplugin-auto-import": "^0.17.5", "unplugin-auto-import": "^0.17.5",
"unplugin-vue-components": "^0.26.0", "unplugin-vue-components": "^0.26.0",
"vite": "^5.1.5", "vite": "^5.1.6",
"vite-plugin-compression": "^0.5.1", "vite-plugin-compression": "^0.5.1",
"vite-plugin-style-import": "^2.0.0", "vite-plugin-style-import": "^2.0.0",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",

View File

@@ -103,17 +103,6 @@
<el-form-item label="管理员状态" v-if="!isRoot"> <el-form-item label="管理员状态" v-if="!isRoot">
<el-switch v-model="formData.isDisable" :active-value="0" :inactive-value="1" /> <el-switch v-model="formData.isDisable" :active-value="0" :inactive-value="1" />
</el-form-item> </el-form-item>
<el-form-item label="多处登录">
<div>
<el-switch
v-model="formData.isMultipoint"
:active-value="1"
:inactive-value="0"
/>
<div class="form-tips">允许多人同时在线登录</div>
</div>
</el-form-item>
</el-form> </el-form>
</popup> </popup>
</div> </div>
@@ -146,7 +135,6 @@ const formData = reactive({
password: '', password: '',
passwordConfirm: '', passwordConfirm: '',
isDisable: 0, isDisable: 0,
isMultipoint: 1,
//服务端为必传参数,先给默认值 //服务端为必传参数,先给默认值
sort: 1 sort: 1
}) })

View File

@@ -9,6 +9,5 @@
{ {
"path": "docs" "path": "docs"
} }
], ]
"settings": {}
} }

View File

@@ -1,7 +1,6 @@
package captcha package captcha
import ( import (
"fmt"
"image/color" "image/color"
"x_admin/config" "x_admin/config"
@@ -58,7 +57,7 @@ func init() {
// //注册自定义配置redis数据库 // //注册自定义配置redis数据库
opt, _ := redis.ParseURL(config.Config.RedisUrl) opt, _ := redis.ParseURL(config.Config.RedisUrl)
fmt.Printf("%#v", opt) // fmt.Printf("%#v", opt)
factory.RegisterCache(constant.RedisCacheKey, service.NewConfigRedisCacheService([]string{opt.Addr}, opt.Username, opt.Password, false, 0)) factory.RegisterCache(constant.RedisCacheKey, service.NewConfigRedisCacheService([]string{opt.Addr}, opt.Username, opt.Password, false, 0))
// 注册了两种验证码服务 可以自行实现更多的验证 // 注册了两种验证码服务 可以自行实现更多的验证

View File

@@ -25,7 +25,7 @@ type SystemAuthAdminAddReq struct {
Role uint `form:"role" binding:"gte=0"` // 角色 Role uint `form:"role" binding:"gte=0"` // 角色
Sort int `form:"sort" binding:"gte=0"` // 排序 Sort int `form:"sort" binding:"gte=0"` // 排序
IsDisable uint8 `form:"isDisable" binding:"oneof=0 1"` // 是否禁用: [0=否, 1=是] IsDisable uint8 `form:"isDisable" binding:"oneof=0 1"` // 是否禁用: [0=否, 1=是]
IsMultipoint uint8 `form:"isMultipoint" binding:"oneof=0 1"` // 多端登录: [0=否, 1=是]
} }
//SystemAuthAdminEditReq 管理员编辑参数 //SystemAuthAdminEditReq 管理员编辑参数
@@ -40,7 +40,6 @@ type SystemAuthAdminEditReq struct {
Role uint `form:"role" binding:"gte=0"` // 角色 Role uint `form:"role" binding:"gte=0"` // 角色
Sort int `form:"sort" binding:"gte=0"` // 排序 Sort int `form:"sort" binding:"gte=0"` // 排序
IsDisable uint8 `form:"isDisable" binding:"oneof=0 1"` // 是否禁用: [0=否, 1=是] IsDisable uint8 `form:"isDisable" binding:"oneof=0 1"` // 是否禁用: [0=否, 1=是]
IsMultipoint uint8 `form:"isMultipoint" binding:"oneof=0 1"` // 多端登录: [0=否, 1=是]
} }
//SystemAuthAdminUpdateReq 管理员更新参数 //SystemAuthAdminUpdateReq 管理员更新参数
@@ -71,7 +70,6 @@ type SystemAuthAdminResp struct {
DeptId uint `json:"deptId" structs:"deptId" excel:"name:部门ID;"` // 部门ID DeptId uint `json:"deptId" structs:"deptId" excel:"name:部门ID;"` // 部门ID
PostId uint `json:"postId" structs:"postId" excel:"name:岗位ID;"` // 岗位ID PostId uint `json:"postId" structs:"postId" excel:"name:岗位ID;"` // 岗位ID
Dept string `json:"dept" structs:"dept" excel:"name:部门;"` // 部门 Dept string `json:"dept" structs:"dept" excel:"name:部门;"` // 部门
IsMultipoint uint8 `json:"isMultipoint" structs:"isMultipoint" excel:"name:多端登录;"` // 多端登录: [0=否, 1=是]
IsDisable uint8 `json:"isDisable" structs:"isDisable" excel:"name:是否禁用;"` // 是否禁用: [0=否, 1=是] IsDisable uint8 `json:"isDisable" structs:"isDisable" excel:"name:是否禁用;"` // 是否禁用: [0=否, 1=是]
LastLoginIp string `json:"lastLoginIp" structs:"lastLoginIp" excel:"name:最后登录IP;"` // 最后登录IP LastLoginIp string `json:"lastLoginIp" structs:"lastLoginIp" excel:"name:最后登录IP;"` // 最后登录IP
LastLoginTime core.TsTime `json:"lastLoginTime" structs:"lastLoginTime" excel:"name:最后登录时间;"` // 最后登录时间 LastLoginTime core.TsTime `json:"lastLoginTime" structs:"lastLoginTime" excel:"name:最后登录时间;"` // 最后登录时间
@@ -87,7 +85,6 @@ type SystemAuthAdminSelfOneResp struct {
Avatar string `json:"avatar" structs:"avatar"` // 头像 Avatar string `json:"avatar" structs:"avatar"` // 头像
Role string `json:"role" structs:"role"` // 角色 Role string `json:"role" structs:"role"` // 角色
Dept string `json:"dept" structs:"dept"` // 部门 Dept string `json:"dept" structs:"dept"` // 部门
IsMultipoint uint8 `json:"isMultipoint" structs:"isMultipoint"` // 多端登录: [0=否, 1=是]
IsDisable uint8 `json:"isDisable" structs:"isDisable"` // 是否禁用: [0=否, 1=是] IsDisable uint8 `json:"isDisable" structs:"isDisable"` // 是否禁用: [0=否, 1=是]
LastLoginIp string `json:"lastLoginIp" structs:"lastLoginIp"` // 最后登录IP LastLoginIp string `json:"lastLoginIp" structs:"lastLoginIp"` // 最后登录IP
LastLoginTime core.TsTime `json:"lastLoginTime" structs:"lastLoginTime"` // 最后登录时间 LastLoginTime core.TsTime `json:"lastLoginTime" structs:"lastLoginTime"` // 最后登录时间

View File

@@ -91,21 +91,6 @@ func (loginSrv systemLoginService) Login(c *gin.Context, req *SystemLoginReq) (r
token := util.ToolsUtil.MakeToken() token := util.ToolsUtil.MakeToken()
adminIdStr := strconv.FormatUint(uint64(sysAdmin.ID), 10) adminIdStr := strconv.FormatUint(uint64(sysAdmin.ID), 10)
//非多处登录
if sysAdmin.IsMultipoint == 0 {
sysAdminSetKey := config.AdminConfig.BackstageTokenSet + adminIdStr
ts := util.RedisUtil.SGet(sysAdminSetKey)
if len(ts) > 0 {
var keys []string
for _, t := range ts {
keys = append(keys, t)
}
util.RedisUtil.Del(keys...)
}
util.RedisUtil.Del(sysAdminSetKey)
util.RedisUtil.SSet(sysAdminSetKey, token)
}
// 缓存登录信息 // 缓存登录信息
util.RedisUtil.Set(config.AdminConfig.BackstageTokenKey+token, adminIdStr, 7200) util.RedisUtil.Set(config.AdminConfig.BackstageTokenKey+token, adminIdStr, 7200)
admin.Service.CacheAdminUserByUid(sysAdmin.ID) admin.Service.CacheAdminUserByUid(sysAdmin.ID)

View File

@@ -22,7 +22,6 @@ type SystemAuthAdmin struct {
Role string `gorm:"not null;default:'';comment:'角色主键'"` Role string `gorm:"not null;default:'';comment:'角色主键'"`
Salt string `gorm:"not null;default:'';comment:'加密盐巴'"` Salt string `gorm:"not null;default:'';comment:'加密盐巴'"`
Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"` Sort uint16 `gorm:"not null;default:0;comment:'排序编号'"`
IsMultipoint uint8 `gorm:"not null;default:0;comment:'多端登录: 0=否, 1=是''"`
IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"` IsDisable uint8 `gorm:"not null;default:0;comment:'是否禁用: 0=否, 1=是'"`
IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"` IsDelete uint8 `gorm:"not null;default:0;comment:'是否删除: 0=否, 1=是'"`
LastLoginIp string `gorm:"not null;default:'';comment:'最后登录IP'"` LastLoginIp string `gorm:"not null;default:'';comment:'最后登录IP'"`

View File

@@ -85,7 +85,6 @@ func BuildConfig(cacheType, resourcePath string, waterConfig *WatermarkConfig, c
} else if strings.Compare(cacheType, constant.MemCacheKey) != 0 && } else if strings.Compare(cacheType, constant.MemCacheKey) != 0 &&
strings.Compare(cacheType, constant.RedisCacheKey) != 0 { strings.Compare(cacheType, constant.RedisCacheKey) != 0 {
panic(errors.New("cache type not support")) panic(errors.New("cache type not support"))
return nil
} }
if cacheExpireSec == 0 { if cacheExpireSec == 0 {
cacheExpireSec = 2 * 60 cacheExpireSec = 2 * 60

View File

@@ -1,11 +1,12 @@
package util package util
import ( import (
"log"
"os"
"unicode"
"github.com/golang/freetype" "github.com/golang/freetype"
"github.com/golang/freetype/truetype" "github.com/golang/freetype/truetype"
"io/ioutil"
"log"
"unicode"
) )
type FontUtil struct { type FontUtil struct {
@@ -19,7 +20,7 @@ func NewFontUtil(src string) *FontUtil {
// GetFont 获取一个字体对象 // GetFont 获取一个字体对象
func (f *FontUtil) GetFont() *truetype.Font { func (f *FontUtil) GetFont() *truetype.Font {
fontSourceBytes, err := ioutil.ReadFile(f.Src) fontSourceBytes, err := os.ReadFile(f.Src)
if err != nil { if err != nil {
log.Println("读取字体失败:", err) log.Println("读取字体失败:", err)
} }