| | |
| | | import Vue from 'vue' |
| | | import App from './App' |
| | | import router from './router' |
| | | import ElementUI from 'element-ui' |
| | | import store from './store' |
| | | import axios from './axios/index' // 这里这里 |
| | | import preview from 'vue-photo-preview' // 查看大图 |
| | | import 'vue-photo-preview/dist/skin.css' // 查看大图样式 |
| | | import echarts from "echarts"; |
| | | import dayjs from 'dayjs'; |
| | | import VueI18n from 'vue-i18n' |
| | | // import i18n from './locales' |
| | | import i18n from '@/locales' |
| | | import 'element-ui/lib/theme-chalk/index.css' |
| | | // import locale from 'element-ui/lib/locale/lang/en' // lang i18n |
| | | import Vue from "vue"; |
| | | import App from "./App.vue"; |
| | | import router from "./router"; |
| | | import store from "./store"; |
| | | import { i18n } from "./lang/index"; |
| | | import * as filter from "@/utils/filter"; |
| | | |
| | | import locale from 'element-ui/lib/locale'; |
| | | import enLocale from 'element-ui/lib/locale/lang/en' |
| | | import zhLocale from 'element-ui/lib/locale/lang/zh-CN' |
| | | // import axios from 'axios' |
| | | import * as filters from './utils/utils' |
| | | import VueClipboard from 'vue-clipboard2' // 复制 |
| | | import md5 from 'js-md5' |
| | | import animated from 'animate.css' // 动画 |
| | | // import enLocale from 'element-ui/lib/locale/lang/en' |
| | | // import i18n from './lang' |
| | | import config from "@/config/index"; // 全局配置 |
| | | Vue.prototype.$mc = config.MajorCurrencies; // 主流币种 |
| | | |
| | | // 按需引入element-ui组件 |
| | | import { |
| | | Button, |
| | | Dropdown, |
| | | DropdownMenu, |
| | | DropdownItem, |
| | | FormItem, |
| | | Input, |
| | | Message, |
| | | Alert, |
| | | Table, |
| | | MessageBox, |
| | | TableColumn, |
| | | Pagination, |
| | | Loading, |
| | | Tag, |
| | | Tabs, |
| | | TabPane, |
| | | Dialog, |
| | | Form, |
| | | Radio, |
| | | RadioGroup, |
| | | RadioButton, |
| | | Select, |
| | | Option, |
| | | Drawer, |
| | | Upload, |
| | | Popconfirm, |
| | | Row, |
| | | Col, |
| | | Empty, |
| | | InputNumber, |
| | | Slider, |
| | | } from "element-ui"; |
| | | import "element-ui/lib/theme-chalk/index.css"; |
| | | // Vue.component(Button.name, Button); |
| | | Vue.use(Slider); |
| | | Vue.use(InputNumber); |
| | | Vue.use(Empty); |
| | | Vue.use(Dropdown); |
| | | Vue.use(DropdownMenu); |
| | | Vue.use(DropdownItem); |
| | | Vue.use(Button); |
| | | Vue.use(FormItem); |
| | | Vue.use(Input); |
| | | Vue.use(Table); |
| | | Vue.use(TableColumn); |
| | | Vue.use(Pagination); |
| | | Vue.use(Tag); |
| | | Vue.use(Tabs); |
| | | Vue.use(TabPane); |
| | | Vue.use(Dialog); |
| | | Vue.use(Form); |
| | | Vue.use(Radio); |
| | | Vue.use(RadioGroup); |
| | | Vue.use(RadioButton); |
| | | Vue.use(Select); |
| | | Vue.use(Option); |
| | | Vue.use(Drawer); |
| | | Vue.use(Upload); |
| | | Vue.use(Popconfirm); |
| | | Vue.use(Row); |
| | | Vue.use(Col); |
| | | Vue.use(Alert); |
| | | Vue.use(Loading.directive); |
| | | // Message组件需要全局挂载 |
| | | Vue.prototype.$message = Message; |
| | | Vue.prototype.$msgbox = MessageBox; |
| | | Vue.prototype.$alert = MessageBox.alert; |
| | | Vue.prototype.$prompt = MessageBox.prompt; |
| | | Vue.prototype.$confirm = MessageBox.confirm; |
| | | import "./assets/style/variables.scss"; |
| | | |
| | | Vue.config.productionTip = false; |
| | | Vue.prototype.$store = store; |
| | | |
| | | Vue.prototype.dayjs = dayjs; |
| | | Vue.prototype.$echarts = echarts |
| | | Vue.prototype.$md5 = md5 |
| | | Vue.config.productionTip = false |
| | | Vue.use(animated) |
| | | Vue.use(preview) |
| | | Vue.use(VueClipboard) |
| | | Vue.use(ElementUI) |
| | | Vue.use(VueI18n); //通过插件的形式挂载 |
| | | Vue.use(ElementUI, { locale }) |
| | | Object.keys(filter).forEach((key) => { |
| | | Vue.filter(key, filter[key]); |
| | | }); |
| | | |
| | | Vue.use(ElementUI, { |
| | | size: 'medium', // set element-ui default size |
| | | i18n: (key, value) => i18n.t(key, value) |
| | | }) |
| | | locale.i18n((key, value) => i18n.t(key, value)) //兼容element |
| | | Object.keys(filters).forEach(key => { |
| | | Vue.filter(key, filters[key]) |
| | | }) |
| | | // Vue.http.options.emulateJSON = true; |
| | | // Vue.http.options.headers = { |
| | | // // 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' |
| | | // 'Content-Type': 'application/json;charset=UTF-8' |
| | | // }; |
| | | Vue.prototype.getCookie = function(name) { |
| | | var arr |
| | | var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)') |
| | | console.log(document.cookie, 'document.cookie') |
| | | if (arr === document.cookie.match(reg)) { |
| | | return unescape(arr[2]) |
| | | } else { |
| | | return null |
| | | // document.cookie = name + "=" + escape(value); |
| | | } |
| | | } |
| | | 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.clearCookie = function() { |
| | | this.setCookie('USER_TOKEN', '', -1) |
| | | } |
| | | // 设置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', |
| | | router, |
| | | store, |
| | | axios, |
| | | i18n, //挂载到实例,一定得在这个位置,而不是comonents中 |
| | | render: h => h(App) |
| | | }).$mount('#app') |
| | | i18n, |
| | | render: (h) => h(App), |
| | | }).$mount("#app"); |