Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sample
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周韬
node-sample
Commits
ce761942
Unverified
Commit
ce761942
authored
Feb 04, 2020
by
Sébastien Chopin
Committed by
GitHub
Feb 04, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from lukyth/lukyth/fix-lint
Run fixlint to fix lint errors
parents
b8c2b382
2c7ac06b
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
36 additions
and
38 deletions
+36
-38
README.md
README.md
+1
-1
Comment.vue
components/Comment.vue
+1
-1
Item.vue
components/Item.vue
+1
-3
ItemListNav.vue
components/ItemListNav.vue
+1
-1
LazyWrapper.vue
components/LazyWrapper.vue
+1
-1
default.vue
layouts/default.vue
+1
-1
nuxt.config.js
nuxt.config.js
+1
-1
_page.vue
pages/_feed/_page.vue
+12
-12
index.vue
pages/index.vue
+1
-1
_id.vue
pages/item/_id.vue
+5
-5
_id.vue
pages/user/_id.vue
+3
-3
filters.js
plugins/filters.js
+4
-4
index.js
store/index.js
+4
-4
No files found.
README.md
View file @
ce761942
...
...
@@ -65,7 +65,7 @@ npm run start-spa # or upload dist/ directory
# validate code with ESLint (with Prettier)
npm run lint
# validate and
f
fix with ESLint (with Prettier)
# validate and fix with ESLint (with Prettier)
npm run lintfix
```
...
...
components/Comment.vue
View file @
ce761942
...
...
@@ -26,7 +26,7 @@ export default {
required
:
true
}
},
data
()
{
data
()
{
return
{
open
:
true
}
...
...
components/Item.vue
View file @
ce761942
...
...
@@ -28,8 +28,6 @@
</template>
<
script
>
import
{
timeAgo
}
from
'~/plugins/filters'
export
default
{
name
:
'NewsItem'
,
props
:
{
...
...
@@ -39,7 +37,7 @@ export default {
}
},
methods
:
{
isAbsolute
(
url
)
{
isAbsolute
(
url
)
{
return
/^https
?
:
\/\/
/
.
test
(
url
)
}
}
...
...
components/ItemListNav.vue
View file @
ce761942
...
...
@@ -29,7 +29,7 @@ export default {
}
},
computed
:
{
hasMore
()
{
hasMore
()
{
return
this
.
page
<
this
.
maxPage
}
}
...
...
components/LazyWrapper.vue
View file @
ce761942
...
...
@@ -9,7 +9,7 @@ export default {
default
:
false
}
},
render
(
h
,
{
props
,
children
})
{
render
(
h
,
{
props
,
children
})
{
return
props
.
loading
?
h
(
'div'
,
{
style
:
{
'text-align'
:
'center'
}
},
[
h
(
Spinner
,
{
props
:
{
show
:
true
}
})
...
...
layouts/default.vue
View file @
ce761942
...
...
@@ -21,7 +21,7 @@
import
{
feeds
}
from
'~/common/api'
export
default
{
head
()
{
head
()
{
const
host
=
process
.
server
?
this
.
$ssrContext
.
req
.
headers
.
host
:
window
.
location
.
host
...
...
nuxt.config.js
View file @
ce761942
...
...
@@ -44,7 +44,7 @@ export default {
},
static
:
{
maxAge
:
'1y'
,
setHeaders
(
res
,
path
)
{
setHeaders
(
res
,
path
)
{
if
(
path
.
includes
(
'sw.js'
))
{
res
.
setHeader
(
'Cache-Control'
,
`public, max-age=
${
15
*
60
}
`
)
}
...
...
pages/_feed/_page.vue
View file @
ce761942
...
...
@@ -28,11 +28,11 @@ export default {
LazyWrapper
},
validate
({
params
:
{
feed
}
})
{
validate
({
params
:
{
feed
}
})
{
return
validFeeds
.
includes
(
feed
)
},
data
()
{
data
()
{
return
{
transition
:
'slide-right'
,
displayedPage
:
Number
(
this
.
page
)
||
1
...
...
@@ -40,22 +40,22 @@ export default {
},
computed
:
{
feed
()
{
feed
()
{
return
this
.
$route
.
params
.
feed
},
page
()
{
page
()
{
return
Number
(
this
.
$route
.
params
.
page
)
||
1
},
maxPage
()
{
maxPage
()
{
return
feeds
[
this
.
feed
].
pages
},
pageData
()
{
pageData
()
{
return
this
.
$store
.
state
.
feeds
[
this
.
feed
][
this
.
page
]
},
displayedItems
()
{
displayedItems
()
{
return
this
.
pageData
.
map
(
id
=>
this
.
$store
.
state
.
items
[
id
])
},
loading
()
{
loading
()
{
return
this
.
displayedItems
.
length
===
0
}
},
...
...
@@ -64,23 +64,23 @@ export default {
page
:
'pageChanged'
},
fetch
({
store
,
params
:
{
feed
,
page
=
1
}
})
{
fetch
({
store
,
params
:
{
feed
,
page
=
1
}
})
{
page
=
Number
(
page
)
||
1
return
store
.
dispatch
(
'FETCH_FEED'
,
{
feed
,
page
})
},
head
()
{
head
()
{
return
{
title
:
feeds
[
this
.
$route
.
params
.
feed
].
title
}
},
mounted
()
{
mounted
()
{
this
.
pageChanged
(
this
.
page
)
},
methods
:
{
pageChanged
(
to
,
from
=
-
1
)
{
pageChanged
(
to
,
from
=
-
1
)
{
if
(
to
<=
0
||
to
>
this
.
maxPage
)
{
this
.
$router
.
replace
(
`/
${
this
.
feed
}
/1`
)
return
...
...
pages/index.vue
View file @
ce761942
...
...
@@ -2,7 +2,7 @@
import
{
validFeeds
}
from
'~/common/api'
export
default
{
fetch
({
redirect
})
{
fetch
({
redirect
})
{
redirect
(
'/'
+
validFeeds
[
0
])
}
}
...
...
pages/item/_id.vue
View file @
ce761942
...
...
@@ -37,27 +37,27 @@ export default {
name
:
'ItemView'
,
components
:
{
Comment
,
LazyWrapper
},
head
()
{
head
()
{
return
{
title
:
this
.
item
.
title
}
},
computed
:
{
id
()
{
id
()
{
return
this
.
$route
.
params
.
id
},
item
()
{
item
()
{
return
this
.
$store
.
state
.
items
[
this
.
id
]
}
},
fetch
({
store
,
params
:
{
id
}
})
{
fetch
({
store
,
params
:
{
id
}
})
{
return
store
.
dispatch
(
'FETCH_ITEM'
,
{
id
})
},
methods
:
{
isAbsolute
(
url
)
{
isAbsolute
(
url
)
{
return
/^https
?
:
\/\/
/
.
test
(
url
)
}
}
...
...
pages/user/_id.vue
View file @
ce761942
...
...
@@ -33,18 +33,18 @@ export default {
components
:
{
LazyWrapper
},
computed
:
{
user
()
{
user
()
{
return
this
.
$store
.
state
.
users
[
this
.
$route
.
params
.
id
]
}
},
head
()
{
head
()
{
return
{
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
})
}
}
...
...
plugins/filters.js
View file @
ce761942
import
Vue
from
'vue'
export
function
host
(
url
)
{
export
function
host
(
url
)
{
const
host
=
url
.
replace
(
/^https
?
:
\/\/
/
,
''
).
replace
(
/
\/
.*$/
,
''
).
replace
(
'?id='
,
'/'
)
const
parts
=
host
.
split
(
'.'
).
slice
(
-
3
)
if
(
parts
[
0
]
===
'www'
)
parts
.
shift
()
if
(
parts
[
0
]
===
'www'
)
{
parts
.
shift
()
}
return
parts
.
join
(
'.'
)
}
export
function
timeAgo
(
time
)
{
export
function
timeAgo
(
time
)
{
const
between
=
Date
.
now
()
/
1000
-
Number
(
time
)
if
(
between
<
3600
)
{
return
pluralize
(
~~
(
between
/
60
),
' minute'
)
...
...
@@ -18,7 +18,7 @@ export function timeAgo(time) {
}
}
function
pluralize
(
time
,
label
)
{
function
pluralize
(
time
,
label
)
{
if
(
time
===
1
)
{
return
time
+
label
}
...
...
store/index.js
View file @
ce761942
import
Vue
from
'vue'
import
{
CancelToken
}
from
'axios'
import
{
validFeeds
}
from
'~/common/api'
import
{
lazy
}
from
'~/common/utils'
import
{
CancelToken
}
from
'axios'
// Learn more on https://nuxtjs.org/guide/vuex-store
...
...
@@ -56,7 +56,7 @@ export const mutations = {
// Actions
// =================================================
export
const
actions
=
{
FETCH_FEED
({
commit
,
state
},
{
feed
,
page
,
prefetch
})
{
FETCH_FEED
({
commit
,
state
},
{
feed
,
page
,
prefetch
})
{
// Don't priorotize already fetched feeds
if
(
state
.
feeds
[
feed
][
page
]
&&
state
.
feeds
[
feed
][
page
].
length
)
{
prefetch
=
true
...
...
@@ -83,7 +83,7 @@ export const actions = {
)
},
FETCH_ITEM
({
commit
,
state
},
{
id
})
{
FETCH_ITEM
({
commit
,
state
},
{
id
})
{
return
lazy
(
item
=>
commit
(
'SET_ITEM'
,
{
item
}),
()
=>
this
.
$axios
.
$get
(
`/item/
${
id
}
`
),
...
...
@@ -91,7 +91,7 @@ export const actions = {
)
},
FETCH_USER
({
state
,
commit
},
{
id
})
{
FETCH_USER
({
state
,
commit
},
{
id
})
{
return
lazy
(
user
=>
commit
(
'SET_USER'
,
{
id
,
user
}),
()
=>
this
.
$axios
.
$get
(
`/user/
${
id
}
`
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment