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
182cf221
Commit
182cf221
authored
Jun 07, 2017
by
Sebastien Chopin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
https & non fixed items
parent
15fdd928
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
43 deletions
+52
-43
ItemList.vue
components/ItemList.vue
+9
-33
ItemListNav.vue
components/ItemListNav.vue
+39
-0
default.vue
layouts/default.vue
+3
-9
https.js
middleware/https.js
+1
-1
No files found.
components/ItemList.vue
View file @
182cf221
<
template
>
<div
class=
"news-view view"
>
<div
class=
"news-list-nav"
>
<router-link
v-if=
"page > 1"
:to=
"'/' + type + '/' + (page - 1)"
>
<
prev
</router-link>
<a
v-else
class=
"disabled"
>
<
prev
</a>
<span>
{{
page
}}
/
{{
maxPage
}}
</span>
<router-link
v-if=
"hasMore"
:to=
"'/' + type + '/' + (page + 1)"
>
more
>
</router-link>
<a
v-else
class=
"disabled"
>
more
>
</a>
</div>
<transition
:name=
"transition"
>
<item-list-nav
:type=
"type"
:page=
"page"
:maxPage=
"maxPage"
></item-list-nav>
<transition
:name=
"transition"
mode=
"out-in"
>
<div
class=
"news-list"
:key=
"displayedPage"
v-if=
"displayedPage > 0"
>
<transition-group
tag=
"ul"
name=
"item"
>
<item
v-for=
"item in displayedItems"
:key=
"item.id"
:item=
"item"
>
...
...
@@ -15,17 +9,20 @@
</transition-group>
</div>
</transition>
<item-list-nav
:type=
"type"
:page=
"page"
:maxPage=
"maxPage"
></item-list-nav>
</div>
</
template
>
<
script
>
import
{
watchList
}
from
'../api'
import
Item
from
'./Item.vue'
import
ItemListNav
from
'./ItemListNav.vue'
export
default
{
name
:
'item-list'
,
components
:
{
Item
Item
,
ItemListNav
},
props
:
{
type
:
String
...
...
@@ -44,9 +41,6 @@ export default {
maxPage
()
{
const
{
itemsPerPage
,
lists
}
=
this
.
$store
.
state
return
Math
.
ceil
(
lists
[
this
.
type
].
length
/
itemsPerPage
)
},
hasMore
()
{
return
this
.
page
<
this
.
maxPage
}
},
...
...
@@ -97,32 +91,14 @@ export default {
</
script
>
<
style
lang=
"stylus"
>
.news-view
padding-top 45px
.news-list-nav, .news-list
.news-list
background-color #fff
border-radius 2px
.news-list-nav
padding 15px 30px
position fixed
text-align center
top 55px
left 0
right 0
z-index 998
box-shadow 0 1px 2px rgba(0, 0, 0, .1)
a
margin 0 1em
.disabled
color #595959
.news-list
position absolute
margin 30px 0
margin 10px 0
width 100%
transition all .
5
s cubic-bezier(.55, 0, .1, 1)
transition all .
3
s cubic-bezier(.55, 0, .1, 1)
ul
list-style-type none
padding 0
...
...
components/ItemListNav.vue
0 → 100644
View file @
182cf221
<
template
>
<div
class=
"news-list-nav"
>
<router-link
v-if=
"page > 1"
:to=
"`/$
{type}/${page - 1}`">
<
prev
</router-link>
<a
v-else
class=
"disabled"
>
<
prev
</a>
<span>
{{
page
}}
/
{{
maxPage
}}
</span>
<router-link
v-if=
"hasMore"
:to=
"`/$
{type}/${page + 1}`">more
>
</router-link>
<a
v-else
class=
"disabled"
>
more
>
</a>
</div>
</
template
>
<
script
>
export
default
{
props
:
{
type
:
String
,
page
:
Number
,
maxPage
:
Number
},
computed
:
{
hasMore
()
{
return
this
.
page
<
this
.
maxPage
}
}
}
</
script
>
<
style
lang=
"stylus"
>
.news-list-nav, .news-list
background-color #fff
border-radius 2px
.news-list-nav
padding 15px 30px
text-align center
box-shadow 0 1px 2px rgba(0, 0, 0, .1)
a
margin 0 1em
.disabled
opacity 0.8
</
style
>
layouts/default.vue
View file @
182cf221
...
...
@@ -24,7 +24,8 @@ export default {
head
()
{
return
{
link
:
[
{
rel
:
'canonical'
,
href
:
`https://hn.nuxtjs.org
${
this
.
$route
.
fullPath
}
`
}
// We use $route.path since we don't use query parameters
{
rel
:
'canonical'
,
href
:
`https://hn.nuxtjs.org
${
this
.
$route
.
path
}
`
}
]
}
}
...
...
@@ -37,7 +38,7 @@ export default {
font-size 15px
background-color lighten(#eceef1, 30%)
margin 0
padding
-top 55px
padding
0
color #34495e
overflow-y scroll
...
...
@@ -45,17 +46,10 @@ export default {
color #34495e
text-decoration none
.progress
z-index: 1000 !important
.header
background-color #188269
position fixed
z-index 999
height 55px
top 0
left 0
right 0
.inner
max-width 800px
box-sizing border-box
...
...
middleware/https.js
View file @
182cf221
export
default
({
isDev
,
req
,
redirect
})
=>
{
// Redirect to https
if
(
!
isDev
&&
req
)
{
const
protocol
=
req
.
headers
[
'
X-Forwarded-P
roto'
]
||
(
req
.
connection
.
encrypted
?
'https'
:
'http'
)
const
protocol
=
req
.
headers
[
'
x-forwarded-p
roto'
]
||
(
req
.
connection
.
encrypted
?
'https'
:
'http'
)
if
(
protocol
===
'http'
)
{
return
redirect
(
301
,
`https://
${
req
.
headers
.
host
}${
req
.
url
}
`
)
}
...
...
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