Skip to content

Commit ee101f4

Browse files
committed
Merge branch 'master' into deploy
2 parents ffc98f6 + 9cba45e commit ee101f4

File tree

10 files changed

+74
-60
lines changed

10 files changed

+74
-60
lines changed

build/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
2626
app.listen(port, function () {
2727
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
2828
if (report) {
29-
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}/report.html`))
29+
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
3030
}
3131

3232
})

mock/mock-server.js

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ const bodyParser = require('body-parser')
33
const chalk = require('chalk')
44

55
function registerRoutes(app) {
6+
let mockStartIndex
67
const { default: mocks } = require('./index.js')
78
for (const mock of mocks) {
89
app[mock.type](mock.url, mock.response)
10+
mockStartIndex = app._router.stack.length
911
}
12+
const mockRoutesLength = Object.keys(mocks).length
1013
return {
11-
mockRoutesLength: Object.keys(mocks).length
14+
mockRoutesLength: mockRoutesLength,
15+
mockStartIndex: mockStartIndex - mockRoutesLength
1216
}
1317
}
1418

@@ -20,28 +24,6 @@ function unregisterRoutes() {
2024
})
2125
}
2226

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-
4527
module.exports = app => {
4628
// es6 polyfill
4729
require('@babel/register')
@@ -53,7 +35,9 @@ module.exports = app => {
5335
extended: true
5436
}))
5537

56-
const { mockRoutesLength } = registerRoutes(app)
38+
const mockRoutes = registerRoutes(app)
39+
var mockRoutesLength = mockRoutes.mockRoutesLength
40+
var mockStartIndex = mockRoutes.mockStartIndex
5741

5842
// watch files, hot reload mock server
5943
chokidar.watch(('./mock'), {
@@ -62,16 +46,15 @@ module.exports = app => {
6246
ignoreInitial: true
6347
}).on('all', (event, path) => {
6448
if (event === 'change' || event === 'add') {
65-
// find mock routes stack index
66-
const index = getMockRoutesIndex(app)
67-
6849
// remove mock routes stack
69-
app._router.stack.splice(index, mockRoutesLength)
50+
app._router.stack.splice(mockStartIndex, mockRoutesLength)
7051

7152
// clear routes cache
7253
unregisterRoutes()
7354

74-
registerRoutes(app)
55+
const mockRoutes = registerRoutes(app)
56+
mockRoutesLength = mockRoutes.mockRoutesLength
57+
mockStartIndex = mockRoutes.mockStartIndex
7558

7659
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
7760
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
"@babel/core": "7.0.0",
7878
"@babel/register": "7.0.0",
7979
"@vue/cli-plugin-babel": "3.5.3",
80+
"@vue/cli-plugin-eslint": "3.5.1",
8081
"@vue/cli-plugin-unit-jest": "3.5.3",
8182
"@vue/cli-service": "3.5.3",
8283
"@vue/test-utils": "1.0.0-beta.29",

src/layout/components/Sidebar/SidebarItem.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export default {
8686
if (isExternal(routePath)) {
8787
return routePath
8888
}
89+
if (isExternal(this.basePath)) {
90+
return this.basePath
91+
}
8992
return path.resolve(this.basePath, routePath)
9093
},
9194

src/layout/components/TagsView/index.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default {
145145
closeSelectedTag(view) {
146146
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
147147
if (this.isActive(view)) {
148-
this.toLastView(visitedViews)
148+
this.toLastView(visitedViews, view)
149149
}
150150
})
151151
},
@@ -160,16 +160,22 @@ export default {
160160
if (this.affixTags.some(tag => tag.path === view.path)) {
161161
return
162162
}
163-
this.toLastView(visitedViews)
163+
this.toLastView(visitedViews, view)
164164
})
165165
},
166-
toLastView(visitedViews) {
166+
toLastView(visitedViews, view) {
167167
const latestView = visitedViews.slice(-1)[0]
168168
if (latestView) {
169169
this.$router.push(latestView)
170170
} else {
171-
// You can set another route
172-
this.$router.push('/')
171+
// now the default is to redirect to the home page if there is no tags-view,
172+
// you can adjust it according to your needs.
173+
if (view.name === 'Dashboard') {
174+
// to reload home page
175+
this.$router.replace({ path: '/redirect' + view.fullPath })
176+
} else {
177+
this.$router.push('/')
178+
}
173179
}
174180
},
175181
openMenu(tag, e) {

src/styles/sidebar.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
.sidebar-container {
1313
transition: width 0.28s;
1414
width: $sideBarWidth !important;
15+
background-color: $menuBg;
1516
height: 100%;
1617
position: fixed;
1718
font-size: 0px;

src/views/svg-icons/element-icon.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["info","error","success","warning","question","back","arrow-left","arrow-down","arrow-right","arrow-up","caret-left","caret-bottom","caret-top","caret-right","d-arrow-left","d-arrow-right","minus","plus","remove","circle-plus","remove-outline","circle-plus-outline","close","check","circle-close","circle-check","circle-close-outline","circle-check-outline","zoom-out","zoom-in","d-caret","sort","sort-down","sort-up","tickets","document","goods","sold-out","news","message","date","printer","time","bell","mobile-phone","service","view","menu","more","more-outline","star-on","star-off","location","location-outline","phone","phone-outline","picture","picture-outline","delete","search","edit","edit-outline","rank","refresh","share","setting","upload","upload2","download","loading"]

src/views/svg-icons/index.vue

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,57 @@
44
<a href="https://panjiachen.github.io/vue-element-admin-site/guide/advanced/icon.html" target="_blank">Add and use
55
</a>
66
</p>
7-
<div class="icons-wrapper">
8-
<div v-for="item of iconsMap" :key="item" @click="handleClipboard(generateIconCode(item),$event)">
9-
<el-tooltip placement="top">
10-
<div slot="content">
11-
{{ generateIconCode(item) }}
12-
</div>
13-
<div class="icon-item">
14-
<svg-icon :icon-class="item" class-name="disabled" />
15-
<span>{{ item }}</span>
16-
</div>
17-
</el-tooltip>
18-
</div>
19-
</div>
7+
<el-tabs type="border-card">
8+
<el-tab-pane label="Icons">
9+
<div v-for="item of iconsMap" :key="item" @click="handleClipboard(generateIconCode(item),$event)">
10+
<el-tooltip placement="top">
11+
<div slot="content">
12+
{{ generateIconCode(item) }}
13+
</div>
14+
<div class="icon-item">
15+
<svg-icon :icon-class="item" class-name="disabled" />
16+
<span>{{ item }}</span>
17+
</div>
18+
</el-tooltip>
19+
</div>
20+
</el-tab-pane>
21+
<el-tab-pane label="Element-UI Icons">
22+
<div v-for="item of elementIcons" :key="item" @click="handleClipboard(generateElementIconCode(item),$event)">
23+
<el-tooltip placement="top">
24+
<div slot="content">
25+
{{ generateElementIconCode(item) }}
26+
</div>
27+
<div class="icon-item">
28+
<i :class="'el-icon-' + item" />
29+
<span>{{ item }}</span>
30+
</div>
31+
</el-tooltip>
32+
</div>
33+
</el-tab-pane>
34+
</el-tabs>
2035
</div>
2136
</template>
2237

2338
<script>
24-
import icons from './requireIcons'
2539
import clipboard from '@/utils/clipboard'
40+
import icons from './requireIcons'
41+
import elementIcons from './element-icon.json'
2642

2743
export default {
2844
name: 'Icons',
2945
data() {
3046
return {
31-
iconsMap: icons
47+
iconsMap: icons,
48+
elementIcons: elementIcons
3249
}
3350
},
3451
methods: {
3552
generateIconCode(symbol) {
3653
return `<svg-icon icon-class="${symbol}" />`
3754
},
55+
generateElementIconCode(symbol) {
56+
return `<i class="el-icon-${symbol}" />`
57+
},
3858
handleClipboard(text, event) {
3959
clipboard(text, event)
4060
}
@@ -46,25 +66,25 @@ export default {
4666
.icons-container {
4767
margin: 10px 20px 0;
4868
overflow: hidden;
49-
.icons-wrapper {
50-
margin: 0 auto;
51-
}
69+
5270
.icon-item {
5371
margin: 20px;
54-
height: 110px;
72+
height: 85px;
5573
text-align: center;
56-
width: 110px;
74+
width: 100px;
5775
float: left;
5876
font-size: 30px;
5977
color: #24292e;
6078
cursor: pointer;
6179
}
80+
6281
span {
6382
display: block;
64-
font-size: 24px;
83+
font-size: 16px;
6584
margin-top: 10px;
6685
}
67-
.disabled{
86+
87+
.disabled {
6888
pointer-events: none;
6989
}
7090
}

src/views/svg-icons/requireIcons.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const req = require.context('../../icons/svg', false, /\.svg$/)
32
const requireAll = requireContext => requireContext.keys()
43

vue.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
publicPath: '/vue-element-admin/',
2222
outputDir: 'dist',
2323
assetsDir: 'static',
24-
lintOnSave: process.env.NODE_ENV === 'development' ? 'error' : false,
24+
lintOnSave: process.env.NODE_ENV === 'development',
2525
productionSourceMap: false,
2626
devServer: {
2727
port: port,
@@ -114,7 +114,7 @@ module.exports = {
114114
elementUI: {
115115
name: 'chunk-elementUI', // split elementUI into a single package
116116
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
117-
test: /[\\/]node_modules[\\/]element-ui[\\/]/
117+
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
118118
},
119119
commons: {
120120
name: 'chunk-commons',

0 commit comments

Comments
 (0)