feat:暂存多入口配置
This commit is contained in:
@@ -34,7 +34,7 @@ const onlyHtml = {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
context: path.resolve(__dirname, '../'),
|
context: path.resolve(__dirname, '../'),
|
||||||
entry: {
|
entry: {
|
||||||
app: './src/main.js',
|
app: './src/app/main.js',
|
||||||
entrance: './src/entrance/entrance.main.js'
|
entrance: './src/entrance/entrance.main.js'
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
|||||||
clientLogLevel: 'warning',
|
clientLogLevel: 'warning',
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
rewrites: [
|
rewrites: [
|
||||||
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }
|
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'src/app/index.html') }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
hot: true,
|
hot: true,
|
||||||
inline:true,
|
inline: true,
|
||||||
contentBase: false, // since we use CopyWebpackPlugin.
|
contentBase: false, // since we use CopyWebpackPlugin.
|
||||||
compress: true,
|
compress: true,
|
||||||
host: HOST || config.dev.host,
|
host: HOST || config.dev.host,
|
||||||
@@ -57,9 +57,9 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
|||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
template: 'index.html',
|
template: 'src/app/index.html',
|
||||||
inject: true,
|
inject: true,
|
||||||
chunks: ['entrance']
|
chunks: ['app']
|
||||||
}),
|
}),
|
||||||
// copy custom static assets
|
// copy custom static assets
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
|||||||
clientLogLevel: 'warning',
|
clientLogLevel: 'warning',
|
||||||
historyApiFallback: {
|
historyApiFallback: {
|
||||||
rewrites: [
|
rewrites: [
|
||||||
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }
|
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'src/entrance/entrance.html') }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
hot: true,
|
hot: true,
|
||||||
@@ -58,9 +58,9 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
|||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||||
filename: 'entrance.html',
|
filename: 'entrance.html',
|
||||||
template: 'entrance.html',
|
template: 'src/entrance/entrance.html',
|
||||||
inject: true,
|
inject: true,
|
||||||
chunks: ['app']
|
chunks: ['entrance']
|
||||||
}),
|
}),
|
||||||
// copy custom static assets
|
// copy custom static assets
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
|
|||||||
281
nezha-fronted/build/webpack.prod-html.conf.js
Normal file
281
nezha-fronted/build/webpack.prod-html.conf.js
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
'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')
|
||||||
|
console.log(process.env.ONLY_HTML,baseWebpackConfig)
|
||||||
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
|
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
||||||
|
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin')
|
||||||
|
const fileManagerPlugin = require('filemanager-webpack-plugin')
|
||||||
|
const WebpackZipPlugin = require('webpack-zip-plugin')
|
||||||
|
// const GitRevisionPlugin = require('git-revision-webpack-plugin')
|
||||||
|
const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
|
||||||
|
const WebpackShellPlugin = require('webpack-shell-plugin')
|
||||||
|
const serverConfig = require('../static/config.json')// 引入根目录下的配置文件
|
||||||
|
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin')
|
||||||
|
|
||||||
|
// const gitRevisionPlugin = new GitRevisionPlugin();
|
||||||
|
const createJson = function () {
|
||||||
|
// serverConfig.version=config.build.version +"-"+gitRevisionPlugin.commithash();
|
||||||
|
serverConfig.version = config.build.version
|
||||||
|
return JSON.stringify(serverConfig)
|
||||||
|
}
|
||||||
|
|
||||||
|
const env = require('../config/prod.env')
|
||||||
|
/* const GenerateAssetPlugin = require('generate-asset-webpack-plugin');
|
||||||
|
const createConfig = function(compilation){
|
||||||
|
let cfgJson={baseUrl:"http://192.168.40.247:8080/nz-admin"};
|
||||||
|
return JSON.stringify(cfgJson);
|
||||||
|
} */
|
||||||
|
let webpackConfig = {}
|
||||||
|
webpackConfig = merge(baseWebpackConfig, {
|
||||||
|
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].js'),
|
||||||
|
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js')
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
/* new GenerateAssetPlugin({
|
||||||
|
filename: 'config.json',
|
||||||
|
fn: (compilation, cb) => {
|
||||||
|
cb(null, createConfig(compilation));
|
||||||
|
},
|
||||||
|
extraFiles: []
|
||||||
|
}), */
|
||||||
|
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': env
|
||||||
|
}),
|
||||||
|
new ParallelUglifyPlugin({
|
||||||
|
cacheDir: '.cache/',
|
||||||
|
uglifyJS: {
|
||||||
|
output: {
|
||||||
|
comments: false
|
||||||
|
},
|
||||||
|
warnings: false,
|
||||||
|
compress: {
|
||||||
|
drop_debugger: true,
|
||||||
|
drop_console: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// extract css into its own file
|
||||||
|
new ExtractTextPlugin({
|
||||||
|
filename: utils.assetsPath('css/[name].[contenthash].css'),
|
||||||
|
// Setting the following option to `false` will not extract CSS from codesplit chunks.
|
||||||
|
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
|
||||||
|
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
|
||||||
|
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
|
||||||
|
allChunks: true
|
||||||
|
}),
|
||||||
|
// Compress extracted CSS. We are using this plugin so that possible
|
||||||
|
// duplicated CSS from different components can be deduped.
|
||||||
|
new OptimizeCSSPlugin({
|
||||||
|
cssProcessorOptions: config.build.productionSourceMap
|
||||||
|
? { safe: true, map: { inline: false } }
|
||||||
|
: { safe: true }
|
||||||
|
}),
|
||||||
|
// 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({
|
||||||
|
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||||
|
filename: config.build.index,
|
||||||
|
template: 'src/entrance/entrance.html',
|
||||||
|
inlineSource: '.(js|css)$', // embed all javascript and css inline
|
||||||
|
hash: false,
|
||||||
|
inject: true,
|
||||||
|
minify: {
|
||||||
|
removeComments: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
removeAttributeQuotes: true
|
||||||
|
// more options:
|
||||||
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
||||||
|
},
|
||||||
|
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||||
|
chunksSortMode: 'dependency',
|
||||||
|
chunks: ['entrance']
|
||||||
|
}),
|
||||||
|
new HtmlWebpackInlineSourcePlugin(),
|
||||||
|
new GenerateAssetPlugin({
|
||||||
|
filename: 'static/config.json',
|
||||||
|
fn: (compilation, cb) => {
|
||||||
|
cb(null, createJson())
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// keep module.id stable when vendor modules does not change
|
||||||
|
new webpack.HashedModuleIdsPlugin(),
|
||||||
|
// enable scope hoisting
|
||||||
|
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||||
|
// split vendor js into its own file
|
||||||
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
|
name: 'vendor',
|
||||||
|
minChunks (module) {
|
||||||
|
// any required modules inside node_modules are extracted to vendor
|
||||||
|
return (
|
||||||
|
module.resource &&
|
||||||
|
/\.js$/.test(module.resource) &&
|
||||||
|
module.resource.indexOf(
|
||||||
|
path.join(__dirname, '../node_modules')
|
||||||
|
) === 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// extract webpack runtime and module manifest to its own file in order to
|
||||||
|
// prevent vendor hash from being updated whenever app bundle is updated
|
||||||
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
|
name: 'manifest',
|
||||||
|
minChunks: Infinity
|
||||||
|
}),
|
||||||
|
// This instance extracts shared chunks from code splitted chunks and bundles them
|
||||||
|
// in a separate chunk, similar to the vendor chunk
|
||||||
|
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
|
||||||
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
|
name: 'entrance',
|
||||||
|
async: 'vendor-async',
|
||||||
|
children: true,
|
||||||
|
minChunks: 3
|
||||||
|
}),
|
||||||
|
|
||||||
|
// copy custom static assets
|
||||||
|
new CopyWebpackPlugin([
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../static'),
|
||||||
|
to: config.build.assetsSubDirectory,
|
||||||
|
ignore: ['*']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../src/components/chart'),
|
||||||
|
to: 'components',
|
||||||
|
ignore: ['.*']
|
||||||
|
}
|
||||||
|
])
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV == 'development') {
|
||||||
|
webpackConfig.plugins.push(
|
||||||
|
new fileManagerPlugin({
|
||||||
|
onStart: [
|
||||||
|
{
|
||||||
|
delete: [path.join(__dirname, '../dist/')]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onEnd: [
|
||||||
|
{
|
||||||
|
move: [
|
||||||
|
{ source: path.join(__dirname, '../dist', '/static/config.json'), destination: path.join(__dirname, '../dist/config.json') }
|
||||||
|
|
||||||
|
],
|
||||||
|
mkdir: [
|
||||||
|
path.join(__dirname, '../dist', '/static')
|
||||||
|
],
|
||||||
|
copy: [
|
||||||
|
{ source: path.join(__dirname, '../dist', '/config.json'), destination: path.join(__dirname, '../dist', '/static/config.json') }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
delete: [
|
||||||
|
path.join(__dirname, '../dist', '/config.json')
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
archive: [
|
||||||
|
{ source: path.join(__dirname, '../dist'), destination: path.join(__dirname, '../dist', '/nz-gui.zip') }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
webpackConfig.plugins.push(
|
||||||
|
new fileManagerPlugin({
|
||||||
|
onStart: [
|
||||||
|
{
|
||||||
|
delete: [path.join(__dirname, '../dist/')]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onEnd: [
|
||||||
|
{
|
||||||
|
move: [
|
||||||
|
{ source: path.join(__dirname, '../dist', '/static/config.json'), destination: path.join(__dirname, '../dist/config.json') }
|
||||||
|
|
||||||
|
],
|
||||||
|
mkdir: [
|
||||||
|
path.join(__dirname, '../dist', '/static')
|
||||||
|
],
|
||||||
|
copy: [
|
||||||
|
{ source: path.join(__dirname, '../dist', '/config.json'), destination: path.join(__dirname, '../dist', '/static/config.json') }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
delete: [
|
||||||
|
path.join(__dirname, '../dist', '/config.json'),
|
||||||
|
path.join(__dirname, '../.cache/')
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
archive: [
|
||||||
|
{ source: path.join(__dirname, '../dist'), destination: path.join(__dirname, '../dist', '/nz-gui.zip') }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
// new WebpackZipPlugin({
|
||||||
|
// initialFile: './dist',
|
||||||
|
// endPath: './dist',
|
||||||
|
// zipName: 'nz-gui.zip'
|
||||||
|
// // behindShell: 'cd ' + path.join(__dirname, '../dist/') + ";md5=`md5sum nz-gui.zip |awk '{print $1}'|cut -c 1-8`;mv nz-gui.zip nz-gui-${md5}.zip;" + (process.env.BUILD_MODE == 'all' ? 'mkdir -p ./dist/static;echo "start add map picture to zip file,it will take a few moment,please wait...";cp -r ../static/Tiles dist/static/;zip -gr nz-gui-${md5}.zip dist/static/Tiles>/dev/null;rm -rf dist;' : '')
|
||||||
|
// })
|
||||||
|
// new WebpackShellPlugin({
|
||||||
|
// onBuildStart: ['/bin/bash ' + path.join(__dirname, 'script') + '/buildStart.sh'],
|
||||||
|
// onBuildEnd: ['/bin/bash ' + path.join(__dirname, 'script') + '/buildEnd.sh ' + process.env.BUILD_MODE]
|
||||||
|
// })
|
||||||
|
// new fileManagerPlugin({
|
||||||
|
// onStart: [
|
||||||
|
// {
|
||||||
|
// delete: [path.join(__dirname, '../dist/')]
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
// })
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.build.productionGzip) {
|
||||||
|
const CompressionWebpackPlugin = require('compression-webpack-plugin')
|
||||||
|
|
||||||
|
webpackConfig.plugins.push(
|
||||||
|
new CompressionWebpackPlugin({
|
||||||
|
asset: '[path].gz[query]',
|
||||||
|
algorithm: 'gzip',
|
||||||
|
test: new RegExp(
|
||||||
|
'\\.(' +
|
||||||
|
config.build.productionGzipExtensions.join('|') +
|
||||||
|
')$'
|
||||||
|
),
|
||||||
|
threshold: 10240,
|
||||||
|
minRatio: 0.8
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.build.bundleAnalyzerReport) {
|
||||||
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
||||||
|
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = webpackConfig
|
||||||
@@ -34,271 +34,136 @@ const createConfig = function(compilation){
|
|||||||
return JSON.stringify(cfgJson);
|
return JSON.stringify(cfgJson);
|
||||||
} */
|
} */
|
||||||
let webpackConfig = {}
|
let webpackConfig = {}
|
||||||
if (!process.env.ONLY_HTML) {
|
webpackConfig = merge(baseWebpackConfig, {
|
||||||
webpackConfig = merge(baseWebpackConfig, {
|
module: {
|
||||||
module: {
|
rules: utils.styleLoaders({
|
||||||
rules: utils.styleLoaders({
|
sourceMap: config.build.productionSourceMap,
|
||||||
sourceMap: config.build.productionSourceMap,
|
extract: true,
|
||||||
extract: true,
|
usePostCSS: true
|
||||||
usePostCSS: true
|
})
|
||||||
})
|
},
|
||||||
},
|
devtool: config.build.productionSourceMap ? config.build.devtool : false,
|
||||||
devtool: config.build.productionSourceMap ? config.build.devtool : false,
|
output: {
|
||||||
output: {
|
path: config.build.assetsRoot,
|
||||||
path: config.build.assetsRoot,
|
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
||||||
filename: utils.assetsPath('js/[name].[chunkhash].js'),
|
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js')
|
||||||
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js')
|
},
|
||||||
},
|
plugins: [
|
||||||
plugins: [
|
/* new GenerateAssetPlugin({
|
||||||
/* new GenerateAssetPlugin({
|
filename: 'config.json',
|
||||||
filename: 'config.json',
|
fn: (compilation, cb) => {
|
||||||
fn: (compilation, cb) => {
|
cb(null, createConfig(compilation));
|
||||||
cb(null, createConfig(compilation));
|
},
|
||||||
|
extraFiles: []
|
||||||
|
}), */
|
||||||
|
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': env
|
||||||
|
}),
|
||||||
|
new ParallelUglifyPlugin({
|
||||||
|
cacheDir: '.cache/',
|
||||||
|
uglifyJS: {
|
||||||
|
output: {
|
||||||
|
comments: false
|
||||||
},
|
},
|
||||||
extraFiles: []
|
warnings: false,
|
||||||
}), */
|
compress: {
|
||||||
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
drop_debugger: true,
|
||||||
new webpack.DefinePlugin({
|
drop_console: true
|
||||||
'process.env': env
|
|
||||||
}),
|
|
||||||
new ParallelUglifyPlugin({
|
|
||||||
cacheDir: '.cache/',
|
|
||||||
uglifyJS: {
|
|
||||||
output: {
|
|
||||||
comments: false
|
|
||||||
},
|
|
||||||
warnings: false,
|
|
||||||
compress: {
|
|
||||||
drop_debugger: true,
|
|
||||||
drop_console: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}),
|
}
|
||||||
// extract css into its own file
|
}),
|
||||||
new ExtractTextPlugin({
|
// extract css into its own file
|
||||||
filename: utils.assetsPath('css/[name].[contenthash].css'),
|
new ExtractTextPlugin({
|
||||||
// Setting the following option to `false` will not extract CSS from codesplit chunks.
|
filename: utils.assetsPath('css/[name].[contenthash].css'),
|
||||||
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
|
// Setting the following option to `false` will not extract CSS from codesplit chunks.
|
||||||
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
|
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
|
||||||
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
|
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
|
||||||
allChunks: true
|
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
|
||||||
}),
|
allChunks: true
|
||||||
// Compress extracted CSS. We are using this plugin so that possible
|
}),
|
||||||
// duplicated CSS from different components can be deduped.
|
// Compress extracted CSS. We are using this plugin so that possible
|
||||||
new OptimizeCSSPlugin({
|
// duplicated CSS from different components can be deduped.
|
||||||
cssProcessorOptions: config.build.productionSourceMap
|
new OptimizeCSSPlugin({
|
||||||
? { safe: true, map: { inline: false } }
|
cssProcessorOptions: config.build.productionSourceMap
|
||||||
: { safe: true }
|
? { safe: true, map: { inline: false } }
|
||||||
}),
|
: { safe: true }
|
||||||
// generate dist index.html with correct asset hash for caching.
|
}),
|
||||||
// you can customize output by editing /index.html
|
// generate dist index.html with correct asset hash for caching.
|
||||||
// see https://github.com/ampedandwired/html-webpack-plugin
|
// you can customize output by editing /index.html
|
||||||
new HtmlWebpackPlugin({
|
// see https://github.com/ampedandwired/html-webpack-plugin
|
||||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
new HtmlWebpackPlugin({
|
||||||
filename: config.build.index,
|
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||||
template: 'index.html',
|
filename: config.build.index,
|
||||||
hash: false,
|
template: 'src/app/index.html',
|
||||||
inject: true,
|
hash: false,
|
||||||
minify: {
|
inject: true,
|
||||||
removeComments: true,
|
minify: {
|
||||||
collapseWhitespace: true,
|
removeComments: true,
|
||||||
removeAttributeQuotes: true
|
collapseWhitespace: true,
|
||||||
// more options:
|
removeAttributeQuotes: true
|
||||||
// https://github.com/kangax/html-minifier#options-quick-reference
|
// more options:
|
||||||
},
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
||||||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
},
|
||||||
chunksSortMode: 'dependency',
|
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||||
chunks: ['entrance']
|
chunksSortMode: 'dependency',
|
||||||
}),
|
chunks: ['app']
|
||||||
new GenerateAssetPlugin({
|
}),
|
||||||
filename: 'static/config.json',
|
new GenerateAssetPlugin({
|
||||||
fn: (compilation, cb) => {
|
filename: 'static/config.json',
|
||||||
cb(null, createJson())
|
fn: (compilation, cb) => {
|
||||||
}
|
cb(null, createJson())
|
||||||
}),
|
}
|
||||||
// keep module.id stable when vendor modules does not change
|
}),
|
||||||
new webpack.HashedModuleIdsPlugin(),
|
// keep module.id stable when vendor modules does not change
|
||||||
// enable scope hoisting
|
new webpack.HashedModuleIdsPlugin(),
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
// enable scope hoisting
|
||||||
// split vendor js into its own file
|
new webpack.optimize.ModuleConcatenationPlugin(),
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
// split vendor js into its own file
|
||||||
name: 'vendor',
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
minChunks (module) {
|
name: 'vendor',
|
||||||
// any required modules inside node_modules are extracted to vendor
|
minChunks (module) {
|
||||||
return (
|
// any required modules inside node_modules are extracted to vendor
|
||||||
module.resource &&
|
return (
|
||||||
/\.js$/.test(module.resource) &&
|
module.resource &&
|
||||||
module.resource.indexOf(
|
/\.js$/.test(module.resource) &&
|
||||||
path.join(__dirname, '../node_modules')
|
module.resource.indexOf(
|
||||||
) === 0
|
path.join(__dirname, '../node_modules')
|
||||||
)
|
) === 0
|
||||||
}
|
)
|
||||||
}),
|
}
|
||||||
// extract webpack runtime and module manifest to its own file in order to
|
}),
|
||||||
// prevent vendor hash from being updated whenever app bundle is updated
|
// extract webpack runtime and module manifest to its own file in order to
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
// prevent vendor hash from being updated whenever app bundle is updated
|
||||||
name: 'manifest',
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
minChunks: Infinity
|
name: 'manifest',
|
||||||
}),
|
minChunks: Infinity
|
||||||
// This instance extracts shared chunks from code splitted chunks and bundles them
|
}),
|
||||||
// in a separate chunk, similar to the vendor chunk
|
// This instance extracts shared chunks from code splitted chunks and bundles them
|
||||||
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
|
// in a separate chunk, similar to the vendor chunk
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
|
||||||
name: 'app',
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
async: 'vendor-async',
|
name: 'app',
|
||||||
children: true,
|
async: 'vendor-async',
|
||||||
minChunks: 3
|
children: true,
|
||||||
}),
|
minChunks: 3
|
||||||
|
}),
|
||||||
|
|
||||||
// copy custom static assets
|
// copy custom static assets
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../static'),
|
from: path.resolve(__dirname, '../static'),
|
||||||
to: config.build.assetsSubDirectory,
|
to: config.build.assetsSubDirectory,
|
||||||
ignore: ['*']
|
ignore: ['*']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: path.resolve(__dirname, '../src/components/chart'),
|
from: path.resolve(__dirname, '../src/components/chart'),
|
||||||
to: 'components',
|
to: 'components',
|
||||||
ignore: ['.*']
|
ignore: ['.*']
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
webpackConfig = merge(baseWebpackConfig, {
|
|
||||||
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].js'),
|
|
||||||
chunkFilename: utils.assetsPath('js/[name].[chunkhash].js')
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
/* new GenerateAssetPlugin({
|
|
||||||
filename: 'config.json',
|
|
||||||
fn: (compilation, cb) => {
|
|
||||||
cb(null, createConfig(compilation));
|
|
||||||
},
|
|
||||||
extraFiles: []
|
|
||||||
}), */
|
|
||||||
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
'process.env': env
|
|
||||||
}),
|
|
||||||
new ParallelUglifyPlugin({
|
|
||||||
cacheDir: '.cache/',
|
|
||||||
uglifyJS: {
|
|
||||||
output: {
|
|
||||||
comments: false
|
|
||||||
},
|
|
||||||
warnings: false,
|
|
||||||
compress: {
|
|
||||||
drop_debugger: true,
|
|
||||||
drop_console: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
// extract css into its own file
|
|
||||||
new ExtractTextPlugin({
|
|
||||||
filename: utils.assetsPath('css/[name].[contenthash].css'),
|
|
||||||
// Setting the following option to `false` will not extract CSS from codesplit chunks.
|
|
||||||
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
|
|
||||||
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
|
|
||||||
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
|
|
||||||
allChunks: true
|
|
||||||
}),
|
|
||||||
// Compress extracted CSS. We are using this plugin so that possible
|
|
||||||
// duplicated CSS from different components can be deduped.
|
|
||||||
new OptimizeCSSPlugin({
|
|
||||||
cssProcessorOptions: config.build.productionSourceMap
|
|
||||||
? { safe: true, map: { inline: false } }
|
|
||||||
: { safe: true }
|
|
||||||
}),
|
|
||||||
// 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({
|
|
||||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
|
||||||
filename: config.build.index,
|
|
||||||
template: 'entrance.html',
|
|
||||||
inlineSource: '.(js|css)$', // embed all javascript and css inline
|
|
||||||
hash: false,
|
|
||||||
inject: true,
|
|
||||||
minify: {
|
|
||||||
removeComments: true,
|
|
||||||
collapseWhitespace: true,
|
|
||||||
removeAttributeQuotes: true
|
|
||||||
// more options:
|
|
||||||
// https://github.com/kangax/html-minifier#options-quick-reference
|
|
||||||
},
|
|
||||||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
|
||||||
chunksSortMode: 'dependency',
|
|
||||||
chunks: ['app']
|
|
||||||
}),
|
|
||||||
new HtmlWebpackInlineSourcePlugin(),
|
|
||||||
new GenerateAssetPlugin({
|
|
||||||
filename: 'static/config.json',
|
|
||||||
fn: (compilation, cb) => {
|
|
||||||
cb(null, createJson())
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
// keep module.id stable when vendor modules does not change
|
|
||||||
new webpack.HashedModuleIdsPlugin(),
|
|
||||||
// enable scope hoisting
|
|
||||||
new webpack.optimize.ModuleConcatenationPlugin(),
|
|
||||||
// split vendor js into its own file
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: 'vendor',
|
|
||||||
minChunks (module) {
|
|
||||||
// any required modules inside node_modules are extracted to vendor
|
|
||||||
return (
|
|
||||||
module.resource &&
|
|
||||||
/\.js$/.test(module.resource) &&
|
|
||||||
module.resource.indexOf(
|
|
||||||
path.join(__dirname, '../node_modules')
|
|
||||||
) === 0
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
// extract webpack runtime and module manifest to its own file in order to
|
|
||||||
// prevent vendor hash from being updated whenever app bundle is updated
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: 'manifest',
|
|
||||||
minChunks: Infinity
|
|
||||||
}),
|
|
||||||
// This instance extracts shared chunks from code splitted chunks and bundles them
|
|
||||||
// in a separate chunk, similar to the vendor chunk
|
|
||||||
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
|
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
|
||||||
name: 'entrance',
|
|
||||||
async: 'vendor-async',
|
|
||||||
children: true,
|
|
||||||
minChunks: 3
|
|
||||||
}),
|
|
||||||
|
|
||||||
// copy custom static assets
|
|
||||||
new CopyWebpackPlugin([
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, '../static'),
|
|
||||||
to: config.build.assetsSubDirectory,
|
|
||||||
ignore: ['*']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, '../src/components/chart'),
|
|
||||||
to: 'components',
|
|
||||||
ignore: ['.*']
|
|
||||||
}
|
|
||||||
])
|
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.NODE_ENV == 'development') {
|
if (process.env.NODE_ENV == 'development') {
|
||||||
webpackConfig.plugins.push(
|
webpackConfig.plugins.push(
|
||||||
|
|||||||
@@ -4,29 +4,29 @@ import 'xterm/dist/xterm.css'
|
|||||||
import '@/assets/css/main.scss'
|
import '@/assets/css/main.scss'
|
||||||
import '@/assets/css/font/iconfont.js'
|
import '@/assets/css/font/iconfont.js'
|
||||||
import ElementUI from 'element-ui'
|
import ElementUI from 'element-ui'
|
||||||
import i18n from './components/common/i18n'
|
import i18n from '@/components/common/i18n'
|
||||||
|
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import store from './store/index'
|
import store from '@/store/index'
|
||||||
import App from './App'
|
import App from '@/app/App'
|
||||||
import router from './router'
|
import router from '@/router'
|
||||||
import VueResource from 'vue-resource'
|
import VueResource from 'vue-resource'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { hasPermission, hasButton } from './permission'
|
import { hasPermission, hasButton } from '@/permission'
|
||||||
import loadsh from 'lodash'
|
import loadsh from 'lodash'
|
||||||
import plTable from 'pl-table'
|
import plTable from 'pl-table'
|
||||||
import 'pl-table/themes/index.css'
|
import 'pl-table/themes/index.css'
|
||||||
|
|
||||||
import { post, get, put, del } from './http.js'
|
import { post, get, put, del } from '@/http.js'
|
||||||
import { clickoutside, bottomBoxWindow, stringTimeParseToUnix, unixTimeParseToString, chartResizeTool, tableSet, cancelWithChange, myLoading } from './components/common/js/tools.js'
|
import { clickoutside, bottomBoxWindow, stringTimeParseToUnix, unixTimeParseToString, chartResizeTool, tableSet, cancelWithChange, myLoading } from '@/components/common/js/tools.js'
|
||||||
import * as tools from './components/common/js/tools.js'
|
import * as tools from '@/components/common/js/tools.js'
|
||||||
import * as constants from './components/common/js/constants.js'
|
import * as constants from '@/components/common/js/constants.js'
|
||||||
|
|
||||||
import Pagination from './components/common/pagination' // 引入全局分页组件
|
import Pagination from '@/components/common/pagination' // 引入全局分页组件
|
||||||
import searchInput from './components/common/searchInput' // 搜索框组件
|
import searchInput from '@/components/common/searchInput' // 搜索框组件
|
||||||
import elementSet from './components/common/elementSet' // 自定义表头组件
|
import elementSet from '@/components/common/elementSet' // 自定义表头组件
|
||||||
import MyElSelect from './components/common/elSelect/MyElSelect'
|
import MyElSelect from '@/components/common/elSelect/MyElSelect'
|
||||||
import chartList from '@/components/chart/chartList.vue' // 全局引入 chartList 组件 防止 chart-group爆粗
|
import chartList from '@/components/chart/chartList.vue' // 全局引入 chartList 组件 防止 chart-group爆粗
|
||||||
|
|
||||||
import loading from '@/components/common/loading'
|
import loading from '@/components/common/loading'
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import vm from '../../../main'
|
import vm from '../../../app/main'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
|
|
||||||
// ipv4 ip校验
|
// ipv4 ip校验
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ import pipelineSelect from './pipelineSelect'
|
|||||||
import selectWalk from '../popBox/selectWalk'
|
import selectWalk from '../popBox/selectWalk'
|
||||||
import editRigthBox from '../mixin/editRigthBox'
|
import editRigthBox from '../mixin/editRigthBox'
|
||||||
import VueTagsInput from '@johmun/vue-tags-input'
|
import VueTagsInput from '@johmun/vue-tags-input'
|
||||||
import vm from '@/main'
|
import vm from '@/app/main'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'editEndpointBoxNew',
|
name: 'editEndpointBoxNew',
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import editRigthBox from '../mixin/editRigthBox'
|
import editRigthBox from '../mixin/editRigthBox'
|
||||||
import vm from '../../../main'
|
import vm from '../../../app/main'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ipDetailsBox',
|
name: 'ipDetailsBox',
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import editRigthBox from '../mixin/editRigthBox'
|
import editRigthBox from '../mixin/editRigthBox'
|
||||||
import vm from '../../../main'
|
import vm from '../../../app/main'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ipamBox',
|
name: 'ipamBox',
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import vm from '../../../main'
|
import vm from '../../../app/main'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'licenseGen',
|
name: 'licenseGen',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import bus from '../../../../libs/bus'
|
import bus from '../../../../libs/bus'
|
||||||
import vm from '../../../../main'
|
import vm from '../../../../app/main'
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
commonOption.toolbox.feature.dataZoom.title.zoom = vm.$i18n.t('overall.toolBox.zoom')
|
commonOption.toolbox.feature.dataZoom.title.zoom = vm.$i18n.t('overall.toolBox.zoom')
|
||||||
commonOption.toolbox.feature.dataZoom.title.back = vm.$i18n.t('overall.toolBox.back')
|
commonOption.toolbox.feature.dataZoom.title.back = vm.$i18n.t('overall.toolBox.back')
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import vSelectPage from '@/components/common/v-selectpagenew'
|
|||||||
import nzDataList from '@/components/common/table/nzDataList'
|
import nzDataList from '@/components/common/table/nzDataList'
|
||||||
import htmlToPdf from '@/components/common/js/htmlToPdf'
|
import htmlToPdf from '@/components/common/js/htmlToPdf'
|
||||||
import mainMixin from '@/components/common/mixin/mainMixinFun'
|
import mainMixin from '@/components/common/mixin/mainMixinFun'
|
||||||
|
window.entrance = true
|
||||||
Vue.use(htmlToPdf)
|
Vue.use(htmlToPdf)
|
||||||
Vue.use(vSelectPage, {
|
Vue.use(vSelectPage, {
|
||||||
dataLoad: function (vue, url, params) {
|
dataLoad: function (vue, url, params) {
|
||||||
|
|||||||
@@ -10,166 +10,170 @@ Vue.use(VueResource)
|
|||||||
|
|
||||||
const loginWhiteList = ['/setup', '/sys/license/upload', '/sys/license/state', '/sys/appearance', '/i18n'] // 免登陆白名单
|
const loginWhiteList = ['/setup', '/sys/license/upload', '/sys/license/state', '/sys/appearance', '/i18n'] // 免登陆白名单
|
||||||
const permissionWhiteList = ['/profile', '/menu', ...loginWhiteList] // 权限白名单
|
const permissionWhiteList = ['/profile', '/menu', ...loginWhiteList] // 权限白名单
|
||||||
// router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
// if (store.getters.getNowPath !== to.path && store.getters.getNowPath !== '/login') {
|
if (window.entrance) {
|
||||||
// requestsArr.forEach(xhr => xhr.cancel())
|
next()
|
||||||
// }
|
return
|
||||||
// store.commit('setNowPath', to.path)
|
}
|
||||||
// const configUrl = 'static/config.json?Timestamp=' + new Date().getTime()
|
if (store.getters.getNowPath !== to.path && store.getters.getNowPath !== '/login') {
|
||||||
// if (to.path === '/login') { // 拦截登录页面,现货区外观设置 再系统初始化检查
|
requestsArr.forEach(xhr => xhr.cancel())
|
||||||
// Vue.http.get(configUrl).then(config => {
|
}
|
||||||
// const appearance = new Promise(resolve => {
|
store.commit('setNowPath', to.path)
|
||||||
// get(config.body.baseUrl + 'sys/appearance').then(res => {
|
const configUrl = 'static/config.json?Timestamp=' + new Date().getTime()
|
||||||
// if (res.code === 200) {
|
if (to.path === '/login') { // 拦截登录页面,现货区外观设置 再系统初始化检查
|
||||||
// localStorage.setItem('nz-sys-name', res.data.system_name || '')
|
Vue.http.get(configUrl).then(config => {
|
||||||
// localStorage.setItem('nz-sys-logo', res.data.system_logo || '')
|
const appearance = new Promise(resolve => {
|
||||||
// localStorage.setItem('nz-sys-favicon', res.data.system_favicon || '')
|
get(config.body.baseUrl + 'sys/appearance').then(res => {
|
||||||
// localStorage.setItem('nz-language', res.data.language || '')
|
if (res.code === 200) {
|
||||||
// store.commit('setLanguage', res.data.language)
|
localStorage.setItem('nz-sys-name', res.data.system_name || '')
|
||||||
// localStorage.setItem('nz-sys-timezone', res.data.timezone || '')
|
localStorage.setItem('nz-sys-logo', res.data.system_logo || '')
|
||||||
// localStorage.setItem('nz-sys-bgImg', res.data.system_bgImg || '')
|
localStorage.setItem('nz-sys-favicon', res.data.system_favicon || '')
|
||||||
// localStorage.setItem('nz-default-theme', res.data.theme || '')
|
localStorage.setItem('nz-language', res.data.language || '')
|
||||||
// localStorage.setItem('nz-default-dateFormat', res.data.dateFormat || '')
|
store.commit('setLanguage', res.data.language)
|
||||||
// changeFavicon(res.data.system_favicon)
|
localStorage.setItem('nz-sys-timezone', res.data.timezone || '')
|
||||||
// }
|
localStorage.setItem('nz-sys-bgImg', res.data.system_bgImg || '')
|
||||||
// resolve()
|
localStorage.setItem('nz-default-theme', res.data.theme || '')
|
||||||
// })
|
localStorage.setItem('nz-default-dateFormat', res.data.dateFormat || '')
|
||||||
// })
|
changeFavicon(res.data.system_favicon)
|
||||||
// appearance.then(() => {
|
}
|
||||||
// get(config.body.baseUrl + 'setup/inited').then(res => {
|
resolve()
|
||||||
// if (res.code === 200) {
|
})
|
||||||
// if (res.inited === 0) {
|
})
|
||||||
// next({ path: '/setup' })
|
appearance.then(() => {
|
||||||
// } else {
|
get(config.body.baseUrl + 'setup/inited').then(res => {
|
||||||
// if (localStorage.getItem('nz-token')) {
|
if (res.code === 200) {
|
||||||
// post('/sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
if (res.inited === 0) {
|
||||||
// if (res.code === 200) {
|
next({ path: '/setup' })
|
||||||
// const menuList = sortByOrderNum(res.data.menus)
|
} else {
|
||||||
// store.commit('setMenuList', menuList)
|
if (localStorage.getItem('nz-token')) {
|
||||||
// const arr = []
|
post('/sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
||||||
// returnMenuCode(menuList, arr)
|
if (res.code === 200) {
|
||||||
// store.commit('setButtonList', arr)
|
const menuList = sortByOrderNum(res.data.menus)
|
||||||
// store.commit('setRoleList', res.data.roles)
|
store.commit('setMenuList', menuList)
|
||||||
// bus.$emit('login')
|
const arr = []
|
||||||
// const path = []
|
returnMenuCode(menuList, arr)
|
||||||
// if (menuList) {
|
store.commit('setButtonList', arr)
|
||||||
// menuList.forEach(e => {
|
store.commit('setRoleList', res.data.roles)
|
||||||
// if (e.route) {
|
bus.$emit('login')
|
||||||
// path.push(e.route)
|
const path = []
|
||||||
// } else {
|
if (menuList) {
|
||||||
// if (e.children) {
|
menuList.forEach(e => {
|
||||||
// e.children.forEach(e => {
|
if (e.route) {
|
||||||
// if (e.route) {
|
path.push(e.route)
|
||||||
// path.push(e.route)
|
} else {
|
||||||
// } else {
|
if (e.children) {
|
||||||
// if (e.children) {
|
e.children.forEach(e => {
|
||||||
// e.children.forEach(e => {
|
if (e.route) {
|
||||||
// if (e.route) {
|
path.push(e.route)
|
||||||
// path.push(e.route)
|
} else {
|
||||||
// }
|
if (e.children) {
|
||||||
// })
|
e.children.forEach(e => {
|
||||||
// }
|
if (e.route) {
|
||||||
// }
|
path.push(e.route)
|
||||||
// })
|
}
|
||||||
// }
|
})
|
||||||
// }
|
}
|
||||||
// })
|
}
|
||||||
// }
|
})
|
||||||
// router.push({
|
}
|
||||||
// path: path[0],
|
}
|
||||||
// query: {
|
})
|
||||||
// t: +new Date()
|
}
|
||||||
// }
|
router.push({
|
||||||
// })
|
path: path[0],
|
||||||
// } else {
|
query: {
|
||||||
// localStorage.setItem('nz-token', '')
|
t: +new Date()
|
||||||
// next()
|
}
|
||||||
// }
|
})
|
||||||
// })
|
} else {
|
||||||
// } else {
|
localStorage.setItem('nz-token', '')
|
||||||
// next()
|
next()
|
||||||
// }
|
}
|
||||||
// }
|
})
|
||||||
// }
|
} else {
|
||||||
// })
|
next()
|
||||||
// if (!store.getters.i18nIsReady) {
|
}
|
||||||
// get(config.body.baseUrl + 'sys/i18n/lang').then(res => {
|
}
|
||||||
// if (res.code === 200) {
|
}
|
||||||
// loadI18n(res.data)
|
})
|
||||||
// store.commit('i18nReady', true)
|
if (!store.getters.i18nIsReady) {
|
||||||
// }
|
get(config.body.baseUrl + 'sys/i18n/lang').then(res => {
|
||||||
// })
|
if (res.code === 200) {
|
||||||
// }
|
loadI18n(res.data)
|
||||||
// })
|
store.commit('i18nReady', true)
|
||||||
// })
|
}
|
||||||
// } else if (localStorage.getItem('nz-token')) {
|
})
|
||||||
// const i18nRequest = new Promise(resolve => {
|
}
|
||||||
// // 从localStorage加载i18n
|
})
|
||||||
// if (!store.getters.i18nIsReady) {
|
})
|
||||||
// const langList = localStorage.getItem('nz-language-list')
|
} else if (localStorage.getItem('nz-token')) {
|
||||||
// if (langList) {
|
const i18nRequest = new Promise(resolve => {
|
||||||
// store.commit('setLangList', JSON.parse(langList))
|
// 从localStorage加载i18n
|
||||||
// }
|
if (!store.getters.i18nIsReady) {
|
||||||
// Vue.http.get(configUrl).then(config => {
|
const langList = localStorage.getItem('nz-language-list')
|
||||||
// get(config.body.baseUrl + 'sys/i18n/lang').then(response => {
|
if (langList) {
|
||||||
// if (response.code === 200) {
|
store.commit('setLangList', JSON.parse(langList))
|
||||||
// loadI18n(response.data)
|
}
|
||||||
// store.commit('i18nReady', true)
|
Vue.http.get(configUrl).then(config => {
|
||||||
// resolve()
|
get(config.body.baseUrl + 'sys/i18n/lang').then(response => {
|
||||||
// }
|
if (response.code === 200) {
|
||||||
// })
|
loadI18n(response.data)
|
||||||
// })
|
store.commit('i18nReady', true)
|
||||||
// } else {
|
resolve()
|
||||||
// resolve()
|
}
|
||||||
// }
|
})
|
||||||
// })
|
})
|
||||||
// const permissionRequest = new Promise(resolve => {
|
} else {
|
||||||
// if (store.getters.menuList.length === 0) {
|
resolve()
|
||||||
// Vue.http.get(configUrl).then(config => {
|
}
|
||||||
// post(config.body.baseUrl + 'sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
})
|
||||||
// if (res.code === 200) {
|
const permissionRequest = new Promise(resolve => {
|
||||||
// store.commit('setMenuList', sortByOrderNum(res.data.menus))
|
if (store.getters.menuList.length === 0) {
|
||||||
// const arr = []
|
Vue.http.get(configUrl).then(config => {
|
||||||
// returnMenuCode(res.data.menus, arr)
|
post(config.body.baseUrl + 'sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
||||||
// store.commit('setButtonList', arr)
|
if (res.code === 200) {
|
||||||
// store.commit('setRoleList', res.data.roles)
|
store.commit('setMenuList', sortByOrderNum(res.data.menus))
|
||||||
// const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
const arr = []
|
||||||
// document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
returnMenuCode(res.data.menus, arr)
|
||||||
// resolve()
|
store.commit('setButtonList', arr)
|
||||||
// } else {
|
store.commit('setRoleList', res.data.roles)
|
||||||
// localStorage.removeItem('nz-token')
|
const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
||||||
// next({ path: '/login' })
|
document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
||||||
// }
|
resolve()
|
||||||
// })
|
} else {
|
||||||
// })
|
localStorage.removeItem('nz-token')
|
||||||
// } else {
|
next({ path: '/login' })
|
||||||
// const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
}
|
||||||
// document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
})
|
||||||
// resolve()
|
})
|
||||||
// }
|
} else {
|
||||||
// })
|
const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
||||||
// Promise.all([i18nRequest, permissionRequest]).then(response => {
|
document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
||||||
// if (to.path) {
|
resolve()
|
||||||
// if (permissionWhiteList.indexOf(to.path) !== -1) {
|
}
|
||||||
// next()
|
})
|
||||||
// } else if (hasMenu(store.getters.menuList, to.path)) {
|
Promise.all([i18nRequest, permissionRequest]).then(response => {
|
||||||
// next()
|
if (to.path) {
|
||||||
// } else {
|
if (permissionWhiteList.indexOf(to.path) !== -1) {
|
||||||
// if (to.path === '/monitor/monitor/project' || to.path === '/monitor/monitor/module' || to.path === '/monitor/monitor/endpoint') {
|
next()
|
||||||
// return
|
} else if (hasMenu(store.getters.menuList, to.path)) {
|
||||||
// }
|
next()
|
||||||
// ElementUI.Message.error(i18n.t('tip.noAccess'))
|
} else {
|
||||||
// }
|
if (to.path === '/monitor/monitor/project' || to.path === '/monitor/monitor/module' || to.path === '/monitor/monitor/endpoint') {
|
||||||
// }
|
return
|
||||||
// })
|
}
|
||||||
// } else {
|
ElementUI.Message.error(i18n.t('tip.noAccess'))
|
||||||
// if (loginWhiteList.indexOf(to.path) !== -1) {
|
}
|
||||||
// next()
|
}
|
||||||
// } else {
|
})
|
||||||
// next({ path: '/login' })
|
} else {
|
||||||
// }
|
if (loginWhiteList.indexOf(to.path) !== -1) {
|
||||||
// }
|
next()
|
||||||
// })
|
} else {
|
||||||
|
next({ path: '/login' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
router.afterEach((to, from) => {
|
router.afterEach((to, from) => {
|
||||||
// store.commit('setNowPath', '')
|
// store.commit('setNowPath', '')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user