├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .postcssrc.js
├── 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
├── config
├── dev.env.js
├── index.js
└── prod.env.js
├── index.html
├── package.json
├── project.config.json
├── src
├── App.vue
├── components
│ ├── card.vue
│ ├── footer.vue
│ ├── music.vue
│ └── navigation.vue
├── fonts
│ ├── icomoon.eot
│ ├── icomoon.svg
│ ├── icomoon.ttf
│ └── icomoon.woff
├── main.js
├── pages
│ ├── blog
│ │ ├── blog.vue
│ │ └── main.js
│ ├── blogdetail
│ │ ├── blogdetail.vue
│ │ └── main.js
│ ├── error
│ │ ├── error.vue
│ │ └── main.js
│ ├── homepage
│ │ ├── homepage.vue
│ │ └── main.js
│ └── me
│ │ ├── main.js
│ │ └── me.vue
└── utils
│ ├── article.js
│ ├── category.js
│ └── config.js
├── static
└── .gitkeep
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "modules": false,
5 | "targets": {
6 | "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7 | }
8 | }],
9 | "stage-2"
10 | ],
11 | "plugins": ["transform-runtime"],
12 | "env": {
13 | "test": {
14 | "presets": ["env", "stage-2"],
15 | "plugins": ["istanbul"]
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.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: false,
11 | node: true,
12 | es6: true
13 | },
14 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md
15 | extends: 'standard',
16 | // required to lint *.vue files
17 | plugins: [
18 | 'html'
19 | ],
20 | // add your custom rules here
21 | 'rules': {
22 | // allow paren-less arrow functions
23 | 'arrow-parens': 0,
24 | // allow async-await
25 | 'generator-star-spacing': 0,
26 | // allow debugger during development
27 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
28 | },
29 | globals: {
30 | App: true,
31 | Page: true,
32 | wx: true,
33 | getApp: true,
34 | getPage: true
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Editor directories and files
9 | .idea
10 | *.suo
11 | *.ntvs*
12 | *.njsproj
13 | *.sln
14 |
--------------------------------------------------------------------------------
/.postcssrc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/michael-ciniawsky/postcss-load-config
2 |
3 | module.exports = {
4 | "plugins": {
5 | // to edit target browsers: use "browserslist" field in package.json
6 | "autoprefixer": {},
7 | "postcss-mpvue-wxss": {}
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 XueCong
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 | ## 项目概述
2 |
3 | 这是我的个人博客小程序版,使用 [Mpvue](https://github.com/Meituan-Dianping/mpvue) 编写而成,web版请访问 [blog](https://github.com/overxue/blog)。
4 |
5 | 后续我会不断完善这个博客,添加一些新的功能,比如文章评论,点赞,分享朋友圈。欢迎小伙伴关注。
6 |
7 | 如果你发现bugs,或者有一些好的建议,欢迎 issue。
8 |
9 | ## 截图展示
10 |
11 |
12 |
13 |
14 |
15 |
16 | ## 扫码体验
17 |
18 |
19 | ## 基础安装
20 | #### 1. 克隆`mpblog`源代码
21 | ```
22 | git clone git@github.com:overxue/mpblog.git
23 | ```
24 |
25 | #### 2. 安装依赖
26 | ```
27 | yarn install 或者 npm install
28 | ```
29 | #### 3. 编译
30 | ```
31 | npm run dev
32 | ```
33 | #### 4. 启动微信开发者工具,引入项目即可预览到mpblog小程序
34 |
35 | 至此, 安装完成 ^_^。
36 |
--------------------------------------------------------------------------------
/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 | if (stats.hasErrors()) {
30 | console.log(chalk.red(' Build failed with errors.\n'))
31 | process.exit(1)
32 | }
33 |
34 | console.log(chalk.cyan(' Build complete.\n'))
35 | console.log(chalk.yellow(
36 | ' Tip: built files are meant to be served over an HTTP server.\n' +
37 | ' Opening index.html over file:// won\'t work.\n'
38 | ))
39 | })
40 | })
41 |
--------------------------------------------------------------------------------
/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 = require('./webpack.dev.conf')
14 |
15 | // default port where dev server listens for incoming traffic
16 | var port = process.env.PORT || config.dev.port
17 | // automatically open browser, if not set will be false
18 | var autoOpenBrowser = !!config.dev.autoOpenBrowser
19 | // Define HTTP proxies to your custom API backend
20 | // https://github.com/chimurai/http-proxy-middleware
21 | var proxyTable = config.dev.proxyTable
22 |
23 | var app = express()
24 | var compiler = webpack(webpackConfig)
25 |
26 | // var devMiddleware = require('webpack-dev-middleware')(compiler, {
27 | // publicPath: webpackConfig.output.publicPath,
28 | // quiet: true
29 | // })
30 |
31 | // var hotMiddleware = require('webpack-hot-middleware')(compiler, {
32 | // log: false,
33 | // heartbeat: 2000
34 | // })
35 | // force page reload when html-webpack-plugin template changes
36 | // compiler.plugin('compilation', function (compilation) {
37 | // compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
38 | // hotMiddleware.publish({ action: 'reload' })
39 | // cb()
40 | // })
41 | // })
42 |
43 | // proxy api requests
44 | Object.keys(proxyTable).forEach(function (context) {
45 | var options = proxyTable[context]
46 | if (typeof options === 'string') {
47 | options = { target: options }
48 | }
49 | app.use(proxyMiddleware(options.filter || context, options))
50 | })
51 |
52 | // handle fallback for HTML5 history API
53 | app.use(require('connect-history-api-fallback')())
54 |
55 | // serve webpack bundle output
56 | // app.use(devMiddleware)
57 |
58 | // enable hot-reload and state-preserving
59 | // compilation error display
60 | // app.use(hotMiddleware)
61 |
62 | // serve pure static assets
63 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
64 | app.use(staticPath, express.static('./static'))
65 |
66 | var uri = 'http://localhost:' + port
67 |
68 | var _resolve
69 | var readyPromise = new Promise(resolve => {
70 | _resolve = resolve
71 | })
72 |
73 | // console.log('> Starting dev server...')
74 | // devMiddleware.waitUntilValid(() => {
75 | // console.log('> Listening at ' + uri + '\n')
76 | // // when env is testing, don't need open it
77 | // if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') {
78 | // opn(uri)
79 | // }
80 | // _resolve()
81 | // })
82 |
83 | var server = app.listen(port, 'localhost')
84 |
85 | // for 小程序的文件保存机制
86 | require('webpack-dev-middleware-hard-disk')(compiler, {
87 | publicPath: webpackConfig.output.publicPath,
88 | quiet: true
89 | })
90 |
91 | module.exports = {
92 | ready: readyPromise,
93 | close: () => {
94 | server.close()
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/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 | var postcssLoader = {
24 | loader: 'postcss-loader',
25 | options: {
26 | sourceMap: true
27 | }
28 | }
29 |
30 | var px2rpxLoader = {
31 | loader: 'px2rpx-loader',
32 | options: {
33 | baseDpr: 1,
34 | rpxUnit: 0.5
35 | }
36 | }
37 |
38 | // generate loader string to be used with extract text plugin
39 | function generateLoaders (loader, loaderOptions) {
40 | var loaders = [cssLoader, px2rpxLoader, postcssLoader]
41 | if (loader) {
42 | loaders.push({
43 | loader: loader + '-loader',
44 | options: Object.assign({}, loaderOptions, {
45 | sourceMap: options.sourceMap
46 | })
47 | })
48 | }
49 |
50 | // Extract CSS when that option is specified
51 | // (which is the case during production build)
52 | if (options.extract) {
53 | return ExtractTextPlugin.extract({
54 | use: loaders,
55 | fallback: 'vue-style-loader'
56 | })
57 | } else {
58 | return ['vue-style-loader'].concat(loaders)
59 | }
60 | }
61 |
62 | // https://vue-loader.vuejs.org/en/configurations/extract-css.html
63 | return {
64 | css: generateLoaders(),
65 | postcss: generateLoaders(),
66 | less: generateLoaders('less'),
67 | sass: generateLoaders('sass', { indentedSyntax: true }),
68 | scss: generateLoaders('sass'),
69 | stylus: generateLoaders('stylus'),
70 | styl: generateLoaders('stylus')
71 | }
72 | }
73 |
74 | // Generate loaders for standalone style files (outside of .vue)
75 | exports.styleLoaders = function (options) {
76 | var output = []
77 | var loaders = exports.cssLoaders(options)
78 | for (var extension in loaders) {
79 | var loader = loaders[extension]
80 | output.push({
81 | test: new RegExp('\\.' + extension + '$'),
82 | use: loader
83 | })
84 | }
85 | return output
86 | }
87 |
--------------------------------------------------------------------------------
/build/vue-loader.conf.js:
--------------------------------------------------------------------------------
1 | var utils = require('./utils')
2 | var config = require('../config')
3 | // var isProduction = process.env.NODE_ENV === 'production'
4 | // for mp
5 | var isProduction = true
6 |
7 | module.exports = {
8 | loaders: utils.cssLoaders({
9 | sourceMap: isProduction
10 | ? config.build.productionSourceMap
11 | : config.dev.cssSourceMap,
12 | extract: isProduction
13 | }),
14 | transformToRequire: {
15 | video: 'src',
16 | source: 'src',
17 | img: 'src',
18 | image: 'xlink:href'
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/build/webpack.base.conf.js:
--------------------------------------------------------------------------------
1 | var path = require('path')
2 | var fs = require('fs')
3 | var utils = require('./utils')
4 | var config = require('../config')
5 | var vueLoaderConfig = require('./vue-loader.conf')
6 |
7 | function resolve (dir) {
8 | return path.join(__dirname, '..', dir)
9 | }
10 |
11 | function getEntry (dir, entryFile) {
12 | const files = fs.readdirSync(dir)
13 | return files.reduce((res, k) => {
14 | const page = path.resolve(dir, k, entryFile)
15 | if (fs.existsSync(page)) {
16 | res[k] = page
17 | }
18 | return res
19 | }, {})
20 | }
21 |
22 | const appEntry = { app: resolve('./src/main.js') }
23 | const pagesEntry = getEntry(resolve('./src/pages'), 'main.js')
24 | const entry = Object.assign({}, appEntry, pagesEntry)
25 |
26 | module.exports = {
27 | entry: entry, // 如果要自定义生成的 dist 目录里面的文件路径,
28 | // 可以将 entry 写成 {'toPath': 'fromPath'} 的形式,
29 | // toPath 为相对于 dist 的路径, 例:index/demo,则生成的文件地址为 dist/index/demo.js
30 | target: require('mpvue-webpack-target'),
31 | output: {
32 | path: config.build.assetsRoot,
33 | filename: '[name].js',
34 | publicPath: process.env.NODE_ENV === 'production'
35 | ? config.build.assetsPublicPath
36 | : config.dev.assetsPublicPath
37 | },
38 | resolve: {
39 | extensions: ['.js', '.vue', '.json'],
40 | alias: {
41 | 'vue': 'mpvue',
42 | '@': resolve('src')
43 | },
44 | symlinks: false
45 | },
46 | module: {
47 | rules: [
48 | {
49 | test: /\.(js|vue)$/,
50 | loader: 'eslint-loader',
51 | enforce: 'pre',
52 | include: [resolve('src'), resolve('test')],
53 | options: {
54 | formatter: require('eslint-friendly-formatter')
55 | }
56 | },
57 | {
58 | test: /\.vue$/,
59 | loader: 'mpvue-loader',
60 | options: vueLoaderConfig
61 | },
62 | {
63 | test: /\.js$/,
64 | include: [resolve('src'), resolve('test')],
65 | use: [
66 | 'babel-loader',
67 | {
68 | loader: 'mpvue-loader',
69 | options: {
70 | checkMPEntry: true
71 | }
72 | },
73 | ]
74 | },
75 | {
76 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
77 | loader: 'url-loader',
78 | options: {
79 | limit: 10000,
80 | name: utils.assetsPath('img/[name].[ext]')
81 | }
82 | },
83 | {
84 | test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
85 | loader: 'url-loader',
86 | options: {
87 | limit: 10000,
88 | name: utils.assetsPath('media/[name]].[ext]')
89 | }
90 | },
91 | {
92 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
93 | loader: 'url-loader',
94 | options: {
95 | limit: 10000,
96 | name: utils.assetsPath('fonts/[name].[ext]')
97 | }
98 | }
99 | ]
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/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 | // copy from ./webpack.prod.conf.js
10 | var path = require('path')
11 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
12 | var CopyWebpackPlugin = require('copy-webpack-plugin')
13 | var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
14 |
15 | // add hot-reload related code to entry chunks
16 | // Object.keys(baseWebpackConfig.entry).forEach(function (name) {
17 | // baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
18 | // })
19 |
20 | module.exports = merge(baseWebpackConfig, {
21 | module: {
22 | rules: utils.styleLoaders({
23 | sourceMap: config.dev.cssSourceMap,
24 | extract: true
25 | })
26 | },
27 | // cheap-module-eval-source-map is faster for development
28 | // devtool: '#cheap-module-eval-source-map',
29 | devtool: '#source-map',
30 | output: {
31 | path: config.build.assetsRoot,
32 | // filename: utils.assetsPath('js/[name].[chunkhash].js'),
33 | // chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
34 | filename: utils.assetsPath('js/[name].js'),
35 | chunkFilename: utils.assetsPath('js/[id].js')
36 | },
37 | plugins: [
38 | new webpack.DefinePlugin({
39 | 'process.env': config.dev.env
40 | }),
41 |
42 | // copy from ./webpack.prod.conf.js
43 | // extract css into its own file
44 | new ExtractTextPlugin({
45 | // filename: utils.assetsPath('css/[name].[contenthash].css')
46 | filename: utils.assetsPath('css/[name].wxss')
47 | }),
48 | // Compress extracted CSS. We are using this plugin so that possible
49 | // duplicated CSS from different components can be deduped.
50 | new OptimizeCSSPlugin({
51 | cssProcessorOptions: {
52 | safe: true
53 | }
54 | }),
55 | new webpack.optimize.CommonsChunkPlugin({
56 | name: 'vendor',
57 | minChunks: function (module, count) {
58 | // any required modules inside node_modules are extracted to vendor
59 | return (
60 | module.resource &&
61 | /\.js$/.test(module.resource) &&
62 | module.resource.indexOf('node_modules') >= 0
63 | )
64 | }
65 | }),
66 | new webpack.optimize.CommonsChunkPlugin({
67 | name: 'manifest',
68 | chunks: ['vendor']
69 | }),
70 | // copy custom static assets
71 | new CopyWebpackPlugin([
72 | {
73 | from: path.resolve(__dirname, '../static'),
74 | to: config.build.assetsSubDirectory,
75 | ignore: ['.*']
76 | }
77 | ]),
78 |
79 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
80 | // new webpack.HotModuleReplacementPlugin(),
81 | new webpack.NoEmitOnErrorsPlugin(),
82 | // https://github.com/ampedandwired/html-webpack-plugin
83 | // new HtmlWebpackPlugin({
84 | // filename: 'index.html',
85 | // template: 'index.html',
86 | // inject: true
87 | // }),
88 | new FriendlyErrorsPlugin()
89 | ]
90 | })
91 |
--------------------------------------------------------------------------------
/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 = config.build.env
13 |
14 | var webpackConfig = merge(baseWebpackConfig, {
15 | module: {
16 | rules: utils.styleLoaders({
17 | sourceMap: config.build.productionSourceMap,
18 | extract: true
19 | })
20 | },
21 | devtool: config.build.productionSourceMap ? '#source-map' : false,
22 | output: {
23 | path: config.build.assetsRoot,
24 | // filename: utils.assetsPath('js/[name].[chunkhash].js'),
25 | // chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
26 | filename: utils.assetsPath('js/[name].js'),
27 | chunkFilename: utils.assetsPath('js/[id].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 | filename: utils.assetsPath('css/[name].wxss')
44 | }),
45 | // Compress extracted CSS. We are using this plugin so that possible
46 | // duplicated CSS from different components can be deduped.
47 | new OptimizeCSSPlugin({
48 | cssProcessorOptions: {
49 | safe: true
50 | }
51 | }),
52 | // generate dist index.html with correct asset hash for caching.
53 | // you can customize output by editing /index.html
54 | // see https://github.com/ampedandwired/html-webpack-plugin
55 | // new HtmlWebpackPlugin({
56 | // filename: config.build.index,
57 | // template: 'index.html',
58 | // inject: true,
59 | // minify: {
60 | // removeComments: true,
61 | // collapseWhitespace: true,
62 | // removeAttributeQuotes: true
63 | // // more options:
64 | // // https://github.com/kangax/html-minifier#options-quick-reference
65 | // },
66 | // // necessary to consistently work with multiple chunks via CommonsChunkPlugin
67 | // chunksSortMode: 'dependency'
68 | // }),
69 | // keep module.id stable when vender modules does not change
70 | new webpack.HashedModuleIdsPlugin(),
71 | // split vendor js into its own file
72 | new webpack.optimize.CommonsChunkPlugin({
73 | name: 'vendor',
74 | minChunks: function (module, count) {
75 | // any required modules inside node_modules are extracted to vendor
76 | return (
77 | module.resource &&
78 | /\.js$/.test(module.resource) &&
79 | module.resource.indexOf('node_modules') >= 0
80 | )
81 | }
82 | }),
83 | // extract webpack runtime and module manifest to its own file in order to
84 | // prevent vendor hash from being updated whenever app bundle is updated
85 | new webpack.optimize.CommonsChunkPlugin({
86 | name: 'manifest',
87 | chunks: ['vendor']
88 | }),
89 | // copy custom static assets
90 | new CopyWebpackPlugin([
91 | {
92 | from: path.resolve(__dirname, '../static'),
93 | to: config.build.assetsSubDirectory,
94 | ignore: ['.*']
95 | }
96 | ])
97 | ]
98 | })
99 |
100 | // if (config.build.productionGzip) {
101 | // var CompressionWebpackPlugin = require('compression-webpack-plugin')
102 |
103 | // webpackConfig.plugins.push(
104 | // new CompressionWebpackPlugin({
105 | // asset: '[path].gz[query]',
106 | // algorithm: 'gzip',
107 | // test: new RegExp(
108 | // '\\.(' +
109 | // config.build.productionGzipExtensions.join('|') +
110 | // ')$'
111 | // ),
112 | // threshold: 10240,
113 | // minRatio: 0.8
114 | // })
115 | // )
116 | // }
117 |
118 | if (config.build.bundleAnalyzerReport) {
119 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
120 | webpackConfig.plugins.push(new BundleAnalyzerPlugin())
121 | }
122 |
123 | module.exports = webpackConfig
124 |
--------------------------------------------------------------------------------
/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: false,
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 | // 在小程序开发者工具中不需要自动打开浏览器
28 | autoOpenBrowser: false,
29 | assetsSubDirectory: 'static',
30 | assetsPublicPath: '/',
31 | proxyTable: {},
32 | // CSS Sourcemaps off by default because relative paths are "buggy"
33 | // with this option, according to the CSS-Loader README
34 | // (https://github.com/webpack/css-loader#sourcemaps)
35 | // In our experience, they generally work as expected,
36 | // just be aware of this issue when enabling this option.
37 | cssSourceMap: false
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/config/prod.env.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | NODE_ENV: '"production"'
3 | }
4 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | mpblog
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mpblog",
3 | "version": "1.0.0",
4 | "description": "My Blog",
5 | "author": "XueCong ",
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 | "lint": "eslint --ext .js,.vue src"
12 | },
13 | "dependencies": {
14 | "mpvue": "^1.0.7",
15 | "timeago.js": "^3.0.2",
16 | "flyio": "^0.4.3",
17 | "mpvue-wxparse": "^0.4.8"
18 | },
19 | "devDependencies": {
20 | "mpvue-loader": "^1.0.9",
21 | "mpvue-webpack-target": "^1.0.0",
22 | "mpvue-template-compiler": "^1.0.7",
23 | "postcss-mpvue-wxss": "^1.0.0",
24 | "px2rpx-loader": "^0.1.8",
25 | "autoprefixer": "^7.1.2",
26 | "babel-core": "^6.22.1",
27 | "babel-eslint": "^7.1.1",
28 | "babel-loader": "^7.1.1",
29 | "babel-plugin-transform-runtime": "^6.22.0",
30 | "babel-preset-env": "^1.3.2",
31 | "babel-preset-stage-2": "^6.22.0",
32 | "babel-register": "^6.22.0",
33 | "chalk": "^2.0.1",
34 | "connect-history-api-fallback": "^1.3.0",
35 | "copy-webpack-plugin": "^4.0.1",
36 | "css-loader": "^0.28.0",
37 | "cssnano": "^3.10.0",
38 | "eslint": "^3.19.0",
39 | "eslint-friendly-formatter": "^3.0.0",
40 | "eslint-loader": "^1.7.1",
41 | "eslint-plugin-html": "^3.0.0",
42 | "eslint-config-standard": "^6.2.1",
43 | "eslint-plugin-promise": "^3.4.0",
44 | "eslint-plugin-standard": "^2.0.1",
45 | "eventsource-polyfill": "^0.9.6",
46 | "express": "^4.14.1",
47 | "extract-text-webpack-plugin": "^2.0.0",
48 | "file-loader": "^0.11.1",
49 | "friendly-errors-webpack-plugin": "^1.1.3",
50 | "html-webpack-plugin": "^2.28.0",
51 | "http-proxy-middleware": "^0.17.3",
52 | "webpack-bundle-analyzer": "^2.2.1",
53 | "semver": "^5.3.0",
54 | "shelljs": "^0.7.6",
55 | "opn": "^5.1.0",
56 | "optimize-css-assets-webpack-plugin": "^2.0.0",
57 | "ora": "^1.2.0",
58 | "rimraf": "^2.6.0",
59 | "url-loader": "^0.5.8",
60 | "vue-style-loader": "^3.0.1",
61 | "webpack": "^2.6.1",
62 | "webpack-dev-middleware": "^1.10.0",
63 | "webpack-hot-middleware": "^2.18.0",
64 | "webpack-dev-middleware-hard-disk": "^1.10.0",
65 | "webpack-merge": "^4.1.0",
66 | "postcss-loader": "^2.0.6",
67 | "stylus": "^0.54.5",
68 | "stylus-loader": "^3.0.1"
69 | },
70 | "engines": {
71 | "node": ">= 4.0.0",
72 | "npm": ">= 3.0.0"
73 | },
74 | "browserslist": [
75 | "> 1%",
76 | "last 2 versions",
77 | "not ie <= 8"
78 | ]
79 | }
80 |
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件。",
3 | "setting": {
4 | "urlCheck": true,
5 | "es6": false,
6 | "postcss": true,
7 | "minified": true,
8 | "newFeature": true
9 | },
10 | "miniprogramRoot": "./dist/",
11 | "compileType": "miniprogram",
12 | "appid": "wx4a012f477ec2a388",
13 | "projectname": "mpblog",
14 | "condition": {
15 | "search": {
16 | "current": -1,
17 | "list": []
18 | },
19 | "conversation": {
20 | "current": -1,
21 | "list": []
22 | },
23 | "game": {
24 | "currentL": -1,
25 | "list": []
26 | },
27 | "miniprogram": {
28 | "current": -1,
29 | "list": []
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
108 |
--------------------------------------------------------------------------------
/src/components/card.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/src/components/footer.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
12 |
13 |
30 |
--------------------------------------------------------------------------------
/src/components/music.vue:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
38 |
39 |
57 |
--------------------------------------------------------------------------------
/src/components/navigation.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
57 |
58 |
168 |
--------------------------------------------------------------------------------
/src/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/overxue/mpblog/6d24914310b3bf592b476f63d0b33a855358c97f/src/fonts/icomoon.eot
--------------------------------------------------------------------------------
/src/fonts/icomoon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/overxue/mpblog/6d24914310b3bf592b476f63d0b33a855358c97f/src/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/src/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/overxue/mpblog/6d24914310b3bf592b476f63d0b33a855358c97f/src/fonts/icomoon.woff
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App'
3 |
4 | Vue.config.productionTip = false
5 | App.mpType = 'app'
6 |
7 | const app = new Vue(App)
8 | app.$mount()
9 |
10 | export default {
11 | // 这个字段走 app.json
12 | config: {
13 | pages: ['^pages/homepage/homepage', 'pages/blog/blog', 'pages/blogdetail/blogdetail', 'pages/me/me', 'pages/error/error'], // 页面前带有 ^ 符号的,会被编译成首页,其他页面可以选填,我们会自动把 webpack entry 里面的入口页面加进去
14 | window: {
15 | backgroundTextStyle: 'light',
16 | navigationBarBackgroundColor: '#fff',
17 | navigationBarTitleText: '薛聪的博客',
18 | navigationBarTextStyle: 'black'
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/pages/blog/blog.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
{{item.name}}{{item.articles_count}}
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
new
29 |
32 |
33 |
34 | XueCong
35 |
36 |
37 | {{item.created_at}}
38 |
39 |
40 | {{item.view_count}}
41 |
42 |
43 |
44 | {{item.excerpt}}
45 |
46 |
47 |
48 |
49 | {{category.name}}
50 |
51 |
52 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
130 |
131 |
343 |
--------------------------------------------------------------------------------
/src/pages/blog/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './blog'
3 |
4 | const app = new Vue(App)
5 | app.$mount()
6 |
--------------------------------------------------------------------------------
/src/pages/blogdetail/blogdetail.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
{{articledetail.title}}
13 |
发布时间:{{articledetail.created_at}}
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | 打赏
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
40 |
41 |
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!
42 |
43 |

44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
94 |
95 |
320 |
--------------------------------------------------------------------------------
/src/pages/blogdetail/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './blogdetail'
3 |
4 | const app = new Vue(App)
5 | app.$mount()
6 |
--------------------------------------------------------------------------------
/src/pages/error/error.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
由于小程序限制跳转至外部网页,您可以通过以下网址访问。
7 |
{{message}} (点我复制)
8 |
9 |
10 |
11 |
12 |
13 |
14 |
54 |
55 |
75 |
--------------------------------------------------------------------------------
/src/pages/error/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './error'
3 |
4 | const app = new Vue(App)
5 | app.$mount()
6 |
--------------------------------------------------------------------------------
/src/pages/homepage/homepage.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |

7 |
8 |
Nothing is impossible.
9 |
23 |
24 |
25 |
26 |
27 |
36 |
37 |
88 |
--------------------------------------------------------------------------------
/src/pages/homepage/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './homepage'
3 |
4 | const app = new Vue(App)
5 | app.$mount()
6 |
--------------------------------------------------------------------------------
/src/pages/me/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './me'
3 |
4 | const app = new Vue(App)
5 | app.$mount()
6 |
--------------------------------------------------------------------------------
/src/pages/me/me.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
20 | - 我不是大神,我只是一枚有点帅的普通php开发者,擅长写各类bug,专业制造bug 30年!
21 | - 爱编程,爱开源,爱分享,爱赚钱,爱生活!
22 | -
23 | 我的人生格言:不要怂,就是干!
24 | - 我很认真,对于任何事!
25 | - 我比较直爽,性格幽默!
26 | - 我很帅,不管你信不信!
27 | - 从17年开始搭建博客,希望这件事可以一直坚持下去!
28 | - 这里不仅是我的技术分享,也是我人生路的记载!
29 | - 这个博客其实帮助不了你什么,除了能让你变得跟我一样帅!
30 | - web端博客地址:www.overxue.com
31 | - 认真生活,认真扯淡!
32 | - 完。
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
59 |
60 |
155 |
--------------------------------------------------------------------------------
/src/utils/article.js:
--------------------------------------------------------------------------------
1 | import Fly from 'flyio/dist/npm/wx'
2 | import { http } from './config'
3 |
4 | const fly = new Fly()
5 |
6 | export function getArticle (page = 1) {
7 | const url = `${http}/api/articles?page=${page}&include=categories`
8 | return fly.get(url).then((res) => {
9 | return Promise.resolve(res.data)
10 | }).catch((err) => {
11 | console.log(err)
12 | })
13 | }
14 |
15 | export function getArticledetail (id) {
16 | const url = `${http}/api/articles/${id}`
17 | return fly.get(url).then((res) => {
18 | return Promise.resolve(res.data)
19 | }).catch((err) => {
20 | console.log(err)
21 | })
22 | }
23 |
--------------------------------------------------------------------------------
/src/utils/category.js:
--------------------------------------------------------------------------------
1 | import Fly from 'flyio/dist/npm/wx'
2 | import { http } from './config'
3 |
4 | const fly = new Fly()
5 |
6 | export function getCategory () {
7 | const url = `${http}/api/categories`
8 | return fly.get(url).then((res) => {
9 | return Promise.resolve(res.data)
10 | })
11 | }
12 |
13 | export function getCategoryArticle (id) {
14 | const url = `${http}/api/categories/${id}/articles?include=categories`
15 | return fly.get(url).then((res) => {
16 | return Promise.resolve(res.data)
17 | }).catch((err) => {
18 | console.log(err)
19 | })
20 | }
21 |
--------------------------------------------------------------------------------
/src/utils/config.js:
--------------------------------------------------------------------------------
1 | export const http = 'https://www.overxue.com'
2 |
--------------------------------------------------------------------------------
/static/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/overxue/mpblog/6d24914310b3bf592b476f63d0b33a855358c97f/static/.gitkeep
--------------------------------------------------------------------------------