├── .babelrc
├── .editorconfig
├── .gitignore
├── .postcssrc.js
├── .travis.yml
├── Dockerfile
├── LICENSE
├── 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
├── assets
│ ├── css
│ │ ├── init.css
│ │ └── init.less
│ ├── imgs
│ │ ├── 1.jpg
│ │ ├── 2.jpg
│ │ ├── 3.jpg
│ │ ├── 4.jpg
│ │ ├── 5.jpg
│ │ ├── 6.jpg
│ │ ├── 7.jpg
│ │ ├── doudou.jpg
│ │ └── github.png
│ └── js
│ │ └── iview.js
├── components
│ ├── home
│ │ ├── about.vue
│ │ ├── articleList
│ │ │ ├── articleList.vue
│ │ │ └── singleArticle.vue
│ │ ├── home.vue
│ │ ├── labelHistory.vue
│ │ ├── labels.vue
│ │ ├── readArticle
│ │ │ ├── comment.vue
│ │ │ ├── commentList.vue
│ │ │ ├── readArticle.vue
│ │ │ └── reply.vue
│ │ └── side.vue
│ ├── login
│ │ └── login.vue
│ ├── manage
│ │ ├── child
│ │ │ ├── about.vue
│ │ │ ├── articleList.vue
│ │ │ ├── commentList.vue
│ │ │ ├── labels.vue
│ │ │ └── saveArticle.vue
│ │ └── home.vue
│ └── public
│ │ └── backTop.vue
├── main.js
├── mixin
│ └── mixin.js
├── plugin
│ └── plugin.js
├── router
│ └── index.js
├── util
│ └── axios.js
└── vuex
│ └── vuex.js
├── static
├── .gitkeep
└── img
│ └── bitbug_favicon.ico
├── 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
└── vhost.nginx.conf
/.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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | test/unit/coverage
8 | test/e2e/reports
9 | selenium-debug.log
10 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | branches:
2 | only:
3 | - master
4 | language: node_js
5 |
6 | node_js:
7 | - 'v13.8.0'
8 |
9 | cache: npm
10 |
11 | before_install:
12 | - git config --global user.name 'DouDou'
13 | - git config --global user.email '564526299@qq.com'
14 |
15 | install:
16 | - npm install
17 | - npm run build
18 |
19 | script:
20 | - git log
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx
2 |
3 | COPY ./dist/ /usr/share/nginx/html/
4 | COPY ./vhost.nginx.conf /etc/nginx/conf.d/pea3nut-info.conf
5 | EXPOSE 80
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 treasureDouDou
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-blog
2 |
3 | > 博客上线地址:[doudoujs.com](http://doudoujs.com),支持手机浏览,自适应。拜访者登录后台地址 [doudoujs.com/login](http://doudoujs.com/login), 欢迎童鞋们查看。有问题的童鞋联系我qq:564526299
4 |
5 | > 后端项目地址: [https://github.com/treasureDouDou/express-blog](https://github.com/treasureDouDou/express-blog)
6 |
7 | ## 前端项目结构
8 |
9 | ```
10 | |-src //开发
11 | |----App.vue //背景初始化
12 | |----main.js //初始化各种配置
13 | |----router.js //路由
14 | |----assets //资源
15 | |----plugin //一些公共方法
16 | |----components //组件
17 | |----utils //axios——http插件
18 | |----vuex //状态管理
19 | ```
20 |
21 | ## 启动
22 |
23 | ``` bash
24 | # install dependencies
25 | npm install
26 |
27 | # serve with hot reload at localhost:8080
28 | npm run dev
29 |
30 | # build for production with minification
31 | npm run build
32 | ```
33 |
--------------------------------------------------------------------------------
/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: ['babel-polyfill', './src/main.js']
13 | },
14 | output: {
15 | path: config.build.assetsRoot,
16 | filename: '[name].js',
17 | publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath
18 | },
19 | resolve: {
20 | extensions: ['.js', '.vue', '.json'],
21 | alias: {
22 | 'vue$': 'vue/dist/vue.esm.js',
23 | '@': resolve('src')
24 | }
25 | },
26 | module: {
27 | rules: [{
28 | test: /\.vue$/,
29 | loader: 'vue-loader',
30 | options: vueLoaderConfig
31 | }, {
32 | test: /\.js$/,
33 | loader: 'babel-loader',
34 | include: [resolve('src'), resolve('test')]
35 | }, {
36 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
37 | loader: 'url-loader',
38 | options: {
39 | limit: 10000,
40 | name: utils.assetsPath('img/[name].[hash:7].[ext]')
41 | }
42 | }, {
43 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
44 | loader: 'url-loader',
45 | options: {
46 | limit: 10000,
47 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
48 | }
49 | }, {
50 | test: /\.less$/,
51 | loader: "style-loader!css-loader!less-loader",
52 |
53 | }]
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/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 | '/api': {
32 | target: 'http://localhost:3000',
33 | changeOrigin: true,
34 | pathRewrite: {
35 | '^/api': ''
36 | }
37 | }
38 | },
39 | // CSS Sourcemaps off by default because relative paths are "buggy"
40 | // with this option, according to the CSS-Loader README
41 | // (https://github.com/webpack/css-loader#sourcemaps)
42 | // In our experience, they generally work as expected,
43 | // just be aware of this issue when enabling this option.
44 | cssSourceMap: false
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/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 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | 兜兜里有糖
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1",
3 | "version": "1.0.0",
4 | "description": "A Vue.js project",
5 | "author": "",
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 | },
15 | "dependencies": {
16 | "axios": "^0.16.1",
17 | "babel-polyfill": "^6.23.0",
18 | "css-loader": "^0.28.1",
19 | "fastclick": "^1.0.6",
20 | "iscroll": "^5.2.0",
21 | "iview": "^2.0.0-rc.18",
22 | "less": "^2.7.2",
23 | "less-loader": "^4.0.3",
24 | "simplemde-theme-base": "^0.1.2",
25 | "vue": "^2.2.6",
26 | "vue-iscroll-view": "^1.0.3",
27 | "vue-router": "^2.3.1",
28 | "vue-simplemde": "^0.3.8",
29 | "vuex": "^2.3.1"
30 | },
31 | "devDependencies": {
32 | "autoprefixer": "^6.7.2",
33 | "babel-cli": "^6.24.1",
34 | "babel-core": "^6.22.1",
35 | "babel-loader": "^6.2.10",
36 | "babel-plugin-istanbul": "^4.1.1",
37 | "babel-plugin-transform-runtime": "^6.22.0",
38 | "babel-preset-env": "^1.3.2",
39 | "babel-preset-stage-2": "^6.22.0",
40 | "babel-register": "^6.22.0",
41 | "chai": "^3.5.0",
42 | "chalk": "^1.1.3",
43 | "chromedriver": "^2.27.2",
44 | "connect-history-api-fallback": "^1.3.0",
45 | "copy-webpack-plugin": "^4.0.1",
46 | "cross-env": "^4.0.0",
47 | "cross-spawn": "^5.0.1",
48 | "css-loader": "^0.28.0",
49 | "eventsource-polyfill": "^0.9.6",
50 | "express": "^4.14.1",
51 | "extract-text-webpack-plugin": "^2.0.0",
52 | "file-loader": "^0.11.1",
53 | "friendly-errors-webpack-plugin": "^1.1.3",
54 | "html-webpack-plugin": "^2.28.0",
55 | "http-proxy-middleware": "^0.17.3",
56 | "inject-loader": "^3.0.0",
57 | "karma": "^1.4.1",
58 | "karma-coverage": "^1.1.1",
59 | "karma-mocha": "^1.3.0",
60 | "karma-phantomjs-launcher": "^1.0.2",
61 | "karma-phantomjs-shim": "^1.4.0",
62 | "karma-sinon-chai": "^1.3.1",
63 | "karma-sourcemap-loader": "^0.3.7",
64 | "karma-spec-reporter": "0.0.30",
65 | "karma-webpack": "^2.0.2",
66 | "less": "^2.7.2",
67 | "less-loader": "^4.0.3",
68 | "lolex": "^1.5.2",
69 | "mocha": "^3.2.0",
70 | "nightwatch": "^0.9.12",
71 | "opn": "^4.0.2",
72 | "optimize-css-assets-webpack-plugin": "^1.3.0",
73 | "ora": "^1.2.0",
74 | "phantomjs-prebuilt": "^2.1.14",
75 | "rimraf": "^2.6.0",
76 | "selenium-server": "^3.0.1",
77 | "semver": "^5.3.0",
78 | "shelljs": "^0.7.6",
79 | "sinon": "^2.1.0",
80 | "sinon-chai": "^2.8.0",
81 | "url-loader": "^0.5.8",
82 | "vue-loader": "^11.3.4",
83 | "vue-style-loader": "^2.0.5",
84 | "vue-template-compiler": "^2.2.6",
85 | "webpack": "^2.3.3",
86 | "webpack-bundle-analyzer": "^2.2.1",
87 | "webpack-dev-middleware": "^1.10.0",
88 | "webpack-hot-middleware": "^2.18.0",
89 | "webpack-merge": "^4.1.0"
90 | },
91 | "engines": {
92 | "node": ">= 4.0.0",
93 | "npm": ">= 3.0.0"
94 | },
95 | "browserslist": [
96 | "> 1%",
97 | "last 2 versions",
98 | "not ie <= 8"
99 | ]
100 | }
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
34 |
106 |
--------------------------------------------------------------------------------
/src/assets/css/init.css:
--------------------------------------------------------------------------------
1 | body,
2 | ol,
3 | ul,
4 | h1,
5 | h2,
6 | h3,
7 | h4,
8 | h5,
9 | h6,
10 | p,
11 | th,
12 | td,
13 | dl,
14 | dd,
15 | form,
16 | fieldset,
17 | legend,
18 | input,
19 | textarea,
20 | select {
21 | margin: 0;
22 | padding: 0
23 | }
24 |
25 | body {
26 | background: #fff;
27 | -webkit-text-size-adjust: 100%;
28 | }
29 |
30 | a {
31 | text-decoration: none
32 | }
33 |
34 | a:hover {
35 | color: #cd0200;
36 | text-decoration: underline
37 | }
38 |
39 | em {
40 | font-style: normal
41 | }
42 |
43 | li {
44 | list-style: none;
45 | }
46 |
47 | img {
48 | border: 0;
49 | vertical-align: middle
50 | }
51 |
52 | table {
53 | border-collapse: collapse;
54 | border-spacing: 0
55 | }
56 |
57 | p {
58 | word-wrap: break-word;
59 | }
60 | *{
61 | -webkit-tap-highlight-color: rgba(0,0,0,0);
62 | }
63 | boyd{
64 | font-family: PingHei,PingFang SC,Microsoft Yahei,Helvetica Neue,Helvetica,STHeitiSC-Light,Arial,sans-serif!important;
65 | }
66 | /*css为clearfix,清除浮动*/
67 |
68 | .clearfix::before,
69 | .clearfix::after {
70 | content: "";
71 | height: 0;
72 | line-height: 0;
73 | display: block;
74 | visibility: hidden;
75 | clear: both;
76 | }
77 |
78 | .clearfix:after {
79 | clear: both;
80 | }
81 |
82 | .fl {
83 | float: left;
84 | }
85 |
86 | .fr {
87 | float: right;
88 | }
89 |
90 | .t-center {
91 | text-align: center;
92 | }
93 |
94 | .f14 {
95 | font-size: 14px;
96 | }
97 |
98 | .f16 {
99 | font-size: 16px;
100 | }
101 |
102 | .f12 {
103 | font-size: 12px;
104 | }
105 |
106 | .color-w {
107 | color: #fff;
108 | }
109 |
110 | .m-auto {
111 | margin: 0 auto;
112 | }
113 |
--------------------------------------------------------------------------------
/src/assets/css/init.less:
--------------------------------------------------------------------------------
1 | .m-t(@number){
2 | margin-top: @number;
3 | }
4 | .m-b(@number){
5 | margin-bottom: @number;
6 | }
7 | .m-l(@number){
8 | margin-left: @number;
9 | }
10 | .m-r(@number){
11 | margin-right: @number;
12 | }
13 |
14 | .p-t(@number){
15 | padding-top: @number;
16 | }
17 | .p-b(@number){
18 | padding-bottom: @number;
19 | }
20 | .p-l(@number){
21 | padding-left: @number;
22 | }
23 | .p-r(@number){
24 | padding-right: @number;
25 | }
26 |
27 | .transform-x(@default: -50%){
28 | transform: translateX(@default)
29 | }
30 | .transform-y(@default: -50%){
31 | transform: translateY(@default)
32 | }
33 | .transform-x-y(@default: -50% -50%){
34 | transform: translateY(@default)
35 | }
--------------------------------------------------------------------------------
/src/assets/imgs/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/1.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/2.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/3.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/4.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/5.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/6.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/7.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/doudou.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/doudou.jpg
--------------------------------------------------------------------------------
/src/assets/imgs/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/imgs/github.png
--------------------------------------------------------------------------------
/src/assets/js/iview.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/src/assets/js/iview.js
--------------------------------------------------------------------------------
/src/components/home/about.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 | ]
46 |
76 |
--------------------------------------------------------------------------------
/src/components/home/articleList/articleList.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
89 |
99 |
--------------------------------------------------------------------------------
/src/components/home/articleList/singleArticle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
By:花解语日期:{{data.showDate}}
8 |
9 |
10 |
11 | 阅读更多
12 |
13 |
14 |
15 |
16 | -
17 |
18 | {{item.content}}
19 | {{el.label}}
20 |
21 |
22 |
23 |
24 |
25 |
26 |
62 |
203 |
--------------------------------------------------------------------------------
/src/components/home/home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | 2017- © doudou
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
117 |
290 |
--------------------------------------------------------------------------------
/src/components/home/labelHistory.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{$route.query.name}}
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{item.showDate.substr(0,4)}}
11 |
12 | {{item.title}}{{item.showDate.substr(0,10)}}
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ]
76 |
154 |
--------------------------------------------------------------------------------
/src/components/home/labels.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
tags
4 |
5 |
共计{{labels && labels.length}}个标签
6 |
7 | {{el.content}}
8 |
9 |
10 |
11 |
42 |
98 |
--------------------------------------------------------------------------------
/src/components/home/readArticle/comment.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
30 |
49 |
--------------------------------------------------------------------------------
/src/components/home/readArticle/commentList.vue:
--------------------------------------------------------------------------------
1 |
2 |
20 |
21 |
103 |
168 |
--------------------------------------------------------------------------------
/src/components/home/readArticle/readArticle.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
{{article.title}}
5 |
6 | By:花解语 日期: {{article.showDate}}
7 |
8 |
9 | {{article.content}}
10 |
11 |
12 |
13 |
14 |
15 |
43 |
87 |
--------------------------------------------------------------------------------
/src/components/home/readArticle/reply.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
108 |
218 |
--------------------------------------------------------------------------------
/src/components/home/side.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
21 | -
22 | 最新文章
23 |
24 | -
25 | 标签页
26 |
27 | -
28 | 关于我
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
50 |
247 |
--------------------------------------------------------------------------------
/src/components/login/login.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
21 |
22 |
23 |
79 |
80 |
96 |
--------------------------------------------------------------------------------
/src/components/manage/child/about.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
63 |
70 |
--------------------------------------------------------------------------------
/src/components/manage/child/articleList.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
10 |
11 |
12 | 删除确认
13 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
136 |
151 |
--------------------------------------------------------------------------------
/src/components/manage/child/commentList.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
10 | {{dialogContent}}
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | 删除确认
19 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
170 |
185 |
--------------------------------------------------------------------------------
/src/components/manage/child/labels.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
15 |
16 |
17 |
18 |
19 | 删除确认
20 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
115 |
121 |
131 |
--------------------------------------------------------------------------------
/src/components/manage/child/saveArticle.vue:
--------------------------------------------------------------------------------
1 |
2 |
38 |
39 |
165 |
185 |
197 |
--------------------------------------------------------------------------------
/src/components/manage/home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
13 |
14 |
15 | 注销账号
16 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | Loading
47 |
48 | 网络异次元!请刷新重试
49 |
50 |
51 |
52 | 2017 © doudou
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
90 |
173 |
--------------------------------------------------------------------------------
/src/components/public/backTop.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
107 |
--------------------------------------------------------------------------------
/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 | //iview组件
7 | import iView from 'iview';
8 | Vue.use(iView)
9 | import 'iview/dist/styles/iview.css' // 使用 CSS
10 |
11 | //vuex状态管理
12 | import store from './vuex/vuex.js'
13 |
14 | //iscroll
15 | import IScrollView from 'vue-iscroll-view'
16 | import IScroll from 'iscroll'
17 | Vue.use(IScrollView, IScroll)
18 |
19 | //公共方法
20 | import myplugin from './plugin/plugin.js'
21 | Vue.use(myplugin)
22 |
23 | if ('addEventListener' in document) {
24 | document.addEventListener('DOMContentLoaded', function() {
25 | FastClick.attach(document.body);
26 | }, false);
27 | }
28 | //微信QQ浏览上下拉动默认事件取消
29 | // document.querySelector('body').addEventListener('touchstart', function(e) {
30 | // e.preventDefault();
31 | // });
32 |
33 | //跳转显示加载中与进度条
34 | router.beforeEach((to, from, next) => {
35 | iView.LoadingBar.start()
36 | store.state.loading = true
37 | store.state.loadErr = false
38 | let name = localStorage.getItem('adminName')
39 | let password = localStorage.getItem('adminPassword')
40 | if (to.meta.needToken) {
41 | if (localStorage.getItem('visit') && localStorage.getItem('visitPassword')) {
42 | next()
43 | } else if (!localStorage.getItem('token') || !name || !password) {
44 | next('/login')
45 | } else {
46 | next()
47 | }
48 | } else {
49 | next()
50 | }
51 | });
52 | router.afterEach(route => {
53 | iView.LoadingBar.finish()
54 | if(Vue.prototype.notpc) {
55 | return false
56 | }
57 | window.scrollTo(0, 0);
58 |
59 | })
60 |
61 |
62 | //富文本
63 | import VueSimplemde from 'vue-simplemde'
64 | Vue.use(VueSimplemde)
65 |
66 | Vue.config.productionTip = false
67 |
68 | const app = new Vue({
69 | el: '#app',
70 | router,
71 | store,
72 | template: '',
73 | components: { App }
74 | })
75 | export default app
76 |
--------------------------------------------------------------------------------
/src/mixin/mixin.js:
--------------------------------------------------------------------------------
1 | const mixin = {
2 | mounted() {
3 |
4 | }
5 | }
6 | export default mixin
7 |
--------------------------------------------------------------------------------
/src/plugin/plugin.js:
--------------------------------------------------------------------------------
1 | //vuex状态管理
2 | import store from '@/vuex/vuex.js'
3 | import http from '@/util/axios.js'
4 | const plugin = {
5 | install(vue) {
6 | //页面等待中
7 | vue.prototype.loading = () => {
8 | store.state.loading = true
9 | };
10 | vue.prototype.loadingClose = () => {
11 | store.state.loading = false
12 | };
13 | //ajax——挂原型
14 | vue.prototype.axios = http
15 | //获取当前时间
16 | vue.prototype.getIntactTime = () => {
17 | let date = new Date(),
18 | year = date.getFullYear(),
19 | month = date.getMonth(),
20 | day = date.getDate(),
21 | hours = date.getHours(),
22 | min = date.getMinutes();
23 | month = (month+1) < 10 ? '0' + (month + 1) : (month + 1);
24 | day = day < 10 ? '0' + day : day;
25 | hours = hours < 10 ? '0' + hours : hours;
26 | min = min < 10 ? '0' + min : min;
27 | date = year + '-' + month + '-' + day + ' ' + hours + ':' + min;
28 | return date
29 | }
30 | //当前设备类型
31 | var userAgentInfo = navigator.userAgent;
32 | var Agents = ["Android", "iPhone",
33 | "SymbianOS", "Windows Phone",
34 | "iPad", "iPod"
35 | ];
36 | var flag = true;
37 | for (var v = 0; v < Agents.length; v++) {
38 | if (userAgentInfo.indexOf(Agents[v]) > 0) {
39 | flag = false;
40 | break;
41 | }
42 | }
43 | vue.prototype.notpc = !flag;
44 |
45 | vue.prototype.bus = new vue()
46 |
47 | }
48 | }
49 |
50 | export default plugin
51 |
--------------------------------------------------------------------------------
/src/router/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Router from 'vue-router'
3 |
4 | Vue.use(Router)
5 |
6 | export default new Router({
7 | mode: 'history',
8 | routes: [{
9 | //前台页面
10 | path: '/home',
11 | component: resolve => require(['../components/home/home'], resolve),
12 | children: [{
13 | //前台首页
14 | path: 'showArticleList',
15 | component: resolve => require(['../components/home/articleList/articleList'], resolve)
16 | }, {
17 | //关于我
18 | path: 'aboutMe',
19 | component: resolve => require(['../components/home/about'], resolve)
20 | }, {
21 | //标签
22 | path: 'labelsList',
23 | component: resolve => require(['../components/home/labels'], resolve)
24 | }, { //标签历史文章
25 | path: 'labelHistory',
26 | component: resolve => require(['../components/home/labelHistory'], resolve)
27 | }, { //文章详情
28 | path: 'readArticle',
29 | component: resolve => require(['../components/home/readArticle/readArticle'], resolve)
30 | }]
31 | }, , {
32 | path: '/login',
33 | component: resolve => require(['../components/login/login'], resolve)
34 | }, {
35 | //后台页面
36 | path: '/manage',
37 | meta: {
38 | needToken: true
39 | },
40 | component: resolve => require(['../components/manage/home'], resolve),
41 | children: [{
42 | //后台文章查看
43 | path: 'saveArticle',
44 | name: 'saveArticle',
45 | meta: {
46 | needToken: true
47 | },
48 | component: resolve => require(['../components/manage/child/saveArticle'], resolve)
49 | }, {
50 | //后台文章新建
51 | path: 'newArticle',
52 | name: 'newArticle',
53 | meta: {
54 | needToken: true
55 | },
56 | component: resolve => require(['../components/manage/child/saveArticle'], resolve)
57 | }, {
58 | //后台文章列表
59 | path: 'articleList',
60 | name: 'articleList',
61 | meta: {
62 | needToken: true
63 | },
64 | component: resolve => require(['../components/manage/child/articleList'], resolve)
65 | }, {
66 | //后台标签管理
67 | path: 'labels',
68 | name: 'labels',
69 | meta: {
70 | needToken: true
71 | },
72 | component: resolve => require(['../components/manage/child/labels'], resolve)
73 | }, {
74 | //后台标签管理
75 | path: 'about',
76 | name: 'about',
77 | meta: {
78 | needToken: true
79 | },
80 | component: resolve => require(['../components/manage/child/about'], resolve)
81 | }, {
82 | //后台留言板管理
83 | path: 'comment',
84 | name: 'comment',
85 | meta: {
86 | needToken: true
87 | },
88 | component: resolve => require(['../components/manage/child/commentList'], resolve)
89 | }]
90 | }, {
91 | path: '*',
92 | redirect: '/home/showArticleList'
93 | }]
94 | })
95 |
--------------------------------------------------------------------------------
/src/util/axios.js:
--------------------------------------------------------------------------------
1 | //axios——设置请求
2 | import iView from 'iview'
3 | import axios from 'axios'
4 | import { Message } from 'iview'
5 | import store from '@/vuex/vuex.js'
6 | import app from '../main.js'
7 | var accessToken = localStorage.getItem('token')
8 |
9 | const http = axios.create({
10 | baseURL: 'http://localhost:3000/api',
11 | timeout: 8000,
12 | data: {},
13 | headers: {
14 | 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
15 | },
16 | })
17 | const qs = require('querystring')
18 | var oldConfig = null
19 | // 请求前
20 | http.interceptors.request.use(config => {
21 | if (config.url.indexOf('login') < 1 && !localStorage.getItem('adminName') && !localStorage.getItem('adminPassword')) {
22 | if (config.method == 'post' && localStorage.getItem('visit') && localStorage.getItem('visitPassword')) {
23 | return Promise.reject({ code: 0 });//0没有权限
24 | }
25 | }
26 |
27 | iView.LoadingBar.start();
28 | config.data = qs.stringify(config.data)
29 | if (accessToken != null) {
30 | config.headers['access-token'] = accessToken
31 | }
32 | return config;
33 | }, err => {
34 | return Promise.reject(err);
35 | });
36 | //请求后
37 | http.interceptors.response.use(res => {
38 | iView.LoadingBar.finish();
39 | if (res.data.code == 300) { //token过期
40 | Message.warning('您的会话已过期,请重新登录');
41 | localStorage.removeItem('token')
42 | app.$router.replace('/login')
43 | return Promise.reject();
44 | } else if (res.data.code != 200) {
45 | Message.error(res.data.msg);
46 | return Promise.reject();
47 | } else {
48 | if (res.data.token) {
49 | localStorage.setItem('token', res.data.token)
50 | accessToken = res.data.token
51 | }
52 | return res.data.data
53 | }
54 | }, err => {
55 | if (err && err.code == 0) {
56 | Message.warning('您没有权限');
57 | } else {
58 | //正则判断超时
59 | let rg = /8000/g
60 | iView.LoadingBar.error();
61 | if (rg.test(err)) {
62 | Message.error('您的网络不给力喔,请刷新重试');
63 | } else {
64 | Message.error('服务器错误');
65 | }
66 | }
67 |
68 | store.state.loadErr = true
69 | return Promise.reject(err);
70 | })
71 |
72 | export default http
73 |
--------------------------------------------------------------------------------
/src/vuex/vuex.js:
--------------------------------------------------------------------------------
1 | import Vuex from 'vuex'
2 | import Vue from 'vue'
3 | Vue.use(Vuex)
4 |
5 | const state = {
6 | loading: false,
7 | articleList: null,
8 | aboutMe: null,
9 | labels: null,
10 | loadErr: false,
11 | total: 0
12 | }
13 |
14 | const mutations = {
15 | loadingDone(state){
16 | state.loading = !state.loading
17 | },
18 | aboutMeData(state, data){
19 | state.aboutMe = data
20 | },
21 | lablesData(state, data){
22 | state.labels = data
23 | },
24 | articleListData(state, data){
25 | state.articleList = data
26 | },
27 | totalData(state, data){
28 | state.total = data
29 | }
30 | }
31 |
32 | const store = new Vuex.Store({
33 | state,
34 | mutations
35 | })
36 |
37 | export default store
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/static/.gitkeep
--------------------------------------------------------------------------------
/static/img/bitbug_favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/treasureDouDou/vue-blog/3ace49048bc3fd9630807ede4146d4e9c009ddc3/static/img/bitbug_favicon.ico
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vhost.nginx.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | server_name localhost;
4 | location / {
5 | root /usr/share/nginx/html;
6 | index index.html index.htm;
7 | proxy_set_header Host $host;
8 |
9 | if (!-f $request_filename) {
10 | rewrite ^.*$ /index.html break;
11 | }
12 |
13 | }
14 |
15 | error_page 500 502 503 504 /50x.html;
16 | location = /50x.html {
17 | root /usr/share/nginx/html;
18 | }
19 | }
--------------------------------------------------------------------------------