Commit b6a69fdb by cwq0219

create

0 parents
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
/build/
/config/
/dist/
/*.js
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}
.DS_Store
node_modules/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}
# template-introduction
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
```
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
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')
const spinner = ora('building for production...')
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, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
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'
))
})
})
'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)
}
}
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-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 = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(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')
})
}
}
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
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: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
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]')
}
}
]
},
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'
}
}
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
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: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
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(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
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)
}
})
})
'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 ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = require('../config/prod.env')
const 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/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: 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({
filename: config.build.index,
template: 'index.html',
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'
}),
// 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: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
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
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})
'use strict'
// Template version: 1.3.1
// 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
host: 'localhost', // can be overwritten by process.env.HOST
port: 8899, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true,
errorOverlay: true,
notifyOnErrors: true,
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-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
/**
* Source Maps
*/
productionSourceMap: true,
// 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 --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}
'use strict'
module.exports = {
NODE_ENV: '"production"'
}
No preview for this file type
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>广联赛讯Vue模板</title>
<link rel="icon" type="image/x-icon" href="static/favicon.ico">
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
This diff could not be displayed because it is too large.
{
"name": "template-introduction",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "cwq0219 <2838673010@qq.com>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"lint": "eslint --ext .js,.vue src",
"build": "node build/build.js"
},
"dependencies": {
"glsx-vue-components": "^1.0.15",
"v-viewer": "^1.4.0",
"vue": "^2.5.2",
"vue-router": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
<template>
<div id="app" class="is-component">
<gl-header :height='"100px"'>
<div>
<div class="img">
<viewer>
<img style="border-width:0;" src="./assets/logo.png">
</viewer>
</div>
<h1>
<span style="color: #409eff">{{header}}</span>
</h1>
</div>
</gl-header>
<div class="app-main">
<el-scrollbar class="page-component__scroll">
<gl-container>
<gl-aside class="aside" :width='"270px"'>
<el-scrollbar style="height: 100%;">
<div class="nav-group" v-for="(i, index) in data" :key="index">
<div class="nav-group__title">{{i.title}}</div>
<ul class="pure-menu-list">
<li v-for="(k, ind) in i.list" :key="ind" @click="scrollTop(i.list[ind])">
<router-link :to="'/' + k.link" ref="list">{{k.text}}</router-link>
</li>
</ul>
</div>
</el-scrollbar>
</gl-aside>
<gl-main class="main">
<router-view></router-view>
</gl-main>
</gl-container>
</el-scrollbar>
</div>
</div>
</template>
<script>
export default {
name: 'App',
data () {
return {
header: 'NodeJs和npm',
data: [
{
title: '环境配置',
list: [
{ text: 'NodeJs和npm', link: 'installNode', list: [{ text: 'nodejs' }, { text: 'npm' }, { text: 'npm安装包安装' }] },
{ text: 'Vue-cli', link: 'installCli' }
]
},
{
title: '定制化模板',
list: [
{ text: '项目结构', link: 'introduce' }
]
},
{
title: '前端接口模拟器',
list: [
{ text: 'Easy-Mock', link: 'easymock' }
]
}
]
}
},
methods: {
scrollTop (val) {
document.documentElement.scrollTop = 0
this.header = val.text
}
}
}
</script>
<style scoped>
.el-header, .el-footer {
width: 100%;
color: #333;
text-align: center;
}
#app .el-header{
position: fixed;
left: 0;
top: 0;
z-index: 2001;
background: #fff;
}
#app .el-header>div{
width: 1360px;
height: 100%;
margin: 0 auto;
}
.el-container{
max-width: 1360px;
height: 100%;
margin: 0 auto;
}
#app .el-header .img{
width: 270px;
height: 100%;
float: left;
box-sizing: border-box;
padding: 20px 25px 25px 0;
}
#app .el-header img{
width: 100%;
}
#app .el-header h1{
display: inline-block;
height: 100px;
line-height: 100px;
font-size: 35px;
letter-spacing: 5px;
color: #4D4D4D;
margin: 0;
}
.page-component__scroll{
height: 100%;
}
.aside{
position: fixed;
top: 0;
bottom: 0;
margin-top: 100px;
margin-bottom: -17px;
overflow-x:auto;
transition: all 1s;
z-index: 1999;
}
.main{
margin-left:270px;
}
.app-main {
margin: 100px 0 40px;
width: 100%;
color: #333;
}
.nav-group__title{
font-size: 14px;
color: #999;
line-height: 26px;
margin-top: 15px;
}
.pure-menu-list li{
list-style-type: none;
}
.pure-menu-list li a{
display: block;
height: 40px;
color: #444;
line-height: 40px;
font-size: 16px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-weight: 400;
text-decoration: none;
}
.pure-menu-list li p{
cursor: pointer;
}
.pure-menu-list li p:hover{
color: #409eff;
}
.pure-menu-list li .router-link-active{
color: #409eff;
}
.el-footer {
position: fixed;
bottom: 0;
left: 50%;
transform: translate3d(-50%,-50%,0);
height: 20px !important;
}
</style>
import easymock from './src/easymock'
easymock.install = function (Vue) {
Vue.component(easymock.name, easymock)
}
export default easymock
<!-- -->
<template>
<div class="box">
<h2>EasyMock</h2>
<p>
<a href="http://192.168.3.171:7300/docs" target="_black">EasyMock</a>
是一个可视化,并且能快速生成模拟数据的服务。
</p>
<h2>优势</h2>
<p>1、前后端分离,让前端独立后端开发。</p>
<p>2、增加单元测试的真实性,能够生成随机数据,模拟各种场景。</p>
<p>3、开发无侵入,无需修改代码,就可以拦截Ajax求取,返回模拟数据。</p>
<p>4、用法简单,内置数据类型丰富,方便扩展多种数据类型(自定义函数和正则)。</p>
<h2>开发遇到的问题</h2>
<p>1、开发过程中,后端还未完成数据输出,某些场景下需要返回大量的不同类型的随机数据。</p>
<p>2、Vue项目会将项目的配置文件一块打包,导致配置文件在当前环境下无法修改,需重新打包上传的重复性行为。</p>
<h2>解决办法</h2>
<p>1、使用EasyMock生成随机数据,并通过不同方法来模拟Ajax请求并返回模拟数据。</p>
<p>2、将项目配置写入EasyMock,通过Ajax动态获取配置。</p>
<h2>配置文件</h2>
<h3 style="margin-top:20px; font-size:20px;">项目中请求配置文件的axios</h3>
<p>admin:src/main.js文件。请求了
<a href="http://192.168.3.171:7300/editor/5be17454f31545347559d499/5be176f7f31545347559d49b" target="_black">【common.config.json】</a>
和
<a href="http://192.168.3.171:7300/editor/5be17454f31545347559d499/5be17725f31545347559d49c" target="_black">【admin.config.json】</a>
两个配置文件。
</p>
<p>subsystem:src/base.js文件。请求了
<a href="http://192.168.3.171:7300/editor/5be17454f31545347559d499/5be179b3f31545347559d49d" target="_black">【common.config.json】</a>
配置文件。
</p>
<h3 style="margin-top:20px; font-size:20px;">简要说明</h3>
<p>1、请求测试环境接口:以'http://sso-perm.test.glsx.com.cn'或者'http://qcsso.glsx.net'为开头。</p>
<p>2、请求开发环境接口:以'http://192.168'为开头。</p>
<p>3、请求线上环境接口:线上。</p>
<p>4、请求EasyMock接口:以'http://localhost'或者其他的为开头。</p>
</div>
</template>
<script>
export default {
name: 'easymock',
data () {
return {
}
}
}
</script>
<style scoped>
</style>
import installNode from './installNode'
import installCli from './installCli'
import introduce from './introduce'
import easymock from './easymock'
export {
installNode,
installCli,
introduce,
easymock
}
import installCli from './src/installCli'
installCli.install = function (Vue) {
Vue.component(installCli.name, installCli)
}
export default installCli
<!-- installCli -->
<template>
<div class="box">
<h2>Vue</h2>
<p><a href="https://cn.vuejs.org/" target="_black">Vue</a>是一套构建用户界面的渐进式前端框架。</p>
<h2>Vue-cli</h2>
<p><a href="https://www.npmjs.com/package/vue-cli" target="_black">Vue-cli</a>是官方提供的一个能够快速构建基于Vue.js项目的脚手架。</p>
<h5>全局安装Vue-cli</h5>
<pre><code class="hljs language-shell">{{code.npmVueCli}}</code></pre>
<h5>查看官方模板</h5>
<pre><code class="hljs language-shell">{{code.template}}</code></pre>
<p>目前,官方提供的模板有
<a href="https://github.com/vuejs-templates/webpack" target="_black">webpack</a>、
<a href="https://github.com/vuejs-templates/webpack-simple" target="_black">webpack-simple</a>、
<a href="https://github.com/vuejs-templates/browserify" target="_black">browserify</a>、
<a href="https://github.com/vuejs-templates/browserify-simple" target="_black">browserify-simple</a>和
<a href="https://github.com/vuejs-templates/simple" target="_black">simple</a>。
</p>
<h5>使用Vue-cli初始化项目</h5>
<pre><code class="hljs language-shell">{{code.npmInit}}</code></pre>
<h5>运行项目</h5>
<pre>
<code class="hljs language-shell">{{code.run}}</code>
<!-- <code class="hljs language-shell" style="margin-top: -90px; border-width: 0 1px 1px 1px;">{{code.installDependent}}</code> -->
<code class="hljs language-shell" style="margin-top: -90px; border-width: 0 1px 1px 1px; margin-bottom: -15px;">{{code.runVue}}</code>
</pre>
<!-- <p>例子</p> -->
<p class="img">
<viewer>
<img src="@/assets/template.png" alt="">
<img src="@/assets/success.png" alt="">
</viewer>
</p>
<h2>深度定制glsx-template</h2>
<p>独立开发项目时,使用官方提供的template确实很方便,省去了繁琐的依赖配置,webpack配置,甚至对于项目的结构都无需多加考虑。</p>
<p>但是,当我们开发多个系统,每个系统虽相对独立但又有一些配置,依赖或者逻辑相互通用时,每次都使用官方提供的模板之后,都需要进行重复性的调整,这是十分麻烦的。</p>
<p>因此,在官方模板的基础上,根据需要,加入了通用的配置和依赖,深度定制化模板。
<a href="https://github.com/glsx-web/webpack/tree/admin" target="_black">【admin-template地址】</a>
<a href="https://github.com/glsx-web/webpack/tree/subsystem" target="_black">【subsystem-template地址】</a>
</p>
<h3>使用定制化模板初始化项目</h3>
<p>在搭建项目之前,
<router-link to="/easymock">
<a href="">需了解项目所需的配置文件。</a>
</router-link>
</p>
<h5>admin-template(主系统模板)</h5>
<pre><code class="hljs language-shell">{{code.npmAdminTemInit}}</code></pre>
<!-- <p>例子</p> -->
<p class="img">
<viewer>
<img src="@/assets/adminInit.jpg" alt="">
</viewer>
</p>
<h5>subsystem-template(子系统模板)</h5>
<pre><code class="hljs language-shell">{{code.npmSubTemInit}}</code></pre>
<h5>安装依赖并运行</h5>
<pre>
<code class="hljs language-shell">{{code.run}}</code>
<code class="hljs language-shell" style="margin-top: -90px; border-width: 0 1px 1px 1px;">{{code.installDependent}}</code>
<code class="hljs language-shell" style="margin-top: -90px; border-width: 0 1px 1px 1px; margin-bottom: -20px;">{{code.runVue}}</code>
</pre>
<!-- <h5>运行</h5>
<pre><code class="hljs language-shell">{{code.runVue}}</code></pre> -->
<!-- <p>例子</p> -->
<p class="img">
<viewer>
<img src="@/assets/templateSuccess.png" alt="">
</viewer>
</p>
<h5>项目打包</h5>
<pre><code class="hljs language-shell">{{code.runPackage}}</code></pre>
</div>
</template>
<script>
export default {
name: 'installCli',
data () {
return {
code: {
npmVueCli: '$ npm install -g vue-cli',
npmInit: '$ vue init <template-name> <project-name>',
run: '$ cd <project-name>',
template: '$ vue list',
npmAdminTemInit: '$ vue init glsx-web/webpack#admin <project-name>',
npmSubTemInit: '$ vue init glsx-web/webpack#subsystem <project-name>',
installDependent: '$ npm install',
runVue: '$ npm run dev',
runPackage: '$ npm run build'
}
}
}
}
</script>
<style scoped>
</style>
import installNode from './src/installNode'
installNode.install = function (Vue) {
Vue.component(installNode.name, installNode)
}
export default installNode
<!-- 安装nodejs -->
<template>
<div class="box">
<h2>nodejs</h2>
<p>Node.js是一个基于Chrome JavaScript运行时建立的平台。</p>
<h2>npm</h2>
<p>在开发过程中,我们常常需要引用他人提供的重复的框架,简称为包(package)或模块(module)。</p>
<p>npm(node package manager)是node的包管理工具,主要用于管理node包,包括:安装、卸载、更新、查看、搜索、发布等。</p>
<!-- <p>npm能够详细记录每个包的信息,包括作者、版本、依赖、授权信息等。因此,开发者能够从繁琐的包管理工作中解放出来,更专注于功能的开发。</p> -->
<h2>npm的安装</h2>
<p>npm是用Node.js编写的,因此需要安装node.js才能使用npm。</p>
<h4>一、使用安装包安装</h4>
<p>如果你使用的是OS X或Windows,请使用<a href="https://nodejs.org/en/download/" target="_black">Nodejs官网</a>提供的标有LTS标识的安装程序。</p>
<p class="img">
<viewer>
<img src="@/assets/download.png" alt="">
</viewer>
</p>
<p>安装node.js时,会自动安装npm。安装完成后,你可以通过cmd命令查看和更新版本。</p>
<h5>查看nodejs版本</h5>
<pre><code class="hljs language-shell">{{code.checkNode}}</code></pre>
<h5>查看npm版本</h5>
<pre><code class="hljs language-shell">{{code.checkNpm}}</code></pre>
<h5>全局安裝最新版本的npm,-g代表全局安装。</h5>
<pre><code class="hljs language-shell">{{code.iNpmlast}}</code></pre>
<h4>二、使用nvm安装</h4>
<p>通过安装包安装的npm,仅安装在具有本地权限的目录中。当你尝试全局运行包时,可能会出现权限错误等提示。</p>
<p>因此,你还能通过nvm来进行安装。
<a href="https://github.com/creationix/nvm/blob/master/README.md#installation" target="_black">【Apple macOS】</a>
<a href="https://github.com/coreybutler/nvm-windows" target="_black">【windows】</a>
<a href="https://github.com/creationix/nvm/blob/master/README.md#installation" target="_black">【Linux】</a>
</p>
<h2>npm包安装模式</h2>
<p>安装npm包有两种方式:本地安装和全局安装。选择哪种方式安装,取决于我们将如何使用这个包。</p>
<p>如果你自己的模块依赖于某个包,并通过Node.js的require或import加载,那么你应该选择本地安装,这种方式也是 npm install 命令的默认行为。</p>
<p>如果你想将包作为一个命令行工具,(比如 vue-cli),那么你应该选择全局安装。</p>
<h5>安装一个包</h5>
<pre><code class="hljs language-shell">{{code.iPackage}}</code></pre>
<p>执行上述命令后,会在当前目录下创建一个node_modules的目录(若不存在该目录),并将包自动保存于该目录下。</p>
<h2>package.json文件</h2>
<p>管理本地安装npm包最好的方式就是创建package.json文件。</p>
<p>json文件作为包的描述文件,能够描述项目中所依赖的包。并且允许使用“
<a href="https://www.npmjs.com.cn/getting-started/semantic-versioning/" target="_black">语义化版本规则</a>
”,指明项目依赖包的版本,能够高效地管理包版本。</p>
<p>若当前目录下有package.json文件,那么将安装json文件中该包的指定版本。否则,将安装包最新版本。</p>
<h5>安装指定版本的包</h5>
<pre><code class="hljs language-shell">{{code.iPackageVer}}</code></pre>
<p>若当前目录下有package.json文件,那么使用如下指令,就能安装该项目所有依赖。</p>
<h5>安装依赖</h5>
<pre><code class="hljs language-shell">{{code.iPackageJson}}</code></pre>
</div>
</template>
<script>
export default {
name: 'installNode',
data () {
return {
code: {
checkNode: '$ node -v',
checkNpm: '$ npm -v',
iNpmlast: '$ npm install npm@latest -g',
iPackage: '$ npm install <package-name>',
iPackageVer: '$ npm install <package-name>@<package-version>',
iPackageJson: '$ npm install'
}
}
}
}
</script>
<style scoped>
</style>
import introduce from './src/introduce'
introduce.install = function (Vue) {
Vue.component(introduce.name, introduce)
}
export default introduce
<!-- 安装nodejs -->
<template>
<div class="box">
<h2>项目配置文件介绍</h2>
<h3 style="margin-top:20px;">文件结构</h3>
<div
class="hljs"
style=""
>
<p>
<span class="halfWidth">|——&emsp;bulid.js</span>
<span>//&emsp;构建脚本目录</span>
</p>
<p>
<span class="halfWidth">|——&emsp;config</span>
<span>//&emsp;项目打包路径</span>
</p>
<p>
<span class="halfWidth">|——&emsp;dist</span>
<span>//&emsp;打包后的项目文件</span>
</p>
<p>
<span class="halfWidth">|——&emsp;node_modules</span>
<span>//&emsp;项目依赖(插件)</span>
</p>
<p>
<span class="halfWidth">|——&emsp;src</span>
<span>//&emsp;源码目录</span>
</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;assets</span>
<span>//&emsp;图片资源文件</span>
</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;components</span>
<span>//&emsp;组件</span>
</p>
<p>|&emsp;&emsp;|————&emsp;lang</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;router</span>
<span>//&emsp;路由配置</span>
</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;store</span>
<span>//&emsp;Vues Store文件,APP核心所在</span>
</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;views</span>
<span>//&emsp;页面编写</span>
</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;App.vue</span>
<span>//&emsp;App入口文件</span>
</p>
<p>
<span class="halfWidth">|&emsp;&emsp;|————&emsp;main.vue</span>
<span>//&emsp;程序入口文件,加载Vuex,Vue-router等插件</span>
</p>
<p>
<span class="halfWidth">|——&emsp;static</span>
<span>//&emsp;项目git版本管理</span>
</p>
<p>
<span class="halfWidth">|——&emsp;test</span>
<span>//&emsp;测试目录</span>
</p>
<p>
<span class="halfWidth">|——&emsp;.babelrc</span>
<span>//&emsp;ES6语法编译配置</span>
</p>
<p>
<span class="halfWidth">|——&emsp;.editorconfig</span>
<span>//&emsp;代码编写规格</span>
</p>
<p>
<span class="halfWidth">|——&emsp;.eslintignore</span>
<span>//&emsp;EsLint 忽略的文件</span>
</p>
<p>
<span class="halfWidth">|——&emsp;.eslintrc.js</span>
<span>//&emsp;EsLint配置</span>
</p>
<p>
<span class="halfWidth">|——&emsp;.gitignore</span>
<span>//&emsp;git ingnore</span>
</p>
<p>
<span class="halfWidth">|——&emsp;.postcssrc.js</span>
<span>//&emsp;postcss配置文件</span>
</p>
<p>
<span class="halfWidth">|——&emsp;index.html</span>
<span>//&emsp;入口html文件</span>
</p>
<p>
<span class="halfWidth">|——&emsp;package.json</span>
<span>//&emsp;项目及工具的依赖配置文件</span>
</p>
<p>
<span class="halfWidth">|——&emsp;readme.md</span>
<span>//&emsp;README</span>
</p>
</div>
<h2>package.json</h2>
<h3 style="margin-top:20px; font-size:20px;">该文件至少包含两个部分:</h3>
<p>1、name:全部小写,不能有空格,可以使用下划线或者横线。</p>
<p>2、version:x.x.x的格式,一般初始化项目的时候,使用默认的即可。</p>
<h3 style="margin-top:20px; font-size:20px;">其他可选内容:</h3>
<p>description:项目描述信息,有助于搜索。(若没有“description”,那么README.md中的第一行将作为该项目的描述信息)</p>
<p>dependencies:在生产环境中需要用到的依赖</p>
<p>devDependencies:在开发、测试环境中用到的依赖</p>
<p>安装依赖参数</p>
<p>方法一:手动修改package.json文件,对dependencies和devDependencies中的内容进行修改,然后重新安装依赖即可。</p>
<p>方法二:命令行。</p>
<h5>将包名及对应的版本添加到 package.json的 dependencies</h5>
<pre><code class="hljs language-shell">{{code.installDepent}}</code></pre>
<h5>将包名及对应的版本添加到 package.json的 devDependencies</h5>
<pre><code class="hljs language-shell">{{code.installDev}}</code></pre>
<p>scripts:支持的脚本。</p>
<h4>srcipts字段分析</h4>
<p>dev:开发模式指令</p>
<p>bulid:构建模式指令</p>
<p>unit、e2e、test、lint:测试模式指令</p>
<h2>build文件夹</h2>
<h5 style="margin:10px 0;">package.json里的字段:</h5>
<div class="hljs">
<p>"dev": "webpack-dev-server ——inline ——progress ——config build/webpack.dev.conf.js"</p>
<p>"build": "node build/build.js"</p>
</div>
<p>由上述代码,可以看到运行的脚本来自于build文件夹。因此,build文件夹是用于存放nodejs脚本的。</p>
<h2>config文件夹</h2>
<h4 style="margin:10px 0;">config/index.js</h4>
<p>描述了开发和构建两种环境的配置。</p>
<div class="hljs language-shell">
<p>var path = require('path')</p>
<p>module.exports = {</p>
<p>&emsp;dev: { ... }</p>
<p>&emsp;build: { ... }</p>
<p>}</p>
</div>
<p>config/dev.env.js、config/prod.env.js和config/test.env.js用于配置环境变量。</p>
<h2>Vue-cli2和Vue-cli3</h2>
<p>本教程以上内容是基于Vue-cli的2.x版本开展的,下面将介绍Vue-cli3.0。</p>
<p>2018年8月11日,Vue的作者尤雨溪正式发布
<a href="https://cli.vuejs.org/" target="_black">Vue-cli3.0。</a>
</p>
<h4>3.0版本与此前的版本完全不同,目的在于:</h4>
<p>1、减少现代前端工具的配置烦扰,尤其是在将多个工具混合在一起使用时。</p>
<p>2、尽可能在工具链中加入最佳实践,让它成为任意 Vue 应用程序的默认实践。</p>
<h4>2.x和3.0的区别</h4>
<p>1、npm包的包名,新版本并未沿用2.x版本的vue-cli,而是另起了@vue/cli。</p>
<h5>卸载vue-cli2.x</h5>
<pre><code class="hljs language-shell">{{code.uninstall}}</code></pre>
<h5>安装Vue-cli3.0</h5>
<pre><code class="hljs language-shell">{{code.installCli3}}</code></pre>
<h5>创建vue项目</h5>
<pre><code class="hljs language-shell">{{code.createCli3}}</code></pre>
<p>目前,官方只提供一套基于Vue-cli3的模板。</p>
<p>2、项目文件结构区别</p>
<p>3.0版本中,少了bulid,config文件夹,极大的简化了项目的配置。</p>
<p>项目的基本配置,存放在根目录下的vue.config.js中。</p>
<p>
<span class="tips">tips:</span>
本教程中提供的两个模板。其中,admin-template是基于vue-cli2.x版本结构编码;subsystem-template是基于vue-cli3.0版本结构编码。
</p>
<p>因此,两个项目的文件结构会有些许不同。</p>
</div>
</template>
<script>
export default {
name: 'introduce',
data () {
return {
code: {
installDepent: '$ npm install <package_name> --save',
installDev: '$ npm install <package_name> --save-dev',
uninstall: '$ npm uninstall vue-cli -g',
installCli3: '$ npm install -g @vue/cli',
createCli3: '$ vue create <project-name>'
}
}
}
}
</script>
<style scoped>
.halfWidth {
display: inline-block;
width: 50%;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
</style>
*{
margin: 0;
padding: 0;
}
a{
color: #409eff;
text-decoration: none
}
body,html{
font-family: 'Helvetica Neue',Helvetica,'PingFang SC','Hiragino Sans GB','Microsoft YaHei','SimSun',sans-serif;
-webkit-font-smoothing: antialiased;
}
.img{
width: 100%;
text-align: center;
}
img{
width: 80%;
border: 1px solid #eaeefb;
border-radius: 4px;
}
.tips{
color: #f56c6c;
}
pre{
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0px;
}
code{
background-color: #f9fafc;
padding: 0 4px;
border: 1px solid #eaeefb;
border-radius: 4px;
}
.hljs{
display: block;
line-height: 1.8;
overflow-x: auto;
font-family: Menlo,Monaco,Consolas,Courier,monospace;
font-size: 16px;
padding: 18px 24px;
background-color: #fafafa;
border: 1px solid #eaeefb;
margin-bottom: 25px;
border-radius: 4px;
-webkit-font-smoothing: auto;
}
.box{
padding: 15px;
}
.box h2,.box h3{
font-weight: 400;
color: #1f2f3d;
}
.box h2{
font-size: 28px;
}
.box h3{
margin: 55px 0 20px;
font-size: 22px;
}
.box p{
font-size: 16px;
color: #5e6d82;
line-height: 1.5em;
margin: 1em 0;
}
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import GlsxVueComponents from 'glsx-vue-components'
import 'glsx-vue-components/dist/glsx-vue-components.css'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import '@/css/common.css'
import { installNode, installCli, introduce, easymock } from '../src/components/index'
const components = [
installNode,
installCli,
introduce,
easymock
]
Vue.use(GlsxVueComponents)
components.map(component => {
Vue.use(component)
})
Vue.config.productionTip = false
Vue.use(Viewer)
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
const installNode = {template: '<installNode />'}
const installCli = {template: '<installCli />'}
const introduce = {template: '<introduce />'}
const easymock = {template: '<easymock />'}
export default new Router({
routes: [
{ path: '/', redirect: '/installNode' },
{ path: '/installNode', name: 'installNode', component: installNode },
{ path: '/installCli', name: 'installCli', component: installCli },
{ path: '/introduce', name: 'introduce', component: introduce },
{ path: '/easymock', name: 'easymock', component: easymock }
]
})
File mode changed
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!