diff --git a/nuxt.config.js b/nuxt.config.js index 188e458..6dbf9b1 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,62 +1,103 @@ const pkg = require('./package') +const DevBaseUrl = 'http://127.0.0.1:65534' +const ProdBashUrl = 'https://api.wyr.me' + module.exports = { mode: 'universal', /* - ** Headers of the page - */ + ** Headers of the page + */ head: { - title: pkg.name, - meta: [ - { charset: 'utf-8' }, - { name: 'viewport', content: 'width=device-width, initial-scale=1' }, - { hid: 'description', name: 'description', content: pkg.description } + title: '轶哥博客', + htmlAttrs: { + lang: 'zh-cn' + }, + meta: [{ + charset: 'utf-8' + }, + { + name: 'viewport', + content: 'width=device-width, initial-scale=1, user-scalable=no' + }, + { + 'http-equiv': 'X-UA-Compatible', + content: 'IE=edge, chrome=1' + }, + { + hid: 'description', + name: 'description', + content: '一个全栈程序员的技术博客。' + } ], - link: [ - { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } + link: [{ + rel: 'stylesheet', + href: 'https://cdn.wyr.me/css/begin.css' + }, + { + rel: 'stylesheet', + href: 'https://cdn.wyr.me/css/highlight/atom-one-light.css' + }, + { + rel: 'icon', + type: 'image/x-icon', + href: '/favicon.ico' + } ] }, /* - ** Customize the progress-bar color - */ - loading: { color: '#fff' }, + ** Customize the progress-bar color + */ + loading: { + color: '#3B8070' + }, /* - ** Global CSS - */ - css: [ + ** Global CSS + */ + css: [], + + /* + ** Plugins to load before mounting the App + */ + plugins: [{ + src: '~/plugins/moment.js' + }, + { + src: '~/plugins/vue.js', + ssr: true + }, + { + src: '~/plugins/browser.js', + ssr: false + } ], /* - ** Plugins to load before mounting the App - */ - plugins: [ - ], - - /* - ** Nuxt.js modules - */ + ** Nuxt.js modules + */ modules: [ // Doc: https://axios.nuxtjs.org/usage '@nuxtjs/axios' ], /* - ** Axios module configuration - */ + ** Axios module configuration + */ axios: { // See https://github.com/nuxt-community/axios-module#options + baseURL: process.env.NODE_ENV === 'development' ? DevBaseUrl : ProdBashUrl // 配置API接口地址 }, /* - ** Build configuration - */ + ** Build configuration + */ build: { /* - ** You can extend webpack config here - */ - extend(config, ctx) { + ** You can extend webpack config here + */ + extend (config, ctx) { // Run ESLint on save if (ctx.isDev && ctx.isClient) { config.module.rules.push({ @@ -66,6 +107,10 @@ module.exports = { exclude: /(node_modules)/ }) } - } + }, + vendor: ['moment'] + }, + env: { + version: pkg.version } } diff --git a/pages/_terms/index.vue b/pages/_terms/index.vue index 4c2cbb1..d4fc37c 100644 --- a/pages/_terms/index.vue +++ b/pages/_terms/index.vue @@ -44,7 +44,7 @@ export default { let Articels = [] const nowPage = params.page ? parseInt(params.page) : 1 - const { data } = await $axios.$get('/public/article/list', { + const data = await $axios.$get('/public/article/list', { params: { page: nowPage, num: 8, @@ -91,7 +91,7 @@ export default { for (const n in this.Articels) { if (this.Articels[n].postimages.length !== 0) { for (const i in this.Articels[n].postimages) { - const { data } = await this.$axios.$get(this.Articels[n].postimages[i].guid + '?x-oss-process=image/info') + const data = await this.$axios.$get(this.Articels[n].postimages[i].guid + '?x-oss-process=image/info') const widthValue = data.ImageWidth.value const heightValue = data.ImageHeight.value if (widthValue > articleImgsWidth && (articleImgsWidth * heightValue / widthValue > this.imageHeight) && this.Articels[n].postImages.length < 10) { diff --git a/pages/_terms/page/_page.vue b/pages/_terms/page/_page.vue index d1b440b..5a471c6 100644 --- a/pages/_terms/page/_page.vue +++ b/pages/_terms/page/_page.vue @@ -44,7 +44,7 @@ export default { let Articels = [] const nowPage = params.page ? parseInt(params.page) : 1 - const { data } = await $axios.$get('/public/article/list', { + const data = await $axios.$get('/public/article/list', { params: { page: nowPage, num: 8, @@ -91,7 +91,7 @@ export default { for (const n in this.Articels) { if (this.Articels[n].postimages.length !== 0) { for (const i in this.Articels[n].postimages) { - const { data } = await this.$axios.$get(this.Articels[n].postimages[i].guid + '?x-oss-process=image/info') + const data = await this.$axios.$get(this.Articels[n].postimages[i].guid + '?x-oss-process=image/info') const widthValue = data.ImageWidth.value const heightValue = data.ImageHeight.value if (widthValue > articleImgsWidth && (articleImgsWidth * heightValue / widthValue > this.imageHeight) && this.Articels[n].postImages.length < 10) { diff --git a/pages/page/_page.vue b/pages/page/_page.vue index 4c2cbb1..d4fc37c 100644 --- a/pages/page/_page.vue +++ b/pages/page/_page.vue @@ -44,7 +44,7 @@ export default { let Articels = [] const nowPage = params.page ? parseInt(params.page) : 1 - const { data } = await $axios.$get('/public/article/list', { + const data = await $axios.$get('/public/article/list', { params: { page: nowPage, num: 8, @@ -91,7 +91,7 @@ export default { for (const n in this.Articels) { if (this.Articels[n].postimages.length !== 0) { for (const i in this.Articels[n].postimages) { - const { data } = await this.$axios.$get(this.Articels[n].postimages[i].guid + '?x-oss-process=image/info') + const data = await this.$axios.$get(this.Articels[n].postimages[i].guid + '?x-oss-process=image/info') const widthValue = data.ImageWidth.value const heightValue = data.ImageHeight.value if (widthValue > articleImgsWidth && (articleImgsWidth * heightValue / widthValue > this.imageHeight) && this.Articels[n].postImages.length < 10) { diff --git a/pages/post/_id.vue b/pages/post/_id.vue index 3a264b6..0db2364 100644 --- a/pages/post/_id.vue +++ b/pages/post/_id.vue @@ -38,7 +38,7 @@ div