zhangzengfei
2020-08-04 20edbbb796f386465c0e703be0f1b602c02a5470
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
  <div class="tools-entry">
    <div class="entry-wrap">
      <div class="app-list clearFix">
        <div
          class="app"
          v-for="dock in this.$store.state.desktop.docks"
          :key="dock.id"
          @click="dockClick(dock)"
        >
          <div class="wrap">
            <div class="app-icon">
              <img :src="dock.src" :alt="dock.alt" />
            </div>
            <div class="app-name">{{dock.name}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  name: 'toolsEntry',
  data() {
    return {
      publicPath: process.env.BASE_URL,
    }
  },
  methods: {
    dockClick(dock) {
      if (dock.type === '1') {
        window.open(dock.url);
      } else if (dock.type === '2') {
        let ids = this.$store.getters["desktop/frames"].map(item => item.id);
        if (ids.indexOf(dock.id) > -1) {
          this.$store.commit('desktop/resetMinFrame', dock.id);
          this.resetDockItem();
          return;
        }
 
        let ret = this.$store.dispatch('desktop/addFrame', {
          id: dock.id,
          icon: dock.src,
          title: dock.name,
          url: dock.url
        });
      }
    },
    resetDockItem() {
      const dockItems = document.getElementsByClassName('dock-item');
      const dockMask = document.getElementsByClassName('dock-mask')[0];
      for (let i = 0; i < dockItems.length; i++) {
        dockItems[i].width = 60;
        if (dockItems[i].parentNode.nextElementSibling) {
          dockItems[i].parentNode.nextElementSibling.style.marginLeft = "-35px";
        }
      }
      dockMask.style.width = dockItems.length * 60 + 40 + 'px';
    },
  }
};
</script>
 
<style lang="scss">
.tools-entry {
  //margin-top: 130px;
  position: absolute;
  top: 142px;
  left: 50%;
  transform: translateX(-50%);
  .entry-wrap {
    width: 1180px;
    padding: 0 60px;
    margin: 0 auto;
    .app-list {
      .app {
        width: 16.6%;
        margin-bottom: 54px;
        float: left;
        .wrap {
          .app-icon {
            text-align: center;
            line-height: 110px;
            width: 110px;
            height: 110px;
            margin: auto;
            img {
              vertical-align: middle;
              margin-right: -3px;
            }
          }
          .app-name {
            padding-top: 10px;
            text-align: center;
            font: Bold 16px/16px Microsoft JhengHei;
            color: #fff;
          }
        }
 
        &:hover {
          .app-icon {
            background: rgba(0, 0, 0, 0.4);
          }
        }
      }
    }
  }
}
</style>