diff --git a/README.md b/README.md index 22e9caf..41782b2 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,10 @@ npm run dev # 构建生产环境 npm run build -``` \ No newline at end of file +``` + +#### 反馈交流 + +- QQ交流群:Quella/el-admin + +- 作者邮箱:elunez@qq.com \ No newline at end of file diff --git a/src/api/alipay.js b/src/api/alipay.js new file mode 100644 index 0000000..54090f5 --- /dev/null +++ b/src/api/alipay.js @@ -0,0 +1,25 @@ +import request from '@/utils/request' + +export function get() { + return request({ + url: 'api/aliPay', + method: 'get' + }) +} + +export function update(data) { + return request({ + url: 'api/aliPay', + data, + method: 'put' + }) +} + +// 支付 +export function toAliPay(url, data) { + return request({ + url: 'api/' + url, + data, + method: 'post' + }) +} diff --git a/src/api/code.js b/src/api/code.js new file mode 100644 index 0000000..b410f48 --- /dev/null +++ b/src/api/code.js @@ -0,0 +1,16 @@ +import request from '@/utils/request' + +export function resetEmail(data) { + return request({ + url: 'api/code/resetEmail', + method: 'post', + data + }) +} + +export function updatePass(pass) { + return request({ + url: 'api/users/updatePass/' + pass, + method: 'get' + }) +} diff --git a/src/api/picture.js b/src/api/picture.js index c2d5ea2..2cc5f78 100644 --- a/src/api/picture.js +++ b/src/api/picture.js @@ -1,13 +1,5 @@ import request from '@/utils/request' -export function uoload(data) { - return request({ - url: 'api/pictures', - method: 'post', - data - }) -} - export function del(id) { return request({ url: 'api/pictures/' + id, diff --git a/src/api/qiniu.js b/src/api/qiniu.js new file mode 100644 index 0000000..299ee97 --- /dev/null +++ b/src/api/qiniu.js @@ -0,0 +1,37 @@ +import request from '@/utils/request' + +export function get() { + return request({ + url: 'api/qiNiuConfig', + method: 'get' + }) +} + +export function update(data) { + return request({ + url: 'api/qiNiuConfig', + data, + method: 'put' + }) +} + +export function del(id) { + return request({ + url: 'api/qiNiuContent/' + id, + method: 'delete' + }) +} + +export function download(id) { + return request({ + url: 'api/qiNiuContent/download/' + id, + method: 'get' + }) +} + +export function sync() { + return request({ + url: 'api/qiNiuContent/synchronize', + method: 'post' + }) +} diff --git a/src/api/user.js b/src/api/user.js index c61b0db..f053957 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -22,3 +22,26 @@ export function edit(data) { data }) } + +export function validPass(pass) { + return request({ + url: 'api/users/validPass/' + pass, + method: 'get' + }) +} + +export function updatePass(pass) { + return request({ + url: 'api/users/updatePass/' + pass, + method: 'get' + }) +} + +export function updateEmail(code, data) { + return request({ + url: 'api/users/updateEmail/' + code, + method: 'post', + data + }) +} + diff --git a/src/icons/svg/alipay.svg b/src/icons/svg/alipay.svg new file mode 100644 index 0000000..c976aa1 --- /dev/null +++ b/src/icons/svg/alipay.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/qiniu.svg b/src/icons/svg/qiniu.svg new file mode 100644 index 0000000..dc30724 --- /dev/null +++ b/src/icons/svg/qiniu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/permission.js b/src/permission.js index ced7a36..e21e167 100644 --- a/src/permission.js +++ b/src/permission.js @@ -20,8 +20,8 @@ function hasPermission(roles, permissionRoles) { router.beforeEach((to, from, next) => { NProgress.start() // start progress bar - if (getToken()) { // determine if there has token - /* has token*/ + if (getToken()) { + // 已登录且要跳转的页面是登录页 if (to.path === '/login') { next({ path: '/' }) NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it diff --git a/src/router/index.js b/src/router/index.js index 37f70e8..1061ed6 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -46,6 +46,20 @@ export const constantRouterMap = [ meta: { title: '首页', icon: 'index', noCache: true } } ] + }, + { + path: '/user', + component: Layout, + hidden: true, + redirect: 'noredirect', + children: [ + { + path: 'center', + component: () => import('@/views/system/user/center'), + name: '个人中心', + meta: { title: '个人中心', icon: 'user' } + } + ] } // { path: '*', redirect: '/404', hidden: true } ] diff --git a/src/store/getters.js b/src/store/getters.js index f508975..42ed41b 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -6,10 +6,14 @@ const getters = { visitedViews: state => state.tagsView.visitedViews, cachedViews: state => state.tagsView.cachedViews, name: state => state.user.name, + createTime: state => state.user.createTime, + email: state => state.user.email, roles: state => state.user.roles, permission_routers: state => state.permission.routers, addRouters: state => state.permission.addRouters, socketApi: state => state.api.socketApi, - imagesUploadApi: state => state.api.imagesUploadApi + imagesUploadApi: state => state.api.imagesUploadApi, + updateAvatarApi: state => state.api.updateAvatarApi, + qiNiuUploadApi: state => state.api.qiNiuUploadApi } export default getters diff --git a/src/store/modules/api.js b/src/store/modules/api.js index 044fd6c..a6a7c84 100644 --- a/src/store/modules/api.js +++ b/src/store/modules/api.js @@ -1,8 +1,14 @@ const baseUrl = process.env.BASE_API const api = { state: { + // 实时控制台 socketApi: baseUrl + '/websocket?token=kl', - imagesUploadApi: baseUrl + '/api/pictures' + // 图片上传 + imagesUploadApi: baseUrl + '/api/pictures', + // 修改头像 + updateAvatarApi: baseUrl + '/api/users/updateAvatar', + // 上传文件到七牛云 + qiNiuUploadApi: baseUrl + '/api/qiNiuContent' } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 35c48f7..2601ef2 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,11 +1,14 @@ import { login, getInfo } from '@/api/login' import { getToken, setToken, removeToken } from '@/utils/auth' +import { parseTime } from '@/utils/index' const user = { state: { token: getToken(), name: '', + email: '', avatar: '', + createTime: '', roles: [] }, @@ -21,6 +24,12 @@ const user = { }, SET_ROLES: (state, roles) => { state.roles = roles + }, + SET_CREATE_TIME: (state, createTime) => { + state.createTime = createTime + }, + SET_EMAIL: (state, email) => { + state.email = email } }, @@ -46,6 +55,8 @@ const user = { commit('SET_ROLES', res.roles) commit('SET_NAME', res.username) commit('SET_AVATAR', res.avatar) + commit('SET_EMAIL', res.email) + commit('SET_CREATE_TIME', parseTime(res.createTime)) resolve(res) }).catch(error => { reject(error) diff --git a/src/utils/index.js b/src/utils/index.js index a6600ae..a8f8124 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -15,7 +15,7 @@ export function parseTime(time) { var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() // 拼接 - return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds + return year + '年' + month + '月' + day + '日 ' + hours + ':' + minutes + ':' + seconds } else { return '' } @@ -93,3 +93,26 @@ export function debounce(func, wait, immediate) { export function isExternal(path) { return /^(https?:|mailto:|tel:)/.test(path) } + +// 替换邮箱字符 +export function regEmail(email) { + if (String(email).indexOf('@') > 0) { + const str = email.split('@') + let _s = '' + if (str[0].length > 3) { + for (var i = 0; i < str[0].length - 3; i++) { + _s += '*' + } + } + var new_email = str[0].substr(0, 3) + _s + '@' + str[1] + } + return new_email +} + +// 替换手机字符 +export function regMobile(mobile) { + if (mobile.length > 7) { + var new_mobile = mobile.substr(0, 3) + '****' + mobile.substr(7) + } + return new_mobile +} diff --git a/src/utils/request.js b/src/utils/request.js index 6052039..3a85607 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,4 +1,5 @@ import axios from 'axios' +import router from '@/router' import { Notification, MessageBox } from 'element-ui' import store from '../store' import { getToken } from '@/utils/auth' @@ -51,9 +52,9 @@ service.interceptors.response.use( return Promise.reject(error) } } - if (code === 403 || code === 401) { + if (code === 401) { MessageBox.confirm( - 'Token 无效或已经过期,你可以取消继续留在该页面,或者重新登录', + '登录状态已失效,你可以取消继续留在该页面,或者重新登录', '提示', { confirmButtonText: '重新登录', @@ -65,6 +66,8 @@ service.interceptors.response.use( location.reload() // 为了重新实例化vue-router对象 避免bug }) }) + } else if (code === 403) { + router.push({ path: '/401' }) } else { const errorMsg = error.response.data.message if (errorMsg !== undefined) { diff --git a/src/views/errorPage/401.vue b/src/views/errorPage/401.vue index 2442012..5e2244c 100644 --- a/src/views/errorPage/401.vue +++ b/src/views/errorPage/401.vue @@ -1,10 +1,9 @@