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