mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 16:17:00 +08:00
调整权限
This commit is contained in:
@@ -25,3 +25,8 @@ export function getProtocol() {
|
|||||||
export function setProtocol(params: any) {
|
export function setProtocol(params: any) {
|
||||||
return request.post({ url: '/setting/protocol/save', params })
|
return request.post({ url: '/setting/protocol/save', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取网站接口列表
|
||||||
|
export function getApiList() {
|
||||||
|
return request.get({ url: '/apiList' })
|
||||||
|
}
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script type="text/babel">
|
<script>
|
||||||
/**
|
/**
|
||||||
* Verify 验证码组件
|
* Verify 验证码组件
|
||||||
* @description 分发验证码使用
|
* @description 分发验证码使用
|
||||||
@@ -41,7 +41,7 @@ import VerifyPoints from './Verify/VerifyPoints.vue'
|
|||||||
import { computed, ref, watch, toRefs, watchEffect } from 'vue'
|
import { computed, ref, watch, toRefs, watchEffect } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Vue2Verify',
|
name: 'Vue3Verify',
|
||||||
components: {
|
components: {
|
||||||
VerifySlide,
|
VerifySlide,
|
||||||
VerifyPoints
|
VerifyPoints
|
||||||
|
@@ -4,7 +4,7 @@ const config = {
|
|||||||
version: '1.3.3', //版本号
|
version: '1.3.3', //版本号
|
||||||
// import.meta.env.VITE_APP_BASE_URL ||
|
// import.meta.env.VITE_APP_BASE_URL ||
|
||||||
baseUrl: '', //请求接口域名
|
baseUrl: '', //请求接口域名
|
||||||
urlPrefix: '/api', //请求默认前缀
|
urlPrefix: '/api/admin', //请求默认前缀
|
||||||
timeout: 60 * 3000 //请求超时时长
|
timeout: 60 * 3000 //请求超时时长
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -96,6 +96,19 @@
|
|||||||
>
|
>
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<el-input v-model="formData.perms" placeholder="请输入权限字符" clearable />
|
<el-input v-model="formData.perms" placeholder="请输入权限字符" clearable />
|
||||||
|
<el-select
|
||||||
|
v-model="formData.perms"
|
||||||
|
placeholder="请选择权限字符"
|
||||||
|
:style="{ width: '100%' }"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in permissionOptions"
|
||||||
|
:key="index"
|
||||||
|
:label="item"
|
||||||
|
:value="item"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
|
||||||
<div class="form-tips">
|
<div class="form-tips">
|
||||||
将作为server端API验权使用,请求路径`api/system/admin/list`权限为`system:admin:list`,请谨慎修改
|
将作为server端API验权使用,请求路径`api/system/admin/list`权限为`system:admin:list`,请谨慎修改
|
||||||
</div>
|
</div>
|
||||||
@@ -177,6 +190,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { FormInstance } from 'element-plus'
|
import type { FormInstance } from 'element-plus'
|
||||||
import { menuLists, menuEdit, menuAdd, menuDetail } from '@/api/perms/menu'
|
import { menuLists, menuEdit, menuAdd, menuDetail } from '@/api/perms/menu'
|
||||||
|
import { getApiList } from '@/api/setting/website'
|
||||||
import { getModulesKey } from '@/router'
|
import { getModulesKey } from '@/router'
|
||||||
import { MenuEnum } from '@/enums/appEnums'
|
import { MenuEnum } from '@/enums/appEnums'
|
||||||
import Popup from '@/components/popup/index.vue'
|
import Popup from '@/components/popup/index.vue'
|
||||||
@@ -190,6 +204,7 @@ const mode = ref('add')
|
|||||||
const popupTitle = computed(() => {
|
const popupTitle = computed(() => {
|
||||||
return mode.value == 'edit' ? '编辑菜单' : '新增菜单'
|
return mode.value == 'edit' ? '编辑菜单' : '新增菜单'
|
||||||
})
|
})
|
||||||
|
const permissionOptions = ref([])
|
||||||
|
|
||||||
const componentsOptions = ref(getModulesKey())
|
const componentsOptions = ref(getModulesKey())
|
||||||
const querySearch = (queryString: string, cb: any) => {
|
const querySearch = (queryString: string, cb: any) => {
|
||||||
@@ -271,7 +286,11 @@ const getMenu = async () => {
|
|||||||
)
|
)
|
||||||
menuOptions.value.push(menu)
|
menuOptions.value.push(menu)
|
||||||
}
|
}
|
||||||
|
function getApiListFn() {
|
||||||
|
getApiList().then((res: any) => {
|
||||||
|
permissionOptions.value = res
|
||||||
|
})
|
||||||
|
}
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
await formRef.value?.validate()
|
await formRef.value?.validate()
|
||||||
mode.value == 'edit' ? await menuEdit(formData) : await menuAdd(formData)
|
mode.value == 'edit' ? await menuEdit(formData) : await menuAdd(formData)
|
||||||
@@ -306,6 +325,7 @@ const handleClose = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMenu()
|
getMenu()
|
||||||
|
getApiListFn()
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
|
@@ -21,6 +21,7 @@ func IndexRoute(rg *gin.RouterGroup) {
|
|||||||
rg = rg.Group("/common", middleware.TokenAuth())
|
rg = rg.Group("/common", middleware.TokenAuth())
|
||||||
rg.GET("/index/console", handle.console)
|
rg.GET("/index/console", handle.console)
|
||||||
rg.GET("/index/config", handle.config)
|
rg.GET("/index/config", handle.config)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type indexHandler struct{}
|
type indexHandler struct{}
|
||||||
|
@@ -38,11 +38,11 @@ func (iSrv indexService) Console() (res map[string]interface{}, e error) {
|
|||||||
version := map[string]interface{}{
|
version := map[string]interface{}{
|
||||||
"name": name,
|
"name": name,
|
||||||
"version": config.Config.Version,
|
"version": config.Config.Version,
|
||||||
"website": "www.x_admin.cn",
|
"website": "x.adtk.cn",
|
||||||
"based": "Vue3.x、ElementUI、MySQL",
|
"based": "Vue3.x、ElementUI、MySQL",
|
||||||
"channel": map[string]string{
|
"channel": map[string]string{
|
||||||
"gitee": "https://gitee.com/x_admin/x_admin_python",
|
"gitee": "https://gitee.com/x_admin/x_admin_python",
|
||||||
"website": "https://www.x_admin.cn",
|
"website": "https://x.adtk.cn",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// 今日数据
|
// 今日数据
|
||||||
|
@@ -2,10 +2,10 @@ package admin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"x_admin/admin/common/album"
|
"x_admin/admin/common/album"
|
||||||
"x_admin/admin/common/captcha"
|
|
||||||
"x_admin/admin/common/index"
|
"x_admin/admin/common/index"
|
||||||
"x_admin/admin/common/upload"
|
"x_admin/admin/common/upload"
|
||||||
"x_admin/admin/flow"
|
"x_admin/admin/flow"
|
||||||
|
"x_admin/admin/generator"
|
||||||
"x_admin/admin/monitor"
|
"x_admin/admin/monitor"
|
||||||
"x_admin/admin/setting/copyright"
|
"x_admin/admin/setting/copyright"
|
||||||
"x_admin/admin/setting/dict_data"
|
"x_admin/admin/setting/dict_data"
|
||||||
@@ -24,6 +24,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func RegisterGroup(rg *gin.RouterGroup) {
|
func RegisterGroup(rg *gin.RouterGroup) {
|
||||||
|
|
||||||
|
rg = rg.Group("/admin")
|
||||||
|
// 所有子路由需要加上前缀 /api/admin
|
||||||
|
|
||||||
upload.UploadRoute(rg)
|
upload.UploadRoute(rg)
|
||||||
album.AlbumRoute(rg)
|
album.AlbumRoute(rg)
|
||||||
index.IndexRoute(rg)
|
index.IndexRoute(rg)
|
||||||
@@ -51,5 +55,5 @@ func RegisterGroup(rg *gin.RouterGroup) {
|
|||||||
flow.FlowApplyRoute(rg)
|
flow.FlowApplyRoute(rg)
|
||||||
flow.FlowHistoryRoute(rg)
|
flow.FlowHistoryRoute(rg)
|
||||||
|
|
||||||
captcha.CaptchaRoute(rg)
|
generator.RegisterGroup(rg)
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package generator
|
package generator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"x_admin/generator/gen"
|
"x_admin/admin/generator/gen"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
@@ -13,14 +13,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GenRoute(rg *gin.RouterGroup) {
|
func GenRoute(rg *gin.RouterGroup) {
|
||||||
// db := core.GetDB()
|
|
||||||
// permSrv := system.NewSystemAuthPermService(db)
|
|
||||||
// roleSrv := system.NewSystemAuthRoleService(db, permSrv)
|
|
||||||
// adminSrv := system.NewSystemAuthAdminService(db, permSrv, roleSrv)
|
|
||||||
// service := system.NewSystemLoginService(db, adminSrv)
|
|
||||||
|
|
||||||
// server := NewGenerateService()
|
|
||||||
|
|
||||||
handle := genHandler{}
|
handle := genHandler{}
|
||||||
|
|
||||||
rg = rg.Group("/gen", middleware.TokenAuth())
|
rg = rg.Group("/gen", middleware.TokenAuth())
|
@@ -3,6 +3,7 @@ package gen
|
|||||||
import (
|
import (
|
||||||
"archive/zip"
|
"archive/zip"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"x_admin/admin/generator/tpl_utils"
|
||||||
"x_admin/config"
|
"x_admin/config"
|
||||||
"x_admin/core"
|
"x_admin/core"
|
||||||
"x_admin/core/request"
|
"x_admin/core/request"
|
||||||
@@ -10,7 +11,7 @@ import (
|
|||||||
"x_admin/model/gen_model"
|
"x_admin/model/gen_model"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
"x_admin/generator/tpl_utils"
|
|
||||||
"x_admin/util"
|
"x_admin/util"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
@@ -23,7 +23,7 @@ type {{{ title (toCamelCase .ModuleName) }}}Handler struct {}
|
|||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
// @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功"
|
// @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功"
|
||||||
// @Failure 400 {object} string "请求错误"
|
// @Failure 400 {object} string "请求错误"
|
||||||
// @Router /api/{{{ .ModuleName }}}/list [get]
|
// @Router /api/admin/{{{ .ModuleName }}}/list [get]
|
||||||
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) List(c *gin.Context) {
|
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) List(c *gin.Context) {
|
||||||
var page request.PageReq
|
var page request.PageReq
|
||||||
var listReq {{{ title (toCamelCase .EntityName) }}}ListReq
|
var listReq {{{ title (toCamelCase .EntityName) }}}ListReq
|
||||||
@@ -41,7 +41,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) List(c *gin.Context) {
|
|||||||
// @Tags {{{ .ModuleName }}}-{{{ .FunctionName }}}
|
// @Tags {{{ .ModuleName }}}-{{{ .FunctionName }}}
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功"
|
// @Success 200 {object} []{{{ title (toCamelCase .EntityName) }}}Resp "成功"
|
||||||
// @Router /api/{{{ .ModuleName }}}/listAll [get]
|
// @Router /api/admin/{{{ .ModuleName }}}/listAll [get]
|
||||||
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ListAll(c *gin.Context) {
|
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ListAll(c *gin.Context) {
|
||||||
res, err := Service.ListAll()
|
res, err := Service.ListAll()
|
||||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||||
@@ -60,7 +60,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) ListAll(c *gin.Context
|
|||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
// @Success 200 {object} {{{ title (toCamelCase .EntityName) }}}Resp "成功"
|
// @Success 200 {object} {{{ title (toCamelCase .EntityName) }}}Resp "成功"
|
||||||
// @Router /api/{{{ .ModuleName }}}/detail [get]
|
// @Router /api/admin/{{{ .ModuleName }}}/detail [get]
|
||||||
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Detail(c *gin.Context) {
|
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Detail(c *gin.Context) {
|
||||||
var detailReq {{{ title (toCamelCase .EntityName) }}}DetailReq
|
var detailReq {{{ title (toCamelCase .EntityName) }}}DetailReq
|
||||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||||
@@ -81,7 +81,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Detail(c *gin.Context)
|
|||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
// @Success 200 {object} response.RespType "成功"
|
// @Success 200 {object} response.RespType "成功"
|
||||||
// @Router /api/{{{ .ModuleName }}}/add [post]
|
// @Router /api/admin/{{{ .ModuleName }}}/add [post]
|
||||||
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Add(c *gin.Context) {
|
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Add(c *gin.Context) {
|
||||||
var addReq {{{ title (toCamelCase .EntityName) }}}AddReq
|
var addReq {{{ title (toCamelCase .EntityName) }}}AddReq
|
||||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
|
||||||
@@ -99,7 +99,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Add(c *gin.Context) {
|
|||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
// @Success 200 {object} response.RespType "成功"
|
// @Success 200 {object} response.RespType "成功"
|
||||||
// @Router /api/{{{ .ModuleName }}}/edit [post]
|
// @Router /api/admin/{{{ .ModuleName }}}/edit [post]
|
||||||
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Edit(c *gin.Context) {
|
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Edit(c *gin.Context) {
|
||||||
var editReq {{{ title (toCamelCase .EntityName) }}}EditReq
|
var editReq {{{ title (toCamelCase .EntityName) }}}EditReq
|
||||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
|
||||||
@@ -117,7 +117,7 @@ func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Edit(c *gin.Context) {
|
|||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
{{{- end }}}
|
{{{- end }}}
|
||||||
// @Success 200 {object} response.RespType "成功"
|
// @Success 200 {object} response.RespType "成功"
|
||||||
// @Router /api/{{{ .ModuleName }}}/del [post]
|
// @Router /api/admin/{{{ .ModuleName }}}/del [post]
|
||||||
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Del(c *gin.Context) {
|
func (hd {{{ title (toCamelCase .ModuleName) }}}Handler) Del(c *gin.Context) {
|
||||||
var delReq {{{ title (toCamelCase .EntityName) }}}DelReq
|
var delReq {{{ title (toCamelCase .EntityName) }}}DelReq
|
||||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
|
@@ -15,29 +15,29 @@ var AdminConfig = adminConfig{
|
|||||||
|
|
||||||
// 免登录验证
|
// 免登录验证
|
||||||
NotLoginUri: []string{
|
NotLoginUri: []string{
|
||||||
"system:login", // 登录接口
|
"admin:system:login", // 登录接口
|
||||||
"common:index:config", // 配置接口
|
"admin:common:index:config", // 配置接口
|
||||||
},
|
},
|
||||||
|
|
||||||
// 免权限验证
|
// 免权限验证
|
||||||
NotAuthUri: []string{
|
NotAuthUri: []string{
|
||||||
"system:logout", // 退出登录
|
"admin:system:logout", // 退出登录
|
||||||
"system:menu:menus", // 系统菜单
|
"admin:system:menu:menus", // 系统菜单
|
||||||
"system:menu:route", // 菜单路由
|
"admin:system:menu:route", // 菜单路由
|
||||||
"system:admin:upInfo", // 管理员更新
|
"admin:system:admin:upInfo", // 管理员更新
|
||||||
"system:admin:self", // 管理员信息
|
"admin:system:admin:self", // 管理员信息
|
||||||
"system:role:all", // 所有角色
|
"admin:system:role:all", // 所有角色
|
||||||
"system:post:all", // 所有岗位
|
"admin:system:post:all", // 所有岗位
|
||||||
"system:dept:list", // 所有部门
|
"admin:system:dept:list", // 所有部门
|
||||||
"setting:dict:type:all", // 所有字典类型
|
"admin:setting:dict:type:all", // 所有字典类型
|
||||||
"setting:dict:data:all", // 所有字典数据
|
"admin:setting:dict:data:all", // 所有字典数据
|
||||||
"article:cate:all", // 所有文章分类
|
"admin:article:cate:all", // 所有文章分类
|
||||||
},
|
},
|
||||||
|
|
||||||
// 演示模式白名单
|
// 演示模式白名单
|
||||||
ShowWhitelistUri: []string{
|
ShowWhitelistUri: []string{
|
||||||
"system:login", // 登录接口
|
"admin:system:login", // 登录接口
|
||||||
"system:logout", // 退出登录
|
"admin:system:logout", // 退出登录
|
||||||
},
|
},
|
||||||
|
|
||||||
// 管理员账号id
|
// 管理员账号id
|
||||||
|
@@ -39,7 +39,14 @@ func initRouter() *gin.Engine {
|
|||||||
|
|
||||||
c.FileFromFS("static"+filepath, staticHttpFs)
|
c.FileFromFS("static"+filepath, staticHttpFs)
|
||||||
})
|
})
|
||||||
|
router.GET("/api/admin/apiList", func(ctx *gin.Context) {
|
||||||
|
var path = []string{}
|
||||||
|
for _, route := range router.Routes() {
|
||||||
|
// fmt.Printf("%s 127.0.0.1:%v%s\n", route.Method, config.Config.ServerPort, route.Path)
|
||||||
|
path = append(path, route.Path)
|
||||||
|
}
|
||||||
|
response.Result(ctx, response.Success, path)
|
||||||
|
})
|
||||||
// 设置中间件
|
// 设置中间件
|
||||||
router.Use(gin.Logger(), middleware.Cors(), middleware.ErrorRecover())
|
router.Use(gin.Logger(), middleware.Cors(), middleware.ErrorRecover())
|
||||||
// 演示模式
|
// 演示模式
|
||||||
@@ -54,10 +61,6 @@ func initRouter() *gin.Engine {
|
|||||||
|
|
||||||
routers.RegisterGroup(group)
|
routers.RegisterGroup(group)
|
||||||
|
|
||||||
for _, route := range router.Routes() {
|
|
||||||
fmt.Printf("%s %s\n", route.Method, route.Path)
|
|
||||||
}
|
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,12 +2,14 @@ package routers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"x_admin/admin"
|
"x_admin/admin"
|
||||||
"x_admin/generator"
|
"x_admin/admin/common/captcha"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterGroup(rg *gin.RouterGroup) {
|
func RegisterGroup(rg *gin.RouterGroup) {
|
||||||
|
// 一下路由前缀为/api
|
||||||
admin.RegisterGroup(rg)
|
admin.RegisterGroup(rg)
|
||||||
generator.RegisterGroup(rg)
|
|
||||||
|
captcha.CaptchaRoute(rg)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user