Compare commits
9 Commits
check-engi
...
v3.11.0
Author | SHA1 | Date | |
---|---|---|---|
|
20f6150741 | ||
|
7703005013 | ||
|
9a5c404ef8 | ||
|
9d975b5eff | ||
|
331173ffee | ||
|
f890685d8d | ||
|
fb30079477 | ||
|
3100d0cff4 | ||
|
ae6bbf7858 |
17
.babelrc
Normal file
17
.babelrc
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
["env", {
|
||||||
|
"modules": false,
|
||||||
|
"targets": {
|
||||||
|
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
"stage-2"
|
||||||
|
],
|
||||||
|
"plugins": ["transform-vue-jsx", "transform-runtime"],
|
||||||
|
"env": {
|
||||||
|
"development":{
|
||||||
|
"plugins": ["dynamic-import-node"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,9 +0,0 @@
|
|||||||
VUE_APP_BASE_API = '/api'
|
|
||||||
ENV = 'development'
|
|
||||||
|
|
||||||
// With this configuration, vue-cli uses babel-plugin-dynamic-import-node
|
|
||||||
// It only does one thing by converting all import() to require()
|
|
||||||
// So that all asynchronous components can be import synchronously using this plugin
|
|
||||||
// This configuration can significantly increase the speed of hot updates when you have a large number of pages
|
|
||||||
// https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
|
|
||||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
|
@@ -1,2 +0,0 @@
|
|||||||
VUE_APP_BASE_API = '/api'
|
|
||||||
ENV = 'production'
|
|
@@ -1,3 +0,0 @@
|
|||||||
NODE_ENV=production
|
|
||||||
VUE_APP_BASE_API = '/api'
|
|
||||||
ENV = 'staging'
|
|
@@ -24,7 +24,6 @@ module.exports = {
|
|||||||
"vue/singleline-html-element-content-newline": "off",
|
"vue/singleline-html-element-content-newline": "off",
|
||||||
"vue/multiline-html-element-content-newline":"off",
|
"vue/multiline-html-element-content-newline":"off",
|
||||||
"vue/name-property-casing": ["error", "PascalCase"],
|
"vue/name-property-casing": ["error", "PascalCase"],
|
||||||
"vue/no-v-html": "off",
|
|
||||||
'accessor-pairs': 2,
|
'accessor-pairs': 2,
|
||||||
'arrow-spacing': [2, {
|
'arrow-spacing': [2, {
|
||||||
'before': true,
|
'before': true,
|
||||||
@@ -47,7 +46,7 @@ module.exports = {
|
|||||||
'curly': [2, 'multi-line'],
|
'curly': [2, 'multi-line'],
|
||||||
'dot-location': [2, 'property'],
|
'dot-location': [2, 'property'],
|
||||||
'eol-last': 2,
|
'eol-last': 2,
|
||||||
'eqeqeq': ["error", "always", {"null": "ignore"}],
|
'eqeqeq': [2, 'allow-null'],
|
||||||
'generator-star-spacing': [2, {
|
'generator-star-spacing': [2, {
|
||||||
'before': true,
|
'before': true,
|
||||||
'after': true
|
'after': true
|
||||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@@ -6,8 +6,8 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
**/*.log
|
**/*.log
|
||||||
|
|
||||||
tests/**/coverage/
|
test/unit/coverage
|
||||||
tests/e2e/reports
|
test/e2e/reports
|
||||||
selenium-debug.log
|
selenium-debug.log
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
@@ -17,7 +17,5 @@ selenium-debug.log
|
|||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.local
|
|
||||||
|
|
||||||
package-lock.json
|
package-lock.json
|
||||||
yarn.lock
|
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"plugins": {
|
"plugins": {
|
||||||
|
"postcss-import": {},
|
||||||
|
"postcss-url": {},
|
||||||
// to edit target browsers: use "browserslist" field in package.json
|
// to edit target browsers: use "browserslist" field in package.json
|
||||||
"autoprefixer": {}
|
"autoprefixer": {}
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,8 @@ English | [简体中文](./README.zh-CN.md)
|
|||||||
|
|
||||||
It is a magical vue admin based on the newest development stack of vue, built-in i18n solution, typical templates for enterprise applications, lots of awesome features. It helps you build a large complex Single-Page Applications. I believe whatever your needs are, this project will help you.
|
It is a magical vue admin based on the newest development stack of vue, built-in i18n solution, typical templates for enterprise applications, lots of awesome features. It helps you build a large complex Single-Page Applications. I believe whatever your needs are, this project will help you.
|
||||||
|
|
||||||
|
**[v4.0](https://github.com/PanJiaChen/vue-element-admin/tree/v4.0) has in beta. It built on vue-cli@3, optimized a lot of code and added a lot of new features. Welcome to use and make suggestions.**
|
||||||
|
|
||||||
- [Preview](http://panjiachen.github.io/vue-element-admin)
|
- [Preview](http://panjiachen.github.io/vue-element-admin)
|
||||||
|
|
||||||
- [Documentation](https://panjiachen.github.io/vue-element-admin-site/)
|
- [Documentation](https://panjiachen.github.io/vue-element-admin-site/)
|
||||||
|
@@ -30,7 +30,9 @@
|
|||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
|
||||||
[vue-element-admin](http://panjiachen.github.io/vue-element-admin) 是一个后台集成解决方案,它基于 [vue](https://github.com/vuejs/vue) 和 [element](https://github.com/ElemeFE/element)。它使用了最新的前端技术栈,内置了 i18 国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件,它可以帮助你快速搭建企业级中后台产品原型。相信不管你的需求是什么,本项目都能帮助到你。
|
[vue-element-admin](http://panjiachen.github.io/vue-element-admin) 是一个后台集成解决方案,它基于 [vue](https://github.com/vuejs/vue) 和 [element](https://github.com/ElemeFE/element)。它使用了最新的前端技术栈,内置了 i18n 国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件,它可以帮助你快速搭建企业级中后台产品原型。相信不管你的需求是什么,本项目都能帮助到你。
|
||||||
|
|
||||||
|
**[v4.0](https://github.com/PanJiaChen/vue-element-admin/tree/v4.0) 已经进入 beta 测试阶段。 它基于 vue-cli@3 进行构建,优化了大量代码(尤其是权限和 mock),并且增加了不少新特性。欢迎使用并提出建议。**
|
||||||
|
|
||||||
- [在线访问](http://panjiachen.github.io/vue-element-admin)
|
- [在线访问](http://panjiachen.github.io/vue-element-admin)
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@
|
|||||||
- 桌面端: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
|
- 桌面端: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
|
||||||
- Typescript版: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (鸣谢: [@Armour](https://github.com/Armour))
|
- Typescript版: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (鸣谢: [@Armour](https://github.com/Armour))
|
||||||
|
|
||||||
群主 **[圈子](https://jianshiapp.com/circles/1209)** 楼主会经常分享一些技术相关的东西,或者加入[qq 群](https://github.com/PanJiaChen/vue-element-admin/issues/602)
|
群主 **[圈子](https://jianshiapp.com/circles/1209)** 楼主会经常分享一些技术相关的东西,或者加入[qq 群](https://github.com/PanJiaChen/vue-element-admin/issues/602)或者关注[微博](https://weibo.com/u/3423485724?is_all=1)
|
||||||
|
|
||||||
**注意:该项目使用 element-ui@2.3.0+ 版本,所以最低兼容 vue@2.5.0+**
|
**注意:该项目使用 element-ui@2.3.0+ 版本,所以最低兼容 vue@2.5.0+**
|
||||||
|
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
'@vue/app'
|
|
||||||
]
|
|
||||||
}
|
|
52
bin/index.js
52
bin/index.js
@@ -1,52 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const checker = require('../lib/checkSystem.js')
|
|
||||||
const colors = require('colors')
|
|
||||||
|
|
||||||
// set color theme
|
|
||||||
colors.setTheme({
|
|
||||||
success: 'green',
|
|
||||||
info: 'grey',
|
|
||||||
warn: 'yellow',
|
|
||||||
error: 'red',
|
|
||||||
boldWarn: ['bold', 'yellow'],
|
|
||||||
boldUnderlineSuccess: ['bold', 'underline', 'green'],
|
|
||||||
boldUnderlineError: ['bold', 'underline', 'red']
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log('Checking versions...'.info, '\n')
|
|
||||||
|
|
||||||
checker(process.argv[2]).then((result) => {
|
|
||||||
// check if the process should exit prematurely
|
|
||||||
if (result.status != 0) {
|
|
||||||
console.log(colors[result.message.type](result.message.text))
|
|
||||||
process.exit(result.status)
|
|
||||||
}
|
|
||||||
|
|
||||||
// print out results for each package
|
|
||||||
result.packages.forEach((p) => {
|
|
||||||
if (p.type === 'success') {
|
|
||||||
console.log(('✔ ' + colors.bold(p.name) + ' was validated with ' + p.expectedVersion + '.').success)
|
|
||||||
} else if (p.type === 'warn') {
|
|
||||||
console.log((colors.bold(p.name) + ' was expected, but no validator found!').warn)
|
|
||||||
} else if (p.type === 'error' && p.commandError) {
|
|
||||||
console.log(('✘ Error validating ' + colors.bold(p.name) + ': ' + p.commandError).error)
|
|
||||||
} else if (p.type === 'error' && !p.commandError) {
|
|
||||||
console.log((
|
|
||||||
'✘ ' + colors.bold(p.name) +
|
|
||||||
' version is incorrect! Expected ' +
|
|
||||||
p.expectedVersion + ' but was ' + p.foundVersion + '.'
|
|
||||||
).error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// print out a summary message
|
|
||||||
if (result.message.type === 'success') {
|
|
||||||
console.log('\n', result.message.text.boldUnderlineSuccess)
|
|
||||||
} else {
|
|
||||||
console.log('\n', result.message.text.boldUnderlineError)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
})
|
|
67
build/build.js
Normal file
67
build/build.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
'use strict'
|
||||||
|
require('./check-versions')()
|
||||||
|
|
||||||
|
const ora = require('ora')
|
||||||
|
const rm = require('rimraf')
|
||||||
|
const path = require('path')
|
||||||
|
const chalk = require('chalk')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const config = require('../config')
|
||||||
|
const webpackConfig = require('./webpack.prod.conf')
|
||||||
|
var connect = require('connect')
|
||||||
|
var serveStatic = require('serve-static')
|
||||||
|
|
||||||
|
const spinner = ora(
|
||||||
|
'building for ' + process.env.env_config + ' environment...'
|
||||||
|
)
|
||||||
|
spinner.start()
|
||||||
|
|
||||||
|
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
|
||||||
|
if (err) throw err
|
||||||
|
webpack(webpackConfig, (err, stats) => {
|
||||||
|
spinner.stop()
|
||||||
|
if (err) throw err
|
||||||
|
process.stdout.write(
|
||||||
|
stats.toString({
|
||||||
|
colors: true,
|
||||||
|
modules: false,
|
||||||
|
children: false,
|
||||||
|
chunks: false,
|
||||||
|
chunkModules: false
|
||||||
|
}) + '\n\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
console.log(chalk.red(' Build failed with errors.\n'))
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(chalk.cyan(' Build complete.\n'))
|
||||||
|
console.log(
|
||||||
|
chalk.yellow(
|
||||||
|
' Tip: built files are meant to be served over an HTTP server.\n' +
|
||||||
|
" Opening index.html over file:// won't work.\n"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (process.env.npm_config_preview) {
|
||||||
|
const port = 9526
|
||||||
|
const host = 'http://localhost:' + port
|
||||||
|
const basePath = config.build.assetsPublicPath
|
||||||
|
const app = connect()
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
basePath,
|
||||||
|
serveStatic('./dist', {
|
||||||
|
index: ['index.html', '/']
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
app.listen(port, function() {
|
||||||
|
console.log(
|
||||||
|
chalk.green(`> Listening at http://localhost:${port}${basePath}`)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
64
build/check-versions.js
Normal file
64
build/check-versions.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
'use strict'
|
||||||
|
const chalk = require('chalk')
|
||||||
|
const semver = require('semver')
|
||||||
|
const packageConfig = require('../package.json')
|
||||||
|
const shell = require('shelljs')
|
||||||
|
|
||||||
|
function exec(cmd) {
|
||||||
|
return require('child_process')
|
||||||
|
.execSync(cmd)
|
||||||
|
.toString()
|
||||||
|
.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
const versionRequirements = [
|
||||||
|
{
|
||||||
|
name: 'node',
|
||||||
|
currentVersion: semver.clean(process.version),
|
||||||
|
versionRequirement: packageConfig.engines.node
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
if (shell.which('npm')) {
|
||||||
|
versionRequirements.push({
|
||||||
|
name: 'npm',
|
||||||
|
currentVersion: exec('npm --version'),
|
||||||
|
versionRequirement: packageConfig.engines.npm
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function() {
|
||||||
|
const warnings = []
|
||||||
|
|
||||||
|
for (let i = 0; i < versionRequirements.length; i++) {
|
||||||
|
const mod = versionRequirements[i]
|
||||||
|
|
||||||
|
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
|
||||||
|
warnings.push(
|
||||||
|
mod.name +
|
||||||
|
': ' +
|
||||||
|
chalk.red(mod.currentVersion) +
|
||||||
|
' should be ' +
|
||||||
|
chalk.green(mod.versionRequirement)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (warnings.length) {
|
||||||
|
console.log('')
|
||||||
|
console.log(
|
||||||
|
chalk.yellow(
|
||||||
|
'To use this template, you must update following to modules:'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
console.log()
|
||||||
|
|
||||||
|
for (let i = 0; i < warnings.length; i++) {
|
||||||
|
const warning = warnings[i]
|
||||||
|
console.log(' ' + warning)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log()
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
@@ -1,31 +0,0 @@
|
|||||||
const { run } = require('runjs')
|
|
||||||
const chalk = require('chalk')
|
|
||||||
const config = require('../vue.config.js')
|
|
||||||
const rawArgv = process.argv.slice(2)
|
|
||||||
const args = rawArgv.join(' ')
|
|
||||||
|
|
||||||
if (process.env.npm_config_preview || rawArgv.includes('--preview')) {
|
|
||||||
run(`vue-cli-service build ${args}`)
|
|
||||||
|
|
||||||
const port = 9526
|
|
||||||
const publicPath = config.publicPath
|
|
||||||
|
|
||||||
var connect = require('connect')
|
|
||||||
var serveStatic = require('serve-static')
|
|
||||||
const app = connect()
|
|
||||||
|
|
||||||
app.use(
|
|
||||||
publicPath,
|
|
||||||
serveStatic('./dist', {
|
|
||||||
index: ['index.html', '/']
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
app.listen(port, function() {
|
|
||||||
console.log(
|
|
||||||
chalk.green(`> Listening at http://localhost:${port}${publicPath}`)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
run(`vue-cli-service build ${args}`)
|
|
||||||
}
|
|
BIN
build/logo.png
Normal file
BIN
build/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
108
build/utils.js
Normal file
108
build/utils.js
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
'use strict'
|
||||||
|
const path = require('path')
|
||||||
|
const config = require('../config')
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
|
const packageConfig = require('../package.json')
|
||||||
|
|
||||||
|
exports.assetsPath = function(_path) {
|
||||||
|
const assetsSubDirectory =
|
||||||
|
process.env.NODE_ENV === 'production'
|
||||||
|
? config.build.assetsSubDirectory
|
||||||
|
: config.dev.assetsSubDirectory
|
||||||
|
|
||||||
|
return path.posix.join(assetsSubDirectory, _path)
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.cssLoaders = function(options) {
|
||||||
|
options = options || {}
|
||||||
|
|
||||||
|
const cssLoader = {
|
||||||
|
loader: 'css-loader',
|
||||||
|
options: {
|
||||||
|
sourceMap: options.sourceMap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const postcssLoader = {
|
||||||
|
loader: 'postcss-loader',
|
||||||
|
options: {
|
||||||
|
sourceMap: options.sourceMap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate loader string to be used with extract text plugin
|
||||||
|
function generateLoaders(loader, loaderOptions) {
|
||||||
|
const loaders = []
|
||||||
|
|
||||||
|
// Extract CSS when that option is specified
|
||||||
|
// (which is the case during production build)
|
||||||
|
if (options.extract) {
|
||||||
|
loaders.push(MiniCssExtractPlugin.loader)
|
||||||
|
} else {
|
||||||
|
loaders.push('vue-style-loader')
|
||||||
|
}
|
||||||
|
|
||||||
|
loaders.push(cssLoader)
|
||||||
|
|
||||||
|
if (options.usePostCSS) {
|
||||||
|
loaders.push(postcssLoader)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loader) {
|
||||||
|
loaders.push({
|
||||||
|
loader: loader + '-loader',
|
||||||
|
options: Object.assign({}, loaderOptions, {
|
||||||
|
sourceMap: options.sourceMap
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return loaders
|
||||||
|
}
|
||||||
|
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
|
||||||
|
return {
|
||||||
|
css: generateLoaders(),
|
||||||
|
postcss: generateLoaders(),
|
||||||
|
less: generateLoaders('less'),
|
||||||
|
sass: generateLoaders('sass', {
|
||||||
|
indentedSyntax: true
|
||||||
|
}),
|
||||||
|
scss: generateLoaders('sass'),
|
||||||
|
stylus: generateLoaders('stylus'),
|
||||||
|
styl: generateLoaders('stylus')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate loaders for standalone style files (outside of .vue)
|
||||||
|
exports.styleLoaders = function(options) {
|
||||||
|
const output = []
|
||||||
|
const loaders = exports.cssLoaders(options)
|
||||||
|
|
||||||
|
for (const extension in loaders) {
|
||||||
|
const loader = loaders[extension]
|
||||||
|
output.push({
|
||||||
|
test: new RegExp('\\.' + extension + '$'),
|
||||||
|
use: loader
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.createNotifierCallback = () => {
|
||||||
|
const notifier = require('node-notifier')
|
||||||
|
|
||||||
|
return (severity, errors) => {
|
||||||
|
if (severity !== 'error') return
|
||||||
|
|
||||||
|
const error = errors[0]
|
||||||
|
const filename = error.file && error.file.split('!').pop()
|
||||||
|
|
||||||
|
notifier.notify({
|
||||||
|
title: packageConfig.name,
|
||||||
|
message: severity + ': ' + error.name,
|
||||||
|
subtitle: filename || '',
|
||||||
|
icon: path.join(__dirname, 'logo.png')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
5
build/vue-loader.conf.js
Normal file
5
build/vue-loader.conf.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
//You can set the vue-loader configuration by yourself.
|
||||||
|
}
|
107
build/webpack.base.conf.js
Normal file
107
build/webpack.base.conf.js
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
'use strict'
|
||||||
|
const path = require('path')
|
||||||
|
const utils = require('./utils')
|
||||||
|
const config = require('../config')
|
||||||
|
const { VueLoaderPlugin } = require('vue-loader')
|
||||||
|
const vueLoaderConfig = require('./vue-loader.conf')
|
||||||
|
|
||||||
|
function resolve(dir) {
|
||||||
|
return path.join(__dirname, '..', dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
const createLintingRule = () => ({
|
||||||
|
test: /\.(js|vue)$/,
|
||||||
|
loader: 'eslint-loader',
|
||||||
|
enforce: 'pre',
|
||||||
|
include: [resolve('src'), resolve('test')],
|
||||||
|
options: {
|
||||||
|
formatter: require('eslint-friendly-formatter'),
|
||||||
|
emitWarning: !config.dev.showEslintErrorsInOverlay
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
context: path.resolve(__dirname, '../'),
|
||||||
|
entry: {
|
||||||
|
app: './src/main.js'
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: config.build.assetsRoot,
|
||||||
|
filename: '[name].js',
|
||||||
|
publicPath:
|
||||||
|
process.env.NODE_ENV === 'production'
|
||||||
|
? config.build.assetsPublicPath
|
||||||
|
: config.dev.assetsPublicPath
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.vue', '.json'],
|
||||||
|
alias: {
|
||||||
|
'@': resolve('src')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
...(config.dev.useEslint ? [createLintingRule()] : []),
|
||||||
|
{
|
||||||
|
test: /\.vue$/,
|
||||||
|
loader: 'vue-loader',
|
||||||
|
options: vueLoaderConfig
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
loader: 'babel-loader?cacheDirectory',
|
||||||
|
include: [
|
||||||
|
resolve('src'),
|
||||||
|
resolve('test'),
|
||||||
|
resolve('node_modules/webpack-dev-server/client')
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.svg$/,
|
||||||
|
loader: 'svg-sprite-loader',
|
||||||
|
include: [resolve('src/icons')],
|
||||||
|
options: {
|
||||||
|
symbolId: 'icon-[name]'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
||||||
|
loader: 'url-loader',
|
||||||
|
exclude: [resolve('src/icons')],
|
||||||
|
options: {
|
||||||
|
limit: 10000,
|
||||||
|
name: utils.assetsPath('img/[name].[hash:7].[ext]')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
|
||||||
|
loader: 'url-loader',
|
||||||
|
options: {
|
||||||
|
limit: 10000,
|
||||||
|
name: utils.assetsPath('media/[name].[hash:7].[ext]')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
||||||
|
loader: 'url-loader',
|
||||||
|
options: {
|
||||||
|
limit: 10000,
|
||||||
|
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [new VueLoaderPlugin()],
|
||||||
|
node: {
|
||||||
|
// prevent webpack from injecting useless setImmediate polyfill because Vue
|
||||||
|
// source contains it (although only uses it if it's native).
|
||||||
|
setImmediate: false,
|
||||||
|
// prevent webpack from injecting mocks to Node native modules
|
||||||
|
// that does not make sense for the client
|
||||||
|
dgram: 'empty',
|
||||||
|
fs: 'empty',
|
||||||
|
net: 'empty',
|
||||||
|
tls: 'empty',
|
||||||
|
child_process: 'empty'
|
||||||
|
}
|
||||||
|
}
|
98
build/webpack.dev.conf.js
Normal file
98
build/webpack.dev.conf.js
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
'use strict'
|
||||||
|
const path = require('path')
|
||||||
|
const utils = require('./utils')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const config = require('../config')
|
||||||
|
const merge = require('webpack-merge')
|
||||||
|
const baseWebpackConfig = require('./webpack.base.conf')
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
|
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
||||||
|
const portfinder = require('portfinder')
|
||||||
|
|
||||||
|
function resolve(dir) {
|
||||||
|
return path.join(__dirname, '..', dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
const HOST = process.env.HOST
|
||||||
|
const PORT = process.env.PORT && Number(process.env.PORT)
|
||||||
|
|
||||||
|
const devWebpackConfig = merge(baseWebpackConfig, {
|
||||||
|
mode: 'development',
|
||||||
|
module: {
|
||||||
|
rules: utils.styleLoaders({
|
||||||
|
sourceMap: config.dev.cssSourceMap,
|
||||||
|
usePostCSS: true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// cheap-module-eval-source-map is faster for development
|
||||||
|
devtool: config.dev.devtool,
|
||||||
|
|
||||||
|
// these devServer options should be customized in /config/index.js
|
||||||
|
devServer: {
|
||||||
|
clientLogLevel: 'warning',
|
||||||
|
historyApiFallback: true,
|
||||||
|
hot: true,
|
||||||
|
compress: true,
|
||||||
|
host: HOST || config.dev.host,
|
||||||
|
port: PORT || config.dev.port,
|
||||||
|
open: config.dev.autoOpenBrowser,
|
||||||
|
overlay: config.dev.errorOverlay
|
||||||
|
? { warnings: false, errors: true }
|
||||||
|
: false,
|
||||||
|
publicPath: config.dev.assetsPublicPath,
|
||||||
|
proxy: config.dev.proxyTable,
|
||||||
|
quiet: true, // necessary for FriendlyErrorsPlugin
|
||||||
|
watchOptions: {
|
||||||
|
poll: config.dev.poll
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': require('../config/dev.env')
|
||||||
|
}),
|
||||||
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
|
// https://github.com/ampedandwired/html-webpack-plugin
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
filename: 'index.html',
|
||||||
|
template: 'index.html',
|
||||||
|
inject: true,
|
||||||
|
favicon: resolve('favicon.ico'),
|
||||||
|
title: 'vue-element-admin',
|
||||||
|
templateParameters: {
|
||||||
|
BASE_URL: config.dev.assetsPublicPath + config.dev.assetsSubDirectory,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = new Promise((resolve, reject) => {
|
||||||
|
portfinder.basePort = process.env.PORT || config.dev.port
|
||||||
|
portfinder.getPort((err, port) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err)
|
||||||
|
} else {
|
||||||
|
// publish the new Port, necessary for e2e tests
|
||||||
|
process.env.PORT = port
|
||||||
|
// add port to devServer config
|
||||||
|
devWebpackConfig.devServer.port = port
|
||||||
|
|
||||||
|
// Add FriendlyErrorsPlugin
|
||||||
|
devWebpackConfig.plugins.push(
|
||||||
|
new FriendlyErrorsPlugin({
|
||||||
|
compilationSuccessInfo: {
|
||||||
|
messages: [
|
||||||
|
`Your application is running here: http://${
|
||||||
|
devWebpackConfig.devServer.host
|
||||||
|
}:${port}`
|
||||||
|
]
|
||||||
|
},
|
||||||
|
onErrors: config.dev.notifyOnErrors
|
||||||
|
? utils.createNotifierCallback()
|
||||||
|
: undefined
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
resolve(devWebpackConfig)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
187
build/webpack.prod.conf.js
Normal file
187
build/webpack.prod.conf.js
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
'use strict'
|
||||||
|
const path = require('path')
|
||||||
|
const utils = require('./utils')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const config = require('../config')
|
||||||
|
const merge = require('webpack-merge')
|
||||||
|
const baseWebpackConfig = require('./webpack.base.conf')
|
||||||
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
|
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
|
||||||
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
||||||
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
|
||||||
|
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
||||||
|
|
||||||
|
function resolve(dir) {
|
||||||
|
return path.join(__dirname, '..', dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
const env = require('../config/' + process.env.env_config + '.env')
|
||||||
|
|
||||||
|
// For NamedChunksPlugin
|
||||||
|
const seen = new Set()
|
||||||
|
const nameLength = 4
|
||||||
|
|
||||||
|
const webpackConfig = merge(baseWebpackConfig, {
|
||||||
|
mode: 'production',
|
||||||
|
module: {
|
||||||
|
rules: utils.styleLoaders({
|
||||||
|
sourceMap: config.build.productionSourceMap,
|
||||||
|
extract: true,
|
||||||
|
usePostCSS: true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
devtool: config.build.productionSourceMap ? config.build.devtool : false,
|
||||||
|
output: {
|
||||||
|
path: config.build.assetsRoot,
|
||||||
|
filename: utils.assetsPath('js/[name].[chunkhash:8].js'),
|
||||||
|
chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].js')
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': env
|
||||||
|
}),
|
||||||
|
// extract css into its own file
|
||||||
|
new MiniCssExtractPlugin({
|
||||||
|
filename: utils.assetsPath('css/[name].[contenthash:8].css'),
|
||||||
|
chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css')
|
||||||
|
}),
|
||||||
|
// generate dist index.html with correct asset hash for caching.
|
||||||
|
// you can customize output by editing /index.html
|
||||||
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
filename: config.build.index,
|
||||||
|
template: 'index.html',
|
||||||
|
inject: true,
|
||||||
|
favicon: resolve('favicon.ico'),
|
||||||
|
title: 'vue-element-admin',
|
||||||
|
templateParameters: {
|
||||||
|
BASE_URL: config.build.assetsPublicPath + config.build.assetsSubDirectory,
|
||||||
|
},
|
||||||
|
minify: {
|
||||||
|
removeComments: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
removeAttributeQuotes: true
|
||||||
|
// more options:
|
||||||
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
||||||
|
}
|
||||||
|
// default sort mode uses toposort which cannot handle cyclic deps
|
||||||
|
// in certain cases, and in webpack 4, chunk order in HTML doesn't
|
||||||
|
// matter anyway
|
||||||
|
}),
|
||||||
|
new ScriptExtHtmlWebpackPlugin({
|
||||||
|
//`runtime` must same as runtimeChunk name. default is `runtime`
|
||||||
|
inline: /runtime\..*\.js$/
|
||||||
|
}),
|
||||||
|
// keep chunk.id stable when chunk has no name
|
||||||
|
new webpack.NamedChunksPlugin(chunk => {
|
||||||
|
if (chunk.name) {
|
||||||
|
return chunk.name
|
||||||
|
}
|
||||||
|
const modules = Array.from(chunk.modulesIterable)
|
||||||
|
if (modules.length > 1) {
|
||||||
|
const hash = require('hash-sum')
|
||||||
|
const joinedHash = hash(modules.map(m => m.id).join('_'))
|
||||||
|
let len = nameLength
|
||||||
|
while (seen.has(joinedHash.substr(0, len))) len++
|
||||||
|
seen.add(joinedHash.substr(0, len))
|
||||||
|
return `chunk-${joinedHash.substr(0, len)}`
|
||||||
|
} else {
|
||||||
|
return modules[0].id
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// keep module.id stable when vender modules does not change
|
||||||
|
new webpack.HashedModuleIdsPlugin(),
|
||||||
|
// copy custom static assets
|
||||||
|
new CopyWebpackPlugin([
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../static'),
|
||||||
|
to: config.build.assetsSubDirectory,
|
||||||
|
ignore: ['.*']
|
||||||
|
}
|
||||||
|
])
|
||||||
|
],
|
||||||
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
chunks: 'all',
|
||||||
|
cacheGroups: {
|
||||||
|
libs: {
|
||||||
|
name: 'chunk-libs',
|
||||||
|
test: /[\\/]node_modules[\\/]/,
|
||||||
|
priority: 10,
|
||||||
|
chunks: 'initial' // 只打包初始时依赖的第三方
|
||||||
|
},
|
||||||
|
elementUI: {
|
||||||
|
name: 'chunk-elementUI', // 单独将 elementUI 拆包
|
||||||
|
priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app
|
||||||
|
test: /[\\/]node_modules[\\/]element-ui[\\/]/
|
||||||
|
},
|
||||||
|
commons: {
|
||||||
|
name: 'chunk-commons',
|
||||||
|
test: resolve('src/components'), // 可自定义拓展你的规则
|
||||||
|
minChunks: 3, // 最小公用次数
|
||||||
|
priority: 5,
|
||||||
|
reuseExistingChunk: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
runtimeChunk: 'single',
|
||||||
|
minimizer: [
|
||||||
|
new UglifyJsPlugin({
|
||||||
|
uglifyOptions: {
|
||||||
|
mangle: {
|
||||||
|
safari10: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sourceMap: config.build.productionSourceMap,
|
||||||
|
cache: true,
|
||||||
|
parallel: true
|
||||||
|
}),
|
||||||
|
// Compress extracted CSS. We are using this plugin so that possible
|
||||||
|
// duplicated CSS from different components can be deduped.
|
||||||
|
new OptimizeCSSAssetsPlugin()
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (config.build.productionGzip) {
|
||||||
|
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
||||||
|
|
||||||
|
webpackConfig.plugins.push(
|
||||||
|
new CompressionWebpackPlugin({
|
||||||
|
algorithm: 'gzip',
|
||||||
|
test: new RegExp(
|
||||||
|
'\\.(' + config.build.productionGzipExtensions.join('|') + ')$'
|
||||||
|
),
|
||||||
|
threshold: 10240,
|
||||||
|
minRatio: 0.8
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) {
|
||||||
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
|
||||||
|
.BundleAnalyzerPlugin
|
||||||
|
|
||||||
|
if (config.build.bundleAnalyzerReport) {
|
||||||
|
webpackConfig.plugins.push(
|
||||||
|
new BundleAnalyzerPlugin({
|
||||||
|
analyzerPort: 8080,
|
||||||
|
generateStatsFile: false
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.build.generateAnalyzerReport) {
|
||||||
|
webpackConfig.plugins.push(
|
||||||
|
new BundleAnalyzerPlugin({
|
||||||
|
analyzerMode: 'static',
|
||||||
|
reportFilename: 'bundle-report.html',
|
||||||
|
openAnalyzer: false
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = webpackConfig
|
5
config/dev.env.js
Normal file
5
config/dev.env.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
NODE_ENV: '"development"',
|
||||||
|
ENV_CONFIG: '"dev"',
|
||||||
|
BASE_API: '"https://api-dev"'
|
||||||
|
}
|
88
config/index.js
Normal file
88
config/index.js
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
'use strict'
|
||||||
|
// Template version: 1.2.6
|
||||||
|
// see http://vuejs-templates.github.io/webpack for documentation.
|
||||||
|
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
dev: {
|
||||||
|
// Paths
|
||||||
|
assetsSubDirectory: 'static',
|
||||||
|
assetsPublicPath: '/',
|
||||||
|
proxyTable: {},
|
||||||
|
|
||||||
|
// Various Dev Server settings
|
||||||
|
|
||||||
|
// can be overwritten by process.env.HOST
|
||||||
|
// if you want dev by ip, please set host: '0.0.0.0'
|
||||||
|
host: 'localhost',
|
||||||
|
port: 9527, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
|
||||||
|
autoOpenBrowser: true,
|
||||||
|
errorOverlay: true,
|
||||||
|
notifyOnErrors: false,
|
||||||
|
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
|
||||||
|
|
||||||
|
// Use Eslint Loader?
|
||||||
|
// If true, your code will be linted during bundling and
|
||||||
|
// linting errors and warnings will be shown in the console.
|
||||||
|
useEslint: true,
|
||||||
|
// If true, eslint errors and warnings will also be shown in the error overlay
|
||||||
|
// in the browser.
|
||||||
|
showEslintErrorsInOverlay: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source Maps
|
||||||
|
*/
|
||||||
|
|
||||||
|
// https://webpack.js.org/configuration/devtool/#development
|
||||||
|
devtool: 'cheap-source-map',
|
||||||
|
|
||||||
|
// CSS Sourcemaps off by default because relative paths are "buggy"
|
||||||
|
// with this option, according to the CSS-Loader README
|
||||||
|
// (https://github.com/webpack/css-loader#sourcemaps)
|
||||||
|
// In our experience, they generally work as expected,
|
||||||
|
// just be aware of this issue when enabling this option.
|
||||||
|
cssSourceMap: false
|
||||||
|
},
|
||||||
|
|
||||||
|
build: {
|
||||||
|
// Template for index.html
|
||||||
|
index: path.resolve(__dirname, '../dist/index.html'),
|
||||||
|
|
||||||
|
// Paths
|
||||||
|
assetsRoot: path.resolve(__dirname, '../dist'),
|
||||||
|
assetsSubDirectory: 'static',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You can set by youself according to actual condition
|
||||||
|
* You will need to set this if you plan to deploy your site under a sub path,
|
||||||
|
* for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/,
|
||||||
|
* then assetsPublicPath should be set to "/bar/".
|
||||||
|
* In most cases please use '/' !!!
|
||||||
|
*/
|
||||||
|
assetsPublicPath: '/',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source Maps
|
||||||
|
*/
|
||||||
|
productionSourceMap: false,
|
||||||
|
// https://webpack.js.org/configuration/devtool/#production
|
||||||
|
devtool: 'source-map',
|
||||||
|
|
||||||
|
// Gzip off by default as many popular static hosts such as
|
||||||
|
// Surge or Netlify already gzip all static assets for you.
|
||||||
|
// Before setting to `true`, make sure to:
|
||||||
|
// npm install --save-dev compression-webpack-plugin
|
||||||
|
productionGzip: false,
|
||||||
|
productionGzipExtensions: ['js', 'css'],
|
||||||
|
|
||||||
|
// Run the build command with an extra argument to
|
||||||
|
// View the bundle analyzer report after build finishes:
|
||||||
|
// `npm run build:prod --report`
|
||||||
|
// Set to `true` or `false` to always turn it on or off
|
||||||
|
bundleAnalyzerReport: process.env.npm_config_report || false,
|
||||||
|
|
||||||
|
// `npm run build:prod --generate_report`
|
||||||
|
generateAnalyzerReport: process.env.npm_config_generate_report || false
|
||||||
|
}
|
||||||
|
}
|
5
config/prod.env.js
Normal file
5
config/prod.env.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
NODE_ENV: '"production"',
|
||||||
|
ENV_CONFIG: '"prod"',
|
||||||
|
BASE_API: '"https://api-prod"'
|
||||||
|
}
|
5
config/sit.env.js
Normal file
5
config/sit.env.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
NODE_ENV: '"production"',
|
||||||
|
ENV_CONFIG: '"sit"',
|
||||||
|
BASE_API: '"https://api-sit"'
|
||||||
|
}
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
@@ -5,11 +5,10 @@
|
|||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta name="renderer" content="webkit">
|
<meta name="renderer" content="webkit">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<title>vue-element-admin</title>
|
||||||
<title><%= webpackConfig.name %></title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="<%= BASE_URL %>static/tinymce4.7.5/tinymce.min.js"></script>
|
<script src=<%= BASE_URL %>/tinymce4.7.5/tinymce.min.js></script>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<!-- built files will be auto injected -->
|
<!-- built files will be auto injected -->
|
||||||
</body>
|
</body>
|
@@ -1,27 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
verbose: true,
|
|
||||||
moduleFileExtensions: ['js', 'jsx', 'json', 'vue'],
|
|
||||||
// transformIgnorePatterns: [
|
|
||||||
// 'node_modules/(?!(babel-jest|jest-vue-preprocessor)/)'
|
|
||||||
// ],
|
|
||||||
transform: {
|
|
||||||
'^.+\\.vue$': 'vue-jest',
|
|
||||||
'.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
|
|
||||||
'^.+\\.jsx?$': 'babel-jest'
|
|
||||||
},
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^@/(.*)$': '<rootDir>/src/$1'
|
|
||||||
},
|
|
||||||
snapshotSerializers: ['jest-serializer-vue'],
|
|
||||||
testMatch: [
|
|
||||||
'**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
|
|
||||||
],
|
|
||||||
collectCoverageFrom: ['src/utils/**/*.{js,vue}', '!src/utils/auth.js', '!src/utils/request.js', 'src/components/**/*.{js,vue}'],
|
|
||||||
coverageDirectory: '<rootDir>/tests/unit/coverage',
|
|
||||||
// 'collectCoverage': true,
|
|
||||||
'coverageReporters': [
|
|
||||||
'lcov',
|
|
||||||
'text-summary'
|
|
||||||
],
|
|
||||||
testURL: 'http://localhost/'
|
|
||||||
}
|
|
@@ -1,122 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
const check = function(pathToPackage) {
|
|
||||||
const path = require('path')
|
|
||||||
const Promise = require('bluebird')
|
|
||||||
const exec = Promise.promisify(require('child_process').exec)
|
|
||||||
const _ = require('lodash')
|
|
||||||
const fs = require('fs')
|
|
||||||
const jsonfile = require('jsonfile')
|
|
||||||
const validaterRules = require('./validatorRules')
|
|
||||||
const promiseHelpers = require('./promiseHelpers')
|
|
||||||
|
|
||||||
let engines
|
|
||||||
|
|
||||||
const checkerResult = {
|
|
||||||
status: 0,
|
|
||||||
message: '',
|
|
||||||
packages: []
|
|
||||||
}
|
|
||||||
|
|
||||||
const packageJsonPath = pathToPackage || path.join(process.cwd(), 'package.json')
|
|
||||||
try {
|
|
||||||
fs.accessSync(packageJsonPath)
|
|
||||||
engines = jsonfile.readFileSync(packageJsonPath).engines
|
|
||||||
} catch (ex) {
|
|
||||||
checkerResult.message = {
|
|
||||||
text: '✘ No package.json found in the current directory so I can\'t validate what you need!',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
checkerResult.status = -1
|
|
||||||
|
|
||||||
return Promise.resolve(checkerResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!engines) {
|
|
||||||
checkerResult.message = {
|
|
||||||
text: '✘ No engines found in package.json so I can\'t validate what you need!',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
checkerResult.status = -1
|
|
||||||
|
|
||||||
return Promise.resolve(checkerResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
const thingsToCheck = Object.getOwnPropertyNames(engines)
|
|
||||||
const validatorPromises = thingsToCheck.map(validate) // run the function over all items.
|
|
||||||
|
|
||||||
return promiseHelpers.allSettled(validatorPromises)
|
|
||||||
.then((inspections) => {
|
|
||||||
const environmentIsValid = _.every(inspections,
|
|
||||||
(inspection) => inspection.isFulfilled() && inspection.value())
|
|
||||||
|
|
||||||
if (environmentIsValid) {
|
|
||||||
checkerResult.message = {
|
|
||||||
text: 'Environment looks good!',
|
|
||||||
type: 'success'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
checkerResult.message = {
|
|
||||||
text: 'Environment is invalid!',
|
|
||||||
type: 'error'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return checkerResult
|
|
||||||
})
|
|
||||||
|
|
||||||
function validate(name) {
|
|
||||||
// find it in the validators
|
|
||||||
const validator = validaterRules[name]
|
|
||||||
|
|
||||||
if (validator === undefined) {
|
|
||||||
checkerResult.packages.push({
|
|
||||||
name: name,
|
|
||||||
validatorFound: false,
|
|
||||||
type: 'warn'
|
|
||||||
})
|
|
||||||
return Promise.resolve(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// call the validator and pass in the version we expect
|
|
||||||
return execAndCheck(validator, engines[name]).then((results) => {
|
|
||||||
if (results.result) {
|
|
||||||
checkerResult.packages.push({
|
|
||||||
name: name,
|
|
||||||
validatorFound: true,
|
|
||||||
expectedVersion: engines[name],
|
|
||||||
foundVersion: engines[name],
|
|
||||||
type: 'success'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
checkerResult.packages.push({
|
|
||||||
name: name,
|
|
||||||
validatorFound: true,
|
|
||||||
expectedVersion: engines[name],
|
|
||||||
foundVersion: results.reason.trim() || 'missing',
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve(results.result)
|
|
||||||
}).catch((error) => {
|
|
||||||
checkerResult.packages.push({
|
|
||||||
name: name,
|
|
||||||
validatorFound: true,
|
|
||||||
expectedVersion: engines[name],
|
|
||||||
commandError: error,
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
return Promise.reject()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function execAndCheck(validator, expectedVersion) {
|
|
||||||
return exec(validator.versionCheck).then((result) => {
|
|
||||||
return {
|
|
||||||
result: validator.versionValidate(result, expectedVersion),
|
|
||||||
reason: result
|
|
||||||
}
|
|
||||||
}).catch((e) => { throw e })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
module.exports = check
|
|
@@ -1,24 +0,0 @@
|
|||||||
const Promise = require('bluebird')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a promise that is resolved when all input promises have been
|
|
||||||
* settled. The returned Promise is resolved with an array of
|
|
||||||
* Promise.Inspection objects.
|
|
||||||
*
|
|
||||||
* This is the commonly accepted way of implementing allSettled() in Bluebird.
|
|
||||||
* See: http://bluebirdjs.com/docs/api/reflect.html
|
|
||||||
*
|
|
||||||
* @param promises - The array of input promises.
|
|
||||||
* @returns {Promise<Promise.Inspection[]>} A promise that will be resolved once
|
|
||||||
* all input Promises have settled. The returned Promise will be resolved with a
|
|
||||||
* corresponding array of Promise.Inspection objects.
|
|
||||||
*/
|
|
||||||
function allSettled(promises) {
|
|
||||||
'use strict'
|
|
||||||
const wrappedPromises = promises.map((curPromise) => curPromise.reflect())
|
|
||||||
return Promise.all(wrappedPromises)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
allSettled: allSettled
|
|
||||||
}
|
|
@@ -1,141 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
const semver = require('semver')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
osx: {
|
|
||||||
versionCheck: 'sw_vers -productVersion',
|
|
||||||
versionValidate:
|
|
||||||
(detectedVersion, expectedVersion) => expectedVersion === detectedVersion.trim()
|
|
||||||
},
|
|
||||||
node: {
|
|
||||||
versionCheck: 'node -v',
|
|
||||||
versionValidate:
|
|
||||||
(detectedVersion, expectedVersion) => semver.satisfies(detectedVersion, expectedVersion)
|
|
||||||
},
|
|
||||||
npm: {
|
|
||||||
versionCheck: 'npm -v',
|
|
||||||
versionValidate:
|
|
||||||
(detectedVersion, expectedVersion) => semver.satisfies(detectedVersion, expectedVersion)
|
|
||||||
},
|
|
||||||
jx: {
|
|
||||||
versionCheck: 'jx -jxv',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => 'v' + version === result.trim()
|
|
||||||
},
|
|
||||||
cordova: {
|
|
||||||
versionCheck: 'cordova -v',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
appium: {
|
|
||||||
versionCheck: 'appium -v',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
'ios-deploy': {
|
|
||||||
versionCheck: 'ios-deploy -V',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
'ios-sim': {
|
|
||||||
versionCheck: 'ios-sim --version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
bower: {
|
|
||||||
versionCheck: 'bower -v',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => semver.satisfies(result, version)
|
|
||||||
},
|
|
||||||
'ios-webkit-debug-proxy': {
|
|
||||||
versionCheck: 'brew list ios-webkit-debug-proxy --versions',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
|
|
||||||
},
|
|
||||||
'ideviceinstaller': {
|
|
||||||
versionCheck: 'brew list ideviceinstaller --versions',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
java: {
|
|
||||||
versionCheck: 'javac -version 2>&1',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
ant: {
|
|
||||||
versionCheck: 'ant -version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
adb: {
|
|
||||||
versionCheck: 'adb version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
git: {
|
|
||||||
versionCheck: 'git --version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => {
|
|
||||||
// http://stackoverflow.com/questions/82064/a-regex-for-version-number-parsing
|
|
||||||
const found = result.match(/(\d+\.)?(\d+\.)?(\d+)/i)
|
|
||||||
return found[0] === version
|
|
||||||
}
|
|
||||||
},
|
|
||||||
windows: {
|
|
||||||
versionCheck: 'ver',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
'gulp-cli': {
|
|
||||||
versionCheck: 'npm list --depth=0 -g |grep gulp-cli',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
cocoapods: {
|
|
||||||
versionCheck: 'pod --version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
xcodebuild: {
|
|
||||||
versionCheck: 'xcodebuild -version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
carthage: {
|
|
||||||
versionCheck: 'carthage version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
xcpretty: {
|
|
||||||
versionCheck: 'xcpretty -v',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
},
|
|
||||||
libimobiledevice: {
|
|
||||||
versionCheck: 'brew list --versions |grep libimobiledevice',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
'deviceconsole': {
|
|
||||||
versionCheck: 'npm list --depth=0 -g |grep deviceconsole',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
'check-engine': {
|
|
||||||
versionCheck: 'npm list --depth=0 -g |grep check-engine',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => result.includes(version)
|
|
||||||
},
|
|
||||||
yarn: {
|
|
||||||
versionCheck: 'yarn -v',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => semver.satisfies(result, version)
|
|
||||||
},
|
|
||||||
nsp: {
|
|
||||||
versionCheck: 'nsp --version',
|
|
||||||
versionValidate:
|
|
||||||
(result, version) => version === result.trim()
|
|
||||||
}
|
|
||||||
}
|
|
116
mock/article.js
116
mock/article.js
@@ -1,116 +0,0 @@
|
|||||||
import Mock from 'mockjs'
|
|
||||||
|
|
||||||
const List = []
|
|
||||||
const count = 100
|
|
||||||
|
|
||||||
const baseContent = '<p>我是测试数据我是测试数据</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
|
|
||||||
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
|
|
||||||
|
|
||||||
for (let i = 0; i < count; i++) {
|
|
||||||
List.push(Mock.mock({
|
|
||||||
id: '@increment',
|
|
||||||
timestamp: +Mock.Random.date('T'),
|
|
||||||
author: '@first',
|
|
||||||
reviewer: '@first',
|
|
||||||
title: '@title(5, 10)',
|
|
||||||
content_short: 'mock data',
|
|
||||||
content: baseContent,
|
|
||||||
forecast: '@float(0, 100, 2, 2)',
|
|
||||||
importance: '@integer(1, 3)',
|
|
||||||
'type|1': ['CN', 'US', 'JP', 'EU'],
|
|
||||||
'status|1': ['published', 'draft', 'deleted'],
|
|
||||||
display_time: '@datetime',
|
|
||||||
comment_disabled: true,
|
|
||||||
pageviews: '@integer(300, 5000)',
|
|
||||||
image_uri,
|
|
||||||
platforms: ['a-platform']
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
url: '/article/list',
|
|
||||||
type: 'get',
|
|
||||||
response: config => {
|
|
||||||
const { importance, type, title, page = 1, limit = 20, sort } = config.query
|
|
||||||
|
|
||||||
let mockList = List.filter(item => {
|
|
||||||
if (importance && item.importance !== +importance) return false
|
|
||||||
if (type && item.type !== type) return false
|
|
||||||
if (title && item.title.indexOf(title) < 0) return false
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
if (sort === '-id') {
|
|
||||||
mockList = mockList.reverse()
|
|
||||||
}
|
|
||||||
|
|
||||||
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
|
|
||||||
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: {
|
|
||||||
total: mockList.length,
|
|
||||||
items: pageList
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
url: '/article/detail',
|
|
||||||
type: 'get',
|
|
||||||
response: config => {
|
|
||||||
const { id } = config.query
|
|
||||||
for (const article of List) {
|
|
||||||
if (article.id === +id) {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: article
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
url: '/article/pv',
|
|
||||||
type: 'get',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: {
|
|
||||||
pvData: [
|
|
||||||
{ key: 'PC', pv: 1024 },
|
|
||||||
{ key: 'mobile', pv: 1024 },
|
|
||||||
{ key: 'ios', pv: 1024 },
|
|
||||||
{ key: 'android', pv: 1024 }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
url: '/article/create',
|
|
||||||
type: 'post',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: 'success'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
url: '/article/update',
|
|
||||||
type: 'post',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: 'success'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@@ -1,53 +0,0 @@
|
|||||||
import Mock from 'mockjs'
|
|
||||||
import mocks from './mocks'
|
|
||||||
import { param2Obj } from '../src/utils'
|
|
||||||
|
|
||||||
const MOCK_API_BASE = '/mock'
|
|
||||||
|
|
||||||
export function mockXHR() {
|
|
||||||
// 修复在使用 MockJS 情况下,设置 withCredentials = true,且未被拦截的跨域请求丢失 Cookies 的问题
|
|
||||||
// https://github.com/nuysoft/Mock/issues/300
|
|
||||||
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
|
|
||||||
Mock.XHR.prototype.send = function() {
|
|
||||||
if (this.custom.xhr) {
|
|
||||||
this.custom.xhr.withCredentials = this.withCredentials || false
|
|
||||||
}
|
|
||||||
this.proxy_send(...arguments)
|
|
||||||
}
|
|
||||||
|
|
||||||
function XHR2ExpressReqWrap(respond) {
|
|
||||||
return function(options) {
|
|
||||||
let result = null
|
|
||||||
if (respond instanceof Function) {
|
|
||||||
const { body, type, url } = options
|
|
||||||
// https://expressjs.com/en/4x/api.html#req
|
|
||||||
result = respond({
|
|
||||||
method: type,
|
|
||||||
body: JSON.parse(body),
|
|
||||||
query: param2Obj(url)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
result = respond
|
|
||||||
}
|
|
||||||
return Mock.mock(result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const i of mocks) {
|
|
||||||
Mock.mock(new RegExp(i.url), i.type || 'get', XHR2ExpressReqWrap(i.response))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const responseFake = (url, type, respond) => {
|
|
||||||
return {
|
|
||||||
url: new RegExp(`${MOCK_API_BASE}${url}`),
|
|
||||||
type: type || 'get',
|
|
||||||
response(req, res) {
|
|
||||||
res.json(Mock.mock(respond instanceof Function ? respond(req, res) : respond))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default mocks.map(route => {
|
|
||||||
return responseFake(route.url, route.type, route.response)
|
|
||||||
})
|
|
@@ -1,12 +0,0 @@
|
|||||||
import user from './user'
|
|
||||||
import role from './role'
|
|
||||||
import article from './article'
|
|
||||||
import search from './remoteSearch'
|
|
||||||
|
|
||||||
export default [
|
|
||||||
...user,
|
|
||||||
...role,
|
|
||||||
...article,
|
|
||||||
...search
|
|
||||||
]
|
|
||||||
|
|
@@ -1,51 +0,0 @@
|
|||||||
import Mock from 'mockjs'
|
|
||||||
|
|
||||||
const NameList = []
|
|
||||||
const count = 100
|
|
||||||
|
|
||||||
for (let i = 0; i < count; i++) {
|
|
||||||
NameList.push(Mock.mock({
|
|
||||||
name: '@first'
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
NameList.push({ name: 'mock-Pan' })
|
|
||||||
|
|
||||||
export default [
|
|
||||||
// username search
|
|
||||||
{
|
|
||||||
url: '/search/user',
|
|
||||||
type: 'get',
|
|
||||||
response: config => {
|
|
||||||
const { name } = config.query
|
|
||||||
const mockNameList = NameList.filter(item => {
|
|
||||||
const lowerCaseName = item.name.toLowerCase()
|
|
||||||
return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: { items: mockNameList }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// transaction list
|
|
||||||
{
|
|
||||||
url: '/transaction/list',
|
|
||||||
type: 'get',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: {
|
|
||||||
total: 20,
|
|
||||||
'items|20': [{
|
|
||||||
order_no: '@guid()',
|
|
||||||
timestamp: +Mock.Random.date('T'),
|
|
||||||
username: '@name()',
|
|
||||||
price: '@float(1000, 15000, 0, 2)',
|
|
||||||
'status|1': ['success', 'pending']
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
@@ -1,98 +0,0 @@
|
|||||||
import Mock from 'mockjs'
|
|
||||||
import { deepClone } from '../../src/utils/index.js'
|
|
||||||
import { asyncRoutes, constantRoutes } from './routes.js'
|
|
||||||
|
|
||||||
const routes = deepClone([...constantRoutes, ...asyncRoutes])
|
|
||||||
|
|
||||||
const roles = [
|
|
||||||
{
|
|
||||||
key: 'admin',
|
|
||||||
name: 'admin',
|
|
||||||
description: 'Super Administrator. Have access to view all pages.',
|
|
||||||
routes: routes
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'editor',
|
|
||||||
name: 'editor',
|
|
||||||
description: 'Normal Editor. Can see all pages except permission page',
|
|
||||||
routes: routes.filter(i => i.path !== '/permission')// just a mock
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'visitor',
|
|
||||||
name: 'visitor',
|
|
||||||
description: 'Just a visitor. Can only see the home page and the document page',
|
|
||||||
routes: [{
|
|
||||||
path: '',
|
|
||||||
redirect: 'dashboard',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'dashboard',
|
|
||||||
name: 'Dashboard',
|
|
||||||
meta: { title: 'dashboard', icon: 'dashboard' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
export default [
|
|
||||||
// mock get all routes form server
|
|
||||||
{
|
|
||||||
url: '/routes',
|
|
||||||
type: 'get',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: routes
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// mock get all roles form server
|
|
||||||
{
|
|
||||||
url: '/roles',
|
|
||||||
type: 'get',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: roles
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// add role
|
|
||||||
{
|
|
||||||
url: '/role',
|
|
||||||
type: 'post',
|
|
||||||
response: {
|
|
||||||
code: 20000,
|
|
||||||
data: {
|
|
||||||
key: Mock.mock('@integer(300, 5000)')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// update role
|
|
||||||
{
|
|
||||||
url: '/role/[A-Za-z0-9]',
|
|
||||||
type: 'put',
|
|
||||||
response: {
|
|
||||||
code: 20000,
|
|
||||||
data: {
|
|
||||||
status: 'success'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// delete role
|
|
||||||
{
|
|
||||||
url: '/role/[A-Za-z0-9]',
|
|
||||||
type: 'delete',
|
|
||||||
response: {
|
|
||||||
code: 20000,
|
|
||||||
data: {
|
|
||||||
status: 'success'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
@@ -1,525 +0,0 @@
|
|||||||
// Just a mock data
|
|
||||||
|
|
||||||
export const constantRoutes = [
|
|
||||||
{
|
|
||||||
path: '/redirect',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
hidden: true,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: '/redirect/:path*',
|
|
||||||
component: 'views/redirect/index'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/login',
|
|
||||||
component: 'views/login/index',
|
|
||||||
hidden: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/auth-redirect',
|
|
||||||
component: 'views/login/authredirect',
|
|
||||||
hidden: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/404',
|
|
||||||
component: 'views/errorPage/404',
|
|
||||||
hidden: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/401',
|
|
||||||
component: 'views/errorPage/401',
|
|
||||||
hidden: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'dashboard',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'dashboard',
|
|
||||||
component: 'views/dashboard/index',
|
|
||||||
name: 'Dashboard',
|
|
||||||
meta: { title: 'dashboard', icon: 'dashboard', noCache: true, affix: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/documentation',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/documentation/index',
|
|
||||||
name: 'Documentation',
|
|
||||||
meta: { title: 'documentation', icon: 'documentation', affix: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/guide',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/guide/index',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/guide/index',
|
|
||||||
name: 'Guide',
|
|
||||||
meta: { title: 'guide', icon: 'guide', noCache: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
export const asyncRoutes = [
|
|
||||||
{
|
|
||||||
path: '/permission',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/permission/index',
|
|
||||||
alwaysShow: true,
|
|
||||||
meta: {
|
|
||||||
title: 'permission',
|
|
||||||
icon: 'lock',
|
|
||||||
roles: ['admin', 'editor']
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'page',
|
|
||||||
component: 'views/permission/page',
|
|
||||||
name: 'PagePermission',
|
|
||||||
meta: {
|
|
||||||
title: 'pagePermission',
|
|
||||||
roles: ['admin']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'directive',
|
|
||||||
component: 'views/permission/directive',
|
|
||||||
name: 'DirectivePermission',
|
|
||||||
meta: {
|
|
||||||
title: 'directivePermission'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'role',
|
|
||||||
component: 'views/permission/role',
|
|
||||||
name: 'RolePermission',
|
|
||||||
meta: {
|
|
||||||
title: 'rolePermission',
|
|
||||||
roles: ['admin']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/icon',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/svg-icons/index',
|
|
||||||
name: 'Icons',
|
|
||||||
meta: { title: 'icons', icon: 'icon', noCache: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/components',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'noredirect',
|
|
||||||
name: 'ComponentDemo',
|
|
||||||
meta: {
|
|
||||||
title: 'components',
|
|
||||||
icon: 'component'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'tinymce',
|
|
||||||
component: 'views/components-demo/tinymce',
|
|
||||||
name: 'TinymceDemo',
|
|
||||||
meta: { title: 'tinymce' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'markdown',
|
|
||||||
component: 'views/components-demo/markdown',
|
|
||||||
name: 'MarkdownDemo',
|
|
||||||
meta: { title: 'markdown' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'json-editor',
|
|
||||||
component: 'views/components-demo/jsonEditor',
|
|
||||||
name: 'JsonEditorDemo',
|
|
||||||
meta: { title: 'jsonEditor' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'splitpane',
|
|
||||||
component: 'views/components-demo/splitpane',
|
|
||||||
name: 'SplitpaneDemo',
|
|
||||||
meta: { title: 'splitPane' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'avatar-upload',
|
|
||||||
component: 'views/components-demo/avatarUpload',
|
|
||||||
name: 'AvatarUploadDemo',
|
|
||||||
meta: { title: 'avatarUpload' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'dropzone',
|
|
||||||
component: 'views/components-demo/dropzone',
|
|
||||||
name: 'DropzoneDemo',
|
|
||||||
meta: { title: 'dropzone' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'sticky',
|
|
||||||
component: 'views/components-demo/sticky',
|
|
||||||
name: 'StickyDemo',
|
|
||||||
meta: { title: 'sticky' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'count-to',
|
|
||||||
component: 'views/components-demo/countTo',
|
|
||||||
name: 'CountToDemo',
|
|
||||||
meta: { title: 'countTo' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'mixin',
|
|
||||||
component: 'views/components-demo/mixin',
|
|
||||||
name: 'ComponentMixinDemo',
|
|
||||||
meta: { title: 'componentMixin' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'back-to-top',
|
|
||||||
component: 'views/components-demo/backToTop',
|
|
||||||
name: 'BackToTopDemo',
|
|
||||||
meta: { title: 'backToTop' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'drag-dialog',
|
|
||||||
component: 'views/components-demo/dragDialog',
|
|
||||||
name: 'DragDialogDemo',
|
|
||||||
meta: { title: 'dragDialog' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'drag-select',
|
|
||||||
component: 'views/components-demo/dragSelect',
|
|
||||||
name: 'DragSelectDemo',
|
|
||||||
meta: { title: 'dragSelect' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'dnd-list',
|
|
||||||
component: 'views/components-demo/dndList',
|
|
||||||
name: 'DndListDemo',
|
|
||||||
meta: { title: 'dndList' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'drag-kanban',
|
|
||||||
component: 'views/components-demo/dragKanban',
|
|
||||||
name: 'DragKanbanDemo',
|
|
||||||
meta: { title: 'dragKanban' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/charts',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'noredirect',
|
|
||||||
name: 'Charts',
|
|
||||||
meta: {
|
|
||||||
title: 'charts',
|
|
||||||
icon: 'chart'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'keyboard',
|
|
||||||
component: 'views/charts/keyboard',
|
|
||||||
name: 'KeyboardChart',
|
|
||||||
meta: { title: 'keyboardChart', noCache: true }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'line',
|
|
||||||
component: 'views/charts/line',
|
|
||||||
name: 'LineChart',
|
|
||||||
meta: { title: 'lineChart', noCache: true }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'mixchart',
|
|
||||||
component: 'views/charts/mixChart',
|
|
||||||
name: 'MixChart',
|
|
||||||
meta: { title: 'mixChart', noCache: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/nested',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/nested/menu1/menu1-1',
|
|
||||||
name: 'Nested',
|
|
||||||
meta: {
|
|
||||||
title: 'nested',
|
|
||||||
icon: 'nested'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'menu1',
|
|
||||||
component: 'views/nested/menu1/index',
|
|
||||||
name: 'Menu1',
|
|
||||||
meta: { title: 'menu1' },
|
|
||||||
redirect: '/nested/menu1/menu1-1',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'menu1-1',
|
|
||||||
component: 'views/nested/menu1/menu1-1',
|
|
||||||
name: 'Menu1-1',
|
|
||||||
meta: { title: 'menu1-1' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'menu1-2',
|
|
||||||
component: 'views/nested/menu1/menu1-2',
|
|
||||||
name: 'Menu1-2',
|
|
||||||
redirect: '/nested/menu1/menu1-2/menu1-2-1',
|
|
||||||
meta: { title: 'menu1-2' },
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'menu1-2-1',
|
|
||||||
component: 'views/nested/menu1/menu1-2/menu1-2-1',
|
|
||||||
name: 'Menu1-2-1',
|
|
||||||
meta: { title: 'menu1-2-1' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'menu1-2-2',
|
|
||||||
component: 'views/nested/menu1/menu1-2/menu1-2-2',
|
|
||||||
name: 'Menu1-2-2',
|
|
||||||
meta: { title: 'menu1-2-2' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'menu1-3',
|
|
||||||
component: 'views/nested/menu1/menu1-3',
|
|
||||||
name: 'Menu1-3',
|
|
||||||
meta: { title: 'menu1-3' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'menu2',
|
|
||||||
name: 'Menu2',
|
|
||||||
component: 'views/nested/menu2/index',
|
|
||||||
meta: { title: 'menu2' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/example',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/example/list',
|
|
||||||
name: 'Example',
|
|
||||||
meta: {
|
|
||||||
title: 'example',
|
|
||||||
icon: 'example'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'create',
|
|
||||||
component: 'views/example/create',
|
|
||||||
name: 'CreateArticle',
|
|
||||||
meta: { title: 'createArticle', icon: 'edit' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'edit/:id(\\d+)',
|
|
||||||
component: 'views/example/edit',
|
|
||||||
name: 'EditArticle',
|
|
||||||
meta: { title: 'editArticle', noCache: true },
|
|
||||||
hidden: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'list',
|
|
||||||
component: 'views/example/list',
|
|
||||||
name: 'ArticleList',
|
|
||||||
meta: { title: 'articleList', icon: 'list' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/tab',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/tab/index',
|
|
||||||
name: 'Tab',
|
|
||||||
meta: { title: 'tab', icon: 'tab' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/error',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'noredirect',
|
|
||||||
name: 'ErrorPages',
|
|
||||||
meta: {
|
|
||||||
title: 'errorPages',
|
|
||||||
icon: '404'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: '401',
|
|
||||||
component: 'views/errorPage/401',
|
|
||||||
name: 'Page401',
|
|
||||||
meta: { title: 'page401', noCache: true }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '404',
|
|
||||||
component: 'views/errorPage/404',
|
|
||||||
name: 'Page404',
|
|
||||||
meta: { title: 'page404', noCache: true }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/error-log',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'noredirect',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'log',
|
|
||||||
component: 'views/errorLog/index',
|
|
||||||
name: 'ErrorLog',
|
|
||||||
meta: { title: 'errorLog', icon: 'bug' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/excel',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/excel/export-excel',
|
|
||||||
name: 'Excel',
|
|
||||||
meta: {
|
|
||||||
title: 'excel',
|
|
||||||
icon: 'excel'
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'export-excel',
|
|
||||||
component: 'views/excel/exportExcel',
|
|
||||||
name: 'ExportExcel',
|
|
||||||
meta: { title: 'exportExcel' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'export-selected-excel',
|
|
||||||
component: 'views/excel/selectExcel',
|
|
||||||
name: 'SelectExcel',
|
|
||||||
meta: { title: 'selectExcel' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'export-merge-header',
|
|
||||||
component: 'views/excel/mergeHeader',
|
|
||||||
name: 'MergeHeader',
|
|
||||||
meta: { title: 'mergeHeader' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'upload-excel',
|
|
||||||
component: 'views/excel/uploadExcel',
|
|
||||||
name: 'UploadExcel',
|
|
||||||
meta: { title: 'uploadExcel' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/zip',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/zip/download',
|
|
||||||
alwaysShow: true,
|
|
||||||
meta: { title: 'zip', icon: 'zip' },
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'download',
|
|
||||||
component: 'views/zip/index',
|
|
||||||
name: 'ExportZip',
|
|
||||||
meta: { title: 'exportZip' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/pdf',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: '/pdf/index',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/pdf/index',
|
|
||||||
name: 'PDF',
|
|
||||||
meta: { title: 'pdf', icon: 'pdf' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/pdf/download',
|
|
||||||
component: 'views/pdf/download',
|
|
||||||
hidden: true
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/theme',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'noredirect',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/theme/index',
|
|
||||||
name: 'Theme',
|
|
||||||
meta: { title: 'theme', icon: 'theme' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/clipboard',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
redirect: 'noredirect',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/clipboard/index',
|
|
||||||
name: 'ClipboardDemo',
|
|
||||||
meta: { title: 'clipboardDemo', icon: 'clipboard' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: '/i18n',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
component: 'views/i18n-demo/index',
|
|
||||||
name: 'I18n',
|
|
||||||
meta: { title: 'i18n', icon: 'international' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
path: 'external-link',
|
|
||||||
component: 'layout/Layout',
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'https://github.com/PanJiaChen/vue-element-admin',
|
|
||||||
meta: { title: 'externalLink', icon: 'link' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
{ path: '*', redirect: '/404', hidden: true }
|
|
||||||
]
|
|
64
mock/user.js
64
mock/user.js
@@ -1,64 +0,0 @@
|
|||||||
|
|
||||||
const tokens = {
|
|
||||||
admin: {
|
|
||||||
token: 'admin-token'
|
|
||||||
},
|
|
||||||
editor: {
|
|
||||||
token: 'editor-token'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const users = {
|
|
||||||
'admin-token': {
|
|
||||||
roles: ['admin'],
|
|
||||||
introduction: 'I am a super administrator',
|
|
||||||
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
|
||||||
name: 'Super Admin'
|
|
||||||
},
|
|
||||||
'editor-token': {
|
|
||||||
roles: ['editor'],
|
|
||||||
introduction: 'I am an editor',
|
|
||||||
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
|
|
||||||
name: 'Normal Editor'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default [
|
|
||||||
// user login
|
|
||||||
{
|
|
||||||
url: '/user/login',
|
|
||||||
type: 'post',
|
|
||||||
response: config => {
|
|
||||||
const { username } = config.body
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: tokens[username]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// get user info
|
|
||||||
{
|
|
||||||
url: '/user/info\.*',
|
|
||||||
type: 'get',
|
|
||||||
response: config => {
|
|
||||||
const { token } = config.query
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: users[token]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// user logout
|
|
||||||
{
|
|
||||||
url: '/user/logout',
|
|
||||||
type: 'post',
|
|
||||||
response: _ => {
|
|
||||||
return {
|
|
||||||
code: 20000,
|
|
||||||
data: 'success'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
128
package.json
128
package.json
@@ -1,25 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-element-admin",
|
"name": "vue-element-admin",
|
||||||
"version": "4.0.0",
|
"version": "3.11.0",
|
||||||
"description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features",
|
"description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features",
|
||||||
"author": "Pan <panfree23@gmail.com>",
|
"author": "Pan <panfree23@gmail.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vue-cli-service serve",
|
"dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
|
||||||
"build:prod": "vue-cli-service build",
|
"build:prod": "cross-env NODE_ENV=production env_config=prod node build/build.js",
|
||||||
"build:stage": "vue-cli-service build --mode staging",
|
"build:sit": "cross-env NODE_ENV=production env_config=sit node build/build.js",
|
||||||
"build:preview": "node build/index.js --preview",
|
|
||||||
"build:report": "node build/index.js --report",
|
|
||||||
"lint": "eslint --ext .js,.vue src",
|
"lint": "eslint --ext .js,.vue src",
|
||||||
"test": "npm run lint",
|
"test": "npm run lint",
|
||||||
"test:unit": "vue-cli-service test:unit",
|
"precommit": "lint-staged",
|
||||||
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
|
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
|
||||||
"new": "plop"
|
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "lint-staged"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"src/**/*.{js,vue}": [
|
"src/**/*.{js,vue}": [
|
||||||
@@ -44,62 +36,92 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "0.18.0",
|
"axios": "0.18.0",
|
||||||
"clipboard": "1.7.1",
|
"clipboard": "1.7.1",
|
||||||
"codemirror": "5.44.0",
|
"codemirror": "5.39.2",
|
||||||
"driver.js": "0.9.5",
|
"driver.js": "0.8.1",
|
||||||
"dropzone": "5.5.1",
|
"dropzone": "5.2.0",
|
||||||
"echarts": "4.1.0",
|
"echarts": "4.1.0",
|
||||||
"element-ui": "2.6.1",
|
"element-ui": "2.4.11",
|
||||||
"file-saver": "2.0.1",
|
"file-saver": "1.3.8",
|
||||||
"fuse.js": "3.4.4",
|
"fuse.js": "3.4.2",
|
||||||
"js-cookie": "2.2.0",
|
"js-cookie": "2.2.0",
|
||||||
"jsonlint": "1.6.3",
|
"jsonlint": "1.6.3",
|
||||||
"jszip": "3.2.0",
|
"jszip": "3.1.5",
|
||||||
|
"mockjs": "1.0.1-beta3",
|
||||||
"normalize.css": "7.0.0",
|
"normalize.css": "7.0.0",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"path-to-regexp": "2.4.0",
|
"screenfull": "4.0.0",
|
||||||
"screenfull": "4.0.1",
|
"showdown": "1.8.6",
|
||||||
"showdown": "1.9.0",
|
"sortablejs": "1.7.0",
|
||||||
"sortablejs": "1.8.3",
|
"tui-editor": "1.2.7",
|
||||||
"tui-editor": "1.3.2",
|
"vue": "2.5.17",
|
||||||
"vue": "2.6.8",
|
|
||||||
"vue-count-to": "1.0.13",
|
"vue-count-to": "1.0.13",
|
||||||
"vue-i18n": "7.3.2",
|
"vue-i18n": "7.3.2",
|
||||||
"vue-router": "3.0.2",
|
"vue-router": "3.0.2",
|
||||||
"vue-splitpane": "1.0.2",
|
"vue-splitpane": "1.0.2",
|
||||||
"vuedraggable": "2.17.0",
|
"vuedraggable": "^2.16.0",
|
||||||
"vuex": "3.1.0",
|
"vuex": "3.0.1",
|
||||||
"xlsx": "0.14.1"
|
"xlsx": "^0.11.16"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.0.0",
|
"autoprefixer": "8.5.0",
|
||||||
"@babel/register": "7.0.0",
|
"babel-core": "6.26.3",
|
||||||
"@vue/cli-plugin-babel": "3.5.0",
|
"babel-eslint": "8.2.6",
|
||||||
"@vue/cli-plugin-unit-jest": "3.5.0",
|
"babel-helper-vue-jsx-merge-props": "2.0.3",
|
||||||
"@vue/cli-service": "3.5.0",
|
"babel-loader": "7.1.5",
|
||||||
"@vue/test-utils": "1.0.0-beta.29",
|
"babel-plugin-dynamic-import-node": "2.0.0",
|
||||||
"babel-core": "7.0.0-bridge.0",
|
"babel-plugin-syntax-jsx": "6.18.0",
|
||||||
"babel-eslint": "10.0.1",
|
"babel-plugin-transform-runtime": "6.23.0",
|
||||||
"babel-jest": "23.6.0",
|
"babel-plugin-transform-vue-jsx": "3.7.0",
|
||||||
"chalk": "2.4.2",
|
"babel-preset-env": "1.7.0",
|
||||||
|
"babel-preset-stage-2": "6.24.1",
|
||||||
|
"chalk": "2.4.1",
|
||||||
|
"compression-webpack-plugin": "2.0.0",
|
||||||
"connect": "3.6.6",
|
"connect": "3.6.6",
|
||||||
"eslint": "5.15.1",
|
"copy-webpack-plugin": "4.5.2",
|
||||||
|
"cross-env": "5.2.0",
|
||||||
|
"css-loader": "1.0.0",
|
||||||
|
"eslint": "5.15.2",
|
||||||
|
"eslint-friendly-formatter": "4.0.1",
|
||||||
|
"eslint-loader": "2.1.2",
|
||||||
"eslint-plugin-vue": "5.2.2",
|
"eslint-plugin-vue": "5.2.2",
|
||||||
"husky": "1.3.1",
|
"file-loader": "1.1.11",
|
||||||
|
"friendly-errors-webpack-plugin": "1.7.0",
|
||||||
|
"hash-sum": "1.0.2",
|
||||||
|
"html-webpack-plugin": "4.0.0-alpha",
|
||||||
|
"husky": "0.14.3",
|
||||||
"lint-staged": "7.2.2",
|
"lint-staged": "7.2.2",
|
||||||
"mockjs": "1.0.1-beta3",
|
"mini-css-extract-plugin": "0.4.1",
|
||||||
"node-sass": "^4.9.0",
|
"node-notifier": "5.2.1",
|
||||||
"plop": "2.3.0",
|
"node-sass": "^4.7.2",
|
||||||
"runjs": "^4.3.2",
|
"optimize-css-assets-webpack-plugin": "5.0.0",
|
||||||
"sass-loader": "^7.1.0",
|
"ora": "3.0.0",
|
||||||
"script-ext-html-webpack-plugin": "2.1.3",
|
"path-to-regexp": "2.4.0",
|
||||||
|
"portfinder": "1.0.13",
|
||||||
|
"postcss-import": "11.1.0",
|
||||||
|
"postcss-loader": "2.1.6",
|
||||||
|
"postcss-url": "7.3.2",
|
||||||
|
"rimraf": "2.6.2",
|
||||||
|
"sass-loader": "7.0.3",
|
||||||
|
"script-ext-html-webpack-plugin": "2.0.1",
|
||||||
"script-loader": "0.7.2",
|
"script-loader": "0.7.2",
|
||||||
"serve-static": "^1.13.2",
|
"semver": "5.5.0",
|
||||||
"svg-sprite-loader": "4.1.3",
|
"serve-static": "1.13.2",
|
||||||
"svgo": "1.2.0",
|
"shelljs": "0.8.2",
|
||||||
"vue-template-compiler": "2.6.8"
|
"svg-sprite-loader": "3.8.0",
|
||||||
|
"svgo": "1.0.5",
|
||||||
|
"uglifyjs-webpack-plugin": "1.2.7",
|
||||||
|
"url-loader": "1.0.1",
|
||||||
|
"vue-loader": "15.3.0",
|
||||||
|
"vue-style-loader": "4.1.2",
|
||||||
|
"vue-template-compiler": "2.5.17",
|
||||||
|
"webpack": "4.16.5",
|
||||||
|
"webpack-bundle-analyzer": "2.13.1",
|
||||||
|
"webpack-cli": "3.1.0",
|
||||||
|
"webpack-dev-server": "3.1.14",
|
||||||
|
"webpack-merge": "4.1.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.9",
|
"node": ">= 6.0.0",
|
||||||
"npm": ">= 3.0.0"
|
"npm": ">= 3.0.0"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
{{#if template}}
|
|
||||||
<template>
|
|
||||||
<div />
|
|
||||||
</template>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if script}}
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: '{{ properCase name }}',
|
|
||||||
props: {},
|
|
||||||
data() {
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
created() {},
|
|
||||||
mounted() {},
|
|
||||||
methods: {}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if style}}
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
{{/if}}
|
|
@@ -1,55 +0,0 @@
|
|||||||
const { notEmpty } = require('../utils.js')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
description: 'generate vue component',
|
|
||||||
prompts: [{
|
|
||||||
type: 'input',
|
|
||||||
name: 'name',
|
|
||||||
message: 'component name please',
|
|
||||||
validate: notEmpty('name')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'checkbox',
|
|
||||||
name: 'blocks',
|
|
||||||
message: 'Blocks:',
|
|
||||||
choices: [{
|
|
||||||
name: '<template>',
|
|
||||||
value: 'template',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '<script>',
|
|
||||||
value: 'script',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'style',
|
|
||||||
value: 'style',
|
|
||||||
checked: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
validate(value) {
|
|
||||||
if (value.indexOf('script') === -1 && value.indexOf('template') === -1) {
|
|
||||||
return 'Components require at least a <script> or <template> tag.'
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
actions: data => {
|
|
||||||
const name = '{{properCase name}}'
|
|
||||||
const actions = [{
|
|
||||||
type: 'add',
|
|
||||||
path: `src/components/${name}/index.vue`,
|
|
||||||
templateFile: 'plop-templates/component/index.hbs',
|
|
||||||
data: {
|
|
||||||
name: name,
|
|
||||||
template: data.blocks.includes('template'),
|
|
||||||
script: data.blocks.includes('script'),
|
|
||||||
style: data.blocks.includes('style')
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
|
|
||||||
return actions
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,9 +0,0 @@
|
|||||||
exports.notEmpty = name => {
|
|
||||||
return v => {
|
|
||||||
if (!v || v.trim === '') {
|
|
||||||
return `${name} is required`
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
{{#if template}}
|
|
||||||
<template>
|
|
||||||
<div />
|
|
||||||
</template>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if script}}
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: '{{ properCase name }}',
|
|
||||||
props: {},
|
|
||||||
data() {
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
created() {},
|
|
||||||
mounted() {},
|
|
||||||
methods: {}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if style}}
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
{{/if}}
|
|
@@ -1,55 +0,0 @@
|
|||||||
const { notEmpty } = require('../utils.js')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
description: 'generate a view',
|
|
||||||
prompts: [{
|
|
||||||
type: 'input',
|
|
||||||
name: 'name',
|
|
||||||
message: 'view name please',
|
|
||||||
validate: notEmpty('name')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'checkbox',
|
|
||||||
name: 'blocks',
|
|
||||||
message: 'Blocks:',
|
|
||||||
choices: [{
|
|
||||||
name: '<template>',
|
|
||||||
value: 'template',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '<script>',
|
|
||||||
value: 'script',
|
|
||||||
checked: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'style',
|
|
||||||
value: 'style',
|
|
||||||
checked: true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
validate(value) {
|
|
||||||
if (value.indexOf('script') === -1 && value.indexOf('template') === -1) {
|
|
||||||
return 'View require at least a <script> or <template> tag.'
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
actions: data => {
|
|
||||||
const name = '{{name}}'
|
|
||||||
const actions = [{
|
|
||||||
type: 'add',
|
|
||||||
path: `src/views/${name}/index.vue`,
|
|
||||||
templateFile: 'plop-templates/view/index.hbs',
|
|
||||||
data: {
|
|
||||||
name: name,
|
|
||||||
template: data.blocks.includes('template'),
|
|
||||||
script: data.blocks.includes('script'),
|
|
||||||
style: data.blocks.includes('style')
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
|
|
||||||
return actions
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,7 +0,0 @@
|
|||||||
const viewGenerator = require('./plop-templates/view/prompt')
|
|
||||||
const componentGenerator = require('./plop-templates/component/prompt')
|
|
||||||
|
|
||||||
module.exports = function(plop) {
|
|
||||||
plop.setGenerator('view', viewGenerator)
|
|
||||||
plop.setGenerator('component', componentGenerator)
|
|
||||||
}
|
|
@@ -1,14 +1,25 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
export function login(data) {
|
export function loginByUsername(username, password) {
|
||||||
|
const data = {
|
||||||
|
username,
|
||||||
|
password
|
||||||
|
}
|
||||||
return request({
|
return request({
|
||||||
url: '/user/login',
|
url: '/login/login',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInfo(token) {
|
export function logout() {
|
||||||
|
return request({
|
||||||
|
url: '/login/logout',
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUserInfo(token) {
|
||||||
return request({
|
return request({
|
||||||
url: '/user/info',
|
url: '/user/info',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@@ -16,10 +27,3 @@ export function getInfo(token) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logout() {
|
|
||||||
return request({
|
|
||||||
url: '/user/logout',
|
|
||||||
method: 'post'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@@ -7,11 +7,3 @@ export function userSearch(name) {
|
|||||||
params: { name }
|
params: { name }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transactionList(query) {
|
|
||||||
return request({
|
|
||||||
url: '/transaction/list',
|
|
||||||
method: 'get',
|
|
||||||
params: query
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
@@ -14,25 +14,25 @@ export function getRoles() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function deleteRole(id) {
|
||||||
|
return request({
|
||||||
|
url: `/roles/${id}`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function addRole(data) {
|
export function addRole(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/role',
|
url: '/roles',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateRole(id, data) {
|
export function updateRole(key, data) {
|
||||||
return request({
|
return request({
|
||||||
url: `/role/${id}`,
|
url: `/roles/${key}`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deleteRole(id) {
|
|
||||||
return request({
|
|
||||||
url: `/role/${id}`,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
9
src/api/transaction.js
Normal file
9
src/api/transaction.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function fetchList(query) {
|
||||||
|
return request({
|
||||||
|
url: '/transaction/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
@@ -2,8 +2,9 @@
|
|||||||
<el-breadcrumb class="app-breadcrumb" separator="/">
|
<el-breadcrumb class="app-breadcrumb" separator="/">
|
||||||
<transition-group name="breadcrumb">
|
<transition-group name="breadcrumb">
|
||||||
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
|
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
|
||||||
<span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">{{
|
<span v-if="item.redirect==='noredirect'||index==levelList.length-1" class="no-redirect">
|
||||||
generateTitle(item.meta.title) }}</span>
|
{{ generateTitle(item.meta.title) }}
|
||||||
|
</span>
|
||||||
<a v-else @click.prevent="handleLink(item)">{{ generateTitle(item.meta.title) }}</a>
|
<a v-else @click.prevent="handleLink(item)">{{ generateTitle(item.meta.title) }}</a>
|
||||||
</el-breadcrumb-item>
|
</el-breadcrumb-item>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
|
@@ -4,9 +4,7 @@
|
|||||||
<h3>{{ list1Title }}</h3>
|
<h3>{{ list1Title }}</h3>
|
||||||
<draggable :list="list1" :options="{group:'article'}" class="dragArea">
|
<draggable :list="list1" :options="{group:'article'}" class="dragArea">
|
||||||
<div v-for="element in list1" :key="element.id" class="list-complete-item">
|
<div v-for="element in list1" :key="element.id" class="list-complete-item">
|
||||||
<div class="list-complete-item-handle">
|
<div class="list-complete-item-handle">{{ element.id }}[{{ element.author }}] {{ element.title }}</div>
|
||||||
{{ element.id }}[{{ element.author }}] {{ element.title }}
|
|
||||||
</div>
|
|
||||||
<div style="position:absolute;right:0px;">
|
<div style="position:absolute;right:0px;">
|
||||||
<span style="float: right ;margin-top: -20px;margin-right:5px;" @click="deleteEle(element)">
|
<span style="float: right ;margin-top: -20px;margin-right:5px;" @click="deleteEle(element)">
|
||||||
<i style="color:#ff4949" class="el-icon-delete" />
|
<i style="color:#ff4949" class="el-icon-delete" />
|
||||||
@@ -19,9 +17,7 @@
|
|||||||
<h3>{{ list2Title }}</h3>
|
<h3>{{ list2Title }}</h3>
|
||||||
<draggable :list="list2" :options="{group:'article'}" class="dragArea">
|
<draggable :list="list2" :options="{group:'article'}" class="dragArea">
|
||||||
<div v-for="element in list2" :key="element.id" class="list-complete-item">
|
<div v-for="element in list2" :key="element.id" class="list-complete-item">
|
||||||
<div class="list-complete-item-handle2" @click="pushEle(element)">
|
<div class="list-complete-item-handle2" @click="pushEle(element)">{{ element.id }} [{{ element.author }}] {{ element.title }}</div>
|
||||||
{{ element.id }} [{{ element.author }}] {{ element.title }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</draggable>
|
</draggable>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -12,23 +12,17 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<div>
|
<div>
|
||||||
<span class="message-title">Msg:</span>
|
<span class="message-title">Msg:</span>
|
||||||
<el-tag type="danger">
|
<el-tag type="danger">{{ scope.row.err.message }}</el-tag>
|
||||||
{{ scope.row.err.message }}
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<span class="message-title" style="padding-right: 10px;">Info: </span>
|
<span class="message-title" style="padding-right: 10px;">Info: </span>
|
||||||
<el-tag type="warning">
|
<el-tag type="warning">{{ scope.row.vm.$vnode.tag }} error in {{ scope.row.info }}</el-tag>
|
||||||
{{ scope.row.vm.$vnode.tag }} error in {{ scope.row.info }}
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<span class="message-title" style="padding-right: 16px;">Url: </span>
|
<span class="message-title" style="padding-right: 16px;">Url: </span>
|
||||||
<el-tag type="success">
|
<el-tag type="success">{{ scope.row.url }}</el-tag>
|
||||||
{{ scope.row.url }}
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -39,6 +33,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@@ -20,11 +20,10 @@ export default {
|
|||||||
isActive: {
|
isActive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
toggleClick: {
|
||||||
toggleClick() {
|
type: Function,
|
||||||
this.$emit('toggleClick')
|
default: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// fuse is a lightweight fuzzy-search module
|
|
||||||
// make search results more in line with expectations
|
|
||||||
import Fuse from 'fuse.js'
|
import Fuse from 'fuse.js'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import i18n from '@/lang'
|
import i18n from '@/lang'
|
||||||
|
@@ -27,7 +27,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
handleSetLanguage(lang) {
|
handleSetLanguage(lang) {
|
||||||
this.$i18n.locale = lang
|
this.$i18n.locale = lang
|
||||||
this.$store.dispatch('app/setLanguage', lang)
|
this.$store.dispatch('setLanguage', lang)
|
||||||
this.$message({
|
this.$message({
|
||||||
message: 'Switch Language Success',
|
message: 'Switch Language Success',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
|
@@ -1,137 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div ref="rightPanel" :class="{show:show}" class="rightPanel-container">
|
|
||||||
<div class="rightPanel-background" />
|
|
||||||
<div class="rightPanel">
|
|
||||||
<el-button class="handle-button" :style="{'top':buttonTop+'px'}" type="primary" circle :icon="show?'el-icon-close':'el-icon-setting'" @click="show=!show" />
|
|
||||||
<div class="rightPanel-items">
|
|
||||||
<slot />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { addClass, removeClass } from '@/utils'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'RightPanel',
|
|
||||||
props: {
|
|
||||||
clickNotClose: {
|
|
||||||
default: false,
|
|
||||||
type: Boolean
|
|
||||||
},
|
|
||||||
buttonTop: {
|
|
||||||
default: 240,
|
|
||||||
type: Number
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
show(value) {
|
|
||||||
if (value && !this.clickNotClose) {
|
|
||||||
this.addEventClick()
|
|
||||||
}
|
|
||||||
if (value) {
|
|
||||||
addClass(document.body, 'showRightPanel')
|
|
||||||
} else {
|
|
||||||
removeClass(document.body, 'showRightPanel')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.insertToBody()
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
const elx = this.$refs.rightPanel
|
|
||||||
elx.remove()
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addEventClick() {
|
|
||||||
window.addEventListener('click', this.closeSidebar)
|
|
||||||
},
|
|
||||||
closeSidebar(evt) {
|
|
||||||
const parent = evt.target.closest('.rightPanel')
|
|
||||||
if (!parent) {
|
|
||||||
this.show = false
|
|
||||||
window.removeEventListener('click', this.closeSidebar)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
insertToBody() {
|
|
||||||
const elx = this.$refs.rightPanel
|
|
||||||
const body = document.querySelector('body')
|
|
||||||
body.insertBefore(elx, body.firstChild)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.showRightPanel {
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
width: calc(100% - 15px);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
||||||
.rightPanel-background {
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity .3s cubic-bezier(.7, .3, .1, 1);
|
|
||||||
background: rgba(0, 0, 0, .2);
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
position: fixed;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rightPanel {
|
|
||||||
background: #fff;
|
|
||||||
z-index: 3000;
|
|
||||||
position: fixed;
|
|
||||||
height: 100vh;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 260px;
|
|
||||||
top: 0px;
|
|
||||||
left: 0px;
|
|
||||||
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, .05);
|
|
||||||
transition: all .25s cubic-bezier(.7, .3, .1, 1);
|
|
||||||
transform: translate(100%);
|
|
||||||
z-index: 40000;
|
|
||||||
left: auto;
|
|
||||||
right: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.show {
|
|
||||||
|
|
||||||
transition: all .3s cubic-bezier(.7, .3, .1, 1);
|
|
||||||
|
|
||||||
.rightPanel-background {
|
|
||||||
z-index: 20000;
|
|
||||||
opacity: 1;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rightPanel {
|
|
||||||
transform: translate(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.handle-button {
|
|
||||||
position: absolute;
|
|
||||||
left: -48px;
|
|
||||||
border-radius: 6px 0 0 6px !important;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
pointer-events: auto;
|
|
||||||
z-index: 0;
|
|
||||||
font-size: 24px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
@@ -5,8 +5,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value">
|
<el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value">
|
||||||
{{
|
{{ item.label }}
|
||||||
item.label }}
|
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
@@ -32,7 +31,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
handleSetSize(size) {
|
handleSetSize(size) {
|
||||||
this.$ELEMENT.size = size
|
this.$ELEMENT.size = size
|
||||||
this.$store.dispatch('app/setSize', size)
|
this.$store.dispatch('setSize', size)
|
||||||
this.refreshView()
|
this.refreshView()
|
||||||
this.$message({
|
this.$message({
|
||||||
message: 'Switch Size Success',
|
message: 'Switch Size Success',
|
||||||
@@ -41,7 +40,7 @@ export default {
|
|||||||
},
|
},
|
||||||
refreshView() {
|
refreshView() {
|
||||||
// In order to make the cached page re-rendered
|
// In order to make the cached page re-rendered
|
||||||
this.$store.dispatch('tagsView/delAllCachedViews', this.$route)
|
this.$store.dispatch('delAllCachedViews', this.$route)
|
||||||
|
|
||||||
const { fullPath } = this.$route
|
const { fullPath } = this.$route
|
||||||
|
|
||||||
|
@@ -20,21 +20,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
async theme(val) {
|
theme(val) {
|
||||||
const oldVal = this.theme
|
const oldVal = this.theme
|
||||||
if (typeof val !== 'string') return
|
if (typeof val !== 'string') return
|
||||||
const themeCluster = this.getThemeCluster(val.replace('#', ''))
|
const themeCluster = this.getThemeCluster(val.replace('#', ''))
|
||||||
const originalCluster = this.getThemeCluster(oldVal.replace('#', ''))
|
const originalCluster = this.getThemeCluster(oldVal.replace('#', ''))
|
||||||
console.log(themeCluster, originalCluster)
|
console.log(themeCluster, originalCluster)
|
||||||
|
|
||||||
const $message = this.$message({
|
|
||||||
message: ' Compiling the theme',
|
|
||||||
customClass: 'theme-message',
|
|
||||||
type: 'success',
|
|
||||||
duration: 0,
|
|
||||||
iconClass: 'el-icon-loading'
|
|
||||||
})
|
|
||||||
|
|
||||||
const getHandler = (variable, id) => {
|
const getHandler = (variable, id) => {
|
||||||
return () => {
|
return () => {
|
||||||
const originalCluster = this.getThemeCluster(ORIGINAL_THEME.replace('#', ''))
|
const originalCluster = this.getThemeCluster(ORIGINAL_THEME.replace('#', ''))
|
||||||
@@ -50,14 +41,14 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.chalk) {
|
|
||||||
const url = `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`
|
|
||||||
await this.getCSSString(url, 'chalk')
|
|
||||||
}
|
|
||||||
|
|
||||||
const chalkHandler = getHandler('chalk', 'chalk-style')
|
const chalkHandler = getHandler('chalk', 'chalk-style')
|
||||||
|
|
||||||
|
if (!this.chalk) {
|
||||||
|
const url = `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`
|
||||||
|
this.getCSSString(url, chalkHandler, 'chalk')
|
||||||
|
} else {
|
||||||
chalkHandler()
|
chalkHandler()
|
||||||
|
}
|
||||||
|
|
||||||
const styles = [].slice.call(document.querySelectorAll('style'))
|
const styles = [].slice.call(document.querySelectorAll('style'))
|
||||||
.filter(style => {
|
.filter(style => {
|
||||||
@@ -69,32 +60,39 @@ export default {
|
|||||||
if (typeof innerText !== 'string') return
|
if (typeof innerText !== 'string') return
|
||||||
style.innerText = this.updateStyle(innerText, originalCluster, themeCluster)
|
style.innerText = this.updateStyle(innerText, originalCluster, themeCluster)
|
||||||
})
|
})
|
||||||
|
this.$message({
|
||||||
$message.close()
|
message: '换肤成功',
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
updateStyle(style, oldCluster, newCluster) {
|
updateStyle(style, oldCluster, newCluster) {
|
||||||
let newStyle = style
|
const colorOverrides = [] // only capture color overides
|
||||||
oldCluster.forEach((color, index) => {
|
oldCluster.forEach((color, index) => {
|
||||||
newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index])
|
const value = newCluster[index]
|
||||||
|
const color_plain = color.replace(/([()])/g, '\\$1')
|
||||||
|
const repl = new RegExp(`(^|})([^{]+{[^{}]+)${color_plain}\\b([^}]*)(?=})`, 'gi')
|
||||||
|
const nestRepl = new RegExp(color_plain, 'ig') // for greed matching before the 'color'
|
||||||
|
let v
|
||||||
|
while ((v = repl.exec(style))) {
|
||||||
|
colorOverrides.push(v[2].replace(nestRepl, value) + value + v[3] + '}') // '}' not captured in the regexp repl to reserve it as locator-boundary
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return newStyle
|
return colorOverrides.join('')
|
||||||
},
|
},
|
||||||
|
|
||||||
getCSSString(url, variable) {
|
getCSSString(url, callback, variable) {
|
||||||
return new Promise(resolve => {
|
|
||||||
const xhr = new XMLHttpRequest()
|
const xhr = new XMLHttpRequest()
|
||||||
xhr.onreadystatechange = () => {
|
xhr.onreadystatechange = () => {
|
||||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||||
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '')
|
this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '')
|
||||||
resolve()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.open('GET', url)
|
xhr.open('GET', url)
|
||||||
xhr.send()
|
xhr.send()
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getThemeCluster(theme) {
|
getThemeCluster(theme) {
|
||||||
@@ -146,12 +144,8 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.theme-message,
|
|
||||||
.theme-picker-dropdown {
|
|
||||||
z-index: 99999 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-picker .el-color-picker__trigger {
|
.theme-picker .el-color-picker__trigger {
|
||||||
|
margin-top: 12px;
|
||||||
height: 26px!important;
|
height: 26px!important;
|
||||||
width: 26px!important;
|
width: 26px!important;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
|
@@ -15,16 +15,10 @@
|
|||||||
action="https://httpbin.org/post"
|
action="https://httpbin.org/post"
|
||||||
list-type="picture-card"
|
list-type="picture-card"
|
||||||
>
|
>
|
||||||
<el-button size="small" type="primary">
|
<el-button size="small" type="primary">点击上传</el-button>
|
||||||
点击上传
|
|
||||||
</el-button>
|
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<el-button @click="dialogVisible = false">
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
取 消
|
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
||||||
</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit">
|
|
||||||
确 定
|
|
||||||
</el-button>
|
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
220
src/components/TreeTable/readme.md
Normal file
220
src/components/TreeTable/readme.md
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
|
||||||
|
- [Enlgish](#Brief)
|
||||||
|
|
||||||
|
# 中文
|
||||||
|
|
||||||
|
## 写在前面
|
||||||
|
|
||||||
|
此组件仅提供一个创建 `TreeTable` 的解决思路。它基于`element-ui`的 table 组件实现,通过`el-table`的`row-style`方法,在里面判断元素是否需要隐藏或者显示,从而实现`TreeTable`的展开与收起。
|
||||||
|
|
||||||
|
并且本组件充分利用 `vue` 插槽的特性来方便用户自定义。
|
||||||
|
|
||||||
|
`evel.js` 里面,`addAttrs` 方法会给数据添加几个属性,`treeTotable` 会对数组扁平化。这些操作都不会破坏源数据,只是会新增属性。
|
||||||
|
|
||||||
|
## Props 说明
|
||||||
|
|
||||||
|
| Attribute | Description | Type | Default |
|
||||||
|
| :--------------: | :--------------------------------- | :-----: | :------: |
|
||||||
|
| data | 原始展示数据 | Array | [] |
|
||||||
|
| columns | 列属性 | Array | [] |
|
||||||
|
| defaultExpandAll | 默认是否全部展开 | Boolean | false |
|
||||||
|
| defaultChildren | 指定子树为节点对象的某个属性值 | String | children | |
|
||||||
|
| indent | 相邻级节点间的水平缩进,单位为像素 | Number | 50 |
|
||||||
|
|
||||||
|
> 任何 `el-table` 的属性都支持,例如`border`、`fit`、`size`或者`@select`、`@cell-click`等方法。详情属性见`el-table`文档。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 代码示例
|
||||||
|
|
||||||
|
```html
|
||||||
|
<tree-table :data="data" :columns="columns" border>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### data(**必填**)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
name:'1'
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: '1-1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '1-2'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `2`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### columns(**必填**)
|
||||||
|
|
||||||
|
- label: 显示在表头的文字
|
||||||
|
- key: 对应 data 的 key。treeTable 将显示相应的 value
|
||||||
|
- expand: `true` or `false`。若为 true,则在该列显示展开收起图标
|
||||||
|
- checkbox: `true` or `false`。若为 true,则在该列显示`checkbox`
|
||||||
|
- width: 每列的宽度,为一个数字(可选)。例如`200`
|
||||||
|
- align: 对齐方式 `left/center/right`
|
||||||
|
- header-align: 表头对齐方式 `left/center/right`
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
label: 'Checkbox',
|
||||||
|
checkbox: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
key: 'id',
|
||||||
|
expand: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Event',
|
||||||
|
key: 'event',
|
||||||
|
width: 200,
|
||||||
|
align: 'left'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Scope',
|
||||||
|
key: 'scope'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
> 树表组件将会根据 columns 的 key 属性生成具名插槽,如果你需要对列数据进行自定义,通过插槽即可实现
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template slot="your key" slot-scope="{scope}">
|
||||||
|
<el-tag>level: {{ scope.row._level }}</el-tag>
|
||||||
|
<el-tag>expand: {{ scope.row._expand }}</el-tag>
|
||||||
|
<el-tag>select: {{ scope.row._select }}</el-tag>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
目前提供了几个方法,不过只是`beta`版本,之后很可能会修改。
|
||||||
|
|
||||||
|
```js
|
||||||
|
this.$refs.TreeTable.addChild(row, data) //添加子元素
|
||||||
|
this.$refs.TreeTable.addBrother(row, data) //添加兄弟元素
|
||||||
|
this.$refs.TreeTable.delete(row) //删除该元素
|
||||||
|
```
|
||||||
|
|
||||||
|
## 其他
|
||||||
|
|
||||||
|
如果有其他的需求,请参考[el-table](http://element-cn.eleme.io/#/en-US/component/table)的 api 自行修改 index.vue
|
||||||
|
|
||||||
|
# English
|
||||||
|
|
||||||
|
## Brief
|
||||||
|
|
||||||
|
This component only provides a solution for creating `TreeTable`. It is based on the `element-ui` table component. It uses the `row-style` method of `el-table` to determine whether the element needs to be hidden or displayed.
|
||||||
|
|
||||||
|
And this component makes full use of the features of the `vue` slot to make it user-friendly.
|
||||||
|
|
||||||
|
In `evel.js`, the `addAttrs` method adds several properties to the data, and `treeTotable` flattens the array. None of these operations will destroy the source data, just add properties.
|
||||||
|
|
||||||
|
## Props
|
||||||
|
|
||||||
|
| Attribute | Description | Type | Default |
|
||||||
|
| :--------------: | :----------------------------------------------------------- | :-----: | :------: |
|
||||||
|
| data | original display data | Array | [] |
|
||||||
|
| columns | column attribute | Array | [] |
|
||||||
|
| defaultExpandAll | whether to expand all nodes by default | Boolean | false |
|
||||||
|
| defaultChildren | specify which node object is used as the node's subtree | String | children | |
|
||||||
|
| indent | horizontal indentation of nodes in adjacent levels in pixels | Number | 50 |
|
||||||
|
|
||||||
|
> Any of the `el-table` properties are supported, such as `border`, `fit`, `size` or `@select`, `@cell-click`. See the ʻel-table` documentation for details.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```html
|
||||||
|
<tree-table :data="data" :columns="columns" border>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### data(**Required**)
|
||||||
|
|
||||||
|
```js
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
name:'1'
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: '1-1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '1-2'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: `2`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### columns(**Required**)
|
||||||
|
|
||||||
|
- label: text displayed in the header
|
||||||
|
- key: data.key will show in column
|
||||||
|
- expand: `true` or `false`
|
||||||
|
- checkbox: `true` or `false`
|
||||||
|
- width: column width 。such as `200`
|
||||||
|
- align: alignment `left/center/right`
|
||||||
|
- header-align: alignment of the table header `left/center/right`
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
label: 'Checkbox',
|
||||||
|
checkbox: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
key: 'id',
|
||||||
|
expand: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Event',
|
||||||
|
key: 'event',
|
||||||
|
width: 200,
|
||||||
|
align: 'left'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Scope',
|
||||||
|
key: 'scope'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
> The tree table component will generate a named slot based on the key property of columns. If you need to customize the column data, you can do it through the slot.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template slot="your key" slot-scope="{scope}">
|
||||||
|
<el-tag>level: {{ scope.row._level }}</el-tag>
|
||||||
|
<el-tag>expand: {{ scope.row._expand }}</el-tag>
|
||||||
|
<el-tag>select: {{ scope.row._select }}</el-tag>
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
Several methods are currently available, but only the `beta` version, which is likely to be modified later.
|
||||||
|
|
||||||
|
```js
|
||||||
|
this.$refs.TreeTable.addChild(row, data) //Add child elements
|
||||||
|
this.$refs.TreeTable.addBrother(row, data) //Add a sibling element
|
||||||
|
this.$refs.TreeTable.delete(row) //Delete the element
|
||||||
|
```
|
||||||
|
|
||||||
|
## Other
|
||||||
|
|
||||||
|
If you have other requirements, please refer to the [el-table](http://element-cn.eleme.io/#/en-US/component/table) api to modify the index.vue
|
@@ -10,9 +10,7 @@
|
|||||||
action="https://httpbin.org/post"
|
action="https://httpbin.org/post"
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload" />
|
<i class="el-icon-upload" />
|
||||||
<div class="el-upload__text">
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
将文件拖到此处,或<em>点击上传</em>
|
|
||||||
</div>
|
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<div class="image-preview">
|
<div class="image-preview">
|
||||||
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
|
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
|
||||||
@@ -79,7 +77,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||||
@import "~@/styles/mixin.scss";
|
@import "src/styles/mixin.scss";
|
||||||
.upload-container {
|
.upload-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@@ -10,9 +10,7 @@
|
|||||||
action="https://httpbin.org/post"
|
action="https://httpbin.org/post"
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload" />
|
<i class="el-icon-upload" />
|
||||||
<div class="el-upload__text">
|
<div class="el-upload__text">Drag或<em>点击上传</em></div>
|
||||||
Drag或<em>点击上传</em>
|
|
||||||
</div>
|
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<div v-show="imageUrl.length>0" class="image-preview">
|
<div v-show="imageUrl.length>0" class="image-preview">
|
||||||
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
|
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
|
||||||
|
@@ -10,9 +10,7 @@
|
|||||||
action="https://httpbin.org/post"
|
action="https://httpbin.org/post"
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload" />
|
<i class="el-icon-upload" />
|
||||||
<div class="el-upload__text">
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
将文件拖到此处,或<em>点击上传</em>
|
|
||||||
</div>
|
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<div class="image-preview image-app-preview">
|
<div class="image-preview image-app-preview">
|
||||||
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
|
<div v-show="imageUrl.length>1" class="image-preview-wrapper">
|
||||||
|
@@ -3,9 +3,7 @@
|
|||||||
<input ref="excel-upload-input" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
|
<input ref="excel-upload-input" class="excel-upload-input" type="file" accept=".xlsx, .xls" @change="handleClick">
|
||||||