Run fixlint

parent ee60bf17
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
required: true required: true
} }
}, },
data() { data () {
return { return {
open: true open: true
} }
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
</template> </template>
<script> <script>
import { timeAgo } from '~/plugins/filters'
export default { export default {
name: 'NewsItem', name: 'NewsItem',
props: { props: {
...@@ -39,7 +37,7 @@ export default { ...@@ -39,7 +37,7 @@ export default {
} }
}, },
methods: { methods: {
isAbsolute(url) { isAbsolute (url) {
return /^https?:\/\//.test(url) return /^https?:\/\//.test(url)
} }
} }
......
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
} }
}, },
computed: { computed: {
hasMore() { hasMore () {
return this.page < this.maxPage return this.page < this.maxPage
} }
} }
......
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
default: false default: false
} }
}, },
render(h, { props, children }) { render (h, { props, children }) {
return props.loading return props.loading
? h('div', { style: { 'text-align': 'center' } }, [ ? h('div', { style: { 'text-align': 'center' } }, [
h(Spinner, { props: { show: true } }) h(Spinner, { props: { show: true } })
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
import { feeds } from '~/common/api' import { feeds } from '~/common/api'
export default { export default {
head() { head () {
const host = process.server const host = process.server
? this.$ssrContext.req.headers.host ? this.$ssrContext.req.headers.host
: window.location.host : window.location.host
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
}, },
static: { static: {
maxAge: '1y', maxAge: '1y',
setHeaders(res, path) { setHeaders (res, path) {
if (path.includes('sw.js')) { if (path.includes('sw.js')) {
res.setHeader('Cache-Control', `public, max-age=${15 * 60}`) res.setHeader('Cache-Control', `public, max-age=${15 * 60}`)
} }
......
...@@ -28,11 +28,11 @@ export default { ...@@ -28,11 +28,11 @@ export default {
LazyWrapper LazyWrapper
}, },
validate({ params: { feed } }) { validate ({ params: { feed } }) {
return validFeeds.includes(feed) return validFeeds.includes(feed)
}, },
data() { data () {
return { return {
transition: 'slide-right', transition: 'slide-right',
displayedPage: Number(this.page) || 1 displayedPage: Number(this.page) || 1
...@@ -40,22 +40,22 @@ export default { ...@@ -40,22 +40,22 @@ export default {
}, },
computed: { computed: {
feed() { feed () {
return this.$route.params.feed return this.$route.params.feed
}, },
page() { page () {
return Number(this.$route.params.page) || 1 return Number(this.$route.params.page) || 1
}, },
maxPage() { maxPage () {
return feeds[this.feed].pages return feeds[this.feed].pages
}, },
pageData() { pageData () {
return this.$store.state.feeds[this.feed][this.page] return this.$store.state.feeds[this.feed][this.page]
}, },
displayedItems() { displayedItems () {
return this.pageData.map(id => this.$store.state.items[id]) return this.pageData.map(id => this.$store.state.items[id])
}, },
loading() { loading () {
return this.displayedItems.length === 0 return this.displayedItems.length === 0
} }
}, },
...@@ -64,23 +64,23 @@ export default { ...@@ -64,23 +64,23 @@ export default {
page: 'pageChanged' page: 'pageChanged'
}, },
fetch({ store, params: { feed, page = 1 } }) { fetch ({ store, params: { feed, page = 1 } }) {
page = Number(page) || 1 page = Number(page) || 1
return store.dispatch('FETCH_FEED', { feed, page }) return store.dispatch('FETCH_FEED', { feed, page })
}, },
head() { head () {
return { return {
title: feeds[this.$route.params.feed].title title: feeds[this.$route.params.feed].title
} }
}, },
mounted() { mounted () {
this.pageChanged(this.page) this.pageChanged(this.page)
}, },
methods: { methods: {
pageChanged(to, from = -1) { pageChanged (to, from = -1) {
if (to <= 0 || to > this.maxPage) { if (to <= 0 || to > this.maxPage) {
this.$router.replace(`/${this.feed}/1`) this.$router.replace(`/${this.feed}/1`)
return return
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { validFeeds } from '~/common/api' import { validFeeds } from '~/common/api'
export default { export default {
fetch({ redirect }) { fetch ({ redirect }) {
redirect('/' + validFeeds[0]) redirect('/' + validFeeds[0])
} }
} }
......
...@@ -37,27 +37,27 @@ export default { ...@@ -37,27 +37,27 @@ export default {
name: 'ItemView', name: 'ItemView',
components: { Comment, LazyWrapper }, components: { Comment, LazyWrapper },
head() { head () {
return { return {
title: this.item.title title: this.item.title
} }
}, },
computed: { computed: {
id() { id () {
return this.$route.params.id return this.$route.params.id
}, },
item() { item () {
return this.$store.state.items[this.id] return this.$store.state.items[this.id]
} }
}, },
fetch({ store, params: { id } }) { fetch ({ store, params: { id } }) {
return store.dispatch('FETCH_ITEM', { id }) return store.dispatch('FETCH_ITEM', { id })
}, },
methods: { methods: {
isAbsolute(url) { isAbsolute (url) {
return /^https?:\/\//.test(url) return /^https?:\/\//.test(url)
} }
} }
......
...@@ -33,18 +33,18 @@ export default { ...@@ -33,18 +33,18 @@ export default {
components: { LazyWrapper }, components: { LazyWrapper },
computed: { computed: {
user() { user () {
return this.$store.state.users[this.$route.params.id] return this.$store.state.users[this.$route.params.id]
} }
}, },
head() { head () {
return { return {
title: this.user ? this.user.id : 'User not found' title: this.user ? this.user.id : 'User not found'
} }
}, },
fetch({ store, route: { params: { id } } }) { fetch ({ store, route: { params: { id } } }) {
return store.dispatch('FETCH_USER', { id }) return store.dispatch('FETCH_USER', { id })
} }
} }
......
import Vue from 'vue' import Vue from 'vue'
export function host(url) { export function host (url) {
const host = url.replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace('?id=', '/') const host = url.replace(/^https?:\/\//, '').replace(/\/.*$/, '').replace('?id=', '/')
const parts = host.split('.').slice(-3) const parts = host.split('.').slice(-3)
if (parts[0] === 'www') parts.shift() if (parts[0] === 'www') { parts.shift() }
return parts.join('.') return parts.join('.')
} }
export function timeAgo(time) { export function timeAgo (time) {
const between = Date.now() / 1000 - Number(time) const between = Date.now() / 1000 - Number(time)
if (between < 3600) { if (between < 3600) {
return pluralize(~~(between / 60), ' minute') return pluralize(~~(between / 60), ' minute')
...@@ -18,7 +18,7 @@ export function timeAgo(time) { ...@@ -18,7 +18,7 @@ export function timeAgo(time) {
} }
} }
function pluralize(time, label) { function pluralize (time, label) {
if (time === 1) { if (time === 1) {
return time + label return time + label
} }
......
import Vue from 'vue' import Vue from 'vue'
import { CancelToken } from 'axios'
import { validFeeds } from '~/common/api' import { validFeeds } from '~/common/api'
import { lazy } from '~/common/utils' import { lazy } from '~/common/utils'
import { CancelToken } from 'axios'
// Learn more on https://nuxtjs.org/guide/vuex-store // Learn more on https://nuxtjs.org/guide/vuex-store
...@@ -56,7 +56,7 @@ export const mutations = { ...@@ -56,7 +56,7 @@ export const mutations = {
// Actions // Actions
// ================================================= // =================================================
export const actions = { export const actions = {
FETCH_FEED({ commit, state }, { feed, page, prefetch }) { FETCH_FEED ({ commit, state }, { feed, page, prefetch }) {
// Don't priorotize already fetched feeds // Don't priorotize already fetched feeds
if (state.feeds[feed][page] && state.feeds[feed][page].length) { if (state.feeds[feed][page] && state.feeds[feed][page].length) {
prefetch = true prefetch = true
...@@ -83,7 +83,7 @@ export const actions = { ...@@ -83,7 +83,7 @@ export const actions = {
) )
}, },
FETCH_ITEM({ commit, state }, { id }) { FETCH_ITEM ({ commit, state }, { id }) {
return lazy( return lazy(
item => commit('SET_ITEM', { item }), item => commit('SET_ITEM', { item }),
() => this.$axios.$get(`/item/${id}`), () => this.$axios.$get(`/item/${id}`),
...@@ -91,7 +91,7 @@ export const actions = { ...@@ -91,7 +91,7 @@ export const actions = {
) )
}, },
FETCH_USER({ state, commit }, { id }) { FETCH_USER ({ state, commit }, { id }) {
return lazy( return lazy(
user => commit('SET_USER', { id, user }), user => commit('SET_USER', { id, user }),
() => this.$axios.$get(`/user/${id}`), () => this.$axios.$get(`/user/${id}`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment