Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ce60f630
authored
Jan 04, 2025
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【功能优化】菜单管理:使用 el-table-v2 解决菜单过多后,存在卡顿的问题
parent
ea133da1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
17 deletions
+25
-17
src/directives/permission/hasPermi.ts
+13
-9
src/views/system/area/index.vue
+12
-8
src/views/system/menu/index.vue
+0
-0
No files found.
src/directives/permission/hasPermi.ts
View file @
ce60f630
...
...
@@ -5,18 +5,10 @@ const { t } = useI18n() // 国际化
export
function
hasPermi
(
app
:
App
<
Element
>
)
{
app
.
directive
(
'hasPermi'
,
(
el
,
binding
)
=>
{
const
{
wsCache
}
=
useCache
()
const
{
value
}
=
binding
const
all_permission
=
'*:*:*'
const
userInfo
=
wsCache
.
get
(
CACHE_KEY
.
USER
)
const
permissions
=
userInfo
?.
permissions
||
[]
if
(
value
&&
value
instanceof
Array
&&
value
.
length
>
0
)
{
const
permissionFlag
=
value
const
hasPermissions
=
permissions
.
some
((
permission
:
string
)
=>
{
return
all_permission
===
permission
||
permissionFlag
.
includes
(
permission
)
})
const
hasPermissions
=
hasPermission
(
value
)
if
(
!
hasPermissions
)
{
el
.
parentNode
&&
el
.
parentNode
.
removeChild
(
el
)
...
...
@@ -26,3 +18,14 @@ export function hasPermi(app: App<Element>) {
}
})
}
export
const
hasPermission
=
(
permission
:
string
[])
=>
{
const
{
wsCache
}
=
useCache
()
const
all_permission
=
'*:*:*'
const
userInfo
=
wsCache
.
get
(
CACHE_KEY
.
USER
)
const
permissions
=
userInfo
?.
permissions
||
[]
return
permissions
.
some
((
p
:
string
)
=>
{
return
all_permission
===
p
||
permission
.
includes
(
p
)
})
}
\ No newline at end of file
src/views/system/area/index.vue
View file @
ce60f630
...
...
@@ -16,6 +16,7 @@
<template
#
default=
"
{ height, width }">
<!-- Virtualized Table 虚拟化表格:高性能,解决表格在大数据量下的卡顿问题 -->
<el-table-v2
v-loading=
"loading"
:columns=
"columns"
:data=
"list"
:width=
"width"
...
...
@@ -31,7 +32,7 @@
<AreaForm
ref=
"formRef"
/>
</template>
<
script
setup
lang=
"tsx"
>
import
type
{
Column
}
from
'element-plus'
import
{
Column
}
from
'element-plus'
import
AreaForm
from
'./AreaForm.vue'
import
*
as
AreaApi
from
'@/api/system/area'
...
...
@@ -40,7 +41,7 @@ defineOptions({ name: 'SystemArea' })
// 表格的 column 字段
const
columns
:
Column
[]
=
[
{
dataKey
:
'id'
,
// 需要渲染当前列的数据字段
。例如说:{id:9527, name:'Mike'},则填 id
dataKey
:
'id'
,
// 需要渲染当前列的数据字段
title
:
'编号'
,
// 显示在单元格表头的文本
width
:
400
,
// 当前列的宽度,必须设置
fixed
:
true
,
// 是否固定列
...
...
@@ -52,14 +53,17 @@ const columns: Column[] = [
width
:
200
}
]
// 表格的数据
const
list
=
ref
([])
const
loading
=
ref
(
true
)
// 列表的加载中
const
list
=
ref
([])
// 表格的数据
/**
* 获得数据列表
*/
/** 获得数据列表 */
const
getList
=
async
()
=>
{
list
.
value
=
await
AreaApi
.
getAreaTree
()
loading
.
value
=
true
try
{
list
.
value
=
await
AreaApi
.
getAreaTree
()
}
finally
{
loading
.
value
=
false
}
}
/** 添加/修改操作 */
...
...
src/views/system/menu/index.vue
View file @
ce60f630
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment