Skip to content

Commit caffe6f

Browse files
committed
Merge branch 'master' into deploy
2 parents 9b68a08 + 0358667 commit caffe6f

File tree

31 files changed

+248
-141
lines changed

31 files changed

+248
-141
lines changed

mock/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
import Mock from 'mockjs'
2-
import mocks from './mocks'
32
import { param2Obj } from '../src/utils'
43

5-
const MOCK_API_BASE = '/mock'
4+
import user from './user'
5+
import role from './role'
6+
import article from './article'
7+
import search from './remoteSearch'
68

9+
const mocks = [
10+
...user,
11+
...role,
12+
...article,
13+
...search
14+
]
15+
16+
// for front mock
17+
// please use it cautiously, it will redefine XMLHttpRequest,
18+
// which will cause many of your third-party libraries to be invalidated(like progress event).
719
export function mockXHR() {
8-
// 修复在使用 MockJS 情况下,设置 withCredentials = true,且未被拦截的跨域请求丢失 Cookies 的问题
20+
// mock patch
921
// https://github.com/nuysoft/Mock/issues/300
1022
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
1123
Mock.XHR.prototype.send = function() {
@@ -42,9 +54,10 @@ export function mockXHR() {
4254
}
4355
}
4456

57+
// for mock server
4558
const responseFake = (url, type, respond) => {
4659
return {
47-
url: new RegExp(`${MOCK_API_BASE}${url}`),
60+
url: new RegExp(`/mock${url}`),
4861
type: type || 'get',
4962
response(req, res) {
5063
res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))

mock/mock-server.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
const chokidar = require('chokidar')
2+
const bodyParser = require('body-parser')
3+
const chalk = require('chalk')
4+
5+
function registerRoutes(app) {
6+
const { default: mocks } = require('./index.js')
7+
for (const mock of mocks) {
8+
app[mock.type](mock.url, mock.response)
9+
}
10+
return {
11+
mockRoutesLength: Object.keys(mocks).length
12+
}
13+
}
14+
15+
function unregisterRoutes() {
16+
Object.keys(require.cache).forEach(i => {
17+
if (i.includes('/mock')) {
18+
delete require.cache[require.resolve(i)]
19+
}
20+
})
21+
}
22+
23+
function getPath(path) {
24+
var match = path.toString()
25+
.replace('\\/?', '')
26+
.replace('(?=\\/|$)', '$')
27+
.match(/^\/\^((?:\\[.*+?^${}()|[\]\\\/]|[^.*+?^${}()|[\]\\\/])*)\$\//)
28+
return match
29+
? match[1].replace(/\\(.)/g, '$1').split('/')
30+
: path.toString()
31+
}
32+
33+
function getMockRoutesIndex(app) {
34+
for (let index = 0; index <= app._router.stack.length; index++) {
35+
const r = app._router.stack[index]
36+
if (r.route && r.route.path) {
37+
const path = getPath(r.route.path)
38+
if (path.includes('mock')) {
39+
return index
40+
}
41+
}
42+
}
43+
}
44+
45+
module.exports = app => {
46+
// es6 polyfill
47+
require('@babel/register')
48+
49+
// parse app.body
50+
// http://expressjs.com/en/4x/api.html#req.body
51+
app.use(bodyParser.json())
52+
app.use(bodyParser.urlencoded({
53+
extended: true
54+
}))
55+
56+
const { mockRoutesLength } = registerRoutes(app)
57+
58+
// watch files, hot reload mock server
59+
chokidar.watch(('./mock'), {
60+
ignored: 'mock/mock-server.js',
61+
persistent: true,
62+
ignoreInitial: true
63+
}).on('all', (event, path) => {
64+
if (event === 'change' || event === 'add') {
65+
// find mock routes stack index
66+
const index = getMockRoutesIndex(app)
67+
68+
// remove mock routes stack
69+
app._router.stack.splice(index, mockRoutesLength)
70+
71+
// clear routes cache
72+
unregisterRoutes()
73+
74+
registerRoutes(app)
75+
76+
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
77+
}
78+
})
79+
}

mock/mocks.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

mock/role/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const constantRoutes = [
1919
},
2020
{
2121
path: '/auth-redirect',
22-
component: 'views/login/authredirect',
22+
component: 'views/login/authRedirect',
2323
hidden: true
2424
},
2525
{

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"babel-eslint": "10.0.1",
8585
"babel-jest": "23.6.0",
8686
"chalk": "2.4.2",
87+
"chokidar": "2.1.5",
8788
"connect": "3.6.6",
8889
"eslint": "5.15.3",
8990
"eslint-plugin-vue": "5.2.2",

src/components/DndList/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="dndList">
33
<div :style="{width:width1}" class="dndList-list">
44
<h3>{{ list1Title }}</h3>
5-
<draggable :list="list1" group="article" class="dragArea">
5+
<draggable :set-data="setData" :list="list1" group="article" class="dragArea">
66
<div v-for="element in list1" :key="element.id" class="list-complete-item">
77
<div class="list-complete-item-handle">
88
{{ element.id }}[{{ element.author }}] {{ element.title }}
@@ -94,6 +94,11 @@ export default {
9494
if (this.isNotInList1(ele)) {
9595
this.list1.push(ele)
9696
}
97+
},
98+
setData(dataTransfer) {
99+
// to avoid Firefox bug
100+
// Detail see : https://github.com/RubaXa/Sortable/issues/1012
101+
dataTransfer.setData('Text', '')
97102
}
98103
}
99104
}

src/components/ErrorLog/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</el-button>
77
</el-badge>
88

9-
<el-dialog :visible.sync="dialogTableVisible" title="Error Log" width="80%">
9+
<el-dialog :visible.sync="dialogTableVisible" title="Error Log" width="80%" append-to-body>
1010
<el-table :data="errorLogs" border>
1111
<el-table-column label="Message">
1212
<template slot-scope="{row}">

src/components/Kanban/index.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:list="list"
88
v-bind="$attrs"
99
class="board-column-content"
10+
:set-data="setData"
1011
>
1112
<div v-for="element in list" :key="element.id" class="board-item">
1213
{{ element.name }} {{ element.id }}
@@ -39,6 +40,13 @@ export default {
3940
return []
4041
}
4142
}
43+
},
44+
methods: {
45+
setData(dataTransfer) {
46+
// to avoid Firefox bug
47+
// Detail see : https://github.com/RubaXa/Sortable/issues/1012
48+
dataTransfer.setData('Text', '')
49+
}
4250
}
4351
}
4452
</script>

src/lang/en.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export default {
22
route: {
33
dashboard: 'Dashboard',
4-
introduction: 'Introduction',
54
documentation: 'Documentation',
65
guide: 'Guide',
76
permission: 'Permission',
@@ -10,7 +9,6 @@ export default {
109
directivePermission: 'Directive Permission',
1110
icons: 'Icons',
1211
components: 'Components',
13-
componentIndex: 'Introduction',
1412
tinymce: 'Tinymce',
1513
markdown: 'Markdown',
1614
jsonEditor: 'JSON Editor',
@@ -19,9 +17,9 @@ export default {
1917
avatarUpload: 'Avatar Upload',
2018
dropzone: 'Dropzone',
2119
sticky: 'Sticky',
22-
countTo: 'CountTo',
20+
countTo: 'Count To',
2321
componentMixin: 'Mixin',
24-
backToTop: 'BackToTop',
22+
backToTop: 'Back To Top',
2523
dragDialog: 'Drag Dialog',
2624
dragSelect: 'Drag Select',
2725
dragKanban: 'Drag Kanban',
@@ -75,7 +73,7 @@ export default {
7573
},
7674
login: {
7775
title: 'Login Form',
78-
logIn: 'Log in',
76+
logIn: 'Login',
7977
username: 'Username',
8078
password: 'Password',
8179
any: 'any',
@@ -88,10 +86,10 @@ export default {
8886
},
8987
permission: {
9088
addRole: 'New Role',
91-
editPermission: 'Edit Permission',
89+
editPermission: 'Edit',
9290
roles: 'Your roles',
9391
switchRoles: 'Switch roles',
94-
tips: 'In some cases it is not suitable to use v-permission, such as element Tab component or el-table-column and other asynchronous rendering dom cases which can only be achieved by manually setting the v-if.',
92+
tips: 'In some cases, using v-permission will have no effect. For example: Element-UI el-tab or el-table-column and other scenes that dynamically render dom. You can only do this with v-if.',
9593
delete: 'Delete',
9694
confirm: 'Confirm',
9795
cancel: 'Cancel'
@@ -102,7 +100,7 @@ export default {
102100
},
103101
components: {
104102
documentation: 'Documentation',
105-
tinymceTips: 'Rich text editor is a core part of management system, but at the same time is a place with lots of problems. In the process of selecting rich texts, I also walked a lot of detours. The common rich text editors in the market are basically used, and the finally chose Tinymce. See documentation for more detailed rich text editor comparisons and introductions.',
103+
tinymceTips: 'Rich text is a core feature of the management backend, but at the same time it is a place with lots of pits. In the process of selecting rich texts, I also took a lot of detours. The common rich texts on the market have been basically used, and I finally chose Tinymce. See the more detailed rich text comparison and introduction.',
106104
dropzoneTips: 'Because my business has special needs, and has to upload images to qiniu, so instead of a third party, I chose encapsulate it by myself. It is very simple, you can see the detail code in @/components/Dropzone.',
107105
stickyTips: 'when the page is scrolled to the preset position will be sticky on the top.',
108106
backToTopTips1: 'When the page is scrolled to the specified position, the Back to Top button appears in the lower right corner',
@@ -143,14 +141,14 @@ export default {
143141
excel: {
144142
export: 'Export',
145143
selectedExport: 'Export Selected Items',
146-
placeholder: 'Please enter the file name(default excel-list)'
144+
placeholder: 'Please enter the file name (default excel-list)'
147145
},
148146
zip: {
149147
export: 'Export',
150-
placeholder: 'Please enter the file name(default file)'
148+
placeholder: 'Please enter the file name (default file)'
151149
},
152150
pdf: {
153-
tips: 'Here we use window.print() to implement the feature of downloading pdf.'
151+
tips: 'Here we use window.print() to implement the feature of downloading PDF.'
154152
},
155153
theme: {
156154
change: 'Change Theme',

src/lang/es.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export default {
22
route: {
33
dashboard: 'Panel de control',
4-
introduction: 'Introducción',
54
documentation: 'Documentación',
65
guide: 'Guía',
76
permission: 'Permisos',
@@ -10,7 +9,6 @@ export default {
109
directivePermission: 'Permisos de la directiva',
1110
icons: 'Iconos',
1211
components: 'Componentes',
13-
componentIndex: 'Introducción',
1412
tinymce: 'Tinymce',
1513
markdown: 'Markdown',
1614
jsonEditor: 'Editor JSON',

0 commit comments

Comments
 (0)