feat:暂存多入口配置
This commit is contained in:
@@ -34,7 +34,7 @@ const onlyHtml = {
|
||||
module.exports = {
|
||||
context: path.resolve(__dirname, '../'),
|
||||
entry: {
|
||||
app: './src/main.js',
|
||||
app: './src/app/main.js',
|
||||
entrance: './src/entrance/entrance.main.js'
|
||||
},
|
||||
output: {
|
||||
|
||||
@@ -25,11 +25,11 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
clientLogLevel: 'warning',
|
||||
historyApiFallback: {
|
||||
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,
|
||||
inline:true,
|
||||
inline: true,
|
||||
contentBase: false, // since we use CopyWebpackPlugin.
|
||||
compress: true,
|
||||
host: HOST || config.dev.host,
|
||||
@@ -57,9 +57,9 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
new HtmlWebpackPlugin({
|
||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||
filename: 'index.html',
|
||||
template: 'index.html',
|
||||
template: 'src/app/index.html',
|
||||
inject: true,
|
||||
chunks: ['entrance']
|
||||
chunks: ['app']
|
||||
}),
|
||||
// copy custom static assets
|
||||
new CopyWebpackPlugin([
|
||||
|
||||
@@ -26,7 +26,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
clientLogLevel: 'warning',
|
||||
historyApiFallback: {
|
||||
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,
|
||||
@@ -58,9 +58,9 @@ const devWebpackConfig = merge(baseWebpackConfig, {
|
||||
new HtmlWebpackPlugin({
|
||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||
filename: 'entrance.html',
|
||||
template: 'entrance.html',
|
||||
template: 'src/entrance/entrance.html',
|
||||
inject: true,
|
||||
chunks: ['app']
|
||||
chunks: ['entrance']
|
||||
}),
|
||||
// copy custom static assets
|
||||
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,8 +34,7 @@ const createConfig = function(compilation){
|
||||
return JSON.stringify(cfgJson);
|
||||
} */
|
||||
let webpackConfig = {}
|
||||
if (!process.env.ONLY_HTML) {
|
||||
webpackConfig = merge(baseWebpackConfig, {
|
||||
webpackConfig = merge(baseWebpackConfig, {
|
||||
module: {
|
||||
rules: utils.styleLoaders({
|
||||
sourceMap: config.build.productionSourceMap,
|
||||
@@ -96,7 +95,7 @@ if (!process.env.ONLY_HTML) {
|
||||
new HtmlWebpackPlugin({
|
||||
favicon: path.resolve(__dirname, '../src/assets/img/favicon.ico'),
|
||||
filename: config.build.index,
|
||||
template: 'index.html',
|
||||
template: 'src/app/index.html',
|
||||
hash: false,
|
||||
inject: true,
|
||||
minify: {
|
||||
@@ -108,7 +107,7 @@ if (!process.env.ONLY_HTML) {
|
||||
},
|
||||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
||||
chunksSortMode: 'dependency',
|
||||
chunks: ['entrance']
|
||||
chunks: ['app']
|
||||
}),
|
||||
new GenerateAssetPlugin({
|
||||
filename: 'static/config.json',
|
||||
@@ -164,141 +163,7 @@ if (!process.env.ONLY_HTML) {
|
||||
}
|
||||
])
|
||||
]
|
||||
})
|
||||
} 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') {
|
||||
webpackConfig.plugins.push(
|
||||
|
||||
@@ -4,29 +4,29 @@ import 'xterm/dist/xterm.css'
|
||||
import '@/assets/css/main.scss'
|
||||
import '@/assets/css/font/iconfont.js'
|
||||
import ElementUI from 'element-ui'
|
||||
import i18n from './components/common/i18n'
|
||||
import i18n from '@/components/common/i18n'
|
||||
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import store from './store/index'
|
||||
import App from './App'
|
||||
import router from './router'
|
||||
import store from '@/store/index'
|
||||
import App from '@/app/App'
|
||||
import router from '@/router'
|
||||
import VueResource from 'vue-resource'
|
||||
import axios from 'axios'
|
||||
import { hasPermission, hasButton } from './permission'
|
||||
import { hasPermission, hasButton } from '@/permission'
|
||||
import loadsh from 'lodash'
|
||||
import plTable from 'pl-table'
|
||||
import 'pl-table/themes/index.css'
|
||||
|
||||
import { post, get, put, del } from './http.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 constants from './components/common/js/constants.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 * as tools from '@/components/common/js/tools.js'
|
||||
import * as constants from '@/components/common/js/constants.js'
|
||||
|
||||
import Pagination from './components/common/pagination' // 引入全局分页组件
|
||||
import searchInput from './components/common/searchInput' // 搜索框组件
|
||||
import elementSet from './components/common/elementSet' // 自定义表头组件
|
||||
import MyElSelect from './components/common/elSelect/MyElSelect'
|
||||
import Pagination from '@/components/common/pagination' // 引入全局分页组件
|
||||
import searchInput from '@/components/common/searchInput' // 搜索框组件
|
||||
import elementSet from '@/components/common/elementSet' // 自定义表头组件
|
||||
import MyElSelect from '@/components/common/elSelect/MyElSelect'
|
||||
import chartList from '@/components/chart/chartList.vue' // 全局引入 chartList 组件 防止 chart-group爆粗
|
||||
|
||||
import loading from '@/components/common/loading'
|
||||
@@ -1,4 +1,4 @@
|
||||
import vm from '../../../main'
|
||||
import vm from '../../../app/main'
|
||||
import lodash from 'lodash'
|
||||
|
||||
// ipv4 ip校验
|
||||
|
||||
@@ -587,7 +587,7 @@ import pipelineSelect from './pipelineSelect'
|
||||
import selectWalk from '../popBox/selectWalk'
|
||||
import editRigthBox from '../mixin/editRigthBox'
|
||||
import VueTagsInput from '@johmun/vue-tags-input'
|
||||
import vm from '@/main'
|
||||
import vm from '@/app/main'
|
||||
|
||||
export default {
|
||||
name: 'editEndpointBoxNew',
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<script>
|
||||
import editRigthBox from '../mixin/editRigthBox'
|
||||
import vm from '../../../main'
|
||||
import vm from '../../../app/main'
|
||||
|
||||
export default {
|
||||
name: 'ipDetailsBox',
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
<script>
|
||||
import editRigthBox from '../mixin/editRigthBox'
|
||||
import vm from '../../../main'
|
||||
import vm from '../../../app/main'
|
||||
|
||||
export default {
|
||||
name: 'ipamBox',
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import vm from '../../../main'
|
||||
import vm from '../../../app/main'
|
||||
|
||||
export default {
|
||||
name: 'licenseGen',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script>
|
||||
import bus from '../../../../libs/bus'
|
||||
import vm from '../../../../main'
|
||||
import vm from '../../../../app/main'
|
||||
window.onload = function () {
|
||||
commonOption.toolbox.feature.dataZoom.title.zoom = vm.$i18n.t('overall.toolBox.zoom')
|
||||
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 htmlToPdf from '@/components/common/js/htmlToPdf'
|
||||
import mainMixin from '@/components/common/mixin/mainMixinFun'
|
||||
|
||||
window.entrance = true
|
||||
Vue.use(htmlToPdf)
|
||||
Vue.use(vSelectPage, {
|
||||
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 permissionWhiteList = ['/profile', '/menu', ...loginWhiteList] // 权限白名单
|
||||
// router.beforeEach((to, from, next) => {
|
||||
// if (store.getters.getNowPath !== to.path && store.getters.getNowPath !== '/login') {
|
||||
// requestsArr.forEach(xhr => xhr.cancel())
|
||||
// }
|
||||
// store.commit('setNowPath', to.path)
|
||||
// const configUrl = 'static/config.json?Timestamp=' + new Date().getTime()
|
||||
// if (to.path === '/login') { // 拦截登录页面,现货区外观设置 再系统初始化检查
|
||||
// Vue.http.get(configUrl).then(config => {
|
||||
// const appearance = new Promise(resolve => {
|
||||
// get(config.body.baseUrl + 'sys/appearance').then(res => {
|
||||
// if (res.code === 200) {
|
||||
// localStorage.setItem('nz-sys-name', res.data.system_name || '')
|
||||
// localStorage.setItem('nz-sys-logo', res.data.system_logo || '')
|
||||
// localStorage.setItem('nz-sys-favicon', res.data.system_favicon || '')
|
||||
// localStorage.setItem('nz-language', res.data.language || '')
|
||||
// store.commit('setLanguage', res.data.language)
|
||||
// localStorage.setItem('nz-sys-timezone', res.data.timezone || '')
|
||||
// localStorage.setItem('nz-sys-bgImg', res.data.system_bgImg || '')
|
||||
// localStorage.setItem('nz-default-theme', res.data.theme || '')
|
||||
// localStorage.setItem('nz-default-dateFormat', res.data.dateFormat || '')
|
||||
// changeFavicon(res.data.system_favicon)
|
||||
// }
|
||||
// resolve()
|
||||
// })
|
||||
// })
|
||||
// appearance.then(() => {
|
||||
// get(config.body.baseUrl + 'setup/inited').then(res => {
|
||||
// if (res.code === 200) {
|
||||
// if (res.inited === 0) {
|
||||
// next({ path: '/setup' })
|
||||
// } else {
|
||||
// if (localStorage.getItem('nz-token')) {
|
||||
// post('/sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
||||
// if (res.code === 200) {
|
||||
// const menuList = sortByOrderNum(res.data.menus)
|
||||
// store.commit('setMenuList', menuList)
|
||||
// const arr = []
|
||||
// returnMenuCode(menuList, arr)
|
||||
// store.commit('setButtonList', arr)
|
||||
// store.commit('setRoleList', res.data.roles)
|
||||
// bus.$emit('login')
|
||||
// const path = []
|
||||
// if (menuList) {
|
||||
// menuList.forEach(e => {
|
||||
// if (e.route) {
|
||||
// path.push(e.route)
|
||||
// } else {
|
||||
// if (e.children) {
|
||||
// e.children.forEach(e => {
|
||||
// if (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()
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// localStorage.setItem('nz-token', '')
|
||||
// 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)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// } else if (localStorage.getItem('nz-token')) {
|
||||
// const i18nRequest = new Promise(resolve => {
|
||||
// // 从localStorage加载i18n
|
||||
// if (!store.getters.i18nIsReady) {
|
||||
// const langList = localStorage.getItem('nz-language-list')
|
||||
// if (langList) {
|
||||
// store.commit('setLangList', JSON.parse(langList))
|
||||
// }
|
||||
// Vue.http.get(configUrl).then(config => {
|
||||
// get(config.body.baseUrl + 'sys/i18n/lang').then(response => {
|
||||
// if (response.code === 200) {
|
||||
// loadI18n(response.data)
|
||||
// store.commit('i18nReady', true)
|
||||
// resolve()
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// } else {
|
||||
// resolve()
|
||||
// }
|
||||
// })
|
||||
// const permissionRequest = new Promise(resolve => {
|
||||
// if (store.getters.menuList.length === 0) {
|
||||
// Vue.http.get(configUrl).then(config => {
|
||||
// post(config.body.baseUrl + 'sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
||||
// if (res.code === 200) {
|
||||
// store.commit('setMenuList', sortByOrderNum(res.data.menus))
|
||||
// const arr = []
|
||||
// returnMenuCode(res.data.menus, arr)
|
||||
// store.commit('setButtonList', arr)
|
||||
// store.commit('setRoleList', res.data.roles)
|
||||
// const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
||||
// document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
||||
// resolve()
|
||||
// } else {
|
||||
// localStorage.removeItem('nz-token')
|
||||
// next({ path: '/login' })
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// } else {
|
||||
// const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
||||
// document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
||||
// resolve()
|
||||
// }
|
||||
// })
|
||||
// Promise.all([i18nRequest, permissionRequest]).then(response => {
|
||||
// if (to.path) {
|
||||
// if (permissionWhiteList.indexOf(to.path) !== -1) {
|
||||
// next()
|
||||
// } else if (hasMenu(store.getters.menuList, to.path)) {
|
||||
// next()
|
||||
// } else {
|
||||
// if (to.path === '/monitor/monitor/project' || to.path === '/monitor/monitor/module' || to.path === '/monitor/monitor/endpoint') {
|
||||
// return
|
||||
// }
|
||||
// ElementUI.Message.error(i18n.t('tip.noAccess'))
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// if (loginWhiteList.indexOf(to.path) !== -1) {
|
||||
// next()
|
||||
// } else {
|
||||
// next({ path: '/login' })
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (window.entrance) {
|
||||
next()
|
||||
return
|
||||
}
|
||||
if (store.getters.getNowPath !== to.path && store.getters.getNowPath !== '/login') {
|
||||
requestsArr.forEach(xhr => xhr.cancel())
|
||||
}
|
||||
store.commit('setNowPath', to.path)
|
||||
const configUrl = 'static/config.json?Timestamp=' + new Date().getTime()
|
||||
if (to.path === '/login') { // 拦截登录页面,现货区外观设置 再系统初始化检查
|
||||
Vue.http.get(configUrl).then(config => {
|
||||
const appearance = new Promise(resolve => {
|
||||
get(config.body.baseUrl + 'sys/appearance').then(res => {
|
||||
if (res.code === 200) {
|
||||
localStorage.setItem('nz-sys-name', res.data.system_name || '')
|
||||
localStorage.setItem('nz-sys-logo', res.data.system_logo || '')
|
||||
localStorage.setItem('nz-sys-favicon', res.data.system_favicon || '')
|
||||
localStorage.setItem('nz-language', res.data.language || '')
|
||||
store.commit('setLanguage', res.data.language)
|
||||
localStorage.setItem('nz-sys-timezone', res.data.timezone || '')
|
||||
localStorage.setItem('nz-sys-bgImg', res.data.system_bgImg || '')
|
||||
localStorage.setItem('nz-default-theme', res.data.theme || '')
|
||||
localStorage.setItem('nz-default-dateFormat', res.data.dateFormat || '')
|
||||
changeFavicon(res.data.system_favicon)
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
appearance.then(() => {
|
||||
get(config.body.baseUrl + 'setup/inited').then(res => {
|
||||
if (res.code === 200) {
|
||||
if (res.inited === 0) {
|
||||
next({ path: '/setup' })
|
||||
} else {
|
||||
if (localStorage.getItem('nz-token')) {
|
||||
post('/sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
||||
if (res.code === 200) {
|
||||
const menuList = sortByOrderNum(res.data.menus)
|
||||
store.commit('setMenuList', menuList)
|
||||
const arr = []
|
||||
returnMenuCode(menuList, arr)
|
||||
store.commit('setButtonList', arr)
|
||||
store.commit('setRoleList', res.data.roles)
|
||||
bus.$emit('login')
|
||||
const path = []
|
||||
if (menuList) {
|
||||
menuList.forEach(e => {
|
||||
if (e.route) {
|
||||
path.push(e.route)
|
||||
} else {
|
||||
if (e.children) {
|
||||
e.children.forEach(e => {
|
||||
if (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()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
localStorage.setItem('nz-token', '')
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
} else if (localStorage.getItem('nz-token')) {
|
||||
const i18nRequest = new Promise(resolve => {
|
||||
// 从localStorage加载i18n
|
||||
if (!store.getters.i18nIsReady) {
|
||||
const langList = localStorage.getItem('nz-language-list')
|
||||
if (langList) {
|
||||
store.commit('setLangList', JSON.parse(langList))
|
||||
}
|
||||
Vue.http.get(configUrl).then(config => {
|
||||
get(config.body.baseUrl + 'sys/i18n/lang').then(response => {
|
||||
if (response.code === 200) {
|
||||
loadI18n(response.data)
|
||||
store.commit('i18nReady', true)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
const permissionRequest = new Promise(resolve => {
|
||||
if (store.getters.menuList.length === 0) {
|
||||
Vue.http.get(configUrl).then(config => {
|
||||
post(config.body.baseUrl + 'sys/user/permissions', { token: localStorage.getItem('nz-token') }).then(res => {
|
||||
if (res.code === 200) {
|
||||
store.commit('setMenuList', sortByOrderNum(res.data.menus))
|
||||
const arr = []
|
||||
returnMenuCode(res.data.menus, arr)
|
||||
store.commit('setButtonList', arr)
|
||||
store.commit('setRoleList', res.data.roles)
|
||||
const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
||||
document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
||||
resolve()
|
||||
} else {
|
||||
localStorage.removeItem('nz-token')
|
||||
next({ path: '/login' })
|
||||
}
|
||||
})
|
||||
})
|
||||
} else {
|
||||
const theme = localStorage.getItem(`nz-user-${localStorage.getItem('nz-user-id')}-theme`) || 'light'
|
||||
document.getElementsByTagName('body')[0].setAttribute('class', 'theme-' + theme)
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
Promise.all([i18nRequest, permissionRequest]).then(response => {
|
||||
if (to.path) {
|
||||
if (permissionWhiteList.indexOf(to.path) !== -1) {
|
||||
next()
|
||||
} else if (hasMenu(store.getters.menuList, to.path)) {
|
||||
next()
|
||||
} else {
|
||||
if (to.path === '/monitor/monitor/project' || to.path === '/monitor/monitor/module' || to.path === '/monitor/monitor/endpoint') {
|
||||
return
|
||||
}
|
||||
ElementUI.Message.error(i18n.t('tip.noAccess'))
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (loginWhiteList.indexOf(to.path) !== -1) {
|
||||
next()
|
||||
} else {
|
||||
next({ path: '/login' })
|
||||
}
|
||||
}
|
||||
})
|
||||
router.afterEach((to, from) => {
|
||||
// store.commit('setNowPath', '')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user