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
58e68f8f
Commit
58e68f8f
authored
Jul 25, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update signin button in visitor mode
parent
cfa4151c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
27 deletions
+55
-27
App.tsx
web/src/App.tsx
+12
-1
MemoList.tsx
web/src/components/MemoList.tsx
+0
-1
Sidebar.tsx
web/src/components/Sidebar.tsx
+0
-14
TagList.tsx
web/src/components/TagList.tsx
+3
-1
home.less
web/src/less/home.less
+12
-0
main.tsx
web/src/main.tsx
+1
-9
Home.tsx
web/src/pages/Home.tsx
+14
-0
locationService.ts
web/src/services/locationService.ts
+5
-1
location.ts
web/src/store/modules/location.ts
+8
-0
No files found.
web/src/App.tsx
View file @
58e68f8f
import
{
useEffect
,
useState
}
from
"react"
;
import
{
appRouterSwitch
}
from
"./routers"
;
import
{
locationService
}
from
"./services"
;
import
{
useAppSelector
}
from
"./store"
;
function
App
()
{
const
pathname
=
useAppSelector
((
state
)
=>
state
.
location
.
pathname
);
const
[
isLoading
,
setLoading
]
=
useState
(
true
);
return
<>
{
appRouterSwitch
(
pathname
)
}
</>;
useEffect
(()
=>
{
locationService
.
updateStateWithLocation
();
window
.
onpopstate
=
()
=>
{
locationService
.
updateStateWithLocation
();
};
setLoading
(
false
);
},
[]);
return
<>
{
isLoading
?
null
:
appRouterSwitch
(
pathname
)
}
</>;
}
export
default
App
;
web/src/components/MemoList.tsx
View file @
58e68f8f
...
...
@@ -83,7 +83,6 @@ const MemoList: React.FC<Props> = () => {
.
fetchAllMemos
()
.
then
(()
=>
{
setFetchStatus
(
false
);
memoService
.
updateTagsState
();
})
.
catch
(()
=>
{
toastHelper
.
error
(
"😭 Fetching failed, please try again later."
);
...
...
web/src/components/Sidebar.tsx
View file @
58e68f8f
import
{
userService
}
from
"../services"
;
import
{
useAppSelector
}
from
"../store"
;
import
Only
from
"./common/OnlyWhen"
;
import
showDailyReviewDialog
from
"./DailyReviewDialog"
;
import
showSettingDialog
from
"./SettingDialog"
;
...
...
@@ -13,8 +12,6 @@ import "../less/siderbar.less";
interface
Props
{}
const
Sidebar
:
React
.
FC
<
Props
>
=
()
=>
{
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
const
handleMyAccountBtnClick
=
()
=>
{
showSettingDialog
();
};
...
...
@@ -44,17 +41,6 @@ const Sidebar: React.FC<Props> = () => {
<
button
className=
"btn action-btn"
onClick=
{
handleArchivedBtnClick
}
>
<
span
className=
"icon"
>
🗂
</
span
>
Archived
</
button
>
<
Only
when=
{
userService
.
isVisitorMode
()
}
>
{
user
?
(
<
button
className=
"btn action-btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/"
)
}
>
<
span
className=
"icon"
>
🏠
</
span
>
Back to Home
</
button
>
)
:
(
<
button
className=
"btn action-btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/signin"
)
}
>
<
span
className=
"icon"
>
👉
</
span
>
Sign in
</
button
>
)
}
</
Only
>
</
div
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
ShortcutList
/>
...
...
web/src/components/TagList.tsx
View file @
58e68f8f
...
...
@@ -20,7 +20,9 @@ const TagList: React.FC<Props> = () => {
const
[
tags
,
setTags
]
=
useState
<
Tag
[]
>
([]);
useEffect
(()
=>
{
if
(
memos
.
length
>
0
)
{
memoService
.
updateTagsState
();
}
},
[
memos
]);
useEffect
(()
=>
{
...
...
web/src/less/home.less
View file @
58e68f8f
...
...
@@ -18,6 +18,18 @@
@apply sticky top-0 w-full h-full flex flex-col justify-start items-start z-10;
background-color: #f6f5f4;
}
> .addtion-btn-container {
@apply fixed bottom-12 left-1/2 -translate-x-1/2;
> .btn {
@apply bg-blue-600 text-white px-4 py-2 rounded-3xl shadow-2xl hover:opacity-80;
> .icon {
@apply text-lg mr-1;
}
}
}
}
}
}
web/src/main.tsx
View file @
58e68f8f
import
{
createRoot
}
from
"react-dom/client"
;
import
{
Provider
}
from
"react-redux"
;
import
store
from
"./store"
;
import
{
updateStateWithLocation
}
from
"./store/modules/location"
;
import
App
from
"./App"
;
import
"./less/global.less"
;
import
"./helpers/polyfill"
;
import
"./less/global.less"
;
import
"./css/index.css"
;
const
container
=
document
.
getElementById
(
"root"
);
...
...
@@ -14,10 +13,3 @@ root.render(
<
App
/>
</
Provider
>
);
window
.
onload
=
()
=>
{
store
.
dispatch
(
updateStateWithLocation
());
window
.
onpopstate
=
()
=>
{
store
.
dispatch
(
updateStateWithLocation
());
};
};
web/src/pages/Home.tsx
View file @
58e68f8f
...
...
@@ -12,6 +12,7 @@ import toastHelper from "../components/Toast";
import
"../less/home.less"
;
function
Home
()
{
const
user
=
useAppSelector
((
state
)
=>
state
.
user
.
user
);
const
location
=
useAppSelector
((
state
)
=>
state
.
location
);
const
loadingState
=
useLoading
();
...
...
@@ -53,6 +54,19 @@ function Home() {
<
MemoFilter
/>
</
div
>
<
MemoList
/>
<
Only
when=
{
userService
.
isVisitorMode
()
}
>
<
div
className=
"addtion-btn-container"
>
{
user
?
(
<
button
className=
"btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/"
)
}
>
<
span
className=
"icon"
>
🏠
</
span
>
Back to Home
</
button
>
)
:
(
<
button
className=
"btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/signin"
)
}
>
<
span
className=
"icon"
>
👉
</
span
>
Sign in
</
button
>
)
}
</
div
>
</
Only
>
</
main
>
</
div
>
)
}
...
...
web/src/services/locationService.ts
View file @
58e68f8f
import
{
stringify
}
from
"qs"
;
import
store
from
"../store"
;
import
{
setQuery
,
setPathname
,
Query
}
from
"../store/modules/location"
;
import
{
setQuery
,
setPathname
,
Query
,
updateStateWithLocation
}
from
"../store/modules/location"
;
const
updateLocationUrl
=
(
method
:
"replace"
|
"push"
=
"replace"
)
=>
{
const
{
query
,
pathname
,
hash
}
=
store
.
getState
().
location
;
...
...
@@ -23,6 +23,10 @@ const locationService = {
return
store
.
getState
().
location
;
},
updateStateWithLocation
:
()
=>
{
store
.
dispatch
(
updateStateWithLocation
());
},
setPathname
:
(
pathname
:
string
)
=>
{
store
.
dispatch
(
setPathname
(
pathname
));
updateLocationUrl
();
...
...
web/src/store/modules/location.ts
View file @
58e68f8f
...
...
@@ -64,12 +64,20 @@ const locationSlice = createSlice({
return
getStateFromLocation
();
},
setPathname
:
(
state
,
action
:
PayloadAction
<
string
>
)
=>
{
if
(
state
.
pathname
===
action
.
payload
)
{
return
state
;
}
return
{
...
state
,
pathname
:
action
.
payload
,
};
},
setQuery
:
(
state
,
action
:
PayloadAction
<
Partial
<
Query
>>
)
=>
{
if
(
JSON
.
stringify
(
action
.
payload
)
===
state
.
query
)
{
return
state
;
}
return
{
...
state
,
query
:
{
...
...
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