Skip to content

Commit aaeb85b

Browse files
committed
feat(rbac): 通用增删改查逻辑封装
1 parent 8bf9635 commit aaeb85b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2165
-213
lines changed

.eslintrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @Author: wenlan
55
* @Date: 2022-01-14 15:22:01
66
* @LastEditors: wenlan
7-
* @LastEditTime: 2022-01-15 16:58:39
7+
* @LastEditTime: 2022-02-22 23:00:24
88
*/
99
module.exports = {
1010
root: true,
@@ -38,6 +38,7 @@ module.exports = {
3838
'@typescript-eslint/no-explicit-any': 'off',
3939
'@typescript-eslint/no-var-requires': 'off',
4040
'vue/multi-word-component-names': 'off',
41+
'@typescript-eslint/no-non-null-assertion': 'off',
4142
// 针对模版中未使用的变量
4243
'vue/no-unused-vars': [
4344
'error',

auto-imports.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Generated by 'unplugin-auto-import'
22
// We suggest you to commit this file into source control
3-
declare global {}
3+
declare global {
4+
5+
}
46
export {}

package-lock.json

+27-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929
},
3030
"dependencies": {
3131
"@element-plus/icons-vue": "^0.2.6",
32+
"@vueuse/core": "^7.6.2",
3233
"animate.css": "^4.1.1",
3334
"axios": "^0.24.0",
35+
"dayjs": "^1.10.7",
3436
"element-plus": "^1.3.0-beta.5",
3537
"less": "^4.1.2",
3638
"normalize.css": "^8.0.1",
3739
"nprogress": "^0.2.0",
40+
"path-to-regexp": "^6.2.0",
3841
"vue": "^3.2.25",
3942
"vue-router": "^4.0.12",
4043
"vuex": "^4.0.2",

src/assets/style/base.less

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ a {
1515
.router-link-active {
1616
text-decoration: none;
1717
}
18+

src/assets/style/index.less

+5
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
@import 'base.less';
2+
@import 'transition.less';
3+
//解决element table设置flex el-image样式被覆盖
4+
.el-table__fixed-body-wrapper {
5+
z-index: auto !important;
6+
}

src/assets/style/transition.less

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// global transition css
2+
3+
/* fade */
4+
.fade-enter-active,
5+
.fade-leave-active {
6+
transition: opacity 0.28s;
7+
}
8+
9+
.fade-enter,
10+
.fade-leave-active {
11+
opacity: 0;
12+
}
13+
.fade-transform-leave-to {
14+
display: none;
15+
}
16+
17+
/* fade-transform */
18+
.fade-transform-leave-active,
19+
.fade-transform-enter-active {
20+
transition: all 0.8s;
21+
}
22+
23+
.fade-transform-enter {
24+
opacity: 0;
25+
transform: translateX(-30px);
26+
}
27+
28+
.fade-transform-leave-to {
29+
opacity: 0;
30+
transform: translateX(30px);
31+
}
32+
33+
/* breadcrumb transition */
34+
.breadcrumb-enter-active,
35+
.breadcrumb-leave-active {
36+
transition: all 0.5s;
37+
}
38+
39+
.breadcrumb-enter,
40+
.breadcrumb-leave-active {
41+
opacity: 0;
42+
transform: translateX(20px);
43+
}
44+
45+
.breadcrumb-move {
46+
transition: all 0.5s;
47+
}
48+
49+
.breadcrumb-leave-active {
50+
position: absolute;
51+
}

src/base-ui/breadcrumb/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* @Descripttion:
3+
* @version:
4+
* @Author: wenlan
5+
* @Date: 2022-02-13 14:50:10
6+
* @LastEditors: wenlan
7+
* @LastEditTime: 2022-02-13 15:47:13
8+
*/
9+
import BreadCrump from './src/bread-crumb.vue'
10+
export default BreadCrump
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<!--
2+
* @Descripttion:
3+
* @version:
4+
* @Author: wenlan
5+
* @Date: 2022-02-13 14:50:20
6+
* @LastEditors: wenlan
7+
* @LastEditTime: 2022-02-13 17:39:27
8+
-->
9+
<script setup lang="ts">
10+
import { compile } from 'path-to-regexp'
11+
import { toRefs, reactive, watch } from 'vue'
12+
import { useRoute, useRouter, RouteRecordRaw } from 'vue-router'
13+
import type { IBreadcrumbList } from '../type'
14+
const route = useRoute()
15+
const router = useRouter()
16+
let breadList = reactive<IBreadcrumbList>({
17+
list: []
18+
})
19+
const { list } = toRefs(breadList)
20+
watch(
21+
() => route.name,
22+
(newValue) => {
23+
console.log('@', newValue)
24+
getBreadcrumb()
25+
},
26+
{ deep: true }
27+
)
28+
const pathCompile = (path: string) => {
29+
const { params } = route
30+
const toPath = compile(path) //解决url中携带参数问题
31+
return toPath(params)
32+
}
33+
const isDashboard = (route: RouteRecordRaw) => {
34+
const name = route?.name
35+
if (!name) {
36+
return false
37+
}
38+
return (
39+
(name as string).trim().toLocaleLowerCase() ===
40+
'dashboard'.toLocaleLowerCase()
41+
)
42+
}
43+
const getBreadcrumb = () => {
44+
// only show routes with meta.title
45+
let matched = route.matched.filter((item) => item.meta && item.meta.title)
46+
console.log('@@', matched)
47+
48+
const first = matched[0] ?? undefined
49+
if (!isDashboard(first)) {
50+
matched = [
51+
{
52+
path: '/dashboard',
53+
meta: { title: 'Dashboard' }
54+
} as any
55+
].concat(matched)
56+
}
57+
58+
breadList.list = matched.filter((item) => item.meta && item.meta.title)
59+
console.log('@@@', breadList)
60+
}
61+
62+
getBreadcrumb()
63+
64+
const handleLink = (item: any) => {
65+
const { redirect, path } = item
66+
console.log(path, redirect)
67+
68+
if (redirect) {
69+
router.push(redirect).catch((err) => {
70+
console.warn(err)
71+
})
72+
return
73+
}
74+
router.push(pathCompile(path)).catch((err) => {
75+
console.warn(err)
76+
})
77+
}
78+
</script>
79+
80+
<template>
81+
<el-breadcrumb class="app-breadcrumb" separator="/">
82+
<transition-group name="breadcrumb">
83+
<el-breadcrumb-item v-for="item in list" :key="item.path">
84+
<a @click.prevent="handleLink(item)">{{ item.meta?.title }}</a>
85+
</el-breadcrumb-item>
86+
</transition-group>
87+
</el-breadcrumb>
88+
</template>
89+
90+
<style scoped lang="less">
91+
.app-breadcrumb.el-breadcrumb {
92+
display: inline-block;
93+
font-size: 14px;
94+
line-height: 50px;
95+
margin-left: 8px;
96+
97+
.no-redirect {
98+
color: #97a8be;
99+
cursor: text;
100+
}
101+
}
102+
</style>

src/base-ui/breadcrumb/type.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* @Descripttion:
3+
* @version:
4+
* @Author: wenlan
5+
* @Date: 2022-02-13 17:33:55
6+
* @LastEditors: wenlan
7+
* @LastEditTime: 2022-02-13 17:36:02
8+
*/
9+
import { RouteRecordRaw } from 'vue-router'
10+
export interface IBreadcrumbList {
11+
list: RouteRecordRaw[]
12+
}

src/base-ui/form/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* @Descripttion:
3+
* @version:
4+
* @Author: wenlan
5+
* @Date: 2022-02-14 17:53:02
6+
* @LastEditors: wenlan
7+
* @LastEditTime: 2022-02-17 17:32:01
8+
*/
9+
import Form from '../form/src/form.vue'
10+
export default Form

0 commit comments

Comments
 (0)