/
AdminLTE.vue
162 lines (150 loc) · 4.35 KB
/
AdminLTE.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<template>
<div class="wrapper">
<NaviBar :logoText="logoText" :logoMiniText="logoMiniText" :versionText="versionText" @modify-password="$refs['modify-password-dlg'].show()"></NaviBar>
<Sider :menus="menus"></Sider>
<ModifyPasswordDlg ref="modify-password-dlg"></ModifyPasswordDlg>
<div class="content-wrapper">
<section class="content">
<router-view></router-view>
</section>
</div>
<footer class="main-footer">
<div class="pull-right hidden-xs hide">
EasyDarwin
</div>
<strong>Copyright © {{ thisYear() }} <a href="http://www.easydarwin.org">www.easydarwin.org</a>.</strong> All rights reserved.
</footer>
</div>
</template>
<script>
import "font-awesome/css/font-awesome.css"
import "bootstrap/dist/css/bootstrap.css"
import "admin-lte/dist/css/AdminLTE.css"
import "admin-lte/dist/css/skins/_all-skins.css"
import "assets/styles/custom.less"
import "bootstrap/dist/js/bootstrap.js"
import "admin-lte/dist/js/adminlte.js"
import { mapState, mapActions } from "vuex"
import Vue from 'vue'
import moment from 'moment'
import Sider from 'components/Sider.vue'
import NaviBar from 'components/NaviBar.vue'
import ModifyPasswordDlg from 'components/ModifyPasswordDlg.vue'
import ElementUI from "element-ui"
import 'assets/styles/element-custom.scss'
Vue.use(ElementUI);
import VCharts from 'v-charts'
Vue.use(VCharts);
import VueClipboards from 'vue-clipboards';
Vue.use(VueClipboards);
import fullscreen from 'vue-fullscreen'
Vue.use(fullscreen);
import BackToTop from 'vue-backtotop'
Vue.use(BackToTop)
import VeeValidate, { Validator } from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN";
Validator.localize("zh_CN", zh_CN);
Vue.use(VeeValidate, {
locale: "zh_CN",
// delay: 500,
dictionary: {
zh_CN: {
messages: {
required: field => `${field} 不能为空`,
confirmed: (field, targetField) => `${field} 和 ${targetField} 不匹配`,
regex: field => `${field} 不符合要求格式`
}
}
}
});
import $ from 'jquery'
$.ajaxSetup({ cache: false });
export default {
data() {
return {
}
},
mounted() {
$(document).ajaxError((evt, xhr, opts, ex) => {
if (xhr.status == 401) {
top.location.href = '/';
return false;
}
let msg = xhr.responseText || "网络请求失败";
if (xhr.status == 404) {
msg = "请求服务不存在或已停止";
}
this.$message({
type: 'error',
message: msg
})
}).on("click", ".main-header .sidebar-toggle", function () {
setTimeout(() => {
localStorage["sidebar-collapse"] = $("body").hasClass("sidebar-collapse") ? "sidebar-collapse" : "";
}, 500)
}).ready(() => {
$("body").layout("fix");
this.fixHover();
});
$("body").addClass(localStorage["sidebar-collapse"]);
this.getServerInfo();
},
components: {
NaviBar, Sider, ModifyPasswordDlg
},
computed: {
...mapState([
"logoText",
"logoMiniText",
"menus",
"serverInfo"
]),
versionText(){
let text = "";
if(this.serverInfo){
text = this.serverInfo.Version || "";
}
return text.substring(text.indexOf(" ") + 1);
}
},
methods: {
...mapActions([
"getServerInfo"
]),
fixHover() {
if(videojs.browser.IS_IOS||videojs.browser.IS_ANDROID) {
for(var sheetI = document.styleSheets.length - 1; sheetI >= 0; sheetI--) {
var sheet = document.styleSheets[sheetI];
if(sheet.cssRules) {
for(var ruleI = sheet.cssRules.length - 1; ruleI >= 0; ruleI--) {
var rule = sheet.cssRules[ruleI];
if(rule.selectorText) {
rule.selectorText = rule.selectorText.replace(":hover", ":active");
rule.selectorText = rule.selectorText.replace(":focus", ":active");
}
}
}
}
}
},
thisYear() {
return moment().format('YYYY');
}
}
}
</script>
<style lang="less" scoped>
.content-wrapper, .right-side, .main-footer {
transition: none;
}
</style>
<style lang="less">
.vue-back-to-top {
background-color: transparent;
left: 30px;
bottom: 10px;
}
.sidebar-collapse .vue-back-to-top {
display: none;
}
</style>