Skip to content

Commit 6eda768

Browse files
committed
finish v2.0.5 demo migrate
1 parent 7e3c358 commit 6eda768

38 files changed

+2677
-669
lines changed

eslintrc/.eslintrc-auto-import.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"elNotify": true,
3030
"filterAsyncRouter": true,
3131
"filterAsyncRouterByReq": true,
32+
"filterNull": true,
3233
"freshRouter": true,
3334
"getCurrentInstance": true,
3435
"getCurrentScope": true,

mock/excel.ts

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ for (let i = 0; i < count; i++) {
1313
NameList.push({ name: 'mock-Pan' })
1414

1515
export default [
16-
// username search
1716
{
1817
url: '/vue3-admin-plus/search/user',
1918
method: 'get',
@@ -30,8 +29,6 @@ export default [
3029
}
3130
}
3231
},
33-
34-
// transaction list
3532
{
3633
url: '/vue3-admin-plus/transaction/list',
3734
method: 'get',

mock/table.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const data = Mock.mock({
1515

1616
export default [
1717
{
18-
url: '/vue3-admin-template/table/list',
18+
url: '/vue3-admin-plus/table/list',
1919
method: 'get',
2020
response: () => {
2121
const items = data.items

src/api/remote-search.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import request from 'axios'
2+
3+
export function searchUser(name) {
4+
return request({
5+
url: '/vue3-admin-plus/search/user',
6+
method: 'get',
7+
params: { name }
8+
})
9+
}
10+
11+
export function transactionList(query) {
12+
return request({
13+
url: '/vue3-admin-plus/transaction/list',
14+
method: 'get',
15+
params: query
16+
})
17+
}

src/hooks/use-common.ts

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ export const sleepTimeout = (time) => {
1717
})
1818
}
1919

20+
export const filterNull = (data) => {
21+
Object.keys(data).forEach((key) => {
22+
if (!data[key]) delete data[key]
23+
})
24+
25+
return data
26+
}
27+
2028
//深拷贝
2129
export function cloneDeep(value) {
2230
return JSON.parse(JSON.stringify(value))

src/hooks/use-permission.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ import { useBasicStore } from '@/store/basic'
1818
export function filterAsyncRouter(data) {
1919
const basicStore = useBasicStore()
2020
const fileAfterRouter = filterAsyncRouterByReq(data)
21-
console.log('fileAfterRouter', fileAfterRouter)
2221
fileAfterRouter.forEach((route) => router.addRoute(route))
2322
basicStore.setFilterAsyncRoutes(fileAfterRouter)
2423
}
2524

2625
import ParentView from '@/components/ParentView/index.vue'
2726
import InnerLink from '@/components/InnerLink/index.vue'
27+
import { filterNull } from '@/hooks/use-common'
2828
// @ts-ignore
2929
const modules = import.meta.glob('../views/**/**.vue')
3030
export const filterAsyncRouterByReq = (asyncRouterMap) => {
3131
return asyncRouterMap.filter((route) => {
3232
// if (type && route.children) {
3333
// route.children = filterChildren(route.children)
3434
// }
35+
console.log(route)
3536
if (route.component) {
3637
// Layout ParentView 组件特殊处理
3738
if (route.component === 'Layout') {
@@ -50,12 +51,15 @@ export const filterAsyncRouterByReq = (asyncRouterMap) => {
5051
delete route['children']
5152
delete route['redirect']
5253
}
53-
route.name = route.routeName
54-
if (route.metaExtra) route.meta = Object.assign(route.meta, JSON.parse(JSON.parse(route.metaExtra)))
54+
if (route.routeName) {
55+
route.name = route.routeName
56+
}
57+
if (route.metaExtra && JSON.parse(route.metaExtra) !== '{}') {
58+
route.meta = Object.assign(route.meta, JSON.parse(JSON.parse(route.metaExtra)))
59+
}
5560
return true
5661
})
5762
}
58-
5963
// const filterChildren = (childrenMap, lastRouter = false) => {
6064
// let children: any = []
6165
// childrenMap.forEach((el) => {

src/router/index.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { createRouter, createWebHashHistory } from 'vue-router'
22
import Layout from '@/layout/index.vue'
3-
3+
/* Router Modules */
4+
import charts from './modules/charts'
5+
import guid from './modules/guid'
6+
import excel from './modules/excel'
7+
import directive from './modules/directive'
8+
import table from './modules/table'
49
export const constantRoutes = [
510
{
611
path: '/redirect',
@@ -28,6 +33,7 @@ export const constantRoutes = [
2833
component: () => import('@/views/error-page/401.vue'),
2934
hidden: true
3035
}
36+
3137
// {
3238
// path: '/',
3339
// component: Layout,
@@ -41,7 +47,13 @@ export const constantRoutes = [
4147
// meta: { title: 'Dashboard', elSvgIcon: 'Fold', affix: true }
4248
// }
4349
// ]
44-
// }
50+
// },
51+
//
52+
// guid,
53+
// charts,
54+
// excel,
55+
// directive,
56+
// table
4557

4658
// {
4759
// path: '/system1',
+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<template>
2+
<div :id="id" :class="className" :style="{ height: height, width: width }" />
3+
</template>
4+
5+
<script setup>
6+
import * as echarts from 'echarts'
7+
8+
const props = defineProps({
9+
className: {
10+
type: String,
11+
default: 'chart'
12+
},
13+
id: {
14+
type: String,
15+
default: 'chart'
16+
},
17+
width: {
18+
type: String,
19+
default: '200px'
20+
},
21+
height: {
22+
type: String,
23+
default: '200px'
24+
}
25+
})
26+
const state = reactive({
27+
chart: null
28+
})
29+
onMounted(() => {
30+
initChart()
31+
})
32+
33+
onBeforeUnmount(() => {
34+
if (!state.chart) {
35+
return
36+
}
37+
state.chart.dispose()
38+
state.chart = null
39+
})
40+
41+
const initChart = () => {
42+
// eslint-disable-next-line unicorn/prefer-query-selector
43+
state.chart = echarts.init(document.getElementById(props.id))
44+
const xAxisData = []
45+
const data = []
46+
const data2 = []
47+
for (let i = 0; i < 50; i++) {
48+
xAxisData.push(i)
49+
data.push((Math.sin(i / 5) * (i / 5 - 10) + i / 6) * 5)
50+
data2.push((Math.sin(i / 5) * (i / 5 + 10) + i / 6) * 3)
51+
}
52+
state.chart.setOption({
53+
backgroundColor: '#08263a',
54+
grid: {
55+
left: '5%',
56+
right: '5%'
57+
},
58+
xAxis: [
59+
{
60+
show: false,
61+
data: xAxisData
62+
},
63+
{
64+
show: false,
65+
data: xAxisData
66+
}
67+
],
68+
visualMap: {
69+
show: false,
70+
min: 0,
71+
max: 50,
72+
dimension: 0,
73+
inRange: {
74+
color: ['#4a657a', '#308e92', '#b1cfa5', '#f5d69f', '#f5898b', '#ef5055']
75+
}
76+
},
77+
yAxis: {
78+
axisLine: {
79+
show: false
80+
},
81+
axisLabel: {
82+
textStyle: {
83+
color: '#4a657a'
84+
}
85+
},
86+
splitLine: {
87+
show: true,
88+
lineStyle: {
89+
color: '#08263f'
90+
}
91+
},
92+
axisTick: {
93+
show: false
94+
}
95+
},
96+
series: [
97+
{
98+
name: 'back',
99+
type: 'bar',
100+
data: data2,
101+
z: 1,
102+
itemStyle: {
103+
normal: {
104+
opacity: 0.4,
105+
barBorderRadius: 5,
106+
shadowBlur: 3,
107+
shadowColor: '#111'
108+
}
109+
}
110+
},
111+
{
112+
name: 'Simulate Shadow',
113+
type: 'line',
114+
data,
115+
z: 2,
116+
showSymbol: false,
117+
animationDelay: 0,
118+
animationEasing: 'linear',
119+
animationDuration: 1200,
120+
lineStyle: {
121+
normal: {
122+
color: 'transparent'
123+
}
124+
},
125+
areaStyle: {
126+
normal: {
127+
color: '#08263a',
128+
shadowBlur: 50,
129+
shadowColor: '#000'
130+
}
131+
}
132+
},
133+
{
134+
name: 'front',
135+
type: 'bar',
136+
data,
137+
xAxisIndex: 1,
138+
z: 3,
139+
itemStyle: {
140+
normal: {
141+
barBorderRadius: 5
142+
}
143+
}
144+
}
145+
],
146+
animationEasing: 'elasticOut',
147+
animationEasingUpdate: 'elasticOut',
148+
animationDelay(idx) {
149+
return idx * 20
150+
},
151+
animationDelayUpdate(idx) {
152+
return idx * 20
153+
}
154+
})
155+
}
156+
</script>
157+
158+
<style scoped lang="scss"></style>

0 commit comments

Comments
 (0)