lxf
2025-04-30 b4c4556a5eddf6708ec55b07e3edc15b2217842e
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
163
164
165
166
167
168
169
import Vue from "vue";
import App from "./App";
import router from "./router";
import Icon from "vue-svg-icon/Icon.vue";
import Mint from "mint-ui";
// import Resource from 'vue-resource' // 已卸载用axios代替
import store from "./store/index";
import axios from "./axios/index";
import ElementUI from "element-ui";
import VueClipboard from "vue-clipboard2"; // 复制
 
import state from "./event";
import Vant, {
  Swipe,
  SwipeItem,
  Skeleton,
  Switch,
  Notify,
  Tab,
  Tabs,
  Popup,
  DatetimePicker
} from "vant";
import "vant/lib/index.css";
import moment from "moment";
 
import i18n from "@/locales";
import "./assets/css/style.css";
 
import "bootstrap/dist/css/bootstrap.min.css";
import "mint-ui/lib/style.css";
import "element-ui/lib/theme-chalk/index.css";
import "lib-flexible";
// import md5 from 'js-md5'
import * as filters from "@/utils/utils";
import * as filter from "@/utils/filter";
import * as allocation from "@/utils/allocation";
import animated from "animate.css"; // npm install animate.css --save安装,在引入
 
import "../static/css/public2.css";
import locale from "element-ui/lib/locale/lang/en"; // lang i18n
import echarts from "echarts";
 
Vue.prototype.$echarts = echarts;
Vue.prototype.$moment = moment;
// import VueTouch from 'vue-touch'
Vue.use(Swipe);
Vue.use(SwipeItem);
Vue.use(Skeleton);
Vue.use(animated);
Vue.use(ElementUI);
Vue.use(VueClipboard);
Vue.use(ElementUI, { locale });
Vue.use(ElementUI, {
  size: "medium", // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
});
 
// Vue.use(VueTouch, { name: 'v-touch' })
// // Vue.prototype.$md5 = md5
// VueTouch.config.swipe = {
//   threshold: 100 // 手指左右滑动距离
// }
 
Vue.use(Vant);
Vue.use(Mint);
Vue.use(Tab);
// Vue.prototype._i18n = i18n
Vue.use(Tabs, Popup, DatetimePicker, Switch, Notify);
Vue.component("icon", Icon);
Vue.config.productionTip = false;
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});
Object.keys(filter).forEach(key => {
  Vue.filter(key, filter[key]);
});
Object.keys(allocation).forEach(key => {
  Vue.prototype[key] = allocation[key];
});
Vue.prototype.$state = state;
Vue.prototype.$setgoindex = function() {
  if (window.history.length <= 1) {
    if (location.href.indexOf("?") === -1) {
      window.location.href = location.href + "?goindex=true";
    } else if (
      location.href.indexOf("?") !== -1 &&
      location.href.indexOf("goindex") === -1
    ) {
      window.location.href = location.href + "&goindex=true";
    }
  }
};
Vue.prototype.setCookie = function(name, value, day) {
  if (day !== 0) {
    // 当设置的时间等于0时,不设置expires属性,cookie在浏览器关闭后删除
    var curDate = new Date();
    var curTamp = curDate.getTime();
    var curWeeHours = new Date(curDate.toLocaleDateString()).getTime() - 1;
    var passedTamp = curTamp - curWeeHours;
    var leftTamp = 24 * 60 * 60 * 1000 - passedTamp;
    var leftTime = new Date();
    leftTime.setTime(leftTamp + curTamp);
    document.cookie =
      name + "=" + escape(value) + ";expires=" + leftTime.toGMTString();
  } else {
    document.cookie = name + "=" + escape(value);
  }
};
Vue.prototype.getCookie = function(name) {
  var arr;
  var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  arr = document.cookie.match(reg);
  if (arr) {
    return unescape(arr[2]);
  } else {
    return null;
  }
  // document.cookie = name + "=" + escape(value);
};
Vue.prototype.clearCookie = function() {
  this.setCookie("USER_TOKEN", "", -1);
};
Vue.prototype.checkCookie = function() {
  var user = this.getCookie("USER_TOKEN");
  if (user !== "") {
    alert("Welcome again " + user);
  } else {
    user = prompt("Please enter your name:", "");
    if (user !== "" && user != null) {
      this.setCookie("USER_TOKEN", user, 365);
    }
  }
};
 
router.beforeEach((to, from, next) => {
  store.state.select = to.path;
  document.title = to.meta.title;
  console.log(store.state, "store.state", !!store.state.token);
  if (to.meta.requireAuth && !!!store.state.token) {
    // next("/login");
    //点击管理后台分享的二维码 进入注册页面 会识别未登录 导致进入登录页面
  }
  // if (!to.query.url && from.query.url) {
  //   to.query.url = from.query.url
  // }
  next();
});
// // 设置title
// router.beforeEach((to, from, next) => {
//   if (to.meta.title) {//如果设置标题,拦截后设置标题
//     if(store.state && store.state.siteInfo && store.state.siteInfo.siteName){
//       document.title =  store.state.siteInfo.siteName + '-' + to.meta.title
//     }else{
//       document.title =  to.meta.title
//     }
//   }
//   next()
// })
/* eslint-disable no-new */
 
new Vue({
  el: "#app",
  // i18n,
  store,
  router,
  axios,
  render: h => h(App)
}).$mount("#app");