├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .postcssrc.js
├── README.md
├── build
├── build.js
├── check-versions.js
├── dev-client.js
├── dev-server.js
├── utils.js
├── vue-loader.conf.js
├── webpack.base.conf.js
├── webpack.dev.conf.js
├── webpack.prod.conf.js
└── webpack.test.conf.js
├── config
├── dev.env.js
├── index.js
├── prod.env.js
└── test.env.js
├── index.html
├── package.json
├── src
├── App.vue
├── api
│ ├── axios.js
│ ├── call.js
│ ├── index.js
│ └── list
│ │ └── common.js
├── assets
│ └── .gitkeep
├── components
│ ├── .gitkeep
│ └── qrcode
│ │ ├── imgs
│ │ └── logo.png
│ │ └── index.vue
├── main.js
├── pages
│ ├── 404
│ │ └── app.vue
│ ├── guide-axios
│ │ ├── index.vue
│ │ ├── style.css
│ │ └── template.html
│ ├── guide-router
│ │ ├── index.vue
│ │ ├── style.css
│ │ └── template.html
│ ├── guide-store
│ │ ├── index.vue
│ │ ├── style.css
│ │ └── template.html
│ └── qrcode
│ │ ├── app.vue
│ │ └── imgs
│ │ └── logo.png
├── router
│ ├── index.js
│ ├── map.js
│ └── name.js
├── store
│ ├── actions.js
│ ├── getters.js
│ ├── index.js
│ ├── modules
│ │ └── child.js
│ ├── mutationTypes.js
│ ├── mutations.js
│ └── state.js
└── utils
│ ├── date.js
│ └── global-config.js
├── static
└── .gitkeep
└── test
├── e2e
├── custom-assertions
│ └── elementCount.js
├── nightwatch.conf.js
├── runner.js
└── specs
│ └── test.js
└── unit
├── .eslintrc
├── index.js
├── karma.conf.js
└── specs
└── Hello.spec.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", { "modules": false }],
4 | "stage-2"
5 | ],
6 | "plugins": ["transform-runtime"],
7 | "comments": false,
8 | "env": {
9 | "test": {
10 | "presets": ["env", "stage-2"],
11 | "plugins": [ "istanbul" ]
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | build/*.js
2 | config/*.js
3 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | 'browser': true,
4 | 'commonjs': true,
5 | 'es6': true
6 | },
7 | root: true,
8 | parser: 'babel-eslint',
9 | // parserOptions: {
10 | // "ecmaVersion": 6,
11 | // "sourceType": "module",
12 | // "ecmaFeatures": {
13 | // "jsx": true
14 | // }
15 | // },
16 | globals: {
17 | 'Vue': false
18 | },
19 | // extends: 'standard',
20 | plugins: [
21 | 'html'
22 | ],
23 | rules: {
24 | // no-console
25 | 'no-console': 0,
26 | //不能有未定义的变量
27 | 'no-undef': 2,
28 | //不能有声明后未被使用的变量或参数
29 | "no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
30 | //未定义前不能使用
31 | "no-use-before-define": 2,
32 | //禁止不必要的call和apply
33 | "no-useless-call": 2,
34 | // no-var
35 | 'no-var': 'error',
36 | // 要求或禁止 var 声明中的初始化
37 | // 'init-declarations': 2,
38 | // 强制使用单引号
39 | 'quotes': ['error', 'single'],
40 | // 要求或禁止使用分号而不是 ASI
41 | 'semi': ['error', 'never'],
42 | // 禁止不必要的分号
43 | 'no-extra-semi': 'error',
44 | // 强制使用一致的换行风格
45 | //'linebreak-style': ['error', 'unix'],
46 | // 空格2个
47 | 'indent': ['error', 2, {'SwitchCase': 1}],
48 | // 指定数组的元素之间要以空格隔开(,后面), never参数:[ 之前和 ] 之后不能带空格,always参数:[ 之前和 ] 之后必须带空格
49 | 'array-bracket-spacing': [2, 'never'],
50 | // 在块级作用域外访问块内定义的变量是否报错提示
51 | 'block-scoped-var': 0,
52 | // if while function 后面的{必须与if在同一行,java风格。
53 | 'brace-style': [2, '1tbs', {'allowSingleLine': true}],
54 | // 双峰驼命名格式
55 | 'camelcase': 2,
56 | // 数组和对象键值对最后一个逗号, never参数:不能带末尾的逗号, always参数:必须带末尾的逗号,
57 | // always-multiline:多行模式必须带逗号,单行模式不能带逗号
58 | 'comma-dangle': [2, 'never'],
59 | // 控制逗号前后的空格
60 | 'comma-spacing': [2, {'before': false, 'after': true}],
61 | // 控制逗号在行尾出现还是在行首出现
62 | 'comma-style': [2, 'last'],
63 | // 圈复杂度
64 | 'complexity': [2, 20],
65 | // 以方括号取对象属性时,[ 后面和 ] 前面是否需要空格, 可选参数 never, always
66 | 'computed-property-spacing': [2, 'never'],
67 | // TODO 关闭 强制方法必须返回值,TypeScript强类型,不配置
68 | // 'consistent-return': 0
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | .idea
4 | dist/
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 | test/unit/coverage
9 | test/e2e/reports
10 | selenium-debug.log
11 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserlist" field in package.json
6 | "autoprefixer": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-frame1
2 |
3 | > A Vue.js project
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | npm install
10 |
11 | # serve with hot reload at localhost:8080
12 | npm run dev
13 |
14 | # build for production with minification
15 | npm run build
16 |
17 | # build for production and view the bundle analyzer report
18 | npm run build --report
19 |
20 | # run unit tests
21 | npm run unit
22 |
23 | # run e2e tests
24 | npm run e2e
25 |
26 | # run all tests
27 | npm test
28 | ```
29 |
30 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
31 |
--------------------------------------------------------------------------------
/build/build.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 |
3 | process.env.NODE_ENV = 'production'
4 |
5 | var ora = require('ora')
6 | var rm = require('rimraf')
7 | var path = require('path')
8 | var chalk = require('chalk')
9 | var webpack = require('webpack')
10 | var config = require('../config')
11 | var webpackConfig = require('./webpack.prod.conf')
12 |
13 | var spinner = ora('building for production...')
14 | spinner.start()
15 |
16 | rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
17 | if (err) throw err
18 | webpack(webpackConfig, function (err, stats) {
19 | spinner.stop()
20 | if (err) throw err
21 | process.stdout.write(stats.toString({
22 | colors: true,
23 | modules: false,
24 | children: false,
25 | chunks: false,
26 | chunkModules: false
27 | }) + '\n\n')
28 |
29 | console.log(chalk.cyan(' Build complete.\n'))
30 | console.log(chalk.yellow(
31 | ' Tip: built files are meant to be served over an HTTP server.\n' +
32 | ' Opening index.html over file:// won\'t work.\n'
33 | ))
34 | })
35 | })
36 |
--------------------------------------------------------------------------------
/build/check-versions.js:
--------------------------------------------------------------------------------
1 | var chalk = require('chalk')
2 | var semver = require('semver')
3 | var packageConfig = require('../package.json')
4 | var shell = require('shelljs')
5 | function exec (cmd) {
6 | return require('child_process').execSync(cmd).toString().trim()
7 | }
8 |
9 | var versionRequirements = [
10 | {
11 | name: 'node',
12 | currentVersion: semver.clean(process.version),
13 | versionRequirement: packageConfig.engines.node
14 | },
15 | ]
16 |
17 | if (shell.which('npm')) {
18 | versionRequirements.push({
19 | name: 'npm',
20 | currentVersion: exec('npm --version'),
21 | versionRequirement: packageConfig.engines.npm
22 | })
23 | }
24 |
25 | module.exports = function () {
26 | var warnings = []
27 | for (var i = 0; i < versionRequirements.length; i++) {
28 | var mod = versionRequirements[i]
29 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
30 | warnings.push(mod.name + ': ' +
31 | chalk.red(mod.currentVersion) + ' should be ' +
32 | chalk.green(mod.versionRequirement)
33 | )
34 | }
35 | }
36 |
37 | if (warnings.length) {
38 | console.log('')
39 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
40 | console.log()
41 | for (var i = 0; i < warnings.length; i++) {
42 | var warning = warnings[i]
43 | console.log(' ' + warning)
44 | }
45 | console.log()
46 | process.exit(1)
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/build/dev-client.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | require('eventsource-polyfill')
3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
4 |
5 | hotClient.subscribe(function (event) {
6 | if (event.action === 'reload') {
7 | window.location.reload()
8 | }
9 | })
10 |
--------------------------------------------------------------------------------
/build/dev-server.js:
--------------------------------------------------------------------------------
1 | require('./check-versions')()
2 |
3 | var config = require('../config')
4 | if (!process.env.NODE_ENV) {
5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV)
6 | }
7 |
8 | var opn = require('opn')
9 | var path = require('path')
10 | var express = require('express')
11 | var webpack = require('webpack')
12 | var proxyMiddleware = require('http-proxy-middleware')
13 | var webpackConfig = process.env.NODE_ENV === 'testing'
14 | ? require('./webpack.prod.conf')
15 | : require('./webpack.dev.conf')
16 |
17 | // default port where dev server listens for incoming traffic
18 | var port = process.env.PORT || config.dev.port
19 | // automatically open browser, if not set will be false
20 | var autoOpenBrowser = !!config.dev.autoOpenBrowser
21 | // Define HTTP proxies to your custom API backend
22 | // https://github.com/chimurai/http-proxy-middleware
23 | var proxyTable = config.dev.proxyTable
24 |
25 | var app = express()
26 | var compiler = webpack(webpackConfig)
27 |
28 | var devMiddleware = require('webpack-dev-middleware')(compiler, {
29 | publicPath: webpackConfig.output.publicPath,
30 | quiet: true
31 | })
32 |
33 | var hotMiddleware = require('webpack-hot-middleware')(compiler, {
34 | log: () => {}
35 | })
36 | // force page reload when html-webpack-plugin template changes
37 | compiler.plugin('compilation', function (compilation) {
38 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
39 | hotMiddleware.publish({ action: 'reload' })
40 | cb()
41 | })
42 | })
43 |
44 | // proxy api requests
45 | Object.keys(proxyTable).forEach(function (context) {
46 | var options = proxyTable[context]
47 | if (typeof options === 'string') {
48 | options = { target: options }
49 | }
50 | app.use(proxyMiddleware(options.filter || context, options))
51 | })
52 |
53 | // handle fallback for HTML5 history API
54 | app.use(require('connect-history-api-fallback')())
55 |
56 | // serve webpack bundle output
57 | app.use(devMiddleware)
58 |
59 | // enable hot-reload and state-preserving
60 | // compilation error display
61 | app.use(hotMiddleware)
62 |
63 | // serve pure static assets
64 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
65 | app.use(staticPath, express.static('./static'))
66 |
67 | var uri = 'http://localhost:' + port
68 |
69 | var _resolve
70 | var readyPromise = new Promise(resolve => {
71 | _resolve = resolve
72 | })
73 |
74 | console.log('> Starting dev server...')
75 | devMiddleware.waitUntilValid(() => {
76 | console.log('> Listening at ' + uri + '\n')
77 | // when env is testing, don't need open it
78 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
79 | opn(uri)
80 | }
81 | _resolve()
82 | })
83 |
84 | var server = app.listen(port)
85 |
86 | module.exports = {
87 | ready: readyPromise,
88 | close: () => {
89 | server.close()
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/build/utils.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var config = require('../config')
3 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
4 |
5 | exports.assetsPath = function (_path) {
6 | var assetsSubDirectory = process.env.NODE_ENV === 'production'
7 | ? config.build.assetsSubDirectory
8 | : config.dev.assetsSubDirectory
9 | return path.posix.join(assetsSubDirectory, _path)
10 | }
11 |
12 | exports.cssLoaders = function (options) {
13 | options = options || {}
14 |
15 | var cssLoader = {
16 | loader: 'css-loader',
17 | options: {
18 | minimize: process.env.NODE_ENV === 'production',
19 | sourceMap: options.sourceMap
20 | }
21 | }
22 |
23 | // generate loader string to be used with extract text plugin
24 | function generateLoaders (loader, loaderOptions) {
25 | var loaders = [cssLoader]
26 | if (loader) {
27 | loaders.push({
28 | loader: loader + '-loader',
29 | options: Object.assign({}, loaderOptions, {
30 | sourceMap: options.sourceMap
31 | })
32 | })
33 | }
34 |
35 | // Extract CSS when that option is specified
36 | // (which is the case during production build)
37 | if (options.extract) {
38 | return ExtractTextPlugin.extract({
39 | use: loaders,
40 | fallback: 'vue-style-loader'
41 | })
42 | } else {
43 | return ['vue-style-loader'].concat(loaders)
44 | }
45 | }
46 |
47 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html
48 | return {
49 | css: generateLoaders(),
50 | postcss: generateLoaders(),
51 | less: generateLoaders('less'),
52 | sass: generateLoaders('sass', { indentedSyntax: true }),
53 | scss: generateLoaders('sass'),
54 | stylus: generateLoaders('stylus'),
55 | styl: generateLoaders('stylus')
56 | }
57 | }
58 |
59 | // Generate loaders for standalone style files (outside of .vue)
60 | exports.styleLoaders = function (options) {
61 | var output = []
62 | var loaders = exports.cssLoaders(options)
63 | for (var extension in loaders) {
64 | var loader = loaders[extension]
65 | output.push({
66 | test: new RegExp('\\.' + extension + '$'),
67 | use: loader
68 | })
69 | }
70 | return output
71 | }
72 |
--------------------------------------------------------------------------------
/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var config = require('../config')
3 | var isProduction = process.env.NODE_ENV === 'production'
4 |
5 | module.exports = {
6 | loaders: utils.cssLoaders({
7 | sourceMap: isProduction
8 | ? config.build.productionSourceMap
9 | : config.dev.cssSourceMap,
10 | extract: isProduction
11 | })
12 | }
13 |
--------------------------------------------------------------------------------
/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var utils = require('./utils')
3 | var config = require('../config')
4 | var vueLoaderConfig = require('./vue-loader.conf')
5 |
6 | function resolve (dir) {
7 | return path.join(__dirname, '..', dir)
8 | }
9 |
10 | module.exports = {
11 | entry: {
12 | app: './src/main.js'
13 | },
14 | output: {
15 | path: config.build.assetsRoot,
16 | filename: '[name].js',
17 | publicPath: process.env.NODE_ENV === 'production'
18 | ? config.build.assetsPublicPath
19 | : config.dev.assetsPublicPath
20 | },
21 | resolve: {
22 | extensions: ['.js', '.vue', '.json'],
23 | alias: {
24 | 'vue$': 'vue/dist/vue.esm.js',
25 | '@': resolve('src'),
26 | 'assets': path.resolve(__dirname, '../src/assets'),
27 | 'components': path.resolve(__dirname, '../src/components'),
28 | 'api': path.resolve(__dirname, '../src/api'),
29 | 'utils': path.resolve(__dirname, '../src/utils'),
30 | 'pages': path.resolve(__dirname, '../src/pages'),
31 | 'router': path.resolve(__dirname, '../src/router'),
32 | 'store': path.resolve(__dirname, '../src/store')
33 | }
34 | },
35 | module: {
36 | rules: [
37 | {
38 | test: /\.(js|vue)$/,
39 | loader: 'eslint-loader',
40 | enforce: 'pre',
41 | include: [resolve('src'), resolve('test')],
42 | options: {
43 | formatter: require('eslint-friendly-formatter')
44 | }
45 | },
46 | {
47 | test: /\.vue$/,
48 | loader: 'vue-loader',
49 | options: vueLoaderConfig
50 | },
51 | {
52 | test: /\.js$/,
53 | loader: 'babel-loader',
54 | include: [resolve('src'), resolve('test')]
55 | },
56 | {
57 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
58 | loader: 'url-loader',
59 | options: {
60 | limit: 10000,
61 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
62 | }
63 | },
64 | {
65 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
66 | loader: 'url-loader',
67 | options: {
68 | limit: 10000,
69 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
70 | }
71 | }
72 | ]
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/build/webpack.dev.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var webpack = require('webpack')
3 | var config = require('../config')
4 | var merge = require('webpack-merge')
5 | var baseWebpackConfig = require('./webpack.base.conf')
6 | var HtmlWebpackPlugin = require('html-webpack-plugin')
7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
8 |
9 | // add hot-reload related code to entry chunks
10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) {
11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
12 | })
13 |
14 | module.exports = merge(baseWebpackConfig, {
15 | module: {
16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
17 | },
18 | // cheap-module-eval-source-map is faster for development
19 | devtool: '#cheap-module-eval-source-map',
20 | plugins: [
21 | new webpack.DefinePlugin({
22 | 'process.env': config.dev.env
23 | }),
24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
25 | new webpack.HotModuleReplacementPlugin(),
26 | new webpack.NoEmitOnErrorsPlugin(),
27 | // https://github.com/ampedandwired/html-webpack-plugin
28 | new HtmlWebpackPlugin({
29 | filename: 'index.html',
30 | template: 'index.html',
31 | inject: true
32 | }),
33 | new FriendlyErrorsPlugin()
34 | ]
35 | })
36 |
--------------------------------------------------------------------------------
/build/webpack.prod.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var utils = require('./utils')
3 | var webpack = require('webpack')
4 | var config = require('../config')
5 | var merge = require('webpack-merge')
6 | var baseWebpackConfig = require('./webpack.base.conf')
7 | var CopyWebpackPlugin = require('copy-webpack-plugin')
8 | var HtmlWebpackPlugin = require('html-webpack-plugin')
9 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
10 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
11 |
12 | var env = process.env.NODE_ENV === 'testing'
13 | ? require('../config/test.env')
14 | : config.build.env
15 |
16 | var webpackConfig = merge(baseWebpackConfig, {
17 | module: {
18 | rules: utils.styleLoaders({
19 | sourceMap: config.build.productionSourceMap,
20 | extract: true
21 | })
22 | },
23 | devtool: config.build.productionSourceMap ? '#source-map' : false,
24 | output: {
25 | path: config.build.assetsRoot,
26 | filename: utils.assetsPath('js/[name].[chunkhash].js'),
27 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
28 | },
29 | plugins: [
30 | // http://vuejs.github.io/vue-loader/en/workflow/production.html
31 | new webpack.DefinePlugin({
32 | 'process.env': env
33 | }),
34 | new webpack.optimize.UglifyJsPlugin({
35 | compress: {
36 | warnings: false
37 | },
38 | sourceMap: true
39 | }),
40 | // extract css into its own file
41 | new ExtractTextPlugin({
42 | filename: utils.assetsPath('css/[name].[contenthash].css')
43 | }),
44 | // Compress extracted CSS. We are using this plugin so that possible
45 | // duplicated CSS from different components can be deduped.
46 | new OptimizeCSSPlugin({
47 | cssProcessorOptions: {
48 | safe: true
49 | }
50 | }),
51 | // generate dist index.html with correct asset hash for caching.
52 | // you can customize output by editing /index.html
53 | // see https://github.com/ampedandwired/html-webpack-plugin
54 | new HtmlWebpackPlugin({
55 | filename: process.env.NODE_ENV === 'testing'
56 | ? 'index.html'
57 | : config.build.index,
58 | template: 'index.html',
59 | inject: true,
60 | minify: {
61 | removeComments: true,
62 | collapseWhitespace: true,
63 | removeAttributeQuotes: true
64 | // more options:
65 | // https://github.com/kangax/html-minifier#options-quick-reference
66 | },
67 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin
68 | chunksSortMode: 'dependency'
69 | }),
70 | // split vendor js into its own file
71 | new webpack.optimize.CommonsChunkPlugin({
72 | name: 'vendor',
73 | minChunks: function (module, count) {
74 | // any required modules inside node_modules are extracted to vendor
75 | return (
76 | module.resource &&
77 | /\.js$/.test(module.resource) &&
78 | module.resource.indexOf(
79 | path.join(__dirname, '../node_modules')
80 | ) === 0
81 | )
82 | }
83 | }),
84 | // extract webpack runtime and module manifest to its own file in order to
85 | // prevent vendor hash from being updated whenever app bundle is updated
86 | new webpack.optimize.CommonsChunkPlugin({
87 | name: 'manifest',
88 | chunks: ['vendor']
89 | }),
90 | // copy custom static assets
91 | new CopyWebpackPlugin([
92 | {
93 | from: path.resolve(__dirname, '../static'),
94 | to: config.build.assetsSubDirectory,
95 | ignore: ['.*']
96 | }
97 | ])
98 | ]
99 | })
100 |
101 | if (config.build.productionGzip) {
102 | var CompressionWebpackPlugin = require('compression-webpack-plugin')
103 |
104 | webpackConfig.plugins.push(
105 | new CompressionWebpackPlugin({
106 | asset: '[path].gz[query]',
107 | algorithm: 'gzip',
108 | test: new RegExp(
109 | '\\.(' +
110 | config.build.productionGzipExtensions.join('|') +
111 | ')$'
112 | ),
113 | threshold: 10240,
114 | minRatio: 0.8
115 | })
116 | )
117 | }
118 |
119 | if (config.build.bundleAnalyzerReport) {
120 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
121 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
122 | }
123 |
124 | module.exports = webpackConfig
125 |
--------------------------------------------------------------------------------
/build/webpack.test.conf.js:
--------------------------------------------------------------------------------
1 | // This is the webpack config used for unit tests.
2 |
3 | var utils = require('./utils')
4 | var webpack = require('webpack')
5 | var merge = require('webpack-merge')
6 | var baseConfig = require('./webpack.base.conf')
7 |
8 | var webpackConfig = merge(baseConfig, {
9 | // use inline sourcemap for karma-sourcemap-loader
10 | module: {
11 | rules: utils.styleLoaders()
12 | },
13 | devtool: '#inline-source-map',
14 | resolveLoader: {
15 | alias: {
16 | // necessary to to make lang="scss" work in test when using vue-loader's ?inject option
17 | // see discussion at https://github.com/vuejs/vue-loader/issues/724
18 | 'scss-loader': 'sass-loader'
19 | }
20 | },
21 | plugins: [
22 | new webpack.DefinePlugin({
23 | 'process.env': require('../config/test.env')
24 | })
25 | ]
26 | })
27 |
28 | // no need for app entry during tests
29 | delete webpackConfig.entry
30 |
31 | module.exports = webpackConfig
32 |
--------------------------------------------------------------------------------
/config/dev.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var prodEnv = require('./prod.env')
3 |
4 | module.exports = merge(prodEnv, {
5 | NODE_ENV: '"development"'
6 | })
7 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // see http://vuejs-templates.github.io/webpack for documentation.
2 | var path = require('path')
3 |
4 | module.exports = {
5 | build: {
6 | env: require('./prod.env'),
7 | index: path.resolve(__dirname, '../dist/index.html'),
8 | assetsRoot: path.resolve(__dirname, '../dist'),
9 | assetsSubDirectory: 'static',
10 | assetsPublicPath: '/',
11 | productionSourceMap: true,
12 | // Gzip off by default as many popular static hosts such as
13 | // Surge or Netlify already gzip all static assets for you.
14 | // Before setting to `true`, make sure to:
15 | // npm install --save-dev compression-webpack-plugin
16 | productionGzip: false,
17 | productionGzipExtensions: ['js', 'css'],
18 | // Run the build command with an extra argument to
19 | // View the bundle analyzer report after build finishes:
20 | // `npm run build --report`
21 | // Set to `true` or `false` to always turn it on or off
22 | bundleAnalyzerReport: process.env.npm_config_report
23 | },
24 | dev: {
25 | env: require('./dev.env'),
26 | port: 8080,
27 | autoOpenBrowser: true,
28 | assetsSubDirectory: 'static',
29 | assetsPublicPath: '/',
30 | proxyTable: {},
31 | // CSS Sourcemaps off by default because relative paths are "buggy"
32 | // with this option, according to the CSS-Loader README
33 | // (https://github.com/webpack/css-loader#sourcemaps)
34 | // In our experience, they generally work as expected,
35 | // just be aware of this issue when enabling this option.
36 | cssSourceMap: false
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/config/test.env.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var devEnv = require('./dev.env')
3 |
4 | module.exports = merge(devEnv, {
5 | NODE_ENV: '"testing"'
6 | })
7 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | vue-frame1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-frame1",
3 | "version": "1.0.0",
4 | "description": "A Vue.js project",
5 | "author": "wangyongdi ",
6 | "private": true,
7 | "scripts": {
8 | "dev": "node build/dev-server.js",
9 | "start": "node build/dev-server.js",
10 | "build": "node build/build.js",
11 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
12 | "e2e": "node test/e2e/runner.js",
13 | "test": "npm run unit && npm run e2e",
14 | "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
15 | },
16 | "dependencies": {
17 | "qartjs": "^1.1.1",
18 | "vue": "^2.2.6",
19 | "vue-router": "^2.3.1"
20 | },
21 | "devDependencies": {
22 | "autoprefixer": "^6.7.2",
23 | "axios": "^0.16.1",
24 | "babel-core": "^6.22.1",
25 | "babel-eslint": "^7.1.1",
26 | "babel-loader": "^6.2.10",
27 | "babel-plugin-istanbul": "^4.1.1",
28 | "babel-plugin-transform-runtime": "^6.22.0",
29 | "babel-preset-env": "^1.3.2",
30 | "babel-preset-stage-2": "^6.22.0",
31 | "babel-register": "^6.22.0",
32 | "chai": "^3.5.0",
33 | "chalk": "^1.1.3",
34 | "chromedriver": "^2.27.2",
35 | "connect-history-api-fallback": "^1.3.0",
36 | "copy-webpack-plugin": "^4.0.1",
37 | "cross-env": "^4.0.0",
38 | "cross-spawn": "^5.0.1",
39 | "css-loader": "^0.28.0",
40 | "element-ui": "^1.3.3",
41 | "eslint": "^3.19.0",
42 | "eslint-config-standard": "^6.2.1",
43 | "eslint-friendly-formatter": "^2.0.7",
44 | "eslint-loader": "^1.7.1",
45 | "eslint-plugin-html": "^2.0.0",
46 | "eslint-plugin-promise": "^3.4.0",
47 | "eslint-plugin-standard": "^2.0.1",
48 | "eventsource-polyfill": "^0.9.6",
49 | "express": "^4.14.1",
50 | "extract-text-webpack-plugin": "^2.0.0",
51 | "file-loader": "^0.11.1",
52 | "friendly-errors-webpack-plugin": "^1.1.3",
53 | "html-webpack-plugin": "^2.28.0",
54 | "http-proxy-middleware": "^0.17.3",
55 | "inject-loader": "^3.0.0",
56 | "karma": "^1.4.1",
57 | "karma-coverage": "^1.1.1",
58 | "karma-mocha": "^1.3.0",
59 | "karma-phantomjs-launcher": "^1.0.2",
60 | "karma-phantomjs-shim": "^1.4.0",
61 | "karma-sinon-chai": "^1.3.1",
62 | "karma-sourcemap-loader": "^0.3.7",
63 | "karma-spec-reporter": "0.0.30",
64 | "karma-webpack": "^2.0.2",
65 | "lolex": "^1.5.2",
66 | "mocha": "^3.2.0",
67 | "nightwatch": "^0.9.12",
68 | "opn": "^4.0.2",
69 | "optimize-css-assets-webpack-plugin": "^1.3.0",
70 | "ora": "^1.2.0",
71 | "phantomjs-prebuilt": "^2.1.14",
72 | "rimraf": "^2.6.0",
73 | "selenium-server": "^3.0.1",
74 | "semver": "^5.3.0",
75 | "shelljs": "^0.7.6",
76 | "sinon": "^2.1.0",
77 | "sinon-chai": "^2.8.0",
78 | "url-loader": "^0.5.8",
79 | "vue-loader": "^11.3.4",
80 | "vue-progressbar": "^0.7.2",
81 | "vue-style-loader": "^2.0.5",
82 | "vue-template-compiler": "^2.2.6",
83 | "vuex": "^2.3.1",
84 | "webpack": "^2.3.3",
85 | "webpack-bundle-analyzer": "^2.2.1",
86 | "webpack-dev-middleware": "^1.10.0",
87 | "webpack-hot-middleware": "^2.18.0",
88 | "webpack-merge": "^4.1.0"
89 | },
90 | "engines": {
91 | "node": ">= 4.0.0",
92 | "npm": ">= 3.0.0"
93 | },
94 | "browserslist": [
95 | "> 1%",
96 | "last 2 versions",
97 | "not ie <= 8"
98 | ]
99 | }
100 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
65 |
--------------------------------------------------------------------------------
/src/api/axios.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description 网络请求框架封装
5 | */
6 |
7 | import Axios from 'axios'
8 | import QS from 'querystring'
9 | import Call from 'api/call'
10 |
11 | // TODO baseURL
12 | // Axios.defaults.baseURL = 'http://172.31.243.44:3000'
13 |
14 | Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
15 |
16 | // TODO 设置超时时间
17 | Axios.defaults.timeout = 2000
18 |
19 | // TODO http code 校验
20 | Axios.defaults.validateStatus = function (status) {
21 | return status
22 | }
23 |
24 | // TODO GET 请求 params 序列化
25 | Axios.defaults.paramsSerializer = function (params) {
26 | return QS.stringify(params)
27 | }
28 |
29 | // TODO 设置POST等请求 body 序列化
30 | // Axios.defaults.transformRequest = [function (body) {
31 | // let data = body || {}
32 | // if (data instanceof window.FormData) {
33 | // return data
34 | // }
35 | // return QS.stringify(data)
36 | // }]
37 |
38 | // TODO 设置统一请求拦截
39 | Axios.interceptors.response.use(response => {
40 | if (response.data.code === 0) {
41 | return response.data
42 | }
43 | return Promise.reject(response.data)
44 | }, error => {
45 | return Promise.reject(error)
46 | })
47 |
48 | /**
49 | * @description 统一 GET 请求
50 | * @param url
51 | * @param params --> GET 请求参数(***?name=walid&age=25)
52 | */
53 | function get (url, params) {
54 | return new Call((resolve, reject) => {
55 | Axios.get(url, {params: params})
56 | .then(response => {
57 | resolve(response)
58 | })
59 | .catch(error => {
60 | reject(error)
61 | })
62 | })
63 | }
64 |
65 | /**
66 | * @description 统一 POST 请求
67 | * @param url
68 | * @param body --> POST 请求 data
69 | */
70 | function post (url, body) {
71 | return new Call((resolve, reject) => {
72 | Axios.post(url, body)
73 | .then(response => {
74 | resolve(response)
75 | })
76 | .catch(error => {
77 | reject(error)
78 | })
79 | })
80 | }
81 |
82 | export default {
83 | get, post
84 | }
85 |
--------------------------------------------------------------------------------
/src/api/call.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description Api Call
5 | */
6 |
7 | export default class Call {
8 | constructor (executor) {
9 | let self = this
10 | try {
11 | executor(function (res) {
12 | self._dispatchResolve(res)
13 | }, function (errRes) {
14 | self._dispatchReject(errRes)
15 | })
16 | } catch (err) {
17 | self._dispatchReject(err)
18 | }
19 | }
20 |
21 | then (onResolved) {
22 | this.resolve = onResolved
23 | return this
24 | }
25 |
26 | catch (onRejected) {
27 | this.reject = onRejected
28 | return this
29 | }
30 |
31 | _dispatchResolve (response) {
32 | if (Call._isFunc(this.resolve)) {
33 | this.resolve(response)
34 | }
35 | }
36 |
37 | _dispatchReject (error) {
38 | if (Call._isFunc(this.reject)) {
39 | this.reject(error)
40 | }
41 | }
42 |
43 | static _isFunc (obj) {
44 | return obj && typeof obj === 'function'
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/api/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description HTTP Utils
5 | */
6 |
7 | import common from './list/common'
8 |
9 | export default {
10 | common
11 | }
12 |
--------------------------------------------------------------------------------
/src/api/list/common.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @description commonApi 模块
4 | * @date 2016/03/16
5 | */
6 |
7 | import Api from '../axios'
8 |
9 | const apiURL = {
10 | // 提交表单信息
11 | submitForm: 'v1/submit-form'
12 | // 获取生成及大怒
13 | // getStatus: 'v1/get-status'
14 | }
15 |
16 | export default {
17 | submitForm (obj) {
18 | return Api.post(apiURL.submitForm, obj)
19 | }
20 | // getStatus () {
21 | // return Api.get(apiURL.getStatus)
22 | // }
23 | }
24 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walid1992/vue-frame/58badc779f2c67d9e1ae83378a2c7092130d19f1/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/components/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walid1992/vue-frame/58badc779f2c67d9e1ae83378a2c7092130d19f1/src/components/.gitkeep
--------------------------------------------------------------------------------
/src/components/qrcode/imgs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walid1992/vue-frame/58badc779f2c67d9e1ae83378a2c7092130d19f1/src/components/qrcode/imgs/logo.png
--------------------------------------------------------------------------------
/src/components/qrcode/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
32 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description 程序入口启动配置
5 | */
6 |
7 | import Vue from 'vue'
8 | import ElementUI from 'element-ui'
9 | import 'element-ui/lib/theme-default/index.css'
10 | import VueProgressBar from 'vue-progressbar'
11 |
12 | import App from './App'
13 | import globalConfig from 'utils/global-config'
14 | import router from 'router'
15 | import store from 'store'
16 |
17 | Vue.config.productionTip = false
18 |
19 | Vue.use(ElementUI)
20 | Vue.use(globalConfig)
21 |
22 | Vue.use(VueProgressBar, {
23 | thickness: '5px',
24 | color: '#00bf11',
25 | autoRevert: true,
26 | location: 'top',
27 | inverse: false
28 | })
29 |
30 | /* eslint-disable no-new */
31 | new Vue({
32 | el: '#app',
33 | store,
34 | router,
35 | template: '',
36 | components: {
37 | App
38 | }
39 | })
40 |
--------------------------------------------------------------------------------
/src/pages/404/app.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
404
4 |
www.syswin.com
5 |
6 |
7 |
8 |
24 |
--------------------------------------------------------------------------------
/src/pages/guide-axios/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
36 |
--------------------------------------------------------------------------------
/src/pages/guide-axios/style.css:
--------------------------------------------------------------------------------
1 | .root {
2 | width: 100%;
3 | height: 100%;
4 | display: flex;
5 | background-color: #f0f0f0;
6 | flex-direction: column;
7 | }
8 |
--------------------------------------------------------------------------------
/src/pages/guide-axios/template.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/pages/guide-router/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
43 |
--------------------------------------------------------------------------------
/src/pages/guide-router/style.css:
--------------------------------------------------------------------------------
1 | .root {
2 | width: 100%;
3 | height: 100%;
4 | display: flex;
5 | background-color: #f0f0f0;
6 | flex-direction: column;
7 | align-items: center;
8 | }
9 |
10 | p {
11 | font-size: 30px;
12 | margin-top: 30px;
13 | }
14 |
--------------------------------------------------------------------------------
/src/pages/guide-router/template.html:
--------------------------------------------------------------------------------
1 |
2 |
点击PUSH跳转
3 |
点击Replace跳转
4 |
5 |
--------------------------------------------------------------------------------
/src/pages/guide-store/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
47 |
--------------------------------------------------------------------------------
/src/pages/guide-store/style.css:
--------------------------------------------------------------------------------
1 | .root {
2 | width: 100%;
3 | height: 100%;
4 | display: flex;
5 | background-color: #f0f0f0;
6 | flex-direction: column;
7 | align-items: center;
8 | }
9 |
10 | p {
11 | width: 500px;
12 | font-size: 40px;
13 | color: red;
14 | }
15 |
16 | span {
17 | width: 500px;
18 | font-size: 30px;
19 | color: dodgerblue;
20 | }
21 |
22 | .p-update {
23 | font-size: 28px;
24 | color: white;
25 | text-align: center;
26 | line-height: 50px;
27 | background-color: #ff8400;
28 | border: 1px #dadada solid;
29 | border-radius: 10px;
30 | }
31 |
--------------------------------------------------------------------------------
/src/pages/guide-store/template.html:
--------------------------------------------------------------------------------
1 |
2 |
global state logo :
{{logo}}
3 |
child module state data :
{{data}}
4 |
5 |
更新全局state logo
6 |
更新child state data
7 |
8 |
--------------------------------------------------------------------------------
/src/pages/qrcode/app.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{msg}}
4 |
5 |
6 |
7 |
8 |
26 |
27 |
51 |
--------------------------------------------------------------------------------
/src/pages/qrcode/imgs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walid1992/vue-frame/58badc779f2c67d9e1ae83378a2c7092130d19f1/src/pages/qrcode/imgs/logo.png
--------------------------------------------------------------------------------
/src/router/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @description vue router
4 | * @date 2016/03/16
5 | */
6 |
7 | import Vue from 'vue'
8 | import VueRouter from 'vue-router'
9 | import map from './map'
10 |
11 | Vue.use(VueRouter)
12 |
13 | export default new VueRouter({
14 | mode: 'history',
15 | saveScrollPosition: true,
16 | scrollBehavior: () => ({
17 | y: 0
18 | }),
19 | routes: map
20 | })
21 |
--------------------------------------------------------------------------------
/src/router/map.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description 路由配置页
5 | */
6 |
7 | import name from './name'
8 |
9 | export default [
10 | {
11 | path: '/',
12 | redirect: {
13 | path: '/guide-router'
14 | }
15 | },
16 | {
17 | title: '示例axios',
18 | path: '/guide-axios',
19 | name: name.guideRouter,
20 | component: (resolve) => {
21 | require(['pages/guide-axios'], resolve)
22 | }
23 | },
24 | {
25 | title: '示例Router',
26 | path: '/guide-router',
27 | name: name.guideRouter,
28 | component: (resolve) => {
29 | require(['pages/guide-router'], resolve)
30 | }
31 | },
32 | {
33 | title: '示例Store',
34 | path: '/guide-store',
35 | name: name.guideStore,
36 | component: (resolve) => {
37 | require(['pages/guide-store'], resolve)
38 | }
39 | },
40 | {
41 | title: '二维码',
42 | path: '/qrcode',
43 | name: name.qrCode,
44 | component: (resolve) => {
45 | require(['pages/qrcode/app'], resolve)
46 | }
47 | },
48 | {
49 | title: '404',
50 | path: '*',
51 | component: (resolve) => {
52 | require(['pages/404/app'], resolve)
53 | }
54 | }
55 | ]
56 |
--------------------------------------------------------------------------------
/src/router/name.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description 路由名称页 由界面跳转时调用
5 | */
6 |
7 | export default {
8 | guideAxios: 'guideAxios',
9 | guideStore: 'guideStore',
10 | guideRouter: 'guideRouter',
11 | qrCode: 'qrCode'
12 | }
13 |
--------------------------------------------------------------------------------
/src/store/actions.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description
5 | */
6 |
7 | import {global as types} from './mutationTypes'
8 |
9 | export default {
10 | [types.actions.updateLogo] ({commit}, payload) {
11 | commit(types.mutations.logo, payload)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/store/getters.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description
5 | */
6 |
7 | import {global as types} from './mutationTypes'
8 |
9 | export default {
10 | [types.getters.logo] (state) {
11 | return state.logo
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/store/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description stats 入口管理类
5 | */
6 |
7 | import Vue from 'vue'
8 | import Vuex from 'vuex'
9 | import actions from './actions'
10 | import getters from './getters'
11 | import state from './state'
12 | import mutations from './mutations'
13 |
14 | Vue.use(Vuex)
15 |
16 | let store = new Vuex.Store({
17 | state,
18 | getters,
19 | mutations,
20 | actions
21 | // modules: {
22 | // appInfo
23 | // }
24 | })
25 |
26 | Vue.$store = store
27 |
28 | export default store
29 |
--------------------------------------------------------------------------------
/src/store/modules/child.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description child 模块示例
5 | */
6 |
7 | import {child as types} from '../mutationTypes'
8 |
9 | const state = {
10 | data: 'default data'
11 | }
12 |
13 | const mutations = {
14 | [types.mutations.data] (state, payload) {
15 | state.data = payload
16 | }
17 | }
18 |
19 | const actions = {
20 | [types.actions.updateData] ({commit, state}, payload) {
21 | return new Promise((resolve, reject) => {
22 | setTimeout(() => {
23 | commit(types.mutations.data, payload)
24 | }, 500)
25 | })
26 | }
27 | }
28 |
29 | const getters = {
30 | [types.getters.data] (state) {
31 | return state.data
32 | }
33 | }
34 |
35 | export default {
36 | state,
37 | mutations,
38 | actions,
39 | getters
40 | }
41 |
--------------------------------------------------------------------------------
/src/store/mutationTypes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description store 常量定义
5 | */
6 |
7 | // global 全局stats
8 | export const global = {
9 | actions: {
10 | updateLogo: 'global/actions/updateLogo'
11 | },
12 | mutations: {
13 | logo: 'global/mutations/logo'
14 | },
15 | getters: {
16 | logo: 'global/getters/logo'
17 | }
18 | }
19 |
20 | // 子page module 相关
21 | export const child = {
22 | actions: {
23 | updateData: 'child/actions/updateData'
24 | },
25 | mutations: {
26 | data: 'child/mutations/data'
27 | },
28 | getters: {
29 | data: 'child/getters/data'
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/store/mutations.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description
5 | */
6 |
7 | import {global as types} from './mutationTypes'
8 |
9 | // 设置LOGO图标
10 | export default {
11 | [types.mutations.logo] (state, payload) {
12 | state.logo = payload
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/store/state.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2017/03/22
4 | * @description 对外暴露state对象
5 | */
6 |
7 | // stats 对象
8 | export default {
9 | logo: 'default logo'
10 | }
11 |
--------------------------------------------------------------------------------
/src/utils/date.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description
5 | */
6 |
7 | export default function plugin (Vue) {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/utils/global-config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author walid
3 | * @date 2016/03/16
4 | * @description api 初始化
5 | */
6 |
7 | import api from 'api'
8 | import routerName from 'router/name'
9 |
10 | export default function plugin (Vue) {
11 | Vue.$api = Vue.prototype.$api = api
12 | Vue.$routerName = Vue.prototype.$routerName = routerName
13 | }
14 |
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/walid1992/vue-frame/58badc779f2c67d9e1ae83378a2c7092130d19f1/static/.gitkeep
--------------------------------------------------------------------------------
/test/e2e/custom-assertions/elementCount.js:
--------------------------------------------------------------------------------
1 | // A custom Nightwatch assertion.
2 | // the name of the method is the filename.
3 | // can be used in tests like this:
4 | //
5 | // browser.assert.elementCount(selector, count)
6 | //
7 | // for how to write custom assertions see
8 | // http://nightwatchjs.org/guide#writing-custom-assertions
9 | exports.assertion = function (selector, count) {
10 | this.message = 'Testing if element <' + selector + '> has count: ' + count
11 | this.expected = count
12 | this.pass = function (val) {
13 | return val === this.expected
14 | }
15 | this.value = function (res) {
16 | return res.value
17 | }
18 | this.command = function (cb) {
19 | var self = this
20 | return this.api.execute(function (selector) {
21 | return document.querySelectorAll(selector).length
22 | }, [selector], function (res) {
23 | cb.call(self, res)
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/e2e/nightwatch.conf.js:
--------------------------------------------------------------------------------
1 | require('babel-register')
2 | var config = require('../../config')
3 |
4 | // http://nightwatchjs.org/gettingstarted#settings-file
5 | module.exports = {
6 | src_folders: ['test/e2e/specs'],
7 | output_folder: 'test/e2e/reports',
8 | custom_assertions_path: ['test/e2e/custom-assertions'],
9 |
10 | selenium: {
11 | start_process: true,
12 | server_path: require('selenium-server').path,
13 | host: '127.0.0.1',
14 | port: 4444,
15 | cli_args: {
16 | 'webdriver.chrome.driver': require('chromedriver').path
17 | }
18 | },
19 |
20 | test_settings: {
21 | default: {
22 | selenium_port: 4444,
23 | selenium_host: 'localhost',
24 | silent: true,
25 | globals: {
26 | devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
27 | }
28 | },
29 |
30 | chrome: {
31 | desiredCapabilities: {
32 | browserName: 'chrome',
33 | javascriptEnabled: true,
34 | acceptSslCerts: true
35 | }
36 | },
37 |
38 | firefox: {
39 | desiredCapabilities: {
40 | browserName: 'firefox',
41 | javascriptEnabled: true,
42 | acceptSslCerts: true
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/test/e2e/runner.js:
--------------------------------------------------------------------------------
1 | // 1. start the dev server using production config
2 | process.env.NODE_ENV = 'testing'
3 | var server = require('../../build/dev-server.js')
4 |
5 | server.ready.then(() => {
6 | // 2. run the nightwatch test suite against it
7 | // to run in additional browsers:
8 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
9 | // 2. add it to the --env flag below
10 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
11 | // For more information on Nightwatch's config file, see
12 | // http://nightwatchjs.org/guide#settings-file
13 | var opts = process.argv.slice(2)
14 | if (opts.indexOf('--config') === -1) {
15 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
16 | }
17 | if (opts.indexOf('--env') === -1) {
18 | opts = opts.concat(['--env', 'chrome'])
19 | }
20 |
21 | var spawn = require('cross-spawn')
22 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
23 |
24 | runner.on('exit', function (code) {
25 | server.close()
26 | process.exit(code)
27 | })
28 |
29 | runner.on('error', function (err) {
30 | server.close()
31 | throw err
32 | })
33 | })
34 |
--------------------------------------------------------------------------------
/test/e2e/specs/test.js:
--------------------------------------------------------------------------------
1 | // For authoring Nightwatch tests, see
2 | // http://nightwatchjs.org/guide#usage
3 |
4 | module.exports = {
5 | 'default e2e tests': function (browser) {
6 | // automatically uses dev Server port from /config.index.js
7 | // default: http://localhost:8080
8 | // see nightwatch.conf.js
9 | const devServer = browser.globals.devServerURL
10 |
11 | browser
12 | .url(devServer)
13 | .waitForElementVisible('#app', 5000)
14 | .assert.elementPresent('.hello')
15 | .assert.containsText('h1', 'Welcome to Your Vue.js App')
16 | .assert.elementCount('img', 1)
17 | .end()
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/test/unit/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "mocha": true
4 | },
5 | "globals": {
6 | "expect": true,
7 | "sinon": true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/test/unit/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | Vue.config.productionTip = false
4 |
5 | // require all test files (files that ends with .spec.js)
6 | const testsContext = require.context('./specs', true, /\.spec$/)
7 | testsContext.keys().forEach(testsContext)
8 |
9 | // require all src files except main.js for coverage.
10 | // you can also change this to match only the subset of files that
11 | // you want coverage for.
12 | const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
13 | srcContext.keys().forEach(srcContext)
14 |
--------------------------------------------------------------------------------
/test/unit/karma.conf.js:
--------------------------------------------------------------------------------
1 | // This is a karma config file. For more details see
2 | // http://karma-runner.github.io/0.13/config/configuration-file.html
3 | // we are also using it with karma-webpack
4 | // https://github.com/webpack/karma-webpack
5 |
6 | var webpackConfig = require('../../build/webpack.test.conf')
7 |
8 | module.exports = function (config) {
9 | config.set({
10 | // to run in additional browsers:
11 | // 1. install corresponding karma launcher
12 | // http://karma-runner.github.io/0.13/config/browsers.html
13 | // 2. add it to the `browsers` array below.
14 | browsers: ['PhantomJS'],
15 | frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
16 | reporters: ['spec', 'coverage'],
17 | files: ['./index.js'],
18 | preprocessors: {
19 | './index.js': ['webpack', 'sourcemap']
20 | },
21 | webpack: webpackConfig,
22 | webpackMiddleware: {
23 | noInfo: true
24 | },
25 | coverageReporter: {
26 | dir: './coverage',
27 | reporters: [
28 | { type: 'lcov', subdir: '.' },
29 | { type: 'text-summary' }
30 | ]
31 | }
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/test/unit/specs/Hello.spec.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Hello from '@/components/Hello'
3 |
4 | describe('Hello.vue', () => {
5 | it('should render correct contents', () => {
6 | const Constructor = Vue.extend(Hello)
7 | const vm = new Constructor().$mount()
8 | expect(vm.$el.querySelector('.hello h1').textContent)
9 | .to.equal('Welcome to Your Vue.js App')
10 | })
11 | })
12 |
--------------------------------------------------------------------------------