+74
-25
lines changedFilter options
+74
-25
lines changed Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
import Mock from 'mockjs'
1
+
const Mock = require('mockjs')
2
2
3
3
const List = []
4
4
const count = 100
@@ -27,7 +27,7 @@ for (let i = 0; i < count; i++) {
27
27
}))
28
28
}
29
29
30
-
export default [
30
+
module.exports = [
31
31
{
32
32
url: '/vue-element-admin/article/list',
33
33
type: 'get',
Original file line number Diff line number Diff 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')
3
3
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')
8
8
9
9
const mocks = [
10
10
...user,
@@ -16,7 +16,7 @@ const mocks = [
16
16
// for front mock
17
17
// please use it cautiously, it will redefine XMLHttpRequest,
18
18
// which will cause many of your third-party libraries to be invalidated(like progress event).
19
-
export function mockXHR() {
19
+
function mockXHR() {
20
20
// mock patch
21
21
// https://github.com/nuysoft/Mock/issues/300
22
22
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
@@ -54,4 +54,7 @@ export function mockXHR() {
54
54
}
55
55
}
56
56
57
-
export default mocks
57
+
module.exports = {
58
+
mocks,
59
+
mockXHR
60
+
}
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ const mockDir = path.join(process.cwd(), 'mock')
8
8
9
9
function registerRoutes(app) {
10
10
let mockLastIndex
11
-
const { default: mocks } = require('./index.js')
11
+
const { mocks } = require('./index.js')
12
12
const mocksForServer = mocks.map(route => {
13
13
return responseFake(route.url, route.type, route.response)
14
14
})
@@ -44,9 +44,6 @@ const responseFake = (url, type, respond) => {
44
44
}
45
45
46
46
module.exports = app => {
47
-
// es6 polyfill
48
-
require('@babel/register')
49
-
50
47
// parse app.body
51
48
// https://expressjs.com/en/4x/api.html#req.body
52
49
app.use(bodyParser.json())
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1
-
import Mock from 'mockjs'
1
+
const Mock = require('mockjs')
2
2
3
3
const NameList = []
4
4
const count = 100
@@ -10,7 +10,7 @@ for (let i = 0; i < count; i++) {
10
10
}
11
11
NameList.push({ name: 'mock-Pan' })
12
12
13
-
export default [
13
+
module.exports = [
14
14
// username search
15
15
{
16
16
url: '/vue-element-admin/search/user',
Original file line number Diff line number Diff 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')
4
4
5
5
const routes = deepClone([...constantRoutes, ...asyncRoutes])
6
6
@@ -35,7 +35,7 @@ const roles = [
35
35
}
36
36
]
37
37
38
-
export default [
38
+
module.exports = [
39
39
// mock get all routes form server
40
40
{
41
41
url: '/vue-element-admin/routes',
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1
1
// Just a mock data
2
2
3
-
export const constantRoutes = [
3
+
const constantRoutes = [
4
4
{
5
5
path: '/redirect',
6
6
component: 'layout/Layout',
@@ -72,7 +72,7 @@ export const constantRoutes = [
72
72
}
73
73
]
74
74
75
-
export const asyncRoutes = [
75
+
const asyncRoutes = [
76
76
{
77
77
path: '/permission',
78
78
component: 'layout/Layout',
@@ -523,3 +523,8 @@ export const asyncRoutes = [
523
523
524
524
{ path: '*', redirect: '/404', hidden: true }
525
525
]
526
+
527
+
module.exports = {
528
+
constantRoutes,
529
+
asyncRoutes
530
+
}
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ const users = {
23
23
}
24
24
}
25
25
26
-
export default [
26
+
module.exports = [
27
27
// user login
28
28
{
29
29
url: '/vue-element-admin/user/login',
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
1
+
/**
2
+
* @param {string} url
3
+
* @returns {Object}
4
+
*/
5
+
function param2Obj(url) {
6
+
const search = url.split('?')[1]
7
+
if (!search) {
8
+
return {}
9
+
}
10
+
return JSON.parse(
11
+
'{"' +
12
+
decodeURIComponent(search)
13
+
.replace(/"/g, '\\"')
14
+
.replace(/&/g, '","')
15
+
.replace(/=/g, '":"')
16
+
.replace(/\+/g, ' ') +
17
+
'"}'
18
+
)
19
+
}
20
+
21
+
/**
22
+
* This is just a simple version of deep copy
23
+
* Has a lot of edge cases bug
24
+
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
25
+
* @param {Object} source
26
+
* @returns {Object}
27
+
*/
28
+
function deepClone(source) {
29
+
if (!source && typeof source !== 'object') {
30
+
throw new Error('error arguments', 'deepClone')
31
+
}
32
+
const targetObj = source.constructor === Array ? [] : {}
33
+
Object.keys(source).forEach(keys => {
34
+
if (source[keys] && typeof source[keys] === 'object') {
35
+
targetObj[keys] = deepClone(source[keys])
36
+
} else {
37
+
targetObj[keys] = source[keys]
38
+
}
39
+
})
40
+
return targetObj
41
+
}
42
+
43
+
module.exports = {
44
+
param2Obj,
45
+
deepClone
46
+
}
Original file line number Diff line number Diff line change
@@ -72,8 +72,6 @@
72
72
"xlsx": "0.14.1"
73
73
},
74
74
"devDependencies": {
75
-
"@babel/core": "7.0.0",
76
-
"@babel/register": "7.0.0",
77
75
"@vue/cli-plugin-babel": "3.5.3",
78
76
"@vue/cli-plugin-eslint": "^3.9.1",
79
77
"@vue/cli-plugin-unit-jest": "3.5.3",
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4