Skip to content

Commit fa26b79

Browse files
committed
update
2 parents 1d22adb + 81a1452 commit fa26b79

File tree

23 files changed

+247
-149
lines changed

23 files changed

+247
-149
lines changed

.env.development

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,3 @@ ENV = 'development'
33

44
# base api
55
VUE_APP_BASE_API = '/dev-api'
6-
7-
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
8-
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
9-
# It only does one thing by converting all import() to require().
10-
# This configuration can significantly increase the speed of hot updates,
11-
# when you have a large number of pages.
12-
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
13-
14-
VUE_CLI_BABEL_TRANSPILE_MODULES = true

babel.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
module.exports = {
22
presets: [
3-
'@vue/app'
4-
]
3+
// https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
4+
'@vue/cli-plugin-babel/preset'
5+
],
6+
'env': {
7+
'development': {
8+
// babel-plugin-dynamic-import-node plugin only does one thing by converting all import() to require().
9+
// This plugin can significantly increase the speed of hot updates, when you have a large number of pages.
10+
// https://panjiachen.github.io/vue-element-admin-site/guide/advanced/lazy-loading.html
11+
'plugins': ['dynamic-import-node']
12+
}
13+
}
514
}

mock/article.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Mock from 'mockjs'
1+
const Mock = require('mockjs')
22

33
const List = []
44
const count = 100
@@ -27,7 +27,7 @@ for (let i = 0; i < count; i++) {
2727
}))
2828
}
2929

30-
export default [
30+
module.exports = [
3131
{
3232
url: '/vue-element-admin/article/list',
3333
type: 'get',

mock/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import Mock from 'mockjs'
2-
import { param2Obj } from '../src/utils'
1+
const Mock = require('mockjs')
2+
const { param2Obj } = require('./utils')
33

4-
import user from './user'
5-
import role from './role'
6-
import article from './article'
7-
import search from './remote-search'
4+
const user = require('./user')
5+
const role = require('./role')
6+
const article = require('./article')
7+
const search = require('./remote-search')
88

99
const mocks = [
1010
...user,
@@ -16,7 +16,7 @@ const mocks = [
1616
// for front mock
1717
// please use it cautiously, it will redefine XMLHttpRequest,
1818
// which will cause many of your third-party libraries to be invalidated(like progress event).
19-
export function mockXHR() {
19+
function mockXHR() {
2020
// mock patch
2121
// https://github.com/nuysoft/Mock/issues/300
2222
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
@@ -54,4 +54,7 @@ export function mockXHR() {
5454
}
5555
}
5656

57-
export default mocks
57+
module.exports = {
58+
mocks,
59+
mockXHR
60+
}

mock/mock-server.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const mockDir = path.join(process.cwd(), 'mock')
88

99
function registerRoutes(app) {
1010
let mockLastIndex
11-
const { default: mocks } = require('./index.js')
11+
const { mocks } = require('./index.js')
1212
const mocksForServer = mocks.map(route => {
1313
return responseFake(route.url, route.type, route.response)
1414
})
@@ -44,9 +44,6 @@ const responseFake = (url, type, respond) => {
4444
}
4545

4646
module.exports = app => {
47-
// es6 polyfill
48-
require('@babel/register')
49-
5047
// parse app.body
5148
// https://expressjs.com/en/4x/api.html#req.body
5249
app.use(bodyParser.json())

mock/remote-search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Mock from 'mockjs'
1+
const Mock = require('mockjs')
22

33
const NameList = []
44
const count = 100
@@ -10,7 +10,7 @@ for (let i = 0; i < count; i++) {
1010
}
1111
NameList.push({ name: 'mock-Pan' })
1212

13-
export default [
13+
module.exports = [
1414
// username search
1515
{
1616
url: '/vue-element-admin/search/user',

mock/role/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Mock from 'mockjs'
2-
import { deepClone } from '../../src/utils/index.js'
3-
import { asyncRoutes, constantRoutes } from './routes.js'
1+
const Mock = require('mockjs')
2+
const { deepClone } = require('../utils')
3+
const { asyncRoutes, constantRoutes } = require('./routes.js')
44

55
const routes = deepClone([...constantRoutes, ...asyncRoutes])
66

@@ -35,7 +35,7 @@ const roles = [
3535
}
3636
]
3737

38-
export default [
38+
module.exports = [
3939
// mock get all routes form server
4040
{
4141
url: '/vue-element-admin/routes',

mock/role/routes.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Just a mock data
22

3-
export const constantRoutes = [
3+
const constantRoutes = [
44
{
55
path: '/redirect',
66
component: 'layout/Layout',
@@ -72,7 +72,7 @@ export const constantRoutes = [
7272
}
7373
]
7474

75-
export const asyncRoutes = [
75+
const asyncRoutes = [
7676
{
7777
path: '/permission',
7878
component: 'layout/Layout',
@@ -523,3 +523,8 @@ export const asyncRoutes = [
523523

524524
{ path: '*', redirect: '/404', hidden: true }
525525
]
526+
527+
module.exports = {
528+
constantRoutes,
529+
asyncRoutes
530+
}

mock/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const users = {
2323
}
2424
}
2525

26-
export default [
26+
module.exports = [
2727
// user login
2828
{
2929
url: '/vue-element-admin/user/login',

mock/utils.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @param {string} url
3+
* @returns {Object}
4+
*/
5+
function param2Obj(url) {
6+
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
7+
if (!search) {
8+
return {}
9+
}
10+
const obj = {}
11+
const searchArr = search.split('&')
12+
searchArr.forEach(v => {
13+
const index = v.indexOf('=')
14+
if (index !== -1) {
15+
const name = v.substring(0, index)
16+
const val = v.substring(index + 1, v.length)
17+
obj[name] = val
18+
}
19+
})
20+
return obj
21+
}
22+
23+
/**
24+
* This is just a simple version of deep copy
25+
* Has a lot of edge cases bug
26+
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
27+
* @param {Object} source
28+
* @returns {Object}
29+
*/
30+
function deepClone(source) {
31+
if (!source && typeof source !== 'object') {
32+
throw new Error('error arguments', 'deepClone')
33+
}
34+
const targetObj = source.constructor === Array ? [] : {}
35+
Object.keys(source).forEach(keys => {
36+
if (source[keys] && typeof source[keys] === 'object') {
37+
targetObj[keys] = deepClone(source[keys])
38+
} else {
39+
targetObj[keys] = source[keys]
40+
}
41+
})
42+
return targetObj
43+
}
44+
45+
module.exports = {
46+
param2Obj,
47+
deepClone
48+
}

package.json

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,29 @@
11
{
22
"name": "vue-element-admin",
3-
"version": "4.3.0",
3+
"version": "4.3.1",
44
"description": "A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features",
55
"author": "Pan <panfree23@gmail.com>",
6-
"license": "MIT",
76
"scripts": {
87
"dev": "vue-cli-service serve",
8+
"lint": "eslint --ext .js,.vue src",
99
"build:prod": "vue-cli-service build",
1010
"build:stage": "vue-cli-service build --mode staging",
1111
"preview": "node build/index.js --preview",
12-
"lint": "eslint --ext .js,.vue src",
12+
"new": "plop",
13+
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
1314
"test:unit": "jest --clearCache && vue-cli-service test:unit",
1415
"test:ci": "npm run lint && npm run test:unit",
15-
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
16-
"new": "plop",
1716
"deploy": "bash deploy.sh"
1817
},
19-
"husky": {
20-
"hooks": {
21-
"pre-commit": "lint-staged"
22-
}
23-
},
24-
"lint-staged": {
25-
"src/**/*.{js,vue}": [
26-
"eslint --fix",
27-
"git add"
28-
]
29-
},
30-
"keywords": [
31-
"vue",
32-
"admin",
33-
"dashboard",
34-
"element-ui",
35-
"boilerplate",
36-
"admin-template",
37-
"management-system"
38-
],
39-
"repository": {
40-
"type": "git",
41-
"url": "git+https://github.com/PanJiaChen/vue-element-admin.git"
42-
},
43-
"bugs": {
44-
"url": "https://github.com/PanJiaChen/vue-element-admin/issues"
45-
},
4618
"dependencies": {
4719
"axios": "0.18.1",
4820
"clipboard": "2.0.4",
4921
"codemirror": "5.45.0",
22+
"core-js": "3.6.5",
5023
"driver.js": "0.9.5",
5124
"dropzone": "5.5.1",
5225
"echarts": "4.2.1",
53-
"element-ui": "2.13.0",
26+
"element-ui": "2.13.2",
5427
"file-saver": "2.0.1",
5528
"fuse.js": "3.4.4",
5629
"js-cookie": "2.2.0",
@@ -62,7 +35,6 @@
6235
"pinyin": "2.9.0",
6336
"screenfull": "4.2.0",
6437
"script-loader": "0.7.2",
65-
"showdown": "1.9.0",
6638
"sortablejs": "1.8.4",
6739
"tui-editor": "1.3.3",
6840
"vue": "2.6.10",
@@ -76,42 +48,68 @@
7648
"xlsx": "0.14.1"
7749
},
7850
"devDependencies": {
79-
"@babel/core": "7.0.0",
80-
"@babel/register": "7.0.0",
81-
"@vue/cli-plugin-babel": "3.5.3",
82-
"@vue/cli-plugin-eslint": "^3.9.1",
83-
"@vue/cli-plugin-unit-jest": "3.5.3",
84-
"@vue/cli-service": "3.5.3",
51+
"@vue/cli-plugin-babel": "4.4.4",
52+
"@vue/cli-plugin-eslint": "4.4.4",
53+
"@vue/cli-plugin-unit-jest": "4.4.4",
54+
"@vue/cli-service": "4.4.4",
8555
"@vue/test-utils": "1.0.0-beta.29",
86-
"autoprefixer": "^9.5.1",
87-
"babel-core": "7.0.0-bridge.0",
88-
"babel-eslint": "10.0.1",
56+
"autoprefixer": "9.5.1",
57+
"babel-eslint": "10.1.0",
8958
"babel-jest": "23.6.0",
59+
"babel-plugin-dynamic-import-node": "2.3.3",
9060
"chalk": "2.4.2",
9161
"chokidar": "2.1.5",
9262
"connect": "3.6.6",
93-
"eslint": "5.15.3",
94-
"eslint-plugin-vue": "5.2.2",
63+
"eslint": "6.7.2",
64+
"eslint-plugin-vue": "6.2.2",
9565
"html-webpack-plugin": "3.2.0",
9666
"husky": "1.3.1",
9767
"lint-staged": "8.1.5",
9868
"mockjs": "1.0.1-beta3",
9969
"plop": "2.3.0",
100-
"runjs": "^4.3.2",
101-
"sass": "^1.26.2",
102-
"sass-loader": "^7.1.0",
70+
"runjs": "4.3.2",
71+
"sass": "1.26.2",
72+
"sass-loader": "8.0.2",
10373
"script-ext-html-webpack-plugin": "2.1.3",
104-
"serve-static": "^1.13.2",
74+
"serve-static": "1.13.2",
10575
"svg-sprite-loader": "4.1.3",
10676
"svgo": "1.2.0",
10777
"vue-template-compiler": "2.6.10"
10878
},
79+
"browserslist": [
80+
"> 1%",
81+
"last 2 versions"
82+
],
83+
"bugs": {
84+
"url": "https://github.com/PanJiaChen/vue-element-admin/issues"
85+
},
10986
"engines": {
11087
"node": ">=8.9",
11188
"npm": ">= 3.0.0"
11289
},
113-
"browserslist": [
114-
"> 1%",
115-
"last 2 versions"
116-
]
90+
"keywords": [
91+
"vue",
92+
"admin",
93+
"dashboard",
94+
"element-ui",
95+
"boilerplate",
96+
"admin-template",
97+
"management-system"
98+
],
99+
"license": "MIT",
100+
"lint-staged": {
101+
"src/**/*.{js,vue}": [
102+
"eslint --fix",
103+
"git add"
104+
]
105+
},
106+
"husky": {
107+
"hooks": {
108+
"pre-commit": "lint-staged"
109+
}
110+
},
111+
"repository": {
112+
"type": "git",
113+
"url": "git+https://github.com/PanJiaChen/vue-element-admin.git"
114+
}
117115
}

plop-templates/utils.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
exports.notEmpty = name => {
2-
return v => {
3-
if (!v || v.trim === '') {
4-
return `${name} is required`
5-
} else {
6-
return true
7-
}
8-
}
9-
}
1+
exports.notEmpty = name => v =>
2+
!v || v.trim() === '' ? `${name} is required` : true

src/components/ImageCropper/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export default {
248248
// 浏览器是否支持该控件
249249
isSupported,
250250
// 浏览器是否支持触屏事件
251+
// eslint-disable-next-line no-prototype-builtins
251252
isSupportTouch: document.hasOwnProperty('ontouchstart'),
252253
// 步骤
253254
step: 1, // 1选择文件 2剪裁 3上传

0 commit comments

Comments
 (0)