gy-webcode2 1.1.8 → 1.2.1

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.
@@ -0,0 +1,362 @@
1
+ <template>
2
+ <div class="wrapper " :class="{hideMenuAll:$route.query.hideMenuAll == 1}" v-if="data.length > 0">
3
+ <headComponent></headComponent>
4
+ <div class="wrapper_body" :class="{max : leftMenu_show}" >
5
+ <sidebarComponent></sidebarComponent>
6
+
7
+ <div class="flex_1 flex_column" v-if="isInitRouteTab()">
8
+ <div class="routerTabs">
9
+ <div class="menuBtn mar_r_4" ref="menuNext">
10
+ <i class="el-icon-arrow-left"></i>
11
+ </div>
12
+ <div class="flex_1 pr">
13
+ <div class="swiper-container mySwiper pa0 oh" ref="swiper_el" >
14
+ <div class="swiper-wrapper">
15
+ <div class="swiper-slide" v-for="item,index in openRouters" :key="item.fullPath">
16
+ <div class="item" @contextmenu.prevent.stop="rightClick($event,item,index)" @click="tabClick(item)" :class="{active:$route.fullPath.includes(item.fullPath)}" >
17
+ <div class="name tesr1">
18
+ {{item.name}}
19
+ </div>
20
+ <div class="other hover2" v-if="openRouters.length > 1">
21
+ <i class="el-icon-close" @click.stop="removeOpenRouter(item,index)"></i>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ <div class="menuBtn mar_l_4" ref="tabsPrev">
29
+ <i class="el-icon-arrow-right"></i>
30
+ </div>
31
+ </div>
32
+ <div class="wrapper_main">
33
+ <template v-for="item,index in openRouters" >
34
+ <component :key="item.fullPath" v-if="item.isLoad" :is="item.component" v-show="$route.fullPath.includes(item.fullPath)" />
35
+ </template>
36
+ </div>
37
+ </div>
38
+ <div class="wrapper_main" v-else>
39
+ <router-view />
40
+ </div>
41
+ </div>
42
+
43
+ <div class="rightMenuBox" ref="rightMenuBox" v-show="rightMenuShow">
44
+ <div class="item" @click.stop="menuClick(0)">
45
+ <div class="icon">
46
+ <i class="el-icon-refresh"></i>
47
+ </div>
48
+ <div class="name">
49
+ 刷新
50
+ </div>
51
+ </div>
52
+ <div class="item" v-show="openRouters.length > 1" @click.stop="menuClick(1)">
53
+ <div class="icon">
54
+ <i class="el-icon-close"></i>
55
+ </div>
56
+ <div class="name">
57
+ 关闭当前
58
+ </div>
59
+ </div>
60
+ <div class="item" v-show="openRouters.length > 1" @click.stop="menuClick(2)">
61
+ <div class="icon">
62
+ <i class="el-icon-folder-delete"></i>
63
+ </div>
64
+ <div class="name">
65
+ 关闭其他
66
+ </div>
67
+ </div>
68
+ <div class="item" v-show="openRouters.length > 1" @click.stop="menuClick(3)">
69
+ <div class="icon">
70
+ <i class="el-icon-back"></i>
71
+ </div>
72
+ <div class="name">
73
+ 关闭左侧
74
+ </div>
75
+ </div>
76
+ <div class="item" v-show="openRouters.length > 1" @click.stop="menuClick(4)">
77
+ <div class="icon">
78
+ <i class="el-icon-right"></i>
79
+ </div>
80
+ <div class="name">
81
+ 关闭右侧
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </template>
87
+
88
+ <script>
89
+ import {computed,provide, watch,defineAsyncComponent, ref, reactive,shallowRef, nextTick,onMounted} from "vue"
90
+ import headComponent from '@/components/head.vue';
91
+ import sidebarComponent from '@/components/sidebar'
92
+ import watermark from "gy-webcode2/scripts/watermark"
93
+ import Swiper from "swiper/bundle";
94
+ import "swiper/css/bundle";
95
+ export default {
96
+ name:"myIndex",
97
+ data(){
98
+ return {
99
+ transitionName:"",
100
+ tabsSwiper:null,
101
+ rightMenuShow:false,
102
+ rightMenuActive:null,
103
+ }
104
+ },
105
+ created(){
106
+ },
107
+ computed:{
108
+ menuPath(){
109
+ return this.$store.state.menu.menuPath
110
+ },
111
+ openRouters(){
112
+ return this.vuex_openRouters
113
+ },
114
+ leftMenu_show(){
115
+ return this.$store.state.leftMenu_show;
116
+ },
117
+ data() {
118
+ return this.$store.state.menu.data;
119
+ },
120
+ },
121
+ watch:{
122
+ '$route':function(){
123
+ // console.log(this.$route);
124
+ this.getRouterTabs()
125
+
126
+ }
127
+ },
128
+ mounted(){
129
+ let username=userInfo.username;
130
+ let usercode=userInfo.usercode;
131
+ this.$vuex('vuex_watermarkImg',watermark({
132
+ text:`${username}(${usercode})`
133
+ }))
134
+ this.getRouterTabs()
135
+ this.initTabsSwiper()
136
+
137
+ $("body").on("click",()=>{
138
+ this.rightMenuShow = false
139
+ })
140
+
141
+ },
142
+ methods:{
143
+ isInitRouteTab(){
144
+ if(this.$route.query.hideMenuAll == 1){
145
+ return false;
146
+ }
147
+ if(this.vuex_routeTabsShow){
148
+ return true;
149
+ }
150
+ return false;
151
+ },
152
+ rightClick(event,data,index){
153
+ event.stopPropagation()
154
+ // console.log(event);
155
+ // if(this.openRouters.length <= 1){
156
+ // return;
157
+ // }
158
+
159
+ this.rightMenuActive = index;
160
+ this.rightMenuShow = true;
161
+
162
+ $(this.$refs.rightMenuBox).css({
163
+ left:event.pageX,
164
+ top:event.pageY
165
+ })
166
+ // alert(1)
167
+ },
168
+ menuClick(val){
169
+ let data = this.openRouters[this.rightMenuActive];
170
+ if(val == 0){
171
+ data.isLoad = false;
172
+ setTimeout(() => {
173
+ data.isLoad = true;
174
+ }, 10);
175
+ }
176
+ // 关闭当前
177
+ if(val == 1){
178
+ this.openRouters.splice(this.rightMenuActive,1);
179
+ if(this.$route.fullPath.includes(data.fullPath)){
180
+ if(this.rightMenuActive != 0){
181
+ this.$router.replace(this.openRouters[this.rightMenuActive-1].fullPath)
182
+ }
183
+ else {
184
+ this.$router.replace(this.openRouters[this.rightMenuActive].fullPath)
185
+ }
186
+ }
187
+ }
188
+ // 关闭其他
189
+ else if(val == 2){
190
+ if(!this.$route.fullPath.includes(data.fullPath)){
191
+ this.$router.replace(this.openRouters[this.rightMenuActive].fullPath)
192
+ }
193
+ this.$store.state.vuex_openRouters = this.$store.state.vuex_openRouters.filter(i => i.fullPath == data.fullPath)
194
+ }
195
+
196
+ // 关闭左侧
197
+ else if(val == 3){
198
+ if(!this.$route.path.includes(data.fullPath)){
199
+ this.$router.replace(this.openRouters[this.rightMenuActive].fullPath)
200
+ }
201
+ this.$store.state.vuex_openRouters = this.$store.state.vuex_openRouters.slice(this.rightMenuActive)
202
+ }
203
+ // 关闭右侧
204
+ else if(val == 4){
205
+ if(!this.$route.path.includes(data.fullPath)){
206
+ this.$router.replace(this.openRouters[this.rightMenuActive].fullPath)
207
+ }
208
+ this.$store.state.vuex_openRouters = this.$store.state.vuex_openRouters.slice(0,this.rightMenuActive+1)
209
+ }
210
+ this.tabsSwiper.update()
211
+ this.rightMenuShow = false;
212
+ },
213
+
214
+ initTabsSwiper(){
215
+ if(!this.isInitRouteTab()){
216
+ return;
217
+ }
218
+
219
+ this.tabsSwiper = new Swiper(this.$refs.swiper_el, {
220
+ // modules: [Navigation, Pagination],
221
+ slidesPerView:'auto',
222
+ spaceBetween: 0,
223
+ navigation: {
224
+ nextEl: this.$refs.tabsPrev,
225
+ prevEl: this.$refs.menuNext,
226
+ },
227
+ });
228
+ },
229
+ tabClick(item){
230
+ // console.log(item);
231
+ if(this.$route.fullPath != item.fullPath){
232
+ this.$router.push(item.fullPath)
233
+ }
234
+ },
235
+ getRoute(){
236
+ // console.log(this.$route.matched[0]);
237
+ // console.log(this.$router.options.routes);
238
+ // console.log("___");
239
+ // // console.log(this.$router.options.routes.find(i => i.path == '/ysj'));
240
+ const router_ysj = this.$router.options.routes.find(i => i.path == this.$route.matched[0].path)
241
+ // console.log(router_ysj);
242
+ let myRoute = router_ysj.children.find(i => i.path == this.$route.path)
243
+ if(myRoute){
244
+ return myRoute;
245
+ }
246
+ },
247
+ async getRouterTabs(){
248
+ if(!this.isInitRouteTab()){
249
+ return;
250
+ }
251
+ let myRoute = this.getRoute()
252
+ let isFind = this.openRouters.findIndex(i => this.$route.fullPath.includes(i.fullPath) || this.$route.path == i.path);
253
+ // console.log(isFind);
254
+
255
+ let findName = this.openRouters.find(i => this.$route.path == i.path);
256
+ // // console.log(this.openRouters);
257
+ // // console.log(this.$route.name);
258
+ // // console.log(findName,isFind);
259
+ if(findName && findName.fullPath != this.$route.fullPath){
260
+ // console.log(findName);
261
+ this.openRouters[isFind].fullPath = this.$route.fullPath
262
+
263
+ }
264
+ // console.log(isFind);
265
+
266
+ if(isFind ==-1 && myRoute.path != 'refresh'){
267
+ let routerMsg = Object.keys(this.menuPath).find(i => decodeURIComponent(this.$route.fullPath).includes(i))
268
+ // console.log(routerMsg);
269
+ // console.log(this.menuPath[routerMsg]);
270
+ this.openRouters.push({
271
+ name:this.menuPath[routerMsg].name,
272
+ path:this.$route.path,
273
+ fullPath:this.$route.fullPath,
274
+ isLoad:true,
275
+ component:myRoute.component
276
+ // component:shallowRef(defineAsyncComponent(myRoute.component))
277
+ })
278
+ // console.log(this.openRouters);
279
+ await nextTick()
280
+ if(this.tabsSwiper){
281
+ this.tabsSwiper.navigation.update();
282
+ }
283
+ this.tabsSwiper.update()
284
+ this.tabsSwiper.slideTo(this.openRouters.length);
285
+ }
286
+ else{
287
+ this.tabsSwiper.slideTo(isFind);
288
+ }
289
+ },
290
+ async removeOpenRouter(item,index){
291
+ this.openRouters.splice(index,1);
292
+ await nextTick()
293
+ if(this.$route.fullPath.includes(item.fullPath)){
294
+ if(index != 0){
295
+ this.$router.replace(this.openRouters[index-1].fullPath)
296
+ }
297
+ else {
298
+ this.$router.replace(this.openRouters[index].fullPath)
299
+ }
300
+ }
301
+ this.tabsSwiper.update()
302
+ },
303
+ },
304
+ components: {
305
+ sidebarComponent,headComponent,
306
+ },
307
+
308
+ beforeRouteUpdate (to, from, next) {
309
+ this.$http.removePending('all');
310
+ next()
311
+ // 在当前路由改变,但是该组件被复用时调用
312
+ // 举例来说,对于一个带有动态参数的路径 /foo/:id,在 /foo/1 和 /foo/2 之间跳转的时候,
313
+ // 由于会渲染同样的 Foo 组件,因此组件实例会被复用。而这个钩子就会在这个情况下被调用。
314
+ // 可以访问组件实例 `this`
315
+ },
316
+ }
317
+ </script>
318
+
319
+ <style lang="scss" scoped>
320
+ .hideMenuAll{
321
+ .wrapper_header{
322
+ display: none;
323
+ }
324
+ .wrapper_body{
325
+ .sidebarBox {
326
+ display: none;
327
+ }
328
+ .routerTabs{
329
+ display: none;
330
+ }
331
+ }
332
+ }
333
+ .rightMenuBox{
334
+ position: fixed;
335
+ width: 100px;
336
+ // height: 200px;
337
+ padding:5px 0;
338
+ background: #fff;
339
+ left: 10px;
340
+ top: 10px;
341
+ z-index: 999;
342
+ // box-shadow: 0 0 10px 3px #aaa;
343
+ box-shadow: 0 0 10px 0px #aaa ;
344
+ border-radius:4px;
345
+ .item{
346
+ display: flex;
347
+ align-items: center;
348
+ font-size: 12px;
349
+ height: 30px;
350
+ // border: 1px solid #000;
351
+ padding-left: 12px;
352
+ cursor: pointer;
353
+ .icon{
354
+ margin-right: 5px;
355
+ }
356
+ &:hover{
357
+ // color: #009499;
358
+ @include themeColor("color",'hover')
359
+ }
360
+ }
361
+ }
362
+ </style>
@@ -0,0 +1,18 @@
1
+ <template>
2
+
3
+ </template>
4
+ <script>
5
+ export default {
6
+ beforeRouteEnter(to, from, next) {
7
+ next(vm => {
8
+ vm.$router.replace({
9
+ path:from.path,
10
+ query:from.query
11
+ })
12
+ })
13
+ }
14
+ }
15
+ </script>
16
+ <style lang="scss" scoped>
17
+
18
+ </style>
package/index.js CHANGED
@@ -10,9 +10,10 @@
10
10
  // ~的意思是匹配最近的小版本 比如~1.0.2将会匹配所有的1.0.x版本,但不匹配1.1.0
11
11
  // ^的意思是最近的一个大版本 比如1.0.2 将会匹配 所有 1.x.x, 但不包括2.x.x
12
12
  // * 这意味着安装最新版本的依赖包
13
- // 已使用项目 指标管理、数据治理
13
+ // 已使用项目 指标管理、数据治理 、数据标准
14
14
  // https://registry.npmjs.org/gy-webcode2
15
15
 
16
+ // 1.2.0 breadcrumb 使用store的menuPath了
16
17
  module.exports = {
17
- version :'1.1.8',
18
+ version :'1.2.1',
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gy-webcode2",
3
- "version": "1.1.8",
3
+ "version": "1.2.1",
4
4
  "description": "gy前端公共代码",
5
5
  "main": "index.js",
6
6
  "scripts": {