Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
imageboard-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Trirst
imageboard-web
Commits
665bc3b6
Commit
665bc3b6
authored
Jul 27, 2021
by
Trirst
Browse files
Options
Downloads
Patches
Plain Diff
Page now changes based on route
parent
18d336e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#836
passed
Jul 27, 2021
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/ImageList.vue
+11
-20
11 additions, 20 deletions
src/components/ImageList.vue
src/components/PaginationBar.vue
+5
-4
5 additions, 4 deletions
src/components/PaginationBar.vue
src/router/index.js
+20
-15
20 additions, 15 deletions
src/router/index.js
with
36 additions
and
39 deletions
src/components/ImageList.vue
+
11
−
20
View file @
665bc3b6
...
...
@@ -50,25 +50,16 @@ export default {
...
mapState
([
"
stateUser
"
,
"
stateHashArray
"
]),
},
async
created
()
{
this
.
pageChange
(
this
.
curren
tPage
);
this
.
lastPage
=
Number
(
await
this
.
getTotalPages
()
);
this
.
lastPage
=
Number
(
await
this
.
getLas
tPage
()
);
this
.
pageChange
(
);
},
methods
:
{
async
pageChange
(
pageNumber
)
{
if
(
pageNumber
===
"
...
"
)
{
let
pageNumber
=
Number
(
prompt
(
"
Jump to page
"
));
if
(
!
Number
.
isInteger
(
pageNumber
)
||
pageNumber
>
this
.
lastPage
||
pageNumber
<
1
)
{
alert
(
"
Invalid page!
"
);
return
;
}
this
.
updatePage
(
pageNumber
);
return
;
}
this
.
currentPage
=
pageNumber
;
async
pageChange
()
{
this
.
currentPage
=
Number
(
window
.
location
.
pathname
.
split
(
"
/
"
).
pop
().
match
(
/^
\d
+$/
)
);
if
(
this
.
currentPage
===
0
)
this
.
currentPage
++
;
if
(
this
.
currentPage
>
this
.
lastPage
)
this
.
currentPage
=
this
.
lastPage
;
window
.
scrollTo
(
0
,
0
);
this
.
setStateHashArray
(
await
this
.
getHashArray
(
this
.
currentPage
-
1
));
},
...
...
@@ -86,10 +77,10 @@ export default {
});
return
hashArray
;
},
async
get
Total
Page
s
()
{
async
get
Last
Page
()
{
const
response
=
await
fetch
(
"
/api/page
"
);
const
total
Page
s
=
await
response
.
text
();
return
total
Page
s
;
const
last
Page
=
await
response
.
text
();
return
last
Page
;
},
appendToDeleteArray
(...
args
)
{
const
[
checked
,
hash
]
=
args
;
...
...
This diff is collapsed.
Click to expand it.
src/components/PaginationBar.vue
+
5
−
4
View file @
665bc3b6
<
template
>
<div
class=
"mx-auto max-w-max"
>
<
button
<
router-link
v-for=
"(page, index) in pages"
:key=
"index"
class=
"mr-2 last:mr-0 text-lg"
:to=
"`/$
{page}`"
@click.native="$emit('onPageChange')"
:class="{
'text-red-800': page === currentPage,
'font-bold': page === currentPage,
}"
@
cl
ick="$emit('onPageChange', page)
"
cl
ass="mr-2 last:mr-0 text-lg
"
>
{{
page
}}
</
button
>
</
router-link
>
</div>
</
template
>
...
...
This diff is collapsed.
Click to expand it.
src/router/index.js
+
20
−
15
View file @
665bc3b6
import
Vue
from
'
vue
'
import
VueRouter
from
'
vue-router
'
import
Home
from
'
../views/Home.vue
'
import
ImageView
from
'
../views/ImageView.vue
'
import
Vue
from
"
vue
"
;
import
VueRouter
from
"
vue-router
"
;
import
Home
from
"
../views/Home.vue
"
;
import
ImageView
from
"
../views/ImageView.vue
"
;
Vue
.
use
(
VueRouter
)
Vue
.
use
(
VueRouter
)
;
const
routes
=
[
{
path
:
'
/
'
,
name
:
'
Home
'
,
component
:
Home
path
:
"
/
"
,
name
:
"
Home
"
,
component
:
Home
,
},
{
path
:
'
/image/:hash
'
,
name
:
'
ImageView
'
,
path
:
"
/:page
"
,
name
:
"
Page
"
,
component
:
Home
,
},
{
path
:
"
/image/:hash
"
,
name
:
"
ImageView
"
,
component
:
ImageView
,
},
]
]
;
const
router
=
new
VueRouter
({
mode
:
'
history
'
,
mode
:
"
history
"
,
base
:
process
.
env
.
BASE_URL
,
routes
})
routes
,
})
;
export
default
router
export
default
router
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment