Merge branch 'master' into deploy
This commit is contained in:
commit
ee101f4a78
|
@ -26,7 +26,7 @@ if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
|
||||||
app.listen(port, function () {
|
app.listen(port, function () {
|
||||||
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
|
console.log(chalk.green(`> Preview at http://localhost:${port}${publicPath}`))
|
||||||
if (report) {
|
if (report) {
|
||||||
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}/report.html`))
|
console.log(chalk.green(`> Report at http://localhost:${port}${publicPath}report.html`))
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,12 +3,16 @@ const bodyParser = require('body-parser')
|
||||||
const chalk = require('chalk')
|
const chalk = require('chalk')
|
||||||
|
|
||||||
function registerRoutes(app) {
|
function registerRoutes(app) {
|
||||||
|
let mockStartIndex
|
||||||
const { default: mocks } = require('./index.js')
|
const { default: mocks } = require('./index.js')
|
||||||
for (const mock of mocks) {
|
for (const mock of mocks) {
|
||||||
app[mock.type](mock.url, mock.response)
|
app[mock.type](mock.url, mock.response)
|
||||||
|
mockStartIndex = app._router.stack.length
|
||||||
}
|
}
|
||||||
|
const mockRoutesLength = Object.keys(mocks).length
|
||||||
return {
|
return {
|
||||||
mockRoutesLength: Object.keys(mocks).length
|
mockRoutesLength: mockRoutesLength,
|
||||||
|
mockStartIndex: mockStartIndex - mockRoutesLength
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,28 +24,6 @@ function unregisterRoutes() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPath(path) {
|
|
||||||
var match = path.toString()
|
|
||||||
.replace('\\/?', '')
|
|
||||||
.replace('(?=\\/|$)', '$')
|
|
||||||
.match(/^\/\^((?:\\[.*+?^${}()|[\]\\\/]|[^.*+?^${}()|[\]\\\/])*)\$\//)
|
|
||||||
return match
|
|
||||||
? match[1].replace(/\\(.)/g, '$1').split('/')
|
|
||||||
: path.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMockRoutesIndex(app) {
|
|
||||||
for (let index = 0; index <= app._router.stack.length; index++) {
|
|
||||||
const r = app._router.stack[index]
|
|
||||||
if (r.route && r.route.path) {
|
|
||||||
const path = getPath(r.route.path)
|
|
||||||
if (path.includes('mock')) {
|
|
||||||
return index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
// es6 polyfill
|
// es6 polyfill
|
||||||
require('@babel/register')
|
require('@babel/register')
|
||||||
|
@ -53,7 +35,9 @@ module.exports = app => {
|
||||||
extended: true
|
extended: true
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const { mockRoutesLength } = registerRoutes(app)
|
const mockRoutes = registerRoutes(app)
|
||||||
|
var mockRoutesLength = mockRoutes.mockRoutesLength
|
||||||
|
var mockStartIndex = mockRoutes.mockStartIndex
|
||||||
|
|
||||||
// watch files, hot reload mock server
|
// watch files, hot reload mock server
|
||||||
chokidar.watch(('./mock'), {
|
chokidar.watch(('./mock'), {
|
||||||
|
@ -62,16 +46,15 @@ module.exports = app => {
|
||||||
ignoreInitial: true
|
ignoreInitial: true
|
||||||
}).on('all', (event, path) => {
|
}).on('all', (event, path) => {
|
||||||
if (event === 'change' || event === 'add') {
|
if (event === 'change' || event === 'add') {
|
||||||
// find mock routes stack index
|
|
||||||
const index = getMockRoutesIndex(app)
|
|
||||||
|
|
||||||
// remove mock routes stack
|
// remove mock routes stack
|
||||||
app._router.stack.splice(index, mockRoutesLength)
|
app._router.stack.splice(mockStartIndex, mockRoutesLength)
|
||||||
|
|
||||||
// clear routes cache
|
// clear routes cache
|
||||||
unregisterRoutes()
|
unregisterRoutes()
|
||||||
|
|
||||||
registerRoutes(app)
|
const mockRoutes = registerRoutes(app)
|
||||||
|
mockRoutesLength = mockRoutes.mockRoutesLength
|
||||||
|
mockStartIndex = mockRoutes.mockStartIndex
|
||||||
|
|
||||||
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@
|
||||||
"@babel/core": "7.0.0",
|
"@babel/core": "7.0.0",
|
||||||
"@babel/register": "7.0.0",
|
"@babel/register": "7.0.0",
|
||||||
"@vue/cli-plugin-babel": "3.5.3",
|
"@vue/cli-plugin-babel": "3.5.3",
|
||||||
|
"@vue/cli-plugin-eslint": "3.5.1",
|
||||||
"@vue/cli-plugin-unit-jest": "3.5.3",
|
"@vue/cli-plugin-unit-jest": "3.5.3",
|
||||||
"@vue/cli-service": "3.5.3",
|
"@vue/cli-service": "3.5.3",
|
||||||
"@vue/test-utils": "1.0.0-beta.29",
|
"@vue/test-utils": "1.0.0-beta.29",
|
||||||
|
|
|
@ -86,6 +86,9 @@ export default {
|
||||||
if (isExternal(routePath)) {
|
if (isExternal(routePath)) {
|
||||||
return routePath
|
return routePath
|
||||||
}
|
}
|
||||||
|
if (isExternal(this.basePath)) {
|
||||||
|
return this.basePath
|
||||||
|
}
|
||||||
return path.resolve(this.basePath, routePath)
|
return path.resolve(this.basePath, routePath)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
||||||
closeSelectedTag(view) {
|
closeSelectedTag(view) {
|
||||||
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
|
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
|
||||||
if (this.isActive(view)) {
|
if (this.isActive(view)) {
|
||||||
this.toLastView(visitedViews)
|
this.toLastView(visitedViews, view)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -160,17 +160,23 @@ export default {
|
||||||
if (this.affixTags.some(tag => tag.path === view.path)) {
|
if (this.affixTags.some(tag => tag.path === view.path)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.toLastView(visitedViews)
|
this.toLastView(visitedViews, view)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toLastView(visitedViews) {
|
toLastView(visitedViews, view) {
|
||||||
const latestView = visitedViews.slice(-1)[0]
|
const latestView = visitedViews.slice(-1)[0]
|
||||||
if (latestView) {
|
if (latestView) {
|
||||||
this.$router.push(latestView)
|
this.$router.push(latestView)
|
||||||
} else {
|
} else {
|
||||||
// You can set another route
|
// now the default is to redirect to the home page if there is no tags-view,
|
||||||
|
// you can adjust it according to your needs.
|
||||||
|
if (view.name === 'Dashboard') {
|
||||||
|
// to reload home page
|
||||||
|
this.$router.replace({ path: '/redirect' + view.fullPath })
|
||||||
|
} else {
|
||||||
this.$router.push('/')
|
this.$router.push('/')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
openMenu(tag, e) {
|
openMenu(tag, e) {
|
||||||
const menuMinWidth = 105
|
const menuMinWidth = 105
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
.sidebar-container {
|
.sidebar-container {
|
||||||
transition: width 0.28s;
|
transition: width 0.28s;
|
||||||
width: $sideBarWidth !important;
|
width: $sideBarWidth !important;
|
||||||
|
background-color: $menuBg;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
font-size: 0px;
|
font-size: 0px;
|
||||||
|
|
|
@ -0,0 +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"]
|
|
@ -4,7 +4,8 @@
|
||||||
<a href="https://panjiachen.github.io/vue-element-admin-site/guide/advanced/icon.html" target="_blank">Add and use
|
<a href="https://panjiachen.github.io/vue-element-admin-site/guide/advanced/icon.html" target="_blank">Add and use
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<div class="icons-wrapper">
|
<el-tabs type="border-card">
|
||||||
|
<el-tab-pane label="Icons">
|
||||||
<div v-for="item of iconsMap" :key="item" @click="handleClipboard(generateIconCode(item),$event)">
|
<div v-for="item of iconsMap" :key="item" @click="handleClipboard(generateIconCode(item),$event)">
|
||||||
<el-tooltip placement="top">
|
<el-tooltip placement="top">
|
||||||
<div slot="content">
|
<div slot="content">
|
||||||
|
@ -16,25 +17,44 @@
|
||||||
</div>
|
</div>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="Element-UI Icons">
|
||||||
|
<div v-for="item of elementIcons" :key="item" @click="handleClipboard(generateElementIconCode(item),$event)">
|
||||||
|
<el-tooltip placement="top">
|
||||||
|
<div slot="content">
|
||||||
|
{{ generateElementIconCode(item) }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="icon-item">
|
||||||
|
<i :class="'el-icon-' + item" />
|
||||||
|
<span>{{ item }}</span>
|
||||||
|
</div>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import icons from './requireIcons'
|
|
||||||
import clipboard from '@/utils/clipboard'
|
import clipboard from '@/utils/clipboard'
|
||||||
|
import icons from './requireIcons'
|
||||||
|
import elementIcons from './element-icon.json'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Icons',
|
name: 'Icons',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
iconsMap: icons
|
iconsMap: icons,
|
||||||
|
elementIcons: elementIcons
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
generateIconCode(symbol) {
|
generateIconCode(symbol) {
|
||||||
return `<svg-icon icon-class="${symbol}" />`
|
return `<svg-icon icon-class="${symbol}" />`
|
||||||
},
|
},
|
||||||
|
generateElementIconCode(symbol) {
|
||||||
|
return `<i class="el-icon-${symbol}" />`
|
||||||
|
},
|
||||||
handleClipboard(text, event) {
|
handleClipboard(text, event) {
|
||||||
clipboard(text, event)
|
clipboard(text, event)
|
||||||
}
|
}
|
||||||
|
@ -46,25 +66,25 @@ export default {
|
||||||
.icons-container {
|
.icons-container {
|
||||||
margin: 10px 20px 0;
|
margin: 10px 20px 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
.icons-wrapper {
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
.icon-item {
|
.icon-item {
|
||||||
margin: 20px;
|
margin: 20px;
|
||||||
height: 110px;
|
height: 85px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 110px;
|
width: 100px;
|
||||||
float: left;
|
float: left;
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
color: #24292e;
|
color: #24292e;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 24px;
|
font-size: 16px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
.disabled{
|
|
||||||
|
.disabled {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
const req = require.context('../../icons/svg', false, /\.svg$/)
|
const req = require.context('../../icons/svg', false, /\.svg$/)
|
||||||
const requireAll = requireContext => requireContext.keys()
|
const requireAll = requireContext => requireContext.keys()
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
||||||
publicPath: '/vue-element-admin/',
|
publicPath: '/vue-element-admin/',
|
||||||
outputDir: 'dist',
|
outputDir: 'dist',
|
||||||
assetsDir: 'static',
|
assetsDir: 'static',
|
||||||
lintOnSave: process.env.NODE_ENV === 'development' ? 'error' : false,
|
lintOnSave: process.env.NODE_ENV === 'development',
|
||||||
productionSourceMap: false,
|
productionSourceMap: false,
|
||||||
devServer: {
|
devServer: {
|
||||||
port: port,
|
port: port,
|
||||||
|
@ -114,7 +114,7 @@ module.exports = {
|
||||||
elementUI: {
|
elementUI: {
|
||||||
name: 'chunk-elementUI', // split elementUI into a single package
|
name: 'chunk-elementUI', // split elementUI into a single package
|
||||||
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
||||||
test: /[\\/]node_modules[\\/]element-ui[\\/]/
|
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
|
||||||
},
|
},
|
||||||
commons: {
|
commons: {
|
||||||
name: 'chunk-commons',
|
name: 'chunk-commons',
|
||||||
|
|
Loading…
Reference in New Issue