123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- // 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} from '@/js/index'
- import {
- Avatar,
- Button,
- ButtonGroup,
- Card,
- Carousel,
- CarouselItem,
- Checkbox,
- CheckboxButton,
- CheckboxGroup,
- Col,
- Collapse,
- CollapseItem,
- DatePicker,
- Dialog,
- Form,
- FormItem,
- Input,
- InputNumber,
- Menu,
- MenuItem,
- MenuItemGroup,
- Message,
- MessageBox,
- Notification,
- Option,
- Radio,
- RadioButton,
- RadioGroup,
- Row,
- Select,
- Submenu,
- Switch,
- Table,
- TableColumn,
- TabPane,
- Tabs,
- Tag,
- TimePicker,
- TimeSelect,
- Upload,
- } from 'element-ui'
- router.beforeEach((to, from, next) => {
- const urls = getAuthUrls()
- //console.log(to.matched[0].path)
- //console.log(urls.includes(to.matched[0].path))
- if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
- //console.log('需要登录')
- if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
- //console.log('未拦截')
- next()
- } else {
- //console.log('拦截')
- next({
- path: '/',
- query: {
- redirect: to.fullPath
- } // 将跳转的路由path作为参数,登录成功后跳转到该路由
- })
- }
- } else {
- //console.log('不需要登录')
- next()
- }
- })
- // 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.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,
- components: {App},
- template: '<App/>'
- })
|