xs-common-plugins 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +309 -299
- package/common.js +110 -110
- package/index.js +1 -1
- package/package.json +16 -16
- package/src/App.vue +12 -12
- package/src/common/common.js +551 -549
- package/src/common/createMenuId.js +7 -7
- package/src/common/uploadImgToBase64.js +12 -12
- package/src/common/utils.js +95 -95
- package/src/components/Breadcrumb/index.vue +81 -81
- package/src/components/CheckBox_Cmp/index.vue +62 -62
- package/src/components/Col_TableCell/data.js +4 -4
- package/src/components/Col_TableCell/index.scss +77 -77
- package/src/components/Col_TableCell/index.vue +43 -43
- package/src/components/Col_TableCell/methods.js +19 -19
- package/src/components/FormItem/index.vue +92 -92
- package/src/components/Hamburger/index.vue +44 -44
- package/src/components/ReportCmp/data.js +3 -3
- package/src/components/ReportCmp/index.scss +29 -29
- package/src/components/ReportCmp/index.vue +76 -76
- package/src/components/ReportCmp/methods.js +30 -30
- package/src/components/Search/cascader/data.js +3 -3
- package/src/components/Search/cascader/index.scss +17 -17
- package/src/components/Search/cascader/index.vue +96 -96
- package/src/components/Search/cascader/methods.js +41 -41
- package/src/components/Search/data.js +5 -5
- package/src/components/Search/hk_cascader/index.vue +104 -104
- package/src/components/Search/hk_cascader_qudao/index.vue +94 -94
- package/src/components/Search/index.scss +219 -219
- package/src/components/Search/index.vue +410 -410
- package/src/components/Search/methods.js +86 -86
- package/src/components/Search/product_option/data.js +3 -3
- package/src/components/Search/product_option/index.scss +68 -68
- package/src/components/Search/product_option/index.vue +412 -412
- package/src/components/Search/product_option/methods.js +58 -58
- package/src/components/Search/select/data.js +3 -3
- package/src/components/Search/select/index.scss +2 -2
- package/src/components/Search/select/index.vue +114 -114
- package/src/components/Search/select/methods.js +51 -51
- package/src/components/Search_filter/data.js +5 -5
- package/src/components/Search_filter/index.scss +104 -104
- package/src/components/Search_filter/index.vue +88 -88
- package/src/components/Search_filter/methods.js +43 -43
- package/src/components/TableCmp/data.js +3 -3
- package/src/components/TableCmp/index.scss +22 -22
- package/src/components/TableCmp/index.vue +98 -98
- package/src/components/TableCmp/methods.js +35 -35
- package/src/components/TableItem/TableItem.vue +55 -55
- package/src/components/TextOVer/index.vue +55 -55
- package/src/components/UploadImg/index.vue +177 -177
- package/src/components/home/BarChart.vue +118 -118
- package/src/components/home/LineChart.vue +146 -146
- package/src/components/home/Panel.vue +135 -135
- package/src/components/home/PanelGroup.vue +146 -146
- package/src/components/home/PieChart.vue +81 -81
- package/src/components/home/RaddarChart.vue +119 -119
- package/src/components/home/TabLayout.vue +88 -88
- package/src/components/home/TableList.vue +158 -158
- package/src/components/home/Teng.vue +248 -248
- package/src/components/home/TransactionTable.vue +49 -49
- package/src/components/home/mixins/resize.js +55 -55
- package/src/components/im/index.vue +155 -155
- package/src/components/im/methods.js +25 -25
- package/src/components/im/pages/chatList/index.vue +45 -45
- package/src/components/im/pages/chatRoom/index.vue +159 -159
- package/src/components/image-singleUpload/data.js +3 -3
- package/src/components/image-singleUpload/index.scss +26 -26
- package/src/components/image-singleUpload/index.vue +56 -56
- package/src/components/image-singleUpload/methods.js +30 -30
- package/src/components/image-upload/data.js +7 -7
- package/src/components/image-upload/index.vue +41 -41
- package/src/components/image-upload/methods.js +80 -80
- package/src/components/multiple-image-upload/data.js +11 -11
- package/src/components/multiple-image-upload/index.scss +8 -8
- package/src/components/multiple-image-upload/index.vue +63 -63
- package/src/components/multiple-image-upload/methods.js +45 -45
- package/src/components/pro-upload/data.js +3 -3
- package/src/components/pro-upload/index.scss +4 -4
- package/src/components/pro-upload/index.vue +89 -89
- package/src/components/pro-upload/methods.js +86 -86
- package/src/components/report_set/index.scss +44 -44
- package/src/components/report_set/index.vue +153 -153
- package/src/components/search-page/src/index.scss +5 -5
- package/src/components/search-page/src/index.vue +76 -76
- package/src/components/search-page/src/methods.js +36 -36
- package/src/components/xsSelect/index.vue +125 -125
- package/src/mixin/dialog.js +31 -31
- package/src/mixin/dlg.js +46 -46
- package/src/mixin/keepAlive.js +53 -53
- package/src/mixin/newDialog.js +19 -19
- package/src/mixin/report.js +82 -82
- package/src/mixin/table.js +93 -93
- package/src/mixin/tableCell/colTableCell_analysis.js +103 -103
- package/src/mixin/upload.js +22 -22
- package/src/mixin/vmodel.js +26 -26
- package/src/plugins/im/components/chat/index.scss +163 -163
- package/src/plugins/im/components/chat/index.vue +144 -144
- package/src/plugins/im/components/chat/methods.js +149 -149
- package/src/plugins/im/components/conversation-list/index.css +91 -91
- package/src/plugins/im/components/conversation-list/index.json +3 -3
- package/src/plugins/im/components/conversation-list/index.vue +89 -89
- package/src/plugins/im/components/loading/loading.css +69 -69
- package/src/plugins/im/components/loading/loading.json +3 -3
- package/src/plugins/im/components/loading/loading.vue +14 -14
- package/src/plugins/im/components/msg-image/index.json +3 -3
- package/src/plugins/im/components/msg-image/index.vue +40 -40
- package/src/plugins/im/components/msg-text/index.json +3 -3
- package/src/plugins/im/components/msg-text/index.vue +24 -24
- package/src/plugins/im/components/send-msg/index.scss +164 -164
- package/src/plugins/im/components/send-msg/index.vue +107 -107
- package/src/plugins/im/components/send-msg/methods.js +125 -125
- package/src/plugins/im/components/template-message/index.vue +76 -76
- package/src/plugins/im/components/without.vue +19 -19
- package/src/plugins/im/im-plug-in/Protobuf-2.3.7.min.js +1 -1
- package/src/plugins/im/im-plug-in/RongCallLib-3.1.5.min.js +74 -74
- package/src/plugins/im/im-plug-in/RongIMLib-4.1.0.js +17420 -17420
- package/src/plugins/im/im-plug-in/init.js +216 -216
- package/src/plugins/im/im-plug-in/qiniu.js +266 -266
- package/src/plugins/im/im-plug-in/send-data.js +431 -431
- package/src/plugins/im/im-plug-in/upload.js +232 -232
- package/src/plugins/im/index.js +31 -31
- package/src/plugins/im/lib/RongIMEmoji-2.2.6.js +332 -332
- package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.js +11635 -11635
- package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.min.js +6 -6
- package/src/plugins/im/utils/services.js +625 -625
- package/src/plugins/im/utils/underscore-1.8.3.js +1531 -1531
- package/src/plugins/im/utils/utils.js +149 -149
- package/src/plugins/index.js +60 -60
- package/src/plugins/row-col-cmp/colCmp/data.js +3 -3
- package/src/plugins/row-col-cmp/colCmp/index.scss +50 -50
- package/src/plugins/row-col-cmp/colCmp/index.vue +53 -53
- package/src/plugins/row-col-cmp/colCmp/methods.js +25 -25
- package/src/plugins/row-col-cmp/index.js +20 -20
- package/src/plugins/row-col-cmp/rowCmp/data.js +3 -3
- package/src/plugins/row-col-cmp/rowCmp/index.scss +3 -3
- package/src/plugins/row-col-cmp/rowCmp/index.vue +43 -43
- package/src/plugins/row-col-cmp/rowCmp/methods.js +29 -29
- package/src/router/index.js +58 -58
- package/src/router/permission.js +126 -126
- package/src/store/getters.js +13 -13
- package/src/store/index.js +60 -60
- package/src/store/modules/app.js +55 -55
- package/src/store/modules/dic.js +74 -74
- package/src/store/modules/oss.js +40 -40
- package/src/store/modules/settings.js +28 -28
- package/src/store/modules/tagsView.js +160 -160
- package/src/store/modules/user.js +94 -94
- package/src/store/modules/widgetdata.js +42 -42
- package/src/styles/element-ui.scss +49 -49
- package/src/styles/index.scss +91 -91
- package/src/styles/mixin.scss +28 -28
- package/src/styles/sidebar.scss +210 -210
- package/src/styles/table.scss +90 -90
- package/src/styles/transition.scss +48 -48
- package/src/styles/variables.scss +25 -25
- package/src/utils/api.js +54 -54
- package/src/utils/auth.js +38 -38
- package/src/utils/concat_batch_btns.js +88 -88
- package/src/utils/enum.js +150 -150
- package/src/utils/filter.js +5 -5
- package/src/utils/filterRules.js +55 -55
- package/src/utils/get-page-title.js +10 -10
- package/src/utils/getMenu.js +82 -82
- package/src/utils/global-config.js +15 -15
- package/src/utils/global_directive.js +10 -10
- package/src/utils/index.js +332 -332
- package/src/utils/localStorage.js +21 -21
- package/src/utils/ossService.js +55 -55
- package/src/utils/prototype.js +46 -46
- package/src/utils/search.js +33 -33
- package/src/utils/signalR.js +24 -24
- package/src/utils/validate.js +20 -20
- package/src/views/callback/index.vue +35 -35
- package/src/views/home/index.vue +25 -25
- package/src/views/layout/components/AllSearch/index.vue +44 -44
- package/src/views/layout/components/AppMain.vue +66 -66
- package/src/views/layout/components/Sidebar/FixiOSBug.js +26 -26
- package/src/views/layout/components/Sidebar/Item.vue +28 -28
- package/src/views/layout/components/Sidebar/Link.vue +34 -34
- package/src/views/layout/components/Sidebar/Logo.vue +79 -79
- package/src/views/layout/components/Sidebar/SidebarItem.vue +67 -67
- package/src/views/layout/components/Sidebar/index.vue +114 -114
- package/src/views/layout/components/TagsView/ScrollPane.vue +94 -94
- package/src/views/layout/components/TagsView/index.vue +330 -330
- package/src/views/layout/components/index.js +3 -3
- package/src/views/layout/index.vue +107 -107
- package/src/views/redirect/index.vue +12 -12
- package/src/views/slienceAuth/index.vue +42 -42
|
@@ -1,330 +1,330 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div id="tags-view-container" class="tags-view-container">
|
|
3
|
-
<scroll-pane
|
|
4
|
-
ref="scrollPane"
|
|
5
|
-
class="tags-view-wrapper"
|
|
6
|
-
@scroll="handleScroll"
|
|
7
|
-
>
|
|
8
|
-
<router-link
|
|
9
|
-
v-for="tag in visitedViews"
|
|
10
|
-
ref="tag"
|
|
11
|
-
:key="tag.path"
|
|
12
|
-
:class="isActive(tag) ? 'active' : ''"
|
|
13
|
-
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
|
14
|
-
tag="span"
|
|
15
|
-
class="tags-view-item"
|
|
16
|
-
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
|
17
|
-
@contextmenu.prevent.native="openMenu(tag, $event)"
|
|
18
|
-
>
|
|
19
|
-
{{ tag.title }}
|
|
20
|
-
<span
|
|
21
|
-
v-if="!isAffix(tag)"
|
|
22
|
-
class="el-icon-close"
|
|
23
|
-
@click.prevent.stop="closeSelectedTag(tag)"
|
|
24
|
-
/>
|
|
25
|
-
</router-link>
|
|
26
|
-
</scroll-pane>
|
|
27
|
-
<ul
|
|
28
|
-
v-show="visible"
|
|
29
|
-
:style="{ left: left + 'px', top: top + 'px' }"
|
|
30
|
-
class="contextmenu"
|
|
31
|
-
>
|
|
32
|
-
<li @click="refreshSelectedTag(selectedTag)">刷新</li>
|
|
33
|
-
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
|
|
34
|
-
关闭
|
|
35
|
-
</li>
|
|
36
|
-
<li @click="closeOthersTags">关闭其他</li>
|
|
37
|
-
<li @click="closeAllTags(selectedTag)">关闭全部</li>
|
|
38
|
-
</ul>
|
|
39
|
-
</div>
|
|
40
|
-
</template>
|
|
41
|
-
|
|
42
|
-
<script>
|
|
43
|
-
import ScrollPane from "./ScrollPane";
|
|
44
|
-
import path from "path";
|
|
45
|
-
import router from "../../../../router/index";
|
|
46
|
-
|
|
47
|
-
function _forEachRoute(arr, path) {
|
|
48
|
-
if (arr && arr.length > 0) {
|
|
49
|
-
arr.find((item) => {
|
|
50
|
-
if (item.url === path) {
|
|
51
|
-
item["meta"]["upload"] = true;
|
|
52
|
-
return item;
|
|
53
|
-
} else {
|
|
54
|
-
_forEachRoute(item.children, path);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export default {
|
|
61
|
-
components: { ScrollPane },
|
|
62
|
-
data() {
|
|
63
|
-
return {
|
|
64
|
-
visible: false,
|
|
65
|
-
top: 0,
|
|
66
|
-
left: 0,
|
|
67
|
-
selectedTag: {},
|
|
68
|
-
affixTags: [],
|
|
69
|
-
};
|
|
70
|
-
},
|
|
71
|
-
computed: {
|
|
72
|
-
visitedViews() {
|
|
73
|
-
return this.$store.state.tagsView.visitedViews;
|
|
74
|
-
},
|
|
75
|
-
routes() {
|
|
76
|
-
return router.options.routes;
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
watch: {
|
|
80
|
-
$route() {
|
|
81
|
-
this.addTags();
|
|
82
|
-
this.moveToCurrentTag();
|
|
83
|
-
},
|
|
84
|
-
visible(value) {
|
|
85
|
-
if (value) {
|
|
86
|
-
document.body.addEventListener("click", this.closeMenu);
|
|
87
|
-
} else {
|
|
88
|
-
document.body.removeEventListener("click", this.closeMenu);
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
mounted() {
|
|
93
|
-
this.initTags();
|
|
94
|
-
this.addTags();
|
|
95
|
-
},
|
|
96
|
-
methods: {
|
|
97
|
-
isActive(route) {
|
|
98
|
-
return route.path === this.$route.path;
|
|
99
|
-
},
|
|
100
|
-
isAffix(tag) {
|
|
101
|
-
return tag.meta && tag.meta.affix;
|
|
102
|
-
},
|
|
103
|
-
filterAffixTags(routes, basePath = "/") {
|
|
104
|
-
let tags = [];
|
|
105
|
-
routes.forEach((route) => {
|
|
106
|
-
if (route.meta && route.meta.affix) {
|
|
107
|
-
const tagPath = path.resolve(basePath, route.path);
|
|
108
|
-
tags.push({
|
|
109
|
-
fullPath: tagPath,
|
|
110
|
-
path: tagPath,
|
|
111
|
-
name: route.name,
|
|
112
|
-
meta: { ...route.meta },
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
if (route.children) {
|
|
116
|
-
const tempTags = this.filterAffixTags(route.children, route.path);
|
|
117
|
-
if (tempTags.length >= 1) {
|
|
118
|
-
tags = [...tags, ...tempTags];
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return tags;
|
|
123
|
-
},
|
|
124
|
-
initTags() {
|
|
125
|
-
const affixTags = (this.affixTags = this.filterAffixTags(this.routes));
|
|
126
|
-
for (const tag of affixTags) {
|
|
127
|
-
if (tag.name) {
|
|
128
|
-
this.$store.dispatch("tagsView/addVisitedView", tag);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
addTags() {
|
|
133
|
-
const { meta } = this.$route;
|
|
134
|
-
if (meta && meta.title) {
|
|
135
|
-
this.$store.dispatch("tagsView/addView", this.$route);
|
|
136
|
-
}
|
|
137
|
-
return false;
|
|
138
|
-
},
|
|
139
|
-
moveToCurrentTag() {
|
|
140
|
-
const tags = this.$refs.tag;
|
|
141
|
-
this.$nextTick(() => {
|
|
142
|
-
for (const tag of tags) {
|
|
143
|
-
if (tag.to.path === this.$route.path) {
|
|
144
|
-
this.$refs.scrollPane.moveToTarget(tag);
|
|
145
|
-
// when query is different then update
|
|
146
|
-
if (tag.to.fullPath !== this.$route.fullPath) {
|
|
147
|
-
this.$store.dispatch("tagsView/updateVisitedView", this.$route);
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
},
|
|
154
|
-
refreshSelectedTag(view) {
|
|
155
|
-
this.$store.dispatch("tagsView/delCachedView", view).then(() => {
|
|
156
|
-
const { fullPath } = view;
|
|
157
|
-
this.$nextTick(() => {
|
|
158
|
-
this.$router.replace({
|
|
159
|
-
path: "/redirect" + fullPath,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
closeSelectedTag(view) {
|
|
166
|
-
console.log('closeTag',view);
|
|
167
|
-
const arr = this.$router.options.routes;
|
|
168
|
-
_forEachRoute(arr, view.path);
|
|
169
|
-
|
|
170
|
-
this.$store
|
|
171
|
-
.dispatch("tagsView/delView", view)
|
|
172
|
-
.then(({ visitedViews }) => {
|
|
173
|
-
if (this.isActive(view)) {
|
|
174
|
-
// 通知标签页组件清除缓存/更新视图
|
|
175
|
-
window.nnav = true;
|
|
176
|
-
this.toLastView(visitedViews, view);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
},
|
|
180
|
-
closeOthersTags() {
|
|
181
|
-
this.$router.push(this.selectedTag);
|
|
182
|
-
this.$store
|
|
183
|
-
.dispatch("tagsView/delOthersViews", this.selectedTag)
|
|
184
|
-
.then(() => {
|
|
185
|
-
this.moveToCurrentTag();
|
|
186
|
-
});
|
|
187
|
-
},
|
|
188
|
-
closeAllTags(view) {
|
|
189
|
-
this.$store.dispatch("tagsView/delAllViews").then(({ visitedViews }) => {
|
|
190
|
-
if (this.affixTags.some((tag) => tag.path === view.path)) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
this.toLastView(visitedViews, view);
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
toLastView(visitedViews, view) {
|
|
197
|
-
const latestView = visitedViews.slice(-1)[0];
|
|
198
|
-
if (latestView) {
|
|
199
|
-
this.$router.push(latestView.fullPath);
|
|
200
|
-
} else {
|
|
201
|
-
// now the default is to redirect to the home page if there is no tags-view,
|
|
202
|
-
// you can adjust it according to your needs.
|
|
203
|
-
if (view.name === "Dashboard") {
|
|
204
|
-
// to reload home page
|
|
205
|
-
this.$router.replace({ path: "/redirect" + view.fullPath });
|
|
206
|
-
} else {
|
|
207
|
-
this.$router.push("/");
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
openMenu(tag, e) {
|
|
212
|
-
const menuMinWidth = 105;
|
|
213
|
-
const offsetLeft = this.$el.getBoundingClientRect().left; // container margin left
|
|
214
|
-
const offsetWidth = this.$el.offsetWidth; // container width
|
|
215
|
-
const maxLeft = offsetWidth - menuMinWidth; // left boundary
|
|
216
|
-
const left = e.clientX - offsetLeft + 15; // 15: margin right
|
|
217
|
-
|
|
218
|
-
if (left > maxLeft) {
|
|
219
|
-
this.left = maxLeft;
|
|
220
|
-
} else {
|
|
221
|
-
this.left = left;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
this.top = e.clientY;
|
|
225
|
-
this.visible = true;
|
|
226
|
-
this.selectedTag = tag;
|
|
227
|
-
},
|
|
228
|
-
closeMenu() {
|
|
229
|
-
this.visible = false;
|
|
230
|
-
},
|
|
231
|
-
handleScroll() {
|
|
232
|
-
this.closeMenu();
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
</script>
|
|
237
|
-
|
|
238
|
-
<style lang="scss" scoped>
|
|
239
|
-
.tags-view-container {
|
|
240
|
-
height: 34px;
|
|
241
|
-
width: 100%;
|
|
242
|
-
background: #fff;
|
|
243
|
-
border-bottom: 1px solid #d8dce5;
|
|
244
|
-
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
|
|
245
|
-
.tags-view-wrapper {
|
|
246
|
-
.tags-view-item {
|
|
247
|
-
display: inline-block;
|
|
248
|
-
position: relative;
|
|
249
|
-
cursor: pointer;
|
|
250
|
-
height: 26px;
|
|
251
|
-
line-height: 26px;
|
|
252
|
-
border: 1px solid #d8dce5;
|
|
253
|
-
color: #495060;
|
|
254
|
-
background: #fff;
|
|
255
|
-
padding: 0 8px;
|
|
256
|
-
font-size: 12px;
|
|
257
|
-
margin-left: 5px;
|
|
258
|
-
margin-top: 4px;
|
|
259
|
-
&:first-of-type {
|
|
260
|
-
margin-left: 15px;
|
|
261
|
-
}
|
|
262
|
-
&:last-of-type {
|
|
263
|
-
margin-right: 15px;
|
|
264
|
-
}
|
|
265
|
-
&.active {
|
|
266
|
-
background-color: #409eff;
|
|
267
|
-
color: #fff;
|
|
268
|
-
border-color: #409eff;
|
|
269
|
-
&::before {
|
|
270
|
-
content: "";
|
|
271
|
-
background: #fff;
|
|
272
|
-
display: inline-block;
|
|
273
|
-
width: 8px;
|
|
274
|
-
height: 8px;
|
|
275
|
-
border-radius: 50%;
|
|
276
|
-
position: relative;
|
|
277
|
-
margin-right: 2px;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
.contextmenu {
|
|
283
|
-
margin: 0;
|
|
284
|
-
background: #fff;
|
|
285
|
-
z-index: 3000;
|
|
286
|
-
position: absolute;
|
|
287
|
-
list-style-type: none;
|
|
288
|
-
padding: 5px 0;
|
|
289
|
-
border-radius: 4px;
|
|
290
|
-
font-size: 12px;
|
|
291
|
-
font-weight: 400;
|
|
292
|
-
color: #333;
|
|
293
|
-
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
|
|
294
|
-
li {
|
|
295
|
-
margin: 0;
|
|
296
|
-
padding: 7px 16px;
|
|
297
|
-
cursor: pointer;
|
|
298
|
-
&:hover {
|
|
299
|
-
background: #eee;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
</style>
|
|
305
|
-
|
|
306
|
-
<style lang="scss">
|
|
307
|
-
//reset element css of el-icon-close
|
|
308
|
-
.tags-view-wrapper {
|
|
309
|
-
.tags-view-item {
|
|
310
|
-
.el-icon-close {
|
|
311
|
-
width: 16px;
|
|
312
|
-
height: 16px;
|
|
313
|
-
vertical-align: 2px;
|
|
314
|
-
border-radius: 50%;
|
|
315
|
-
text-align: center;
|
|
316
|
-
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
317
|
-
transform-origin: 100% 50%;
|
|
318
|
-
&:before {
|
|
319
|
-
transform: scale(0.6);
|
|
320
|
-
display: inline-block;
|
|
321
|
-
vertical-align: -3px;
|
|
322
|
-
}
|
|
323
|
-
&:hover {
|
|
324
|
-
background-color: #b4bccc;
|
|
325
|
-
color: #fff;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div id="tags-view-container" class="tags-view-container">
|
|
3
|
+
<scroll-pane
|
|
4
|
+
ref="scrollPane"
|
|
5
|
+
class="tags-view-wrapper"
|
|
6
|
+
@scroll="handleScroll"
|
|
7
|
+
>
|
|
8
|
+
<router-link
|
|
9
|
+
v-for="tag in visitedViews"
|
|
10
|
+
ref="tag"
|
|
11
|
+
:key="tag.path"
|
|
12
|
+
:class="isActive(tag) ? 'active' : ''"
|
|
13
|
+
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
|
14
|
+
tag="span"
|
|
15
|
+
class="tags-view-item"
|
|
16
|
+
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
|
17
|
+
@contextmenu.prevent.native="openMenu(tag, $event)"
|
|
18
|
+
>
|
|
19
|
+
{{ tag.title }}
|
|
20
|
+
<span
|
|
21
|
+
v-if="!isAffix(tag)"
|
|
22
|
+
class="el-icon-close"
|
|
23
|
+
@click.prevent.stop="closeSelectedTag(tag)"
|
|
24
|
+
/>
|
|
25
|
+
</router-link>
|
|
26
|
+
</scroll-pane>
|
|
27
|
+
<ul
|
|
28
|
+
v-show="visible"
|
|
29
|
+
:style="{ left: left + 'px', top: top + 'px' }"
|
|
30
|
+
class="contextmenu"
|
|
31
|
+
>
|
|
32
|
+
<li @click="refreshSelectedTag(selectedTag)">刷新</li>
|
|
33
|
+
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
|
|
34
|
+
关闭
|
|
35
|
+
</li>
|
|
36
|
+
<li @click="closeOthersTags">关闭其他</li>
|
|
37
|
+
<li @click="closeAllTags(selectedTag)">关闭全部</li>
|
|
38
|
+
</ul>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
import ScrollPane from "./ScrollPane";
|
|
44
|
+
import path from "path";
|
|
45
|
+
import router from "../../../../router/index";
|
|
46
|
+
|
|
47
|
+
function _forEachRoute(arr, path) {
|
|
48
|
+
if (arr && arr.length > 0) {
|
|
49
|
+
arr.find((item) => {
|
|
50
|
+
if (item.url === path) {
|
|
51
|
+
item["meta"]["upload"] = true;
|
|
52
|
+
return item;
|
|
53
|
+
} else {
|
|
54
|
+
_forEachRoute(item.children, path);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
components: { ScrollPane },
|
|
62
|
+
data() {
|
|
63
|
+
return {
|
|
64
|
+
visible: false,
|
|
65
|
+
top: 0,
|
|
66
|
+
left: 0,
|
|
67
|
+
selectedTag: {},
|
|
68
|
+
affixTags: [],
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
computed: {
|
|
72
|
+
visitedViews() {
|
|
73
|
+
return this.$store.state.tagsView.visitedViews;
|
|
74
|
+
},
|
|
75
|
+
routes() {
|
|
76
|
+
return router.options.routes;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
watch: {
|
|
80
|
+
$route() {
|
|
81
|
+
this.addTags();
|
|
82
|
+
this.moveToCurrentTag();
|
|
83
|
+
},
|
|
84
|
+
visible(value) {
|
|
85
|
+
if (value) {
|
|
86
|
+
document.body.addEventListener("click", this.closeMenu);
|
|
87
|
+
} else {
|
|
88
|
+
document.body.removeEventListener("click", this.closeMenu);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
mounted() {
|
|
93
|
+
this.initTags();
|
|
94
|
+
this.addTags();
|
|
95
|
+
},
|
|
96
|
+
methods: {
|
|
97
|
+
isActive(route) {
|
|
98
|
+
return route.path === this.$route.path;
|
|
99
|
+
},
|
|
100
|
+
isAffix(tag) {
|
|
101
|
+
return tag.meta && tag.meta.affix;
|
|
102
|
+
},
|
|
103
|
+
filterAffixTags(routes, basePath = "/") {
|
|
104
|
+
let tags = [];
|
|
105
|
+
routes.forEach((route) => {
|
|
106
|
+
if (route.meta && route.meta.affix) {
|
|
107
|
+
const tagPath = path.resolve(basePath, route.path);
|
|
108
|
+
tags.push({
|
|
109
|
+
fullPath: tagPath,
|
|
110
|
+
path: tagPath,
|
|
111
|
+
name: route.name,
|
|
112
|
+
meta: { ...route.meta },
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (route.children) {
|
|
116
|
+
const tempTags = this.filterAffixTags(route.children, route.path);
|
|
117
|
+
if (tempTags.length >= 1) {
|
|
118
|
+
tags = [...tags, ...tempTags];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return tags;
|
|
123
|
+
},
|
|
124
|
+
initTags() {
|
|
125
|
+
const affixTags = (this.affixTags = this.filterAffixTags(this.routes));
|
|
126
|
+
for (const tag of affixTags) {
|
|
127
|
+
if (tag.name) {
|
|
128
|
+
this.$store.dispatch("tagsView/addVisitedView", tag);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
addTags() {
|
|
133
|
+
const { meta } = this.$route;
|
|
134
|
+
if (meta && meta.title) {
|
|
135
|
+
this.$store.dispatch("tagsView/addView", this.$route);
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
},
|
|
139
|
+
moveToCurrentTag() {
|
|
140
|
+
const tags = this.$refs.tag;
|
|
141
|
+
this.$nextTick(() => {
|
|
142
|
+
for (const tag of tags) {
|
|
143
|
+
if (tag.to.path === this.$route.path) {
|
|
144
|
+
this.$refs.scrollPane.moveToTarget(tag);
|
|
145
|
+
// when query is different then update
|
|
146
|
+
if (tag.to.fullPath !== this.$route.fullPath) {
|
|
147
|
+
this.$store.dispatch("tagsView/updateVisitedView", this.$route);
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
refreshSelectedTag(view) {
|
|
155
|
+
this.$store.dispatch("tagsView/delCachedView", view).then(() => {
|
|
156
|
+
const { fullPath } = view;
|
|
157
|
+
this.$nextTick(() => {
|
|
158
|
+
this.$router.replace({
|
|
159
|
+
path: "/redirect" + fullPath,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
closeSelectedTag(view) {
|
|
166
|
+
console.log('closeTag',view);
|
|
167
|
+
const arr = this.$router.options.routes;
|
|
168
|
+
_forEachRoute(arr, view.path);
|
|
169
|
+
|
|
170
|
+
this.$store
|
|
171
|
+
.dispatch("tagsView/delView", view)
|
|
172
|
+
.then(({ visitedViews }) => {
|
|
173
|
+
if (this.isActive(view)) {
|
|
174
|
+
// 通知标签页组件清除缓存/更新视图
|
|
175
|
+
window.nnav = true;
|
|
176
|
+
this.toLastView(visitedViews, view);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
closeOthersTags() {
|
|
181
|
+
this.$router.push(this.selectedTag);
|
|
182
|
+
this.$store
|
|
183
|
+
.dispatch("tagsView/delOthersViews", this.selectedTag)
|
|
184
|
+
.then(() => {
|
|
185
|
+
this.moveToCurrentTag();
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
closeAllTags(view) {
|
|
189
|
+
this.$store.dispatch("tagsView/delAllViews").then(({ visitedViews }) => {
|
|
190
|
+
if (this.affixTags.some((tag) => tag.path === view.path)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
this.toLastView(visitedViews, view);
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
toLastView(visitedViews, view) {
|
|
197
|
+
const latestView = visitedViews.slice(-1)[0];
|
|
198
|
+
if (latestView) {
|
|
199
|
+
this.$router.push(latestView.fullPath);
|
|
200
|
+
} else {
|
|
201
|
+
// now the default is to redirect to the home page if there is no tags-view,
|
|
202
|
+
// you can adjust it according to your needs.
|
|
203
|
+
if (view.name === "Dashboard") {
|
|
204
|
+
// to reload home page
|
|
205
|
+
this.$router.replace({ path: "/redirect" + view.fullPath });
|
|
206
|
+
} else {
|
|
207
|
+
this.$router.push("/");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
openMenu(tag, e) {
|
|
212
|
+
const menuMinWidth = 105;
|
|
213
|
+
const offsetLeft = this.$el.getBoundingClientRect().left; // container margin left
|
|
214
|
+
const offsetWidth = this.$el.offsetWidth; // container width
|
|
215
|
+
const maxLeft = offsetWidth - menuMinWidth; // left boundary
|
|
216
|
+
const left = e.clientX - offsetLeft + 15; // 15: margin right
|
|
217
|
+
|
|
218
|
+
if (left > maxLeft) {
|
|
219
|
+
this.left = maxLeft;
|
|
220
|
+
} else {
|
|
221
|
+
this.left = left;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
this.top = e.clientY;
|
|
225
|
+
this.visible = true;
|
|
226
|
+
this.selectedTag = tag;
|
|
227
|
+
},
|
|
228
|
+
closeMenu() {
|
|
229
|
+
this.visible = false;
|
|
230
|
+
},
|
|
231
|
+
handleScroll() {
|
|
232
|
+
this.closeMenu();
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
</script>
|
|
237
|
+
|
|
238
|
+
<style lang="scss" scoped>
|
|
239
|
+
.tags-view-container {
|
|
240
|
+
height: 34px;
|
|
241
|
+
width: 100%;
|
|
242
|
+
background: #fff;
|
|
243
|
+
border-bottom: 1px solid #d8dce5;
|
|
244
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
|
|
245
|
+
.tags-view-wrapper {
|
|
246
|
+
.tags-view-item {
|
|
247
|
+
display: inline-block;
|
|
248
|
+
position: relative;
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
height: 26px;
|
|
251
|
+
line-height: 26px;
|
|
252
|
+
border: 1px solid #d8dce5;
|
|
253
|
+
color: #495060;
|
|
254
|
+
background: #fff;
|
|
255
|
+
padding: 0 8px;
|
|
256
|
+
font-size: 12px;
|
|
257
|
+
margin-left: 5px;
|
|
258
|
+
margin-top: 4px;
|
|
259
|
+
&:first-of-type {
|
|
260
|
+
margin-left: 15px;
|
|
261
|
+
}
|
|
262
|
+
&:last-of-type {
|
|
263
|
+
margin-right: 15px;
|
|
264
|
+
}
|
|
265
|
+
&.active {
|
|
266
|
+
background-color: #409eff;
|
|
267
|
+
color: #fff;
|
|
268
|
+
border-color: #409eff;
|
|
269
|
+
&::before {
|
|
270
|
+
content: "";
|
|
271
|
+
background: #fff;
|
|
272
|
+
display: inline-block;
|
|
273
|
+
width: 8px;
|
|
274
|
+
height: 8px;
|
|
275
|
+
border-radius: 50%;
|
|
276
|
+
position: relative;
|
|
277
|
+
margin-right: 2px;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
.contextmenu {
|
|
283
|
+
margin: 0;
|
|
284
|
+
background: #fff;
|
|
285
|
+
z-index: 3000;
|
|
286
|
+
position: absolute;
|
|
287
|
+
list-style-type: none;
|
|
288
|
+
padding: 5px 0;
|
|
289
|
+
border-radius: 4px;
|
|
290
|
+
font-size: 12px;
|
|
291
|
+
font-weight: 400;
|
|
292
|
+
color: #333;
|
|
293
|
+
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
|
|
294
|
+
li {
|
|
295
|
+
margin: 0;
|
|
296
|
+
padding: 7px 16px;
|
|
297
|
+
cursor: pointer;
|
|
298
|
+
&:hover {
|
|
299
|
+
background: #eee;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
</style>
|
|
305
|
+
|
|
306
|
+
<style lang="scss">
|
|
307
|
+
//reset element css of el-icon-close
|
|
308
|
+
.tags-view-wrapper {
|
|
309
|
+
.tags-view-item {
|
|
310
|
+
.el-icon-close {
|
|
311
|
+
width: 16px;
|
|
312
|
+
height: 16px;
|
|
313
|
+
vertical-align: 2px;
|
|
314
|
+
border-radius: 50%;
|
|
315
|
+
text-align: center;
|
|
316
|
+
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
317
|
+
transform-origin: 100% 50%;
|
|
318
|
+
&:before {
|
|
319
|
+
transform: scale(0.6);
|
|
320
|
+
display: inline-block;
|
|
321
|
+
vertical-align: -3px;
|
|
322
|
+
}
|
|
323
|
+
&:hover {
|
|
324
|
+
background-color: #b4bccc;
|
|
325
|
+
color: #fff;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Navbar } from './Navbar'
|
|
2
|
-
export { default as Sidebar } from './Sidebar'
|
|
3
|
-
export { default as AppMain } from './AppMain'
|
|
1
|
+
export { default as Navbar } from './Navbar'
|
|
2
|
+
export { default as Sidebar } from './Sidebar'
|
|
3
|
+
export { default as AppMain } from './AppMain'
|
|
4
4
|
export { default as TagsView } from './TagsView/index.vue'
|