Browse Source

新增文件,解决秘钥公钥前后台解密问题

master
刘力 3 years ago
parent
commit
d5ff104a30
  1. 92
      src/assets/styles/btn.scss
  2. 117
      src/assets/styles/eladmin.scss
  3. 78
      src/assets/styles/element-ui.scss
  4. 14
      src/assets/styles/index.scss
  5. 48
      src/assets/styles/transition.scss
  6. 1
      src/layout/index.js
  7. 10
      src/layout/mixin/ResizeHandler.js
  8. 11
      src/main.js
  9. 3
      src/router/index.js
  10. 30
      src/router/routers.js
  11. 6
      src/settings.js
  12. 56
      src/store/modules/app.js
  13. 36
      src/store/modules/settings.js
  14. 165
      src/store/modules/tagsView.js
  15. 93
      src/store/modules/user.js
  16. 22
      src/utils/rsaEncrypt.js
  17. 42
      src/views/login.vue
  18. 104
      vue.config.js

92
src/assets/styles/btn.scss

@ -0,0 +1,92 @@
@import 'variables';
@mixin colorBtn($color) {
background: $color;
&:hover {
color: $color;
&:before,
&:after {
background: $color;
}
}
}
.blue-btn {
@include colorBtn($blue)
}
.light-blue-btn {
@include colorBtn($light-blue)
}
.red-btn {
@include colorBtn($red)
}
.pink-btn {
@include colorBtn($pink)
}
.green-btn {
@include colorBtn($green)
}
.tiffany-btn {
@include colorBtn($tiffany)
}
.yellow-btn {
@include colorBtn($yellow)
}
.pan-btn {
font-size: 14px;
color: #fff;
padding: 14px 36px;
border-radius: 8px;
border: none;
outline: none;
transition: 600ms ease all;
position: relative;
display: inline-block;
&:hover {
background: #fff;
&:before,
&:after {
width: 100%;
transition: 600ms ease all;
}
}
&:before,
&:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 2px;
width: 0;
transition: 400ms ease all;
}
&::after {
right: inherit;
top: inherit;
left: 0;
bottom: 0;
}
}
.custom-button {
display: inline-block;
line-height: 1;
white-space: nowrap;
cursor: pointer;
background: #fff;
color: #fff;
-webkit-appearance: none;
text-align: center;
box-sizing: border-box;
outline: 0;
margin: 0;
padding: 10px 15px;
font-size: 14px;
border-radius: 4px;
}

117
src/assets/styles/eladmin.scss

@ -0,0 +1,117 @@
.head-container {
padding-bottom: 10px;
.filter-item {
display: inline-block;
vertical-align: middle;
margin: 0 3px 10px 0;
input {
height: 30.5px;
line-height: 30.5px;
}
}
.el-form-item-label {
margin: 0 3px 9px 0;
display: inline-block;
text-align: right;
vertical-align: middle;
font-size: 14px;
color: #606266;
line-height: 30.5px;
padding: 0 7px 0 7px;
}
.el-button+.el-button {
margin-left: 0 !important;
}
.el-select__caret.el-input__icon.el-icon-arrow-up{
line-height: 30.5px;
}
.date-item {
display: inline-block;
vertical-align: middle;
margin-bottom: 10px;
height: 30.5px !important;
width: 230px !important;
}
}
.el-avatar {
display: inline-block;
text-align: center;
background: #ccc;
color: #fff;
white-space: nowrap;
position: relative;
overflow: hidden;
vertical-align: middle;
width: 32px;
height: 32px;
line-height: 32px;
border-radius: 16px;
}
.logo-con{
height: 60px;
padding: 13px 0 0;
img{
height: 32px;
width: 135px;
display: block;
//margin: 0 auto;
}
}
#el-login-footer {
height: 40px;
line-height: 40px;
position: fixed;
bottom: 0;
width: 100%;
text-align: center;
color: #fff;
font-family: Arial, serif;
font-size: 12px;
letter-spacing: 1px;
}
#el-main-footer {
background: none repeat scroll 0 0 white;
border-top: 1px solid #e7eaec;
overflow: hidden;
padding: 10px 6px 0 6px;
height: 33px;
font-size: 0.7rem !important;
color: #7a8b9a;
letter-spacing: 0.8px;
font-family: Arial, sans-serif !important;
position: fixed;
bottom: 0;
z-index: 99;
width: 100%;
}
.eladmin-upload {
border: 1px dashed #c0ccda;
border-radius: 5px;
height: 45px;
line-height: 45px;
width: 368px;
}
.my-blockquote{
margin: 0 0 10px;
padding: 15px;
line-height: 22px;
border-left: 5px solid #00437B;
border-radius: 0 2px 2px 0;
background-color: #f2f2f2;
}
.my-code{
position: relative;
padding: 15px;
line-height: 20px;
border-left: 5px solid #ddd;
color: #333;
font-family: Courier New, serif;
font-size: 12px
}
.el-tabs{
margin-bottom: 25px;
}

78
src/assets/styles/element-ui.scss

@ -0,0 +1,78 @@
.el-breadcrumb__inner,
.el-breadcrumb__inner a {
font-weight: 400 !important;
}
.el-upload {
input[type="file"] {
display: none !important;
}
}
.el-upload__input {
display: none;
}
.cell {
.el-tag {
margin-right: 0;
}
}
.small-padding {
.cell {
padding-left: 5px;
padding-right: 5px;
}
}
.fixed-width {
.el-button--mini {
padding: 7px 10px;
width: 60px;
}
}
.status-col {
.cell {
padding: 0 10px;
text-align: center;
.el-tag {
margin-right: 0;
}
}
}
.el-dialog {
transform: none;
left: 0;
position: relative;
margin: 0 auto;
}
// refine element ui upload
.upload-container {
.el-upload {
width: 100%;
.el-upload-dragger {
width: 100%;
height: 200px;
}
}
}
// dropdown
.el-dropdown-menu {
a {
display: block
}
}
// fix date-picker ui bug in filter-item
.el-range-editor.el-input__inner {
display: inline-flex !important;
}

14
src/assets/styles/index.scss

@ -1,6 +1,6 @@
@import 'variables'; @import 'variables';
@import 'mixin'; @import 'mixin';
//@import 'transition';
@import 'transition';
@import 'element-ui'; @import 'element-ui';
@import 'sidebar'; @import 'sidebar';
@import 'btn'; @import 'btn';
@ -148,13 +148,11 @@ aside {
text-align: right; text-align: right;
padding-right: 20px; padding-right: 20px;
transition: 600ms ease position; transition: 600ms ease position;
background: linear-gradient(
90deg,
rgba(32, 182, 249, 1) 0%,
rgba(32, 182, 249, 1) 0%,
rgba(33, 120, 241, 1) 100%,
rgba(33, 120, 241, 1) 100%
);
background: linear-gradient(90deg,
rgba(32, 182, 249, 1) 0%,
rgba(32, 182, 249, 1) 0%,
rgba(33, 120, 241, 1) 100%,
rgba(33, 120, 241, 1) 100%);
.subtitle { .subtitle {
font-size: 20px; font-size: 20px;

48
src/assets/styles/transition.scss

@ -0,0 +1,48 @@
/* fade */
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.28s;
}
.fade-enter,
.fade-leave-active {
opacity: 0;
}
/* fade-transform */
.fade-transform-leave-active,
.fade-transform-enter-active {
transition: all .5s;
}
.fade-transform-enter {
opacity: 0;
transform: translateX(-30px);
}
.fade-transform-leave-to {
opacity: 0;
transform: translateX(30px);
}
/* breadcrumb transition */
.breadcrumb-enter-active,
.breadcrumb-leave-active {
transition: all .5s;
}
.breadcrumb-enter,
.breadcrumb-leave-active {
opacity: 0;
transform: translateX(20px);
}
.breadcrumb-move {
transition: all .5s;
}
.breadcrumb-leave-active {
position: absolute;
}

1
src/layout/index.js

@ -0,0 +1 @@
export { default as TopMenus } from './TopMenus.vue'

10
src/layout/mixin/ResizeHandler.js

@ -1,9 +1,9 @@
import store from '@/store'
import store from '@/store'
const { body} =document
const WIDTH=992
const { body } = document
const WIDTH = 992
export default {
export default {
watch: { watch: {
$route(route) { $route(route) {
if (this.device === 'mobile' && this.sidebar.opened) { if (this.device === 'mobile' && this.sidebar.opened) {
@ -41,4 +41,4 @@
} }
} }
} }
}
}

11
src/main.js

@ -18,24 +18,25 @@ import permission from './components/Permission'
import './assets/styles/element-variables.scss' import './assets/styles/element-variables.scss'
// 全局CSS // 全局CSS
// import './assets/styles/index.scss'
import './assets/styles/index.scss'
// 代码高亮 // 代码高亮
import VueHighlightJS from 'vue-highlightjs' import VueHighlightJS from 'vue-highlightjs'
import 'highlight.js/styles/atom-one-dark.css' import 'highlight.js/styles/atom-one-dark.css'
// icon // icon
// import './assets/icons'
import './assets/icons'
// 加载代码高亮 // 加载代码高亮
Vue.use(VueHighlightJS) Vue.use(VueHighlightJS)
// 加载权限指令
Vue.use(checkPer)
Vue.use(permission)
// 加载elementui // 加载elementui
Vue.use(ElementUI, { Vue.use(ElementUI, {
// 设置element-ui默认大小 // 设置element-ui默认大小
size: Cookies.get('size') || 'small' size: Cookies.get('size') || 'small'
}) })
// 加载权限指令
Vue.use(checkPer)
Vue.use(permission)
Vue.config.productionTip = false Vue.config.productionTip = false
new Vue({ new Vue({

3
src/router/index.js

@ -63,7 +63,8 @@ router.beforeEach((to, from, next) => {
next() next()
} else { } else {
// 否则全部重定向到登录页面 // 否则全部重定向到登录页面
next(`/loginredirect=${to.fullPath}`)
// next(`/loginredirect=${to.fullPath}`)
next()
NProgress.done() NProgress.done()
} }
} }

30
src/router/routers.js

@ -6,22 +6,32 @@ Vue.use(Router)
export const constantRouterMap = [ export const constantRouterMap = [
{ {
path: '/login',
path: '/',
meta: { title: '登录', noCache: true }, meta: { title: '登录', noCache: true },
component: (resolve) => require(['@/views/login'], resolve), component: (resolve) => require(['@/views/login'], resolve),
hidden: true hidden: true
}, },
{ {
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path*',
component: (resolve) => require(['@/views/features/redirect'], resolve)
}
]
path: '/404',
component: (resolve) => require(['@/views/features/404'], resolve),
hidden: true
},
{
path: '/401',
component: (resolve) => require(['@/views/features/401'], resolve),
hidden: true
} }
// {
// path: '/redirect',
// component: Layout,
// hidden: true,
// children: [
// {
// path: '/redirect/:path*',
// component: (resolve) => require(['@/views/features/redirect'], resolve)
// }
// ]
// }
] ]

6
src/settings.js

@ -19,6 +19,8 @@ module.exports = {
showFooter: true, showFooter: true,
// 底部文字,支持html语法 // 底部文字,支持html语法
footerTxt:
'© 2021 <a href="https://www.aixylib.com" target="_blank">阅行后台集成管理系统</a>'
footerTxt: '© 2021 <a href="https://www.aixylib.com" target="_blank">阅行后台集成管理系统</a>',
// 备案号
caseNumber: '鄂ICP备XXXX号'
} }

56
src/store/modules/app.js

@ -0,0 +1,56 @@
import Cookies from 'js-cookie'
const state = {
sidebar: {
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
withoutAnimation: false
},
device: 'desktop',
size: Cookies.get('size') || 'small'
}
const mutations = {
TOGGLE_SIDEBAR: state => {
state.sidebar.opened = !state.sidebar.opened
state.sidebar.withoutAnimation = false
if (state.sidebar.opened) {
Cookies.set('sidebarStatus', 1)
} else {
Cookies.set('sidebarStatus', 0)
}
},
CLOSE_SIDEBAR: (state, withoutAnimation) => {
Cookies.set('sidebarStatus', 0)
state.sidebar.opened = false
state.sidebar.withoutAnimation = withoutAnimation
},
TOGGLE_DEVICE: (state, device) => {
state.device = device
},
SET_SIZE: (state, size) => {
state.size = size
Cookies.set('size', size)
}
}
const actions = {
toggleSideBar({ commit }) {
commit('TOGGLE_SIDEBAR')
},
closeSideBar({ commit }, { withoutAnimation }) {
commit('CLOSE_SIDEBAR', withoutAnimation)
},
toggleDevice({ commit }, device) {
commit('TOGGLE_DEVICE', device)
},
setSize({ commit }, size) {
commit('SET_SIZE', size)
}
}
export default {
namespaced: true,
state,
mutations,
actions
}

36
src/store/modules/settings.js

@ -0,0 +1,36 @@
import variables from '@/assets/styles/element-variables.scss'
import defaultSettings from '@/settings'
const { tagsView, fixedHeader, sidebarLogo, uniqueOpened, showFooter, footerTxt, caseNumber } = defaultSettings
const state = {
theme: variables.theme,
showSettings: tagsView,
fixedHeader: fixedHeader,
sidebarLogo: sidebarLogo,
uniqueOpened: uniqueOpened,
showFooter: showFooter,
footerTxt: footerTxt,
caseNumber: caseNumber
}
const mutations = {
CHANGE_SETTING: (state, { key, value }) => {
if (state.hasOwnProperty(key)) {
state[key] = value
}
}
}
const actions = {
changeSetting({ commit }, data) {
commit('CHANGE_SETTING', data)
}
}
export default {
namespaced: true,
state,
mutations,
actions
}

165
src/store/modules/tagsView.js

@ -0,0 +1,165 @@
const state = {
visitedViews: [],
cachedViews: []
}
const mutations = {
ADD_VISITED_VIEW: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return
state.visitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
},
ADD_CACHED_VIEW: (state, view) => {
if (state.cachedViews.includes(view.name)) return
if (!view.meta.noCache) {
state.cachedViews.push(view.name)
}
},
DEL_VISITED_VIEW: (state, view) => {
for (const [i, v] of state.visitedViews.entries()) {
if (v.path === view.path) {
state.visitedViews.splice(i, 1)
break
}
}
},
DEL_CACHED_VIEW: (state, view) => {
for (const i of state.cachedViews) {
if (i === view.name) {
const index = state.cachedViews.indexOf(i)
state.cachedViews.splice(index, 1)
break
}
}
},
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
state.visitedViews = state.visitedViews.filter(v => {
return v.meta.affix || v.path === view.path
})
},
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
for (const i of state.cachedViews) {
if (i === view.name) {
const index = state.cachedViews.indexOf(i)
state.cachedViews = state.cachedViews.slice(index, index + 1)
break
}
}
},
DEL_ALL_VISITED_VIEWS: state => {
// keep affix tags
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
state.visitedViews = affixTags
},
DEL_ALL_CACHED_VIEWS: state => {
state.cachedViews = []
},
UPDATE_VISITED_VIEW: (state, view) => {
for (let v of state.visitedViews) {
if (v.path === view.path) {
v = Object.assign(v, view)
break
}
}
}
}
const actions = {
addView({ dispatch }, view) {
dispatch('addVisitedView', view)
dispatch('addCachedView', view)
},
addVisitedView({ commit }, view) {
commit('ADD_VISITED_VIEW', view)
},
addCachedView({ commit }, view) {
commit('ADD_CACHED_VIEW', view)
},
delView({ dispatch, state }, view) {
return new Promise(resolve => {
dispatch('delVisitedView', view)
dispatch('delCachedView', view)
resolve({
visitedViews: [...state.visitedViews],
cachedViews: [...state.cachedViews]
})
})
},
delVisitedView({ commit, state }, view) {
return new Promise(resolve => {
commit('DEL_VISITED_VIEW', view)
resolve([...state.visitedViews])
})
},
delCachedView({ commit, state }, view) {
return new Promise(resolve => {
commit('DEL_CACHED_VIEW', view)
resolve([...state.cachedViews])
})
},
delOthersViews({ dispatch, state }, view) {
return new Promise(resolve => {
dispatch('delOthersVisitedViews', view)
dispatch('delOthersCachedViews', view)
resolve({
visitedViews: [...state.visitedViews],
cachedViews: [...state.cachedViews]
})
})
},
delOthersVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('DEL_OTHERS_VISITED_VIEWS', view)
resolve([...state.visitedViews])
})
},
delOthersCachedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('DEL_OTHERS_CACHED_VIEWS', view)
resolve([...state.cachedViews])
})
},
delAllViews({ dispatch, state }, view) {
return new Promise(resolve => {
dispatch('delAllVisitedViews', view)
dispatch('delAllCachedViews', view)
resolve({
visitedViews: [...state.visitedViews],
cachedViews: [...state.cachedViews]
})
})
},
delAllVisitedViews({ commit, state }) {
return new Promise(resolve => {
commit('DEL_ALL_VISITED_VIEWS')
resolve([...state.visitedViews])
})
},
delAllCachedViews({ commit, state }) {
return new Promise(resolve => {
commit('DEL_ALL_CACHED_VIEWS')
resolve([...state.cachedViews])
})
},
updateVisitedView({ commit }, view) {
commit('UPDATE_VISITED_VIEW', view)
}
}
export default {
namespaced: true,
state,
mutations,
actions
}

93
src/store/modules/user.js

@ -0,0 +1,93 @@
import { login, getInfo, logout } from '@/api/login'
import { getToken, setToken, removeToken } from '@/utils/auth'
const user = {
state: {
token: getToken(),
user: {},
roles: [],
// 第一次加载菜单时用到
loadMenus: false
},
mutations: {
SET_TOKEN: (state, token) => {
state.token = token
},
SET_USER: (state, user) => {
state.user = user
},
SET_ROLES: (state, roles) => {
state.roles = roles
},
SET_LOAD_MENUS: (state, loadMenus) => {
state.loadMenus = loadMenus
}
},
actions: {
// 登录
Login({ commit }, userInfo) {
const rememberMe = userInfo.rememberMe
return new Promise((resolve, reject) => {
login(userInfo.username, userInfo.password, userInfo.code, userInfo.uuid).then(res => {
setToken(res.token, rememberMe)
commit('SET_TOKEN', res.token)
setUserInfo(res.user, commit)
// 第一次加载菜单时用到, 具体见 src 目录下的 permission.js
commit('SET_LOAD_MENUS', true)
resolve()
}).catch(error => {
reject(error)
})
})
},
// 获取用户信息
getInfo({ commit }) {
return new Promise((resolve, reject) => {
getInfo().then(res => {
setUserInfo(res, commit)
resolve(res)
}).catch(error => {
reject(error)
})
})
},
// 登出
LogOut({ commit }) {
return new Promise((resolve, reject) => {
logout().then(res => {
logOut(commit)
resolve()
}).catch(error => {
logOut(commit)
reject(error)
})
})
},
updateLoadMenus({ commit }) {
return new Promise((resolve, reject) => {
commit('SET_LOAD_MENUS', false)
})
}
}
}
export const logOut = (commit) => {
commit('SET_TOKEN', '')
commit('SET_ROLES', [])
removeToken()
}
export const setUserInfo = (res, commit) => {
if (res.roles.length === 0) {
commit('SET_ROLES', ['ROLE_SYSTEM_DEFAULT'])
} else {
commit('SET_ROLES', res.roles)
}
commit('SET_USER', res.user)
}
export default user

22
src/utils/rsaEncrypt.js

@ -2,18 +2,18 @@ import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
// 密钥对生成:http://web.chacuo.net/netrsakeypair // 密钥对生成:http://web.chacuo.net/netrsakeypair
// 设置公钥 // 设置公钥
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMEOuFWzyferOY27HOOKkeNCexTXunvK\n' +
'Bk62mavgNn6G6r9PB4gT71YdXkk/3JmnrUue3L/MPOIpAD5ZadAXdBcCAwEAAQ=='
// 设置私钥
const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAwQ64VbPJ96s5jbsc\n' +
'44qR40J7FNe6e8oGTraZq+A2fobqv08HiBPvVh1eST/cmaetS57cv8w84ikAPllp\n' +
'0Bd0FwIDAQABAkBf3tB5dsPoIvZ8xJuu/2Q9KAl5KzwnNwb01cbwTHKjV7yORPaL\n' +
'Y6rlCmIae8GCkvJMtaJRiLbViM14U2jIKEgxAiEA9jIJm34V4nGlqg3M3EZjnn/B\n' +
'nDUrIp/FRsG4yEbDMukCIQDIvvDrMM9Ay3mbQjUOayjFguA5qlA8o8oj58WJnocO\n' +
'/wIgetNL579nu6lnNQfdhKe5W4HxXbVI5+U9zqcnQQPMrsECIQDDMte0+jstOC3B\n' +
'SLmqkYyNsdsyd2eZ73IpQ7+TN/EAJQIgWmJh6+b5sw4Q/Emb9ypPAE3peP09QmhP\n' +
'ZnAyYEuUiNY='
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
'2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='
const privateKey = 'MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8\n' +
'mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9p\n' +
'B6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue\n' +
'/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZ\n' +
'UBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6\n' +
'vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha\n' +
'4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3\n' +
'tTbklZkD2A=='
// 输入加密 // 输入加密
export function encrypt(txt) { export function encrypt(txt) {

42
src/views/login.vue

@ -1,7 +1,9 @@
<template> <template>
<div class="login" :style="'background-image:url(' + Background + ');'">
<div class="login" :style="'background-image:url('+ Background +');'">
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-position="left" label-width="0px" class="login-form"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" label-position="left" label-width="0px" class="login-form">
<h3 class="title">阅行集成后台管理</h3>
<h3 class="title">
阅行客后台管理系统
</h3>
<el-form-item prop="username"> <el-form-item prop="username">
<el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号"> <el-input v-model="loginForm.username" type="text" auto-complete="off" placeholder="账号">
<svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" /> <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
@ -31,35 +33,27 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 底部 --> <!-- 底部 -->
<!-- <div v-if="$store.state.settings.showFooter" id="el-login-footer">
<div v-if="$store.state.settings.showFooter" id="el-login-footer">
<span v-html="$store.state.settings.footerTxt" /> <span v-html="$store.state.settings.footerTxt" />
<span> </span> <span> </span>
<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">{{
$store.state.settings.caseNumber
}}</a>
</div> -->
<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">{{ $store.state.settings.caseNumber }}</a>
</div>
</div> </div>
</template> </template>
<script> <script>
import { encrypt } from '@/utils/rsaEncrypt' import { encrypt } from '@/utils/rsaEncrypt'
import Config from '@/settings' import Config from '@/settings'
import { getCodeImg } from '@/api/login'
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import Background from '@/assets/images/background.jpg' import Background from '@/assets/images/background.jpg'
import { getCodeImg } from '@/api/login'
export default { export default {
//
name: 'Login', name: 'Login',
data() { data() {
return { return {
//
Background: Background, Background: Background,
//
codeUrl: '', codeUrl: '',
//
cookiePass: '', cookiePass: '',
// --
loginForm: { loginForm: {
username: 'admin', username: 'admin',
password: '123456', password: '123456',
@ -67,7 +61,6 @@ export default {
code: '', code: '',
uuid: '' uuid: ''
}, },
//
loginRules: { loginRules: {
username: [ username: [
{ required: true, trigger: 'blur', message: '用户名不能为空' } { required: true, trigger: 'blur', message: '用户名不能为空' }
@ -77,40 +70,33 @@ export default {
], ],
code: [{ required: true, trigger: 'change', message: '验证码不能为空' }] code: [{ required: true, trigger: 'change', message: '验证码不能为空' }]
}, },
//
loading: false, loading: false,
//
redirect: undefined redirect: undefined
} }
}, },
watch: { watch: {
//
$route: { $route: {
handler: function(route) { handler: function(route) {
this.redirect = route.query && route.query.redirect this.redirect = route.query && route.query.redirect
}, },
// handler
immediate: true immediate: true
} }
}, },
// 使
created() { created() {
// //
this.getCode() this.getCode()
// Cookie
// Cookie
this.getCookie() this.getCookie()
// token
// token
this.point() this.point()
}, },
methods: { methods: {
//
getCode() { getCode() {
getCodeImg().then(res => { getCodeImg().then(res => {
this.codeUrl = res.img this.codeUrl = res.img
this.loginForm.uuid = res.uuid this.loginForm.uuid = res.uuid
}) })
}, },
// Cookie
getCookie() { getCookie() {
const username = Cookies.get('username') const username = Cookies.get('username')
let password = Cookies.get('password') let password = Cookies.get('password')
@ -127,7 +113,6 @@ export default {
}, },
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
//
const user = { const user = {
username: this.loginForm.username, username: this.loginForm.username,
password: this.loginForm.password, password: this.loginForm.password,
@ -135,9 +120,7 @@ export default {
code: this.loginForm.code, code: this.loginForm.code,
uuid: this.loginForm.uuid uuid: this.loginForm.uuid
} }
// cookie
if (user.password !== this.cookiePass) { if (user.password !== this.cookiePass) {
//
user.password = encrypt(user.password) user.password = encrypt(user.password)
} }
if (valid) { if (valid) {
@ -157,15 +140,16 @@ export default {
Cookies.remove('password') Cookies.remove('password')
Cookies.remove('rememberMe') Cookies.remove('rememberMe')
} }
this.$store.dispatch('Login', user).then(() => { this.$store.dispatch('Login', user).then(() => {
this.loading = false this.loading = false
this.$router.push({ path: this.redirect || '/' })
this.$router.push({ path: this.redirect || '/layout/TopMenus' })
}).catch(() => { }).catch(() => {
this.loading = false this.loading = false
this.getCode() this.getCode()
}) })
} else { } else {
console.log('提交错误!!')
console.log('error submit!!')
return false return false
} }
}) })

104
vue.config.js

@ -1,21 +1,21 @@
"use strict";
const path = require("path");
const defaultSettings = require("./src/settings.js");
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir);
return path.join(__dirname, dir)
} }
const name = defaultSettings.title; // 网址标题
const port = 8013; // 端口配置
const name = defaultSettings.title // 网址标题
const port = 8013 // 端口配置
module.exports = { module.exports = {
// hash 模式下可使用 // hash 模式下可使用
// publicPath: process.env.NODE_ENV === 'development' ? '/' : './', // publicPath: process.env.NODE_ENV === 'development' ? '/' : './',
publicPath: "/",
outputDir: "dist",
assetsDir: "static",
lintOnSave: process.env.NODE_ENV === "development",
publicPath: '/',
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false, productionSourceMap: false,
devServer: { devServer: {
port: port, port: port,
@ -25,18 +25,18 @@ module.exports = {
errors: true errors: true
}, },
proxy: { proxy: {
"/api": {
'/api': {
target: process.env.VUE_APP_BASE_API, target: process.env.VUE_APP_BASE_API,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
"^/api": "api"
'^/api': 'api'
} }
}, },
"/auth": {
'/auth': {
target: process.env.VUE_APP_BASE_API, target: process.env.VUE_APP_BASE_API,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
"^/auth": "auth"
'^/auth': 'auth'
} }
} }
} }
@ -45,82 +45,82 @@ module.exports = {
name: name, name: name,
resolve: { resolve: {
alias: { alias: {
"@": resolve("src"),
"@crud": resolve("src/components/Crud")
'@': resolve('src'),
'@crud': resolve('src/components/Crud')
} }
} }
}, },
chainWebpack(config) { chainWebpack(config) {
config.plugins.delete("preload"); // TODO: need test
config.plugins.delete("prefetch"); // TODO: need test
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// set svg-sprite-loader // set svg-sprite-loader
config.module config.module
.rule("svg")
.exclude.add(resolve("src/assets/icons"))
.end();
.rule('svg')
.exclude.add(resolve('src/assets/icons'))
.end()
config.module config.module
.rule("icons")
.rule('icons')
.test(/\.svg$/) .test(/\.svg$/)
.include.add(resolve("src/assets/icons"))
.include.add(resolve('src/assets/icons'))
.end() .end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({ .options({
symbolId: "icon-[name]"
symbolId: 'icon-[name]'
}) })
.end();
.end()
// set preserveWhitespace // set preserveWhitespace
config.module config.module
.rule("vue")
.use("vue-loader")
.loader("vue-loader")
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => { .tap(options => {
options.compilerOptions.preserveWhitespace = true;
return options;
options.compilerOptions.preserveWhitespace = true
return options
}) })
.end();
.end()
config.when(process.env.NODE_ENV === "development", config =>
config.devtool("cheap-source-map")
);
config.when(process.env.NODE_ENV === 'development', config =>
config.devtool('cheap-source-map')
)
config.when(process.env.NODE_ENV !== "development", config => {
config.when(process.env.NODE_ENV !== 'development', config => {
config config
.plugin("ScriptExtHtmlWebpackPlugin")
.after("html")
.use("script-ext-html-webpack-plugin", [
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [
{ {
inline: /runtime\..*\.js$/ inline: /runtime\..*\.js$/
} }
]) ])
.end();
.end()
config.optimization.splitChunks({ config.optimization.splitChunks({
chunks: "all",
chunks: 'all',
cacheGroups: { cacheGroups: {
libs: { libs: {
name: "chunk-libs",
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/, test: /[\\/]node_modules[\\/]/,
priority: 10, priority: 10,
chunks: "initial"
chunks: 'initial'
}, },
elementUI: { elementUI: {
name: "chunk-elementUI",
name: 'chunk-elementUI',
priority: 20, priority: 20,
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ test: /[\\/]node_modules[\\/]_?element-ui(.*)/
}, },
commons: { commons: {
name: "chunk-commons",
test: resolve("src/components"),
name: 'chunk-commons',
test: resolve('src/components'),
minChunks: 3, minChunks: 3,
priority: 5, priority: 5,
reuseExistingChunk: true reuseExistingChunk: true
} }
} }
});
config.optimization.runtimeChunk("single");
});
})
config.optimization.runtimeChunk('single')
})
}, },
transpileDependencies: ["vue-echarts", "resize-detector"]
};
transpileDependencies: ['vue-echarts', 'resize-detector']
}
Loading…
Cancel
Save