-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathApp.vue
71 lines (68 loc) · 1.93 KB
/
App.vue
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
<template>
<!-- 务必保持 APP节点下元素为 h-menu,router-view,player 因为播放容器列表设置了margin -->
<div id="app">
<h-menu />
<!-- 仅保存singer路由时的缓存 -->
<keep-alive include="singer">
<router-view></router-view>
</keep-alive>
<player />
</div>
</template>
<script lang="ts">
import hMenu from "components/content/head-menu/head-menu.vue";
import player from "views/player/index.vue";
import { Component, Vue, Watch } from "vue-property-decorator";
import {
playerSetMarginBottom,
playerRemoveMarginBottom
} from "@/conf/playlist";
@Component({
components: {
hMenu,
player
}
})
export default class App extends Vue {
created() {
let first_loading = document.getElementById("first-loading");
if (!!first_loading) {
document.body.removeChild(<HTMLElement>first_loading);
}
}
mounted() {
document.body.style.margin = "0px";
}
updated() {
// 界面DOM渲染完成的margin距离设置
if (this.$store.getters.playListLength === 0) {
playerRemoveMarginBottom();
} else {
if (
this.$route.path.indexOf("/login") == -1 &&
!this.$route.path.match(/^\/comment\/((?:[^\/]+?))(?:\/(?=$))?$/i)
) {
playerSetMarginBottom();
}
}
}
// 当有播放内容时,底部需要margin出距离 需要注意的是 这里的marginBottom设置的值并不会被替换vw单位 ,要在postcss.config.js中配置
// 登陆,评论 不需要margin出距离
// 有无播放容器时设置的margin
@Watch("$store.getters.playListLength", { immediate: true })
changePlaylistLength(newVal: number) {
if (newVal === 0) {
playerRemoveMarginBottom();
} else {
if (
this.$route.path.indexOf("/login") == -1 &&
!this.$route.path.match(/^\/comment\/((?:[^\/]+?))(?:\/(?=$))?$/i)
) {
playerSetMarginBottom();
}
}
}
}
</script>
<style lang="less">
</style>