├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── 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
├── business
│ ├── dashboard
│ │ ├── dashboard.vue
│ │ ├── gridpanel.vue
│ │ ├── listpanel.vue
│ │ └── money-panel.vue
│ └── employee
│ │ ├── employee-detail.vue
│ │ ├── employee-list.vue
│ │ └── employee.vue
├── components
│ ├── common
│ │ ├── calendar.vue
│ │ ├── datatable.vue
│ │ ├── hint.vue
│ │ └── list.vue
│ ├── hint-container.vue
│ ├── icons
│ │ └── dashboard.vue
│ ├── message
│ │ ├── message-list.vue
│ │ └── message.vue
│ └── side-nav.vue
├── css
│ └── admin.css
├── main.js
├── router
│ └── index.js
├── services
│ ├── employee.js
│ ├── hint-service.js
│ ├── http-service.js
│ ├── message.js
│ ├── money.js
│ └── timer.js
└── utils
│ └── datetime.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
└── side-nav.spec.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["es2015", { "modules": false }],
4 | "stage-2"
5 | ],
6 | "plugins": ["transform-runtime"],
7 | "comments": false,
8 | "env": {
9 | "test": {
10 | "plugins": [ "istanbul" ]
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/.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 | // http://eslint.org/docs/user-guide/configuring
2 |
3 | module.exports = {
4 | root: true,
5 | parser: 'babel-eslint',
6 | parserOptions: {
7 | sourceType: 'module'
8 | },
9 | env: {
10 | browser: true,
11 | },
12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
13 | extends: 'standard',
14 | // required to lint *.vue files
15 | plugins: [
16 | 'html'
17 | ],
18 | // add your custom rules here
19 | 'rules': {
20 | // allow paren-less arrow functions
21 | 'arrow-parens': 0,
22 | // allow async-await
23 | 'generator-star-spacing': 0,
24 | // allow debugger during development
25 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log
5 | test/unit/coverage
6 | test/e2e/reports
7 | selenium-debug.log
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-admin
2 | admin portal with vuejs
3 |
4 | ## Build Setup
5 |
6 | ``` bash
7 | # install dependencies
8 | npm install
9 |
10 | # serve with hot reload at localhost:8080
11 | npm run dev
12 |
13 | # build for production with minification
14 | npm run build
15 |
16 | # run unit tests
17 | npm run unit
18 |
19 | # run e2e tests
20 | npm run e2e
21 |
22 | # run all tests
23 | npm test
24 | ```
25 |
--------------------------------------------------------------------------------
/build/build.js:
--------------------------------------------------------------------------------
1 | // https://github.com/shelljs/shelljs
2 | require('./check-versions')()
3 |
4 | process.env.NODE_ENV = 'production'
5 |
6 | var ora = require('ora')
7 | var path = require('path')
8 | var chalk = require('chalk')
9 | var shell = require('shelljs')
10 | var webpack = require('webpack')
11 | var config = require('../config')
12 | var webpackConfig = require('./webpack.prod.conf')
13 |
14 | var spinner = ora('building for production...')
15 | spinner.start()
16 |
17 | var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
18 | shell.rm('-rf', assetsPath)
19 | shell.mkdir('-p', assetsPath)
20 | shell.config.silent = true
21 | shell.cp('-R', 'static/*', assetsPath)
22 | shell.config.silent = false
23 |
24 | webpack(webpackConfig, function (err, stats) {
25 | spinner.stop()
26 | if (err) throw err
27 | process.stdout.write(stats.toString({
28 | colors: true,
29 | modules: false,
30 | children: false,
31 | chunks: false,
32 | chunkModules: false
33 | }) + '\n\n')
34 |
35 | console.log(chalk.cyan(' Build complete.\n'))
36 | console.log(chalk.yellow(
37 | ' Tip: built files are meant to be served over an HTTP server.\n' +
38 | ' Opening index.html over file:// won\'t work.\n'
39 | ))
40 | })
41 |
--------------------------------------------------------------------------------
/build/check-versions.js:
--------------------------------------------------------------------------------
1 | var chalk = require('chalk')
2 | var semver = require('semver')
3 | var packageConfig = require('../package.json')
4 |
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 | name: 'npm',
17 | currentVersion: exec('npm --version'),
18 | versionRequirement: packageConfig.engines.npm
19 | }
20 | ]
21 |
22 | module.exports = function () {
23 | var warnings = []
24 | for (var i = 0; i < versionRequirements.length; i++) {
25 | var mod = versionRequirements[i]
26 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
27 | warnings.push(mod.name + ': ' +
28 | chalk.red(mod.currentVersion) + ' should be ' +
29 | chalk.green(mod.versionRequirement)
30 | )
31 | }
32 | }
33 |
34 | if (warnings.length) {
35 | console.log('')
36 | console.log(chalk.yellow('To use this template, you must update following to modules:'))
37 | console.log()
38 | for (var i = 0; i < warnings.length; i++) {
39 | var warning = warnings[i]
40 | console.log(' ' + warning)
41 | }
42 | console.log()
43 | process.exit(1)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/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 | devMiddleware.waitUntilValid(function () {
70 | console.log('> Listening at ' + uri + '\n')
71 | })
72 |
73 | module.exports = app.listen(port, function (err) {
74 | if (err) {
75 | console.log(err)
76 | return
77 | }
78 |
79 | // when env is testing, don't need open it
80 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
81 | opn(uri)
82 | }
83 | })
84 |
--------------------------------------------------------------------------------
/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 | var isProduction = process.env.NODE_ENV === 'production'
15 | var cssLoader = 'css' + (isProduction ? '?minimize' : '')
16 |
17 | // generate loader string to be used with extract text plugin
18 | function generateLoaders (loader) {
19 | var loaders = [cssLoader]
20 | if (loader) loaders.push(loader)
21 | var sourceLoader = loaders.map(function (loader) {
22 | var extraParamChar
23 | if (/\?/.test(loader)) {
24 | loader = loader.replace(/\?/, '-loader?')
25 | extraParamChar = '&'
26 | } else {
27 | loader = loader + '-loader'
28 | extraParamChar = '?'
29 | }
30 | return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '')
31 | })
32 |
33 | // Extract CSS when that option is specified
34 | // (which is the case during production build)
35 | if (options.extract) {
36 | return ExtractTextPlugin.extract({
37 | use: sourceLoader,
38 | fallback: 'vue-style-loader'
39 | })
40 | } else {
41 | return ['vue-style-loader'].concat(sourceLoader)
42 | }
43 | }
44 |
45 | // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html
46 | return {
47 | css: generateLoaders(),
48 | postcss: generateLoaders(),
49 | less: generateLoaders('less'),
50 | sass: generateLoaders('sass?indentedSyntax'),
51 | scss: generateLoaders('sass'),
52 | stylus: generateLoaders('stylus'),
53 | styl: generateLoaders('stylus')
54 | }
55 | }
56 |
57 | // Generate loaders for standalone style files (outside of .vue)
58 | exports.styleLoaders = function (options) {
59 | var output = []
60 | var loaders = exports.cssLoaders(options)
61 | for (var extension in loaders) {
62 | var loader = loaders[extension]
63 | output.push({
64 | test: new RegExp('\\.' + extension + '$'),
65 | loader: loader
66 | })
67 | }
68 | return output
69 | }
70 |
--------------------------------------------------------------------------------
/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 | postcss: [
13 | require('autoprefixer')({
14 | browsers: ['last 2 versions']
15 | })
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/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 | modules: [
24 | resolve('src'),
25 | resolve('node_modules')
26 | ],
27 | alias: {
28 | 'vue$': 'vue/dist/vue.common.js',
29 | 'src': resolve('src'),
30 | 'assets': resolve('src/assets'),
31 | 'components': resolve('src/components')
32 | }
33 | },
34 | module: {
35 | rules: [
36 | {
37 | test: /\.(js|vue)$/,
38 | loader: 'eslint-loader',
39 | enforce: "pre",
40 | include: [resolve('src'), resolve('test')],
41 | options: {
42 | formatter: require('eslint-friendly-formatter')
43 | }
44 | },
45 | {
46 | test: /\.vue$/,
47 | loader: 'vue-loader',
48 | options: vueLoaderConfig
49 | },
50 | {
51 | test: /\.js$/,
52 | loader: 'babel-loader',
53 | include: [resolve('src'), resolve('test')]
54 | },
55 | {
56 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
57 | loader: 'url-loader',
58 | query: {
59 | limit: 10000,
60 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
61 | }
62 | },
63 | {
64 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
65 | loader: 'url-loader',
66 | query: {
67 | limit: 10000,
68 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
69 | }
70 | }
71 | ]
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/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 HtmlWebpackPlugin = require('html-webpack-plugin')
8 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
9 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
10 |
11 | var env = process.env.NODE_ENV === 'testing'
12 | ? require('../config/test.env')
13 | : config.build.env
14 |
15 | var webpackConfig = merge(baseWebpackConfig, {
16 | module: {
17 | rules: utils.styleLoaders({
18 | sourceMap: config.build.productionSourceMap,
19 | extract: true
20 | })
21 | },
22 | devtool: config.build.productionSourceMap ? '#source-map' : false,
23 | output: {
24 | path: config.build.assetsRoot,
25 | filename: utils.assetsPath('js/[name].[chunkhash].js'),
26 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
27 | },
28 | plugins: [
29 | // http://vuejs.github.io/vue-loader/en/workflow/production.html
30 | new webpack.DefinePlugin({
31 | 'process.env': env
32 | }),
33 | new webpack.optimize.UglifyJsPlugin({
34 | compress: {
35 | warnings: false
36 | },
37 | sourceMap: true
38 | }),
39 | // extract css into its own file
40 | new ExtractTextPlugin({
41 | filename: utils.assetsPath('css/[name].[contenthash].css')
42 | }),
43 | // Compress extracted CSS. We are using this plugin so that possible
44 | // duplicated CSS from different components can be deduped.
45 | new OptimizeCSSPlugin(),
46 | // generate dist index.html with correct asset hash for caching.
47 | // you can customize output by editing /index.html
48 | // see https://github.com/ampedandwired/html-webpack-plugin
49 | new HtmlWebpackPlugin({
50 | filename: process.env.NODE_ENV === 'testing'
51 | ? 'index.html'
52 | : config.build.index,
53 | template: 'index.html',
54 | inject: true,
55 | minify: {
56 | removeComments: true,
57 | collapseWhitespace: true,
58 | removeAttributeQuotes: true
59 | // more options:
60 | // https://github.com/kangax/html-minifier#options-quick-reference
61 | },
62 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin
63 | chunksSortMode: 'dependency'
64 | }),
65 | // split vendor js into its own file
66 | new webpack.optimize.CommonsChunkPlugin({
67 | name: 'vendor',
68 | minChunks: function (module, count) {
69 | // any required modules inside node_modules are extracted to vendor
70 | return (
71 | module.resource &&
72 | /\.js$/.test(module.resource) &&
73 | module.resource.indexOf(
74 | path.join(__dirname, '../node_modules')
75 | ) === 0
76 | )
77 | }
78 | }),
79 | // extract webpack runtime and module manifest to its own file in order to
80 | // prevent vendor hash from being updated whenever app bundle is updated
81 | new webpack.optimize.CommonsChunkPlugin({
82 | name: 'manifest',
83 | chunks: ['vendor']
84 | })
85 | ]
86 | })
87 |
88 | if (config.build.productionGzip) {
89 | var CompressionWebpackPlugin = require('compression-webpack-plugin')
90 |
91 | webpackConfig.plugins.push(
92 | new CompressionWebpackPlugin({
93 | asset: '[path].gz[query]',
94 | algorithm: 'gzip',
95 | test: new RegExp(
96 | '\\.(' +
97 | config.build.productionGzipExtensions.join('|') +
98 | ')$'
99 | ),
100 | threshold: 10240,
101 | minRatio: 0.8
102 | })
103 | )
104 | }
105 |
106 | if (config.build.bundleAnalyzerReport) {
107 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
108 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
109 | }
110 |
111 | module.exports = webpackConfig
112 |
--------------------------------------------------------------------------------
/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 | plugins: [
15 | new webpack.DefinePlugin({
16 | 'process.env': require('../config/test.env')
17 | })
18 | ]
19 | })
20 |
21 | // no need for app entry during tests
22 | delete webpackConfig.entry
23 |
24 | module.exports = webpackConfig
25 |
--------------------------------------------------------------------------------
/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-admin
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-admin",
3 | "version": "0.2.0",
4 | "description": "Vue.js admin portal",
5 | "author": "xufei ",
6 | "private": true,
7 | "scripts": {
8 | "dev": "node build/dev-server.js",
9 | "build": "node build/build.js",
10 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
11 | "e2e": "node test/e2e/runner.js",
12 | "test": "npm run unit && npm run e2e",
13 | "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
14 | },
15 | "dependencies": {
16 | "moment": "^2.17.1",
17 | "rxjs": "^5.1.1",
18 | "vue": "^2.1.10",
19 | "vue-router": "^2.2.0",
20 | "vue-rx": "^2.3.1"
21 | },
22 | "devDependencies": {
23 | "autoprefixer": "^6.7.2",
24 | "babel-core": "^6.22.1",
25 | "babel-eslint": "^7.1.1",
26 | "babel-loader": "^6.2.10",
27 | "babel-plugin-transform-runtime": "^6.22.0",
28 | "babel-preset-es2015": "^6.22.0",
29 | "babel-preset-stage-2": "^6.22.0",
30 | "babel-register": "^6.22.0",
31 | "chalk": "^1.1.3",
32 | "connect-history-api-fallback": "^1.3.0",
33 | "css-loader": "^0.26.1",
34 | "eslint": "^3.14.1",
35 | "eslint-friendly-formatter": "^2.0.7",
36 | "eslint-loader": "^1.6.1",
37 | "eslint-plugin-html": "^2.0.0",
38 | "eslint-config-standard": "^6.2.1",
39 | "eslint-plugin-promise": "^3.4.0",
40 | "eslint-plugin-standard": "^2.0.1",
41 | "eventsource-polyfill": "^0.9.6",
42 | "express": "^4.14.1",
43 | "extract-text-webpack-plugin": "^2.0.0-rc.2",
44 | "file-loader": "^0.10.0",
45 | "friendly-errors-webpack-plugin": "^1.1.3",
46 | "function-bind": "^1.1.0",
47 | "html-webpack-plugin": "^2.28.0",
48 | "http-proxy-middleware": "^0.17.3",
49 | "webpack-bundle-analyzer": "^2.2.1",
50 | "cross-env": "^3.1.4",
51 | "karma": "^1.4.1",
52 | "karma-coverage": "^1.1.1",
53 | "karma-mocha": "^1.3.0",
54 | "karma-phantomjs-launcher": "^1.0.2",
55 | "karma-sinon-chai": "^1.2.4",
56 | "karma-sourcemap-loader": "^0.3.7",
57 | "karma-spec-reporter": "0.0.26",
58 | "karma-webpack": "^2.0.2",
59 | "lolex": "^1.5.2",
60 | "mocha": "^3.2.0",
61 | "chai": "^3.5.0",
62 | "sinon": "^1.17.7",
63 | "sinon-chai": "^2.8.0",
64 | "inject-loader": "^2.0.1",
65 | "babel-plugin-istanbul": "^3.1.2",
66 | "phantomjs-prebuilt": "^2.1.14",
67 | "chromedriver": "^2.27.2",
68 | "cross-spawn": "^5.0.1",
69 | "nightwatch": "^0.9.12",
70 | "selenium-server": "^3.0.1",
71 | "semver": "^5.3.0",
72 | "opn": "^4.0.2",
73 | "optimize-css-assets-webpack-plugin": "^1.3.0",
74 | "ora": "^1.1.0",
75 | "shelljs": "^0.7.6",
76 | "url-loader": "^0.5.7",
77 | "vue-loader": "^11.0.0",
78 | "vue-style-loader": "^2.0.0",
79 | "vue-template-compiler": "^2.1.10",
80 | "webpack": "^2.2.1",
81 | "webpack-dev-middleware": "^1.10.0",
82 | "webpack-hot-middleware": "^2.16.1",
83 | "webpack-merge": "^2.6.1"
84 | },
85 | "engines": {
86 | "node": ">= 4.0.0",
87 | "npm": ">= 3.0.0"
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
20 |
21 |
28 |
--------------------------------------------------------------------------------
/src/business/dashboard/dashboard.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | Vue Admin Portal
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
49 |
50 |
51 |
56 |
--------------------------------------------------------------------------------
/src/business/dashboard/gridpanel.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Table Header
4 |
5 |
6 |
7 |
8 |
28 |
--------------------------------------------------------------------------------
/src/business/dashboard/listpanel.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Panel Header
4 |
5 |
6 |
7 |
8 |
31 |
--------------------------------------------------------------------------------
/src/business/dashboard/money-panel.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Make Money
4 |
5 | - 工资:{{salary$}}
6 | - 房子:{{houseCount$}}
7 | - 租金:{{rent$}}
8 | - 现金:{{cash$}}
9 |
10 |
11 |
12 |
13 |
14 |
36 |
--------------------------------------------------------------------------------
/src/business/employee/employee-detail.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | - {{employee.name}}
4 | - {{employee.gender}}
5 | - {{employee.age}}
6 |
7 |
8 |
9 |
22 |
--------------------------------------------------------------------------------
/src/business/employee/employee-list.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | Employee List
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Name |
16 | Gender |
17 | Age |
18 |
19 |
20 |
21 |
22 |
23 | {{employee.name}}
24 | |
25 | {{employee.gender}} |
26 | {{employee.age}} |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
53 |
54 |
84 |
--------------------------------------------------------------------------------
/src/business/employee/employee.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/components/common/calendar.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
13 |
30 |
31 |
32 |
33 | {{day}}
34 |
35 |
36 |
37 |
45 |
46 |
68 |
69 |
91 |
92 |
93 |
94 |
241 |
242 |
350 |
--------------------------------------------------------------------------------
/src/components/common/datatable.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 | {{key}}
9 |
11 |
12 | |
13 |
14 |
15 |
16 |
20 |
21 | {{entry[key]}}
22 | |
23 |
24 |
25 |
26 |
27 |
28 |
55 |
56 |
86 |
--------------------------------------------------------------------------------
/src/components/common/hint.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{title}}
4 |
{{content}}
5 |
6 |
7 |
8 |
16 |
17 |
47 |
--------------------------------------------------------------------------------
/src/components/common/list.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
16 |
17 |
32 |
--------------------------------------------------------------------------------
/src/components/hint-container.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
22 |
23 |
32 |
--------------------------------------------------------------------------------
/src/components/icons/dashboard.vue:
--------------------------------------------------------------------------------
1 |
2 |
157 |
158 |
159 |
--------------------------------------------------------------------------------
/src/components/message/message-list.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
31 |
--------------------------------------------------------------------------------
/src/components/message/message.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{title}}
4 |
5 | {{content}}
6 | {{dateFromNow$}}
7 |
8 |
9 |
10 |
11 |
33 |
--------------------------------------------------------------------------------
/src/components/side-nav.vue:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
49 |
50 |
118 |
--------------------------------------------------------------------------------
/src/css/admin.css:
--------------------------------------------------------------------------------
1 | * {
2 | margin: 0;
3 | padding: 0;
4 | box-sizing: border-box;
5 | }
6 |
7 | :before, :after {
8 | display: block;
9 | position: absolute;
10 | }
11 |
12 | html, body {
13 | min-height: 100%;
14 | }
15 |
16 | body {
17 | display: flex;
18 | font: 15px/1 Lato, sans-serif;
19 | color: #777;
20 | }
21 |
22 | a {
23 | cursor: pointer;
24 | text-decoration: none;
25 | }
26 |
27 | ul {
28 | list-style: none;
29 | }
30 |
31 | button {
32 | font-family: inherit;
33 | font-size: 100%;
34 | padding: 0.5em 1em;
35 | color: rgba(0, 0, 0, 0.80); /* rgba supported */
36 | border: none rgba(0, 0, 0, 0); /*IE9 + everything else*/
37 | background-color: #E6E6E6;
38 | text-decoration: none;
39 | border-radius: 2px;
40 | }
41 |
42 | button:hover,
43 | button:focus {
44 | background-image: linear-gradient(transparent, rgba(0,0,0, 0.05) 40%, rgba(0,0,0, 0.10));
45 | }
46 | button:focus {
47 | outline: 0;
48 | }
49 | button:active {
50 | box-shadow: 0 0 0 1px rgba(0,0,0, 0.15) inset, 0 0 6px rgba(0,0,0, 0.20) inset;
51 | border-color: #000;
52 | }
53 |
54 | button[disabled] {
55 | border: none;
56 | background-image: none;
57 | filter: alpha(opacity=40);
58 | opacity: 0.40;
59 | cursor: not-allowed;
60 | box-shadow: none;
61 | }
62 |
63 | main {
64 | flex: 1;
65 | padding: 15px;
66 | background: #f5f5f5;
67 | }
68 |
69 | main h1 {
70 | height: 80px;
71 | margin: -25px -25px 25px -25px;
72 | padding: 0 25px;
73 | line-height: 76px;
74 | font-size: 28px;
75 | font-weight: 300;
76 | text-transform: uppercase;
77 | border-bottom: 1px solid #fff;
78 | background: #fafafa;
79 | }
80 |
81 | .flex-grid {
82 | display: flex;
83 | }
84 |
85 | .flex-grid > div {
86 | flex: 1;
87 | margin: 0 20px 20px 0;
88 | padding: 15px;
89 | border: 1px solid #ddd;
90 | background: #fff;
91 | }
92 |
93 | .flex-grid > div:last-child {
94 | margin-right: 0;
95 | }
96 |
97 | .flex-grid h2 {
98 | margin: -15px -15px 15px -15px;
99 | padding: 12px 15px;
100 | font-size: 16px;
101 | font-weight: 300;
102 | text-transform: uppercase;
103 | border-bottom: 1px solid #ddd;
104 | background: #fafafa;
105 | }
106 |
107 | #app {
108 | display: flex;
109 | flex: 1;
110 | }
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | // The Vue build version to load with the `import` command
2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3 | import Vue from 'vue'
4 | import App from './App'
5 | import router from './router'
6 |
7 | import { Observable } from 'rxjs/Observable'
8 | import { Subscription } from 'rxjs/Subscription'
9 |
10 | import VueRx from 'vue-rx'
11 |
12 | import './css/admin.css'
13 |
14 | // tada!
15 | Vue.use(VueRx, { Observable, Subscription })
16 |
17 | /* eslint-disable no-new */
18 | new Vue({
19 | el: '#app',
20 | router,
21 | template: '',
22 | components: { App }
23 | })
24 |
--------------------------------------------------------------------------------
/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Router from 'vue-router'
3 |
4 | import Dashboard from '../business/dashboard/dashboard'
5 | import Employee from '../business/employee/employee'
6 | import EmployeeList from '../business/employee/employee-list'
7 | import EmployeeDetail from '../business/employee/employee-detail'
8 |
9 | Vue.use(Router)
10 |
11 | export default new Router({
12 | routes: [
13 | {
14 | path: '/login',
15 | name: 'Login',
16 | component: Dashboard
17 | },
18 | {
19 | path: '/dashboard',
20 | name: 'Dashboard',
21 | component: Dashboard
22 | },
23 | {
24 | path: '/employee',
25 | name: 'Employee',
26 | component: Employee,
27 | children: [
28 | {
29 | path: '/',
30 | name: 'EmployeeList',
31 | component: EmployeeList
32 | },
33 | {
34 | path: '/detail/:id',
35 | name: 'EmployeeDetail',
36 | component: EmployeeDetail
37 | }
38 | ]
39 | }
40 | ]
41 | })
42 |
43 | /*
44 | router.beforeEach(function () {
45 | window.scrollTo(0, 0)
46 | })
47 |
48 | router.afterEach(function (transition) {
49 | console.log(transition.to)
50 | })
51 |
52 | router.alias({
53 | '/': '/login'
54 | })
55 |
56 | router.start(App, '#app')
57 | */
58 |
--------------------------------------------------------------------------------
/src/services/employee.js:
--------------------------------------------------------------------------------
1 | const list = [
2 | { id: '001', name: 'Tom', gender: 1, age: 5 },
3 | { id: '002', name: 'Jerry', gender: 0, age: 2 },
4 | { id: '003', name: 'Sun Wukong', gender: 1, age: 534 }
5 | ]
6 |
7 | class EmployeeService {
8 | getEmployeeList () {
9 | return Promise.resolve(list)
10 | }
11 | getEmployee (id) {
12 | return Promise.resolve(list.find(item => item.id === id))
13 | }
14 | }
15 |
16 | export default new EmployeeService()
17 |
--------------------------------------------------------------------------------
/src/services/hint-service.js:
--------------------------------------------------------------------------------
1 | const hints = []
2 |
3 | export default {
4 | hints,
5 | hint (title, content) {
6 | const hint = { title, content }
7 | hints.push(hint)
8 | setTimeout(() => {
9 | hints.forEach((k, i) => {
10 | if (k === hint) {
11 | hints.splice(i, 1)
12 | return false
13 | }
14 | })
15 | }, 5000)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/services/http-service.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | // import VueResource from 'vue-resource'
3 |
4 | // Vue.use(VueResource)
5 |
6 | // Vue.http.options.root = ''
7 | // Vue.http.headers.common['Authorization'] = 'Basic YXBpOnBhc3N3b3Jk'
8 |
9 | export default class HttpService {
10 | get (url, param) {
11 | // GET request
12 | return Vue.http.get(url, param).then(response => {
13 | // get status
14 | response.status
15 | // get all headers
16 | response.headers()
17 | // get 'expires' header
18 | response.headers('expires')
19 | // set data on vm
20 | this.$set('someData', response.data)
21 | }, response => {
22 | // error callback
23 | })
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/services/message.js:
--------------------------------------------------------------------------------
1 | const list = [
2 | { id: '001', title: '画', content: '远看山有色,静听水无声。春去花还在,人来鸟不惊。', createAt: new Date() },
3 | { id: '002', title: '静夜思', content: '床前明月光,疑似地上霜。举头望明月,低头思故乡。', createAt: new Date() },
4 | { id: '003', title: '登鹳雀楼', content: '白日依山尽,黄河入海流。欲穷千里目,更上一层楼', createAt: new Date() }
5 | ]
6 |
7 | class MessageService {
8 | getMessageList () {
9 | return Promise.resolve(list)
10 | }
11 | getMessage (id) {
12 | return Promise.resolve(list.find(item => item.id === id))
13 | }
14 | }
15 |
16 | export default new MessageService()
17 |
--------------------------------------------------------------------------------
/src/services/money.js:
--------------------------------------------------------------------------------
1 | import { Observable } from 'rxjs/Observable'
2 | import { Subject } from 'rxjs/Subject'
3 | import 'rxjs/add/operator/scan'
4 | import 'rxjs/add/observable/interval'
5 | import 'rxjs/add/operator/mapTo'
6 | import 'rxjs/add/operator/startWith'
7 | import 'rxjs/add/operator/merge'
8 | import 'rxjs/add/observable/combineLatest'
9 | import 'rxjs/add/operator/distinct'
10 | import 'rxjs/add/observable/merge'
11 |
12 | // 挣钱是为了买房,买房是为了赚钱
13 | const house$ = new Subject()
14 | const houseCount$ = house$.startWith(0).scan((acc, num) => acc + num, 0)
15 |
16 | // 工资始终不涨
17 | const salary$ = Observable.interval(100).mapTo(2)
18 |
19 | const rent$ = Observable
20 | .combineLatest(Observable.interval(3000), houseCount$)
21 | .distinct(arr => arr[0])
22 | .map(arr => arr[1] * 5)
23 | .startWith(0)
24 |
25 | // 一买了房,就没现金了……
26 | const cash$ = Observable.merge(salary$, rent$)
27 | .scan((acc, num) => {
28 | const newSum = acc + num
29 |
30 | const newHouse = Math.floor(newSum / 100)
31 | if (newHouse > 0) {
32 | house$.next(newHouse)
33 | }
34 |
35 | return newSum % 100
36 | }, 0)
37 |
38 | export { salary$, houseCount$, rent$, cash$ }
39 |
--------------------------------------------------------------------------------
/src/services/timer.js:
--------------------------------------------------------------------------------
1 | import { Observable } from 'rxjs/Observable'
2 |
3 | const timerMap = {}
4 |
5 | const getTimer = interval => {
6 | if (!timerMap[interval]) {
7 | timerMap[interval] = Observable.interval(interval)
8 | }
9 | return timerMap[interval]
10 | }
11 |
12 | export const getTimer
13 |
--------------------------------------------------------------------------------
/src/utils/datetime.js:
--------------------------------------------------------------------------------
1 | import moment from 'moment'
2 |
3 | const fromNow = date => {
4 | return moment(date).fromNow()
5 | }
6 |
7 | export { fromNow }
8 |
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xufei/vue-admin/7e3158a2f0ecb1db899935d41a2c4b041b005730/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/guide#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 | // 2. run the nightwatch test suite against it
6 | // to run in additional browsers:
7 | // 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
8 | // 2. add it to the --env flag below
9 | // or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
10 | // For more information on Nightwatch's config file, see
11 | // http://nightwatchjs.org/guide#settings-file
12 | var opts = process.argv.slice(2)
13 | if (opts.indexOf('--config') === -1) {
14 | opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
15 | }
16 | if (opts.indexOf('--env') === -1) {
17 | opts = opts.concat(['--env', 'chrome'])
18 | }
19 |
20 | var spawn = require('cross-spawn')
21 | var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
22 |
23 | runner.on('exit', function (code) {
24 | server.close()
25 | process.exit(code)
26 | })
27 |
28 | runner.on('error', function (err) {
29 | server.close()
30 | throw err
31 | })
32 |
--------------------------------------------------------------------------------
/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 | // Polyfill fn.bind() for PhantomJS
2 | /* eslint-disable no-extend-native */
3 | Function.prototype.bind = require('function-bind')
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'],
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/side-nav.spec.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import SideNav from 'src/components/side-nav.vue'
3 |
4 | describe('SideNav.vue', () => {
5 | it('should render correct contents', () => {
6 | const Constructor = Vue.extend(SideNav)
7 | const vm = new Constructor().$mount()
8 | expect(vm.$el.querySelector('header span').textContent)
9 | .to.equal('Xu Fei')
10 | })
11 | })
12 |
--------------------------------------------------------------------------------