修改基础配置

1.0.0
黄崇栋 6 years ago
parent 3d2c2804f2
commit e0f252431e

@ -1,4 +1,4 @@
[*.{js,jsx,ts,tsx,vue}]
[*.{js,jsx,ts,tsx,vue,json}]
indent_style = space
indent_size = 4
end_of_line = lf

@ -0,0 +1,2 @@
NODE_ENV=development
VUE_APP_API_URL=/api

@ -0,0 +1,2 @@
NODE_ENV=production
VUE_APP_API_URL=/api

@ -1,29 +1,35 @@
# user-center
# 垛机监控系统
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Run your tests
```
npm run test
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

13046
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
{
"name": "user-center",
"name": "duoji-frontend",
"version": "0.1.0",
"private": true,
"scripts": {
@ -30,4 +30,4 @@
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 27 KiB

@ -1,131 +0,0 @@
[{
"description": "用户管理",
"rights": "userIndex",
"type": 2,
"children": [{
"description": "新增用户",
"rights": "addUser",
"type": 3
},
{
"description": "用户详情",
"rights": "userDetailIndex",
"type": 3,
"children": [{
"description": "编辑用户",
"rights": "editUser",
"type": 3
},
{
"description": "修改密码",
"rights": "editUserPwd",
"type": 3
},
{
"description": "绑定角色",
"rights": "bindRole",
"type": 3
},
{
"description": "解绑角色",
"rights": "unbindRole",
"type": 3
},
{
"description": "角色详情",
"rights": "roleDetailIndex",
"type": 3
}
]
},
{
"description": "停用/启用",
"rights": "enableUser",
"type": 3
},
{
"description": "删除用户",
"rights": "removeUser",
"type": 3
}
]
},
{
"description": "角色管理",
"rights": "roleIndex",
"type": 2,
"children": [{
"description": "新增角色",
"rights": "addRole",
"type": 3
},
{
"description": "角色详情",
"rights": "roleDetailIndex",
"type": 3,
"children": [{
"description": "编辑角色",
"rights": "editRole",
"type": 3
},
{
"description": "新增应用权限",
"rights": "addAppAuth",
"type": 3
},
{
"description": "绑定用户",
"rights": "bindUser",
"type": 3
},
{
"description": "用户详情",
"rights": "userDetailIndex",
"type": 3
},
{
"description": "解绑用户",
"rights": "unbindUser",
"type": 3
}
]
},
{
"description": "停用/启用",
"rights": "enableRole",
"type": 3
},
{
"description": "删除角色",
"rights": "removeRole",
"type": 3
}
]
},
{
"description": "应用管理",
"rights": "appIndex",
"type": 2,
"children": [{
"description": "新增应用",
"rights": "addApp",
"type": 3
},
{
"description": "应用详情",
"rights": "appDetailIndex",
"type": 3,
"children": [{
"description": "编辑应用",
"rights": "editApp",
"type": 3
}]
},
{
"description": "删除应用",
"rights": "removeApp",
"type": 3
}
]
}
]

@ -1,7 +1,7 @@
<template>
<div class="aside">
<div class="aside-logo" v-show="!aside_collapsed">
<span>用户中心</span>
<span>昆船随行式垛机监测系统</span>
</div>
<a-menu
:selectedKeys="selectedKeys"

@ -12,11 +12,12 @@ const instance = axios.create({
instance.interceptors.request.use((config) => {
const reqObj = config;
// 在发送请求之前做些什么
const reg = /\{(.+?)\}/g; // 匹配{}
// 在发送请求之前做些什么 -- 路径参数拼接
const reg = /\{(.+?)\}/g;
if (reg.test(reqObj.url)) {
reqObj.url = reqObj.url.replace(reg, Object.values(reqObj.path)[0]);
}
// token
if (sessionStorage.getItem('token')) {
reqObj.headers.token = sessionStorage.getItem('token');
}
@ -32,6 +33,13 @@ instance.interceptors.response.use((response) => {
if (res.code !== 200) {
console.log(res);
Vue.prototype.$message.error(res.message);
// 未认证
if (res.code === 401) {
sessionStorage.clear()
this.$router.push({
name: 'login'
})
}
return Promise.reject(res.message);
}
return res;

@ -8,7 +8,7 @@ const trans = (apiObj) => {
};
obj[apiKey] = (payload) => _axiosInstance({
method: data.method,
url: '/api' + data.url,
url: data.url,
...payload,
});
});

@ -5,9 +5,6 @@ const files = require.context('@/views', true, /-router\.js$/)
let allRouter = [];
// 匹配成功的名字数组
files.keys().map(key => {
// 获取default
// console.log('模块', key, files(key).default)
// 整合所有模块路由
allRouter = allRouter.concat(files(key).default)
})
allRouter.sort((a, b) => {
@ -26,25 +23,25 @@ VueRouter.prototype.push = function push(location) {
}
const routes = [{
path: '/',
redirect: {
name: 'login'
path: '/',
redirect: {
name: 'login'
},
component: () => import('../views/main.vue'),
children: [
...allRouter
]
},
component: () => import('../views/main.vue'),
children: [
...allRouter
]
},
{
path: '/login',
name: 'login',
component: () => import('../views/login.vue')
},
{
path: '*',
name: '404',
component: () => import('../views/404.vue')
}
{
path: '/login',
name: 'login',
component: () => import('../views/login.vue')
},
{
path: '*',
name: '404',
component: () => import('../views/404.vue')
}
]
const router = new VueRouter({
@ -55,16 +52,12 @@ router.beforeEach((to, from, next) => {
let userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}')
// 校验是否登录
if (userInfo.id) {
// console.log(to)
// 匹配不到 404
if (!to.name) next();
if (to.name.startsWith('center')) {
next()
return
}
// 权限
if (userInfo.permissionList.some((item) => {
return item.rights === to.name
})) {
return item.rights === to.name
})) {
next()
} else {
if (to.name === 'login') {

@ -5,10 +5,10 @@ export default {
var hours = parseInt((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((time % (1000 * 60 * 60)) / (1000 * 60));
var seconds = (time % (1000 * 60)) / 1000;
return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 " ;
return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 ";
},
//计算字符串长度英文1个字符中文2个字符
computedStrLen (str) {
computedStrLen(str) {
var len = 0;
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
@ -57,7 +57,7 @@ export default {
cleanData(data) {
let _data = {};
for (let key in data) {
if(Object.prototype.toString.call(data[key]) === '[object Object]') {
if (Object.prototype.toString.call(data[key]) === '[object Object]') {
_data[key] = null;
} else if (data[key] instanceof Array) {
_data[key] = [];
@ -71,7 +71,7 @@ export default {
* 判断对象类型
* @param {Object} object
* @return {String} object type
*/
*/
getType(object) {
var toString = Object.prototype.toString;
var map = {
@ -92,13 +92,12 @@ export default {
return map[toString.call(object)];
},
// 下载
downloadFile (fileName, blob) {
downloadFile(fileName, blob) {
if (window.navigator.msSaveBlob) {
// for ie10 and later
try {
window.navigator.msSaveBlob(blob, fileName);
}
catch(e) {
window.navigator.msSaveBlob(blob, fileName);
} catch (e) {
console.log(e);
}
} else {
@ -114,9 +113,9 @@ export default {
}
},
/*
* 根据文件名的尾缀 返回文件类型
* @param {any} fileName 文件名
*/
* 根据文件名的尾缀 返回文件类型
* @param {any} fileName 文件名
*/
getFileType(fileName) {
// 后缀获取
let suffix = '';
@ -129,7 +128,9 @@ export default {
suffix = '';
}
// fileName无后缀返回 false
if (!suffix) { return false; }
if (!suffix) {
return false;
}
suffix = suffix.toLocaleLowerCase();
// 图片格式
const imglist = ['png', 'jpg', 'jpeg', 'bmp', 'gif'];
@ -184,7 +185,7 @@ export default {
return 'other';
},
// 千位分隔符
numFormat(num){
numFormat(num) {
var res = num.toString().replace(/\d+/, (n) => { // 先提取整数部分
return n.replace(/(\d)(?=(\d{3})+$)/g, ($1) => {
return $1 + ",";
@ -192,79 +193,4 @@ export default {
})
return res;
},
reg: {
required: [{
required: true,
message: '必填'
}],
phone: [{
pattern: /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/,
message: '请填写正确的手机号码'
}],
shouldSelectProduction:[{
required: true,
message: '请选择所属产品'
}],
equipmentId:[{
required: true,
pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,8}$/,
message: '设备id必须为8位数字字母组合'
}],
morethanTwo:[{
min: 2,
message: '长度至少为2个字符'
}],
morethanFour:[{
min: 4,
message: '长度至少为4个字符'
}],
positiveInteger: [{
pattern: /^[1-9]\d*$/,
message: '请填写正整数'
}],
integer: [{
pattern: /^[0-9]\d*$/,
message: '请填写非负整数'
}],
price: [{
pattern: /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/,
message: '请填写正确的钱数'
}],
long: [{
pattern: /^(-?\d+)(\.\d+)?$/,
message: '请填写正确的数值'
}],
space: [{
pattern: /^\S*$/,
message: '请勿输入空格'
}],
lengthMax: [{
max: 200,
message: '超出最大字数限制'
}],
absLong: [{
pattern: /^(\d+)(\.\d+)?$/,
message: '请填写大于等于的0的数字'
}],
long1: [{
pattern: /(^[1-9]\d*(\.\d{0,1})?$)|(^0(\.\d{0,1})?$)/,
message: '保留一位小数'
}],
long2: [{
pattern: /(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/,
message: '保留两位小数'
}],
date: [{
pattern: /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/,
message: '日期格式应为2018-01-01'
}],
coordinates: [{
pattern: /^(\\-|\\+)?\d+(\.\d+)?(,(\\-|\+)?\d+(\.\d+)?)$/,
message: '格式错误,例:‘经度’,‘纬度’'
}],
email:[{
pattern: /^([a-zA-Z0-9\\_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
message: '请填写正确的邮箱'
}]
},
}
}

@ -1,20 +1,20 @@
module.exports = {
css: {
loaderOptions: {
// Sass 样式传入共享的全局变量
sass: {
// data: `@import "@/style/variable.scss"; @import "@/style/mixin.scss";`
},
less: {
javascriptEnabled: true,
}
}
},
// css: {
// loaderOptions: {
// // Sass 样式传入共享的全局变量
// sass: {
// // data: `@import "@/style/variable.scss"; @import "@/style/mixin.scss";`
// },
// less: {
// javascriptEnabled: true,
// }
// }
// },
productionSourceMap: process.env.NODE_ENV === 'production' ? false : true,
chainWebpack: config => {
// vuecli 3默认开启prefetch(预先加载模块),提前获取用户未来可能会访问的内容 (也可手动设置)
config.plugins.delete('prefetch')
},
// chainWebpack: config => {
// // vuecli 3默认开启prefetch(预先加载模块),提前获取用户未来可能会访问的内容 (也可手动设置)
// config.plugins.delete('prefetch')
// },
devServer: {
proxy: {
'/api': {

Loading…
Cancel
Save