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
56d3daf8
Commit
56d3daf8
authored
Aug 10, 2016
by
Evan You
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spinner position
parent
987a6283
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
39 deletions
+48
-39
Item.vue
src/components/Item.vue
+3
-2
ItemList.vue
src/components/ItemList.vue
+1
-6
Spinner.vue
src/components/Spinner.vue
+3
-0
index.js
src/router/index.js
+1
-1
ItemView.vue
src/views/ItemView.vue
+20
-16
UserView.vue
src/views/UserView.vue
+20
-14
No files found.
src/components/Item.vue
View file @
56d3daf8
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<span
class=
"title"
>
<span
class=
"title"
>
<template
v-if=
"item.url"
>
<template
v-if=
"item.url"
>
<a
:href=
"item.url"
target=
"_blank"
>
{{
item
.
title
}}
</a>
<a
:href=
"item.url"
target=
"_blank"
>
{{
item
.
title
}}
</a>
<span>
(
{{
item
.
url
|
host
}}
)
</span>
<span
class=
"host"
>
(
{{
item
.
url
|
host
}}
)
</span>
</
template
>
</
template
>
<
template
v-else
>
<
template
v-else
>
<router-link
:to=
"'/item/' + item.id"
>
{{
item
.
title
}}
</router-link>
<router-link
:to=
"'/item/' + item.id"
>
{{
item
.
title
}}
</router-link>
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
|
<router-link
:to=
"'/item/' + item.id"
>
{{ item.descendants }} comments
</router-link>
|
<router-link
:to=
"'/item/' + item.id"
>
{{ item.descendants }} comments
</router-link>
</span>
</span>
</span>
</span>
<span
class=
"label"
v-if=
"item.type !== 'story'"
>
{{ item.type }}
</span>
</li>
</li>
</template>
</template>
...
@@ -49,7 +50,7 @@ export default {
...
@@ -49,7 +50,7 @@ export default {
width 80px
width 80px
text-align center
text-align center
margin-top -10px
margin-top -10px
.meta
.meta
, .host
font-size .85em
font-size .85em
color #999
color #999
a
a
...
...
src/components/ItemList.vue
View file @
56d3daf8
<
template
>
<
template
>
<div
class=
"news"
>
<div
class=
"news"
>
<spinner
:show=
"loading"
></spinner>
<div
class=
"news-list-nav"
>
<div
class=
"news-list-nav"
>
<router-link
v-if=
"page > 1"
:to=
"'/' + type + '/' + (page - 1)"
>
<
prev
</router-link>
<router-link
v-if=
"page > 1"
:to=
"'/' + type + '/' + (page - 1)"
>
<
prev
</router-link>
<a
v-else
class=
"disabled"
>
<
prev
</a>
<a
v-else
class=
"disabled"
>
<
prev
</a>
<span>
{{
page
}}
/
{{
maxPage
}}
</span>
<span>
{{
page
}}
/
{{
maxPage
}}
</span>
<router-link
v-if=
"hasMore"
:to=
"'/' + type + '/' + (page + 1)"
>
more
>
</router-link>
<router-link
v-if=
"hasMore"
:to=
"'/' + type + '/' + (page + 1)"
>
more
>
</router-link>
<a
v-else
class=
"disabled"
>
more
>
</a>
<a
v-else
class=
"disabled"
>
more
>
</a>
<spinner
:show=
"loading"
></spinner>
</div>
</div>
<transition
:name=
"transition"
>
<transition
:name=
"transition"
>
<div
class=
"news-list"
:key=
"displayedPage"
v-if=
"displayedPage > 0"
>
<div
class=
"news-list"
:key=
"displayedPage"
v-if=
"displayedPage > 0"
>
...
@@ -124,11 +124,6 @@ export default {
...
@@ -124,11 +124,6 @@ export default {
margin 0 1em
margin 0 1em
.disabled
.disabled
color #ccc
color #ccc
.spinner
position absolute
top 50%
left 50%
transform translate(-50%, -50%)
.news-list
.news-list
position absolute
position absolute
...
...
src/components/Spinner.vue
View file @
56d3daf8
...
@@ -15,6 +15,9 @@ $offset = 126
...
@@ -15,6 +15,9 @@ $offset = 126
$duration = 1.4s
$duration = 1.4s
.spinner
.spinner
position fixed
right 15px
bottom 15px
opacity 0
opacity 0
transition opacity .15s ease
transition opacity .15s ease
animation rotator $duration linear infinite
animation rotator $duration linear infinite
...
...
src/router/index.js
View file @
56d3daf8
...
@@ -18,6 +18,6 @@ export default new Router({
...
@@ -18,6 +18,6 @@ export default new Router({
{
path
:
'/job/:page(
\\
d+)?'
,
component
:
createListView
(
'job'
)
},
{
path
:
'/job/:page(
\\
d+)?'
,
component
:
createListView
(
'job'
)
},
{
path
:
'/item/:id(
\\
d+)'
,
component
:
ItemView
},
{
path
:
'/item/:id(
\\
d+)'
,
component
:
ItemView
},
{
path
:
'/user/:id'
,
component
:
UserView
},
{
path
:
'/user/:id'
,
component
:
UserView
},
{
path
:
'*'
,
redirect
:
'/top
/1
'
}
{
path
:
'*'
,
redirect
:
'/top'
}
]
]
})
})
src/views/ItemView.vue
View file @
56d3daf8
<
template
>
<
template
>
<div
class=
"item-view"
v-if=
"item"
>
<div
class=
"item-view"
v-if=
"item"
>
<div
class=
"item-view-header"
>
<spinner
:show=
"!item"
></spinner>
<a
:href=
"item.url"
target=
"_blank"
>
<template
v-if=
"item"
>
<h2>
{{
item
.
title
}}
</h2>
<div
class=
"item-view-header"
>
</a>
<a
:href=
"item.url"
target=
"_blank"
>
<span
v-if=
"item.url"
>
(
{{
item
.
url
|
host
}}
)
</span>
<h2>
{{
item
.
title
}}
</h2>
<p>
</a>
{{
item
.
score
}}
points
<span
v-if=
"item.url"
>
(
{{
item
.
url
|
host
}}
)
</span>
| by
<router-link
:to=
"'/user/' + item.by"
>
{{
item
.
by
}}
</router-link>
<p>
{{
item
.
time
|
timeAgo
}}
ago
{{
item
.
score
}}
points
|
{{
item
.
descendants
}}
comments
| by
<router-link
:to=
"'/user/' + item.by"
>
{{
item
.
by
}}
</router-link>
</p>
{{
item
.
time
|
timeAgo
}}
ago
</div>
|
{{
item
.
descendants
}}
comments
<ul
v-if=
"item.kids"
class=
"item-view-comments"
>
</p>
<comment
v-for=
"id in item.kids"
:id=
"id"
></comment>
</div>
</ul>
<ul
v-if=
"item.kids"
class=
"item-view-comments"
>
<comment
v-for=
"id in item.kids"
:id=
"id"
></comment>
</ul>
</
template
>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
Spinner
from
'../components/Spinner.vue'
import
Comment
from
'../components/Comment.vue'
import
Comment
from
'../components/Comment.vue'
function
fetchItem
(
store
)
{
function
fetchItem
(
store
)
{
...
@@ -29,7 +33,7 @@ function fetchItem (store) {
...
@@ -29,7 +33,7 @@ function fetchItem (store) {
export
default
{
export
default
{
name
:
'item-view'
,
name
:
'item-view'
,
components
:
{
Comment
},
components
:
{
Spinner
,
Comment
},
computed
:
{
computed
:
{
item
()
{
item
()
{
return
this
.
$store
.
state
.
items
[
this
.
$route
.
params
.
id
]
return
this
.
$store
.
state
.
items
[
this
.
$route
.
params
.
id
]
...
...
src/views/UserView.vue
View file @
56d3daf8
<
template
>
<
template
>
<div
class=
"user-view"
v-if=
"user"
>
<div
class=
"user-view"
>
<ul>
<spinner
:show=
"!user"
></spinner>
<li><span
class=
"label"
>
user:
</span>
{{
user
.
id
}}
</li>
<template
v-if=
"user"
>
<li><span
class=
"label"
>
created:
</span>
{{
user
.
created
|
timeAgo
}}
ago
</li>
<ul>
<li><span
class=
"label"
>
karma:
</span>
{{
user
.
karma
}}
</li>
<li><span
class=
"label"
>
user:
</span>
{{
user
.
id
}}
</li>
<li>
<li><span
class=
"label"
>
created:
</span>
{{
user
.
created
|
timeAgo
}}
ago
</li>
<span
class=
"label"
>
about:
</span>
<li><span
class=
"label"
>
karma:
</span>
{{
user
.
karma
}}
</li>
<div
class=
"about"
v-html=
"user.about"
></div>
<li>
</li>
<span
class=
"label"
>
about:
</span>
</ul>
<div
class=
"about"
v-html=
"user.about"
></div>
<p
class=
"links"
>
</li>
<a
:href=
"'https://news.ycombinator.com/submitted?id=' + user.id"
>
submissions
</a><br>
</ul>
<a
:href=
"'https://news.ycombinator.com/threads?id=' + user.id"
>
comments
</a>
<p
class=
"links"
>
</p>
<a
:href=
"'https://news.ycombinator.com/submitted?id=' + user.id"
>
submissions
</a><br>
<a
:href=
"'https://news.ycombinator.com/threads?id=' + user.id"
>
comments
</a>
</p>
</
template
>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
Spinner
from
'../components/Spinner.vue'
function
fetchUser
(
store
)
{
function
fetchUser
(
store
)
{
return
store
.
dispatch
(
'FETCH_USER'
,
{
return
store
.
dispatch
(
'FETCH_USER'
,
{
id
:
store
.
state
.
route
.
params
.
id
id
:
store
.
state
.
route
.
params
.
id
...
@@ -25,6 +30,7 @@ function fetchUser (store) {
...
@@ -25,6 +30,7 @@ function fetchUser (store) {
export
default
{
export
default
{
name
:
'user-view'
,
name
:
'user-view'
,
components
:
{
Spinner
},
computed
:
{
computed
:
{
user
()
{
user
()
{
return
this
.
$store
.
state
.
users
[
this
.
$route
.
params
.
id
]
return
this
.
$store
.
state
.
users
[
this
.
$route
.
params
.
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