Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
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
Vũ Hoàng Anh
canifa_note
Commits
70d1301d
Commit
70d1301d
authored
Jan 25, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: use filter in url params
parent
6d5e1def
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletion
+84
-1
Explore.tsx
web/src/pages/Explore.tsx
+28
-0
Home.tsx
web/src/pages/Home.tsx
+28
-0
UserProfile.tsx
web/src/pages/UserProfile.tsx
+28
-1
No files found.
web/src/pages/Explore.tsx
View file @
70d1301d
import
{
Button
}
from
"@mui/joy"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
Empty
from
"@/components/Empty"
;
import
Icon
from
"@/components/Icon"
;
import
MemoFilter
from
"@/components/MemoFilter"
;
...
...
@@ -14,6 +15,7 @@ import { useTranslate } from "@/utils/i18n";
const
Explore
=
()
=>
{
const
t
=
useTranslate
();
const
location
=
useLocation
();
const
user
=
useCurrentUser
();
const
filterStore
=
useFilterStore
();
const
memoStore
=
useMemoStore
();
...
...
@@ -24,6 +26,32 @@ const Explore = () => {
const
sortedMemos
=
memoList
.
value
.
sort
((
a
,
b
)
=>
getTimeStampByDate
(
b
.
displayTime
)
-
getTimeStampByDate
(
a
.
displayTime
));
useEffect
(()
=>
{
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
const
tag
=
urlParams
.
get
(
"tag"
);
const
text
=
urlParams
.
get
(
"text"
);
if
(
tag
)
{
filterStore
.
setTagFilter
(
tag
);
}
if
(
text
)
{
filterStore
.
setTextFilter
(
text
);
}
},
[]);
useEffect
(()
=>
{
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
if
(
tagQuery
)
{
urlParams
.
set
(
"tag"
,
tagQuery
);
}
else
{
urlParams
.
delete
(
"tag"
);
}
if
(
textQuery
)
{
urlParams
.
set
(
"text"
,
textQuery
);
}
else
{
urlParams
.
delete
(
"text"
);
}
const
params
=
urlParams
.
toString
();
window
.
history
.
replaceState
({},
""
,
`
${
location
.
pathname
}${
params
?.
length
>
0
?
`?
${
params
}
`
:
""
}
`);
memoList.reset();
fetchMemos();
}, [tagQuery, textQuery]);
...
...
web/src/pages/Home.tsx
View file @
70d1301d
import
{
Button
}
from
"@mui/joy"
;
import
classNames
from
"classnames"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
Empty
from
"@/components/Empty"
;
import
HomeSidebar
from
"@/components/HomeSidebar"
;
import
HomeSidebarDrawer
from
"@/components/HomeSidebarDrawer"
;
...
...
@@ -20,6 +21,7 @@ import { useTranslate } from "@/utils/i18n";
const
Home
=
()
=>
{
const
t
=
useTranslate
();
const
location
=
useLocation
();
const
{
md
}
=
useResponsiveWidth
();
const
user
=
useCurrentUser
();
const
filterStore
=
useFilterStore
();
...
...
@@ -34,6 +36,32 @@ const Home = () => {
.
sort
((
a
,
b
)
=>
Number
(
b
.
pinned
)
-
Number
(
a
.
pinned
));
useEffect
(()
=>
{
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
const
tag
=
urlParams
.
get
(
"tag"
);
const
text
=
urlParams
.
get
(
"text"
);
if
(
tag
)
{
filterStore
.
setTagFilter
(
tag
);
}
if
(
text
)
{
filterStore
.
setTextFilter
(
text
);
}
},
[]);
useEffect
(()
=>
{
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
if
(
tagQuery
)
{
urlParams
.
set
(
"tag"
,
tagQuery
);
}
else
{
urlParams
.
delete
(
"tag"
);
}
if
(
textQuery
)
{
urlParams
.
set
(
"text"
,
textQuery
);
}
else
{
urlParams
.
delete
(
"text"
);
}
const
params
=
urlParams
.
toString
();
window
.
history
.
replaceState
({},
""
,
`
${
location
.
pathname
}${
params
?.
length
>
0
?
`?
${
params
}
`
:
""
}
`);
memoList.reset();
fetchMemos();
}, [tagQuery, textQuery]);
...
...
web/src/pages/UserProfile.tsx
View file @
70d1301d
import
{
Button
}
from
"@mui/joy"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
useParams
}
from
"react-router-dom"
;
import
{
use
Location
,
use
Params
}
from
"react-router-dom"
;
import
Empty
from
"@/components/Empty"
;
import
Icon
from
"@/components/Icon"
;
import
MemoFilter
from
"@/components/MemoFilter"
;
...
...
@@ -18,6 +18,7 @@ import { useTranslate } from "@/utils/i18n";
const
UserProfile
=
()
=>
{
const
t
=
useTranslate
();
const
location
=
useLocation
();
const
params
=
useParams
();
const
userStore
=
useUserStore
();
const
loadingState
=
useLoading
();
...
...
@@ -32,6 +33,18 @@ const UserProfile = () => {
.
sort
((
a
,
b
)
=>
getTimeStampByDate
(
b
.
displayTime
)
-
getTimeStampByDate
(
a
.
displayTime
))
.
sort
((
a
,
b
)
=>
Number
(
b
.
pinned
)
-
Number
(
a
.
pinned
));
useEffect
(()
=>
{
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
const
tag
=
urlParams
.
get
(
"tag"
);
const
text
=
urlParams
.
get
(
"text"
);
if
(
tag
)
{
filterStore
.
setTagFilter
(
tag
);
}
if
(
text
)
{
filterStore
.
setTextFilter
(
text
);
}
},
[]);
useEffect
(()
=>
{
const
username
=
params
.
username
;
if
(
!
username
)
{
...
...
@@ -55,6 +68,20 @@ const UserProfile = () => {
return
;
}
const
urlParams
=
new
URLSearchParams
(
location
.
search
);
if
(
tagQuery
)
{
urlParams
.
set
(
"tag"
,
tagQuery
);
}
else
{
urlParams
.
delete
(
"tag"
);
}
if
(
textQuery
)
{
urlParams
.
set
(
"text"
,
textQuery
);
}
else
{
urlParams
.
delete
(
"text"
);
}
const
params
=
urlParams
.
toString
();
window
.
history
.
replaceState
({},
""
,
`
${
location
.
pathname
}${
params
?.
length
>
0
?
`?
${
params
}
`
:
""
}
`);
memoList.reset();
fetchMemos();
}, [user, tagQuery, textQuery]);
...
...
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