import Vue from 'vue' import iView from 'iview' import lodash from 'lodash' import VueLodash from 'vue-lodash' import Router from 'vue-router' import { routers, menuList, setMenuTree } from './routers'; import 'iview/dist/styles/iview.css' Vue.use(Router); Vue.use(iView); Vue.use(VueLodash, lodash); export const router = new Router({ routes: routers.router }) export let getMenuFuc = function (list) { setMenuTree(list) } if (sessionStorage.getItem("role")) { getMenuFuc(JSON.parse(sessionStorage.getItem("menuTree"))) } router.beforeEach((to, from, next) => { if (!sessionStorage.getItem("role") && to.name !== 'login') { next('/login') } else { next() } })
login.vue
<template> <div> <div @keydown.enter="handleSubmit"> <div> <p>江苏消防数据资源管理服务平台</p> <div></div> <div> <div> <Form ref="loginForm" :model="form" :rules="rules"> <div> <FormItem prop="account"> <Icon :size="20" type="person"></Icon> <input v-model="form.account" type="text" placeholder="用户名"> </FormItem> </div> <div> <FormItem prop="password" v-show="hidePass"> <Icon :size="16" type="locked"></Icon> <div @click="showPwd"><Icon :size="22" type="eye-disabled"></Icon></div> <input v-model="form.password" type="password" data-type="password" placeholder="密码"> </FormItem> <FormItem prop="password" v-show="showPass"> <Icon :size="16" type="locked"></Icon> <div @click="hidePwd"><Icon :size="22" type="eye"></Icon></div> <input v-model="form.password" type="text" data-type="text" placeholder="密码"> </FormItem> </div> <div> <!--<FormItem prop="code">--> <FormItem prop="code"> <Icon :size="18" type="android-checkmark-circle"></Icon> <input v-model="form.code" type="text" data-type="text" placeholder="验证码" maxlength="4"> <img alt="验证码" :src="cfg.api.obtain" @click="changeImg"/> </FormItem> </div> <!--<div> <input type="checkbox" checked> <label for="check"><span></span> 记住密码</label> <a href="#forgot">忘记密码?</a> </div>--> <Alert type="error" v-show="error"> <span>{{errorMessage}}</span> </Alert> <div> <input type="button" value="登录" @click="handleSubmit"> </div> </Form> </div> </div> <div span="8" v-show="spinShow"> <Spin fix> <Icon type="load-c" size=50></Icon> <div>登录中,请稍后...</div> </Spin> </div> </div> </div> </div> </template> <style> @import "./login.css"; </style> <script src="https://www.jb51.net/article/loginJs.js"></script>
login.css