main.js
1.59 KB
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
import Vue from "vue";
import App from "./App.vue";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import router from "./router";
import store from "./store";
import resetCss from "./assets/resetElementCss/index.css";
import api from "./api/install";
import "./assets/css/public.css";
import echarts from "echarts";
import "./assets/icon/iconfont.css";
import { buildCode } from "../src/assets/js/buildcodes";
import moment from "moment";
Vue.prototype.$echarts = echarts;
Vue.prototype.$moment = moment;
Vue.prototype.$buildCode = buildCode;
Vue.prototype.oParse = new XML.ObjTree();
Vue.use(api);
Vue.use(ElementUI, { size: "small", zIndex: 3000 });
Vue.use(resetCss);
Vue.config.productionTip = false;
new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
/**
* 图片上传限制
*/
Vue.prototype.uploadImgCondition = function (file) {
const isJPG = file.type === "image/jpeg";
const isLt2M = file.size / 1024 / 1024 < 2;
if (!isJPG) {
this.$message.error("上传头像图片只能是 JPG 格式!");
}
if (!isLt2M) {
this.$message.error("上传头像图片大小不能超过 2MB!");
}
return isJPG && isLt2M;
}
/**
* tar文件上传设置
*/
Vue.prototype.uploadFile = function(file, type, size) {
debugger
const isType = file.type === type;
let isSize = null;
if (size) {
isSize = file.size / 1024 / 1024 < size;
}
if (!isType) {
this.$message.error(`上传头像文件只能${type}是格式!`);
}
if (size && !isSize) {
this.$message.error(`文件大小不能超过 ${size}MB!`);
}
return isType && isSize;
}