123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- // The Vue build version to load with the `import` command
- // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
- import Vue from 'vue'
- import App from './App'
- import router from './router'
- import 'font-awesome/css/font-awesome.css'
- import './style/main.scss'
- import {getAuthUrls, getCurrentUser, getRolesPermissions, storageGet, storageSave} from '@/js/index'
- import {notify} from '@/constants/index'
- import store from './store'
- import moment from 'moment'
- import {
- Avatar,
- Badge,
- Button,
- ButtonGroup,
- Card,
- Carousel,
- CarouselItem,
- Checkbox,
- CheckboxButton,
- CheckboxGroup,
- Col,
- Collapse,
- CollapseItem,
- DatePicker,
- Dialog,
- Dropdown,
- DropdownItem,
- DropdownMenu,
- Form,
- FormItem,
- Image,
- Input,
- InputNumber,
- Link,
- Loading,
- Menu,
- MenuItem,
- MenuItemGroup,
- Message,
- MessageBox,
- Notification,
- Option,
- Pagination,
- Popover,
- Radio,
- RadioButton,
- RadioGroup,
- Row,
- Select,
- Submenu,
- Switch,
- Table,
- TableColumn,
- TabPane,
- Tabs,
- Tag,
- TimePicker,
- TimeSelect,
- Tooltip,
- Upload,
- Progress,
- Step,
- Steps,
- } from 'element-ui'
- Vue.prototype.$moment = moment
- function getCurrentUserSuccess(res){
- }
- // var _hmt = _hmt || [];
- // (function() {
- // var hm = document.createElement("script");
- // hm.src = "https://hm.baidu.com/hm.js?0e3bd98236bd62558926fc433751d60c";
- // var s = document.getElementsByTagName("script")[0];
- // s.parentNode.insertBefore(hm, s);
- // })();
- router.beforeEach((to, from, next) => {
- // if (_hmt) {
- // if (to.path) {
- // _hmt.push(['_trackPageview', '/#' + to.fullPath]);
- // }
- // }
- const urls = getAuthUrls()
- if (storageGet('user') == null) {
- getCurrentUser().then((res) => {
- storageSave('user', res)
- storageSave('rolesPermissions', getRolesPermissions(res.roleList))
- if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
- if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
- next()
- } else {
- next({
- path: '/',
- query: {
- redirect: to.fullPath
- } // 将跳转的路由path作为参数,登录成功后跳转到该路由
- })
- }
- } else {
- next()
- }
- }).catch((error) => {
- // notify('warning', '请登录')
- if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
- if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
- next()
- } else {
- next({
- path: '/',
- query: {
- redirect: to.fullPath
- } // 将跳转的路由path作为参数,登录成功后跳转到该路由
- })
- }
- } else {
- next()
- }
- })
- } else {
- if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
- if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
- next()
- } else {
- next({
- path: '/',
- query: {
- redirect: to.fullPath
- } // 将跳转的路由path作为参数,登录成功后跳转到该路由
- })
- }
- } else {
- next()
- }
- }
- //console.log(to.matched[0].path)
- //console.log(urls.includes(to.matched[0].path))
- })
- // require('./mock.js')
- Vue.use(Carousel)
- Vue.use(CarouselItem)
- Vue.use(Row)
- Vue.use(Col)
- Vue.use(Table)
- Vue.use(TableColumn)
- Vue.use(Form)
- Vue.use(FormItem)
- Vue.use(Button)
- Vue.use(ButtonGroup)
- Vue.use(Menu)
- Vue.use(Submenu)
- Vue.use(MenuItem)
- Vue.use(MenuItemGroup)
- Vue.use(Input)
- Vue.use(InputNumber)
- Vue.use(Radio)
- Vue.use(RadioGroup)
- Vue.use(RadioButton)
- Vue.use(Checkbox)
- Vue.use(CheckboxButton)
- Vue.use(CheckboxGroup)
- Vue.use(DatePicker)
- Vue.use(TimeSelect)
- Vue.use(TimePicker)
- Vue.use(Switch)
- Vue.use(Select)
- Vue.use(Option)
- Vue.use(Upload)
- Vue.use(Tabs)
- Vue.use(TabPane)
- Vue.use(Collapse)
- Vue.use(CollapseItem)
- Vue.use(Dialog)
- Vue.use(Card)
- Vue.use(Tag)
- Vue.use(Avatar)
- Vue.use(Pagination)
- Vue.use(Link)
- Vue.use(Loading)
- Vue.use(Tooltip)
- Vue.use(Dropdown)
- Vue.use(DropdownItem)
- Vue.use(DropdownMenu)
- Vue.use(Image)
- Vue.use(Badge)
- Vue.use(Popover)
- Vue.use(Progress)
- Vue.use(Steps)
- Vue.use(Step)
- Vue.prototype.$msgbox = MessageBox
- Vue.prototype.$alert = MessageBox.alert
- Vue.prototype.$confirm = MessageBox.confirm
- Vue.prototype.$prompt = MessageBox.prompt
- Vue.prototype.$notify = Notification
- Vue.prototype.$message = Message
- Vue.config.productionTip = false
- /* eslint-disable no-new */
- new Vue({
- el: '#app',
- router,
- data:{
- Bus:new Vue()
- },
- components: {App},
- template: '<App/>',
- store
- })
|