Skip to content

Commit 9e7ec0c

Browse files
committed
feature:路由缓存
1 parent 98261e3 commit 9e7ec0c

File tree

11 files changed

+290
-364
lines changed

11 files changed

+290
-364
lines changed

src/assets/css/main.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ a {
8484

8585
.move-enter-active,
8686
.move-leave-active {
87-
transition: opacity .5s;
87+
transition: opacity .1s ease;
8888
}
8989

90-
.move-enter,
91-
.move-leave {
90+
.move-enter-from,
91+
.move-leave-to {
9292
opacity: 0;
9393
}
9494

src/components/Tags.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default {
8080
this.$store.commit("delTagsItem", { index: 0 });
8181
}
8282
this.$store.commit("setTagsItem", {
83+
name: route.name,
8384
title: route.meta.title,
8485
path: route.fullPath
8586
});

src/router/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const routes = [
1212
children: [
1313
{
1414
path: "/dashboard",
15-
name: "Dashboard",
15+
name: "dashboard",
1616
meta: {
1717
title: '系统首页'
1818
},
@@ -21,7 +21,7 @@ const routes = [
2121
"../views/Dashboard.vue")
2222
}, {
2323
path: "/table",
24-
name: "BaseTable",
24+
name: "basetable",
2525
meta: {
2626
title: '表格'
2727
},
@@ -30,7 +30,7 @@ const routes = [
3030
"../views/BaseTable.vue")
3131
}, {
3232
path: "/charts",
33-
name: "BaseCharts",
33+
name: "basecharts",
3434
meta: {
3535
title: '图表'
3636
},
@@ -39,7 +39,7 @@ const routes = [
3939
"../views/BaseCharts.vue")
4040
}, {
4141
path: "/form",
42-
name: "BaseForm",
42+
name: "baseform",
4343
meta: {
4444
title: '表单'
4545
},
@@ -48,7 +48,7 @@ const routes = [
4848
"../views/BaseForm.vue")
4949
}, {
5050
path: "/tabs",
51-
name: "Tabs",
51+
name: "tabs",
5252
meta: {
5353
title: 'tab标签'
5454
},
@@ -57,7 +57,7 @@ const routes = [
5757
"../views/Tabs.vue")
5858
}, {
5959
path: "/donate",
60-
name: "Donate",
60+
name: "donate",
6161
meta: {
6262
title: '鼓励作者'
6363
},
@@ -66,7 +66,7 @@ const routes = [
6666
"../views/Donate.vue")
6767
}, {
6868
path: "/permission",
69-
name: "Permission",
69+
name: "permission",
7070
meta: {
7171
title: '权限管理',
7272
permission: true
@@ -76,7 +76,7 @@ const routes = [
7676
"../views/Permission.vue")
7777
}, {
7878
path: "/i18n",
79-
name: "I18n",
79+
name: "i18n",
8080
meta: {
8181
title: '国际化语言'
8282
},
@@ -85,7 +85,7 @@ const routes = [
8585
"../views/I18n.vue")
8686
}, {
8787
path: "/upload",
88-
name: "Upload",
88+
name: "upload",
8989
meta: {
9090
title: '上传插件'
9191
},
@@ -94,7 +94,7 @@ const routes = [
9494
"../views/Upload.vue")
9595
}, {
9696
path: "/icon",
97-
name: "Icon",
97+
name: "icon",
9898
meta: {
9999
title: '自定义图标'
100100
},

src/views/BaseTable.vue

Lines changed: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,13 @@
1414
icon="el-icon-delete"
1515
class="handle-del mr10"
1616
@click="delAllSelection"
17-
>批量删除</el-button
18-
>
19-
<el-select
20-
v-model="query.address"
21-
placeholder="地址"
22-
class="handle-select mr10"
23-
>
24-
<el-option
25-
key="1"
26-
label="广东省"
27-
value="广东省"
28-
></el-option>
29-
<el-option
30-
key="2"
31-
label="湖南省"
32-
value="湖南省"
33-
></el-option>
17+
>批量删除</el-button>
18+
<el-select v-model="query.address" placeholder="地址" class="handle-select mr10">
19+
<el-option key="1" label="广东省" value="广东省"></el-option>
20+
<el-option key="2" label="湖南省" value="湖南省"></el-option>
3421
</el-select>
35-
<el-input
36-
v-model="query.name"
37-
placeholder="用户名"
38-
class="handle-input mr10"
39-
></el-input>
40-
<el-button
41-
type="primary"
42-
icon="el-icon-search"
43-
@click="handleSearch"
44-
>搜索</el-button
45-
>
22+
<el-input v-model="query.name" placeholder="用户名" class="handle-input mr10"></el-input>
23+
<el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
4624
</div>
4725
<el-table
4826
:data="tableData"
@@ -52,22 +30,11 @@
5230
header-cell-class-name="table-header"
5331
@selection-change="handleSelectionChange"
5432
>
55-
<el-table-column
56-
type="selection"
57-
width="55"
58-
align="center"
59-
></el-table-column>
60-
<el-table-column
61-
prop="id"
62-
label="ID"
63-
width="55"
64-
align="center"
65-
></el-table-column>
33+
<el-table-column type="selection" width="55" align="center"></el-table-column>
34+
<el-table-column prop="id" label="ID" width="55" align="center"></el-table-column>
6635
<el-table-column prop="name" label="用户名"></el-table-column>
6736
<el-table-column label="账户余额">
68-
<template #default="scope"
69-
>¥{{ scope.row.money }}</template
70-
>
37+
<template #default="scope">¥{{ scope.row.money }}</template>
7138
</el-table-column>
7239
<el-table-column label="头像(查看大图)" align="center">
7340
<template #default="scope">
@@ -89,8 +56,7 @@
8956
? 'danger'
9057
: ''
9158
"
92-
>{{ scope.row.state }}</el-tag
93-
>
59+
>{{ scope.row.state }}</el-tag>
9460
</template>
9561
</el-table-column>
9662

@@ -101,15 +67,13 @@
10167
type="text"
10268
icon="el-icon-edit"
10369
@click="handleEdit(scope.$index, scope.row)"
104-
>编辑</el-button
105-
>
70+
>编辑</el-button>
10671
<el-button
10772
type="text"
10873
icon="el-icon-delete"
10974
class="red"
11075
@click="handleDelete(scope.$index, scope.row)"
111-
>删除</el-button
112-
>
76+
>删除</el-button>
11377
</template>
11478
</el-table-column>
11579
</el-table>
@@ -138,9 +102,7 @@
138102
<template #footer>
139103
<span class="dialog-footer">
140104
<el-button @click="editVisible = false">取 消</el-button>
141-
<el-button type="primary" @click="saveEdit"
142-
>确 定</el-button
143-
>
105+
<el-button type="primary" @click="saveEdit">确 定</el-button>
144106
</span>
145107
</template>
146108
</el-dialog>
@@ -150,13 +112,14 @@
150112
<script>
151113
import { fetchData } from "../api/index";
152114
export default {
115+
name: "basetable",
153116
data() {
154117
return {
155118
query: {
156119
address: "",
157120
name: "",
158121
pageIndex: 1,
159-
pageSize: 10,
122+
pageSize: 10
160123
},
161124
tableData: [],
162125
multipleSelection: [],
@@ -165,7 +128,7 @@ export default {
165128
pageTotal: 0,
166129
form: {},
167130
idx: -1,
168-
id: -1,
131+
id: -1
169132
};
170133
},
171134
created() {
@@ -174,7 +137,7 @@ export default {
174137
methods: {
175138
// 获取 easy-mock 的模拟数据
176139
getData() {
177-
fetchData(this.query).then((res) => {
140+
fetchData(this.query).then(res => {
178141
console.log(res);
179142
this.tableData = res.list;
180143
this.pageTotal = res.pageTotal || 50;
@@ -189,7 +152,7 @@ export default {
189152
handleDelete(index) {
190153
// 二次确认删除
191154
this.$confirm("确定要删除吗?", "提示", {
192-
type: "warning",
155+
type: "warning"
193156
})
194157
.then(() => {
195158
this.$message.success("删除成功");
@@ -227,8 +190,8 @@ export default {
227190
handlePageChange(val) {
228191
this.$set(this.query, "pageIndex", val);
229192
this.getData();
230-
},
231-
},
193+
}
194+
}
232195
};
233196
</script>
234197

0 commit comments

Comments
 (0)