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
b596d049
Commit
b596d049
authored
Aug 14, 2022
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update i18n for auth page
parent
84a35482
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
190 additions
and
159 deletions
+190
-159
GitHubBadge.tsx
web/src/components/GitHubBadge.tsx
+1
-4
MenuBtnsPopup.tsx
web/src/components/MenuBtnsPopup.tsx
+9
-5
auth.less
web/src/less/auth.less
+105
-0
github-badge.less
web/src/less/github-badge.less
+1
-20
signin.less
web/src/less/signin.less
+0
-81
en.json
web/src/locales/en.json
+6
-0
zh.json
web/src/locales/zh.json
+6
-0
Auth.tsx
web/src/pages/Auth.tsx
+57
-44
Home.tsx
web/src/pages/Home.tsx
+2
-2
appRouter.tsx
web/src/routers/appRouter.tsx
+2
-2
location.ts
web/src/store/modules/location.ts
+1
-1
No files found.
web/src/components/GitHubBadge.tsx
View file @
b596d049
...
@@ -20,10 +20,7 @@ const GitHubBadge: React.FC<Props> = () => {
...
@@ -20,10 +20,7 @@ const GitHubBadge: React.FC<Props> = () => {
<
Icon
.
GitHub
className=
"icon-img"
/>
<
Icon
.
GitHub
className=
"icon-img"
/>
Star
Star
</
div
>
</
div
>
<
div
className=
"count-text"
>
<
div
className=
"count-text"
>
{
starCount
||
""
}
</
div
>
{
starCount
||
""
}
<
span
className=
"icon-text"
>
🌟
</
span
>
</
div
>
</
a
>
</
a
>
);
);
};
};
...
...
web/src/components/MenuBtnsPopup.tsx
View file @
b596d049
...
@@ -49,11 +49,15 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
...
@@ -49,11 +49,15 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
};
};
const
handleSignOutBtnClick
=
async
()
=>
{
const
handleSignOutBtnClick
=
async
()
=>
{
userService
.
doSignOut
().
catch
(()
=>
{
userService
// do nth
.
doSignOut
()
});
.
then
(()
=>
{
locationService
.
replaceHistory
(
"/signin"
);
locationService
.
replaceHistory
(
"/auth"
);
window
.
location
.
reload
();
window
.
location
.
reload
();
})
.
catch
(()
=>
{
// do nth
});
};
};
return
(
return
(
...
...
web/src/less/auth.less
0 → 100644
View file @
b596d049
@import "./mixin.less";
.page-wrapper.auth {
@apply flex flex-row justify-center items-center w-full h-screen bg-white;
> .page-container {
@apply w-80 max-w-full h-full py-4 flex flex-col justify-start items-center;
> .auth-form-wrapper {
@apply w-full py-4 grow flex flex-col justify-center items-center;
> .page-header-container {
@apply flex flex-col justify-start items-start w-full mb-4;
> .title-container {
@apply w-full flex flex-row justify-between items-center;
> .title-text {
@apply text-2xl mb-2;
> .icon-text {
@apply text-4xl;
}
}
}
> .slogan-text {
@apply text-sm text-gray-700;
}
}
> .page-content-container {
@apply flex flex-col justify-start items-start w-full;
> .form-item-container {
@apply flex flex-col justify-start items-start relative w-full text-base mt-2;
> .normal-text {
@apply absolute top-3 left-3 px-1 leading-10 flex-shrink-0 text-base cursor-text text-gray-400 bg-transparent transition-all select-none;
&.not-null {
@apply text-sm top-0 z-10 leading-4 bg-white rounded;
}
}
&.input-form-container {
@apply py-2;
> input {
@apply w-full py-3 px-3 text-base shadow-inner rounded-lg border border-solid border-gray-400 hover:opacity-80;
}
}
}
&.requesting {
@apply opacity-80;
}
}
> .action-btns-container {
@apply flex flex-row justify-end items-center w-full mt-2;
> .btn {
@apply px-1 py-2 text-sm rounded hover:opacity-80;
&.signin-btn {
@apply bg-green-600 text-white px-3 shadow;
}
&.requesting {
@apply cursor-wait opacity-80;
}
}
}
> .tip-text {
@apply w-full inline-block float-right text-sm mt-4 text-gray-500 text-right whitespace-pre-wrap;
&.host-tip {
@apply bg-blue-500 text-white px-2 py-1 rounded;
}
}
}
> .footer-container {
@apply w-full flex flex-col justify-start items-center;
> .language-container {
@apply mt-2 w-full flex flex-row justify-center items-center text-sm text-gray-400;
> .locale-item {
@apply px-2 cursor-pointer;
&.active {
@apply text-blue-600 font-bold;
}
}
> .split-line {
@apply font-mono text-gray-400;
}
}
}
}
}
web/src/less/github-badge.less
View file @
b596d049
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
@apply h-7 flex flex-row justify-start items-center border rounded cursor-pointer hover:opacity-80;
@apply h-7 flex flex-row justify-start items-center border rounded cursor-pointer hover:opacity-80;
> .github-icon {
> .github-icon {
@apply w-auto h-full px-2 border-r rounded-l flex flex-row justify-center items-center text-xs
font-bold
text-gray-800 bg-gray-100;
@apply w-auto h-full px-2 border-r rounded-l flex flex-row justify-center items-center text-xs text-gray-800 bg-gray-100;
> .icon-img {
> .icon-img {
@apply mr-1 w-4 h-4;
@apply mr-1 w-4 h-4;
...
@@ -11,24 +11,5 @@
...
@@ -11,24 +11,5 @@
> .count-text {
> .count-text {
@apply w-auto h-full flex flex-row justify-center items-center px-3 text-xs font-bold text-gray-800;
@apply w-auto h-full flex flex-row justify-center items-center px-3 text-xs font-bold text-gray-800;
> .icon-text {
@apply text-sm ml-1;
animation: 1.6s linear 0s infinite pulse;
}
}
}
@keyframes pulse {
0% {
transform: scale(0.95);
}
70% {
transform: scale(1.2);
}
100% {
transform: scale(0.95);
}
}
}
}
web/src/less/signin.less
deleted
100644 → 0
View file @
84a35482
@import "./mixin.less";
.page-wrapper.signin {
@apply flex flex-row justify-center items-center w-full min-h-screen bg-white;
> .page-container {
@apply w-80 max-w-full py-4 -mt-16;
> .page-header-container {
@apply flex flex-col justify-start items-start w-full mb-4;
> .title-container {
@apply w-full flex flex-row justify-between items-center;
> .title-text {
@apply text-2xl mb-2;
> .icon-text {
@apply text-4xl;
}
}
}
> .slogan-text {
@apply text-sm text-gray-700;
}
}
> .page-content-container {
@apply flex flex-col justify-start items-start w-full;
> .form-item-container {
@apply flex flex-col justify-start items-start relative w-full text-base mt-2;
> .normal-text {
@apply absolute top-3 left-3 px-1 leading-10 flex-shrink-0 text-base cursor-text text-gray-400 bg-transparent transition-all select-none;
&.not-null {
@apply text-sm top-0 z-10 leading-4 bg-white rounded;
}
}
&.input-form-container {
@apply py-2;
> input {
@apply w-full py-3 px-3 text-base shadow-inner rounded-lg border border-solid border-gray-400 hover:opacity-80;
}
}
}
&.requesting {
@apply opacity-80;
}
}
> .action-btns-container {
@apply flex flex-row justify-end items-center w-full mt-2;
> .btn {
@apply px-1 py-2 text-sm rounded hover:opacity-80;
&.signin-btn {
@apply bg-green-600 text-white px-3 shadow;
}
&.requesting {
@apply cursor-wait opacity-80;
}
}
}
> .tip-text {
@apply w-auto inline-block float-right text-sm mt-4 text-gray-500 text-right whitespace-pre-wrap;
&.host-tip {
@apply bg-blue-500 text-white px-2 py-1 rounded;
}
}
}
}
web/src/locales/en.json
View file @
b596d049
...
@@ -4,5 +4,11 @@
...
@@ -4,5 +4,11 @@
"email"
:
"Email"
,
"email"
:
"Email"
,
"password"
:
"Password"
,
"password"
:
"Password"
,
"sign-in"
:
"Sign in"
"sign-in"
:
"Sign in"
},
"slogan"
:
"An open source, self-hosted knowledge base that works with a SQLite db file."
,
"auth"
:
{
"signup-as-host"
:
"Sign up as Host"
,
"host-tip"
:
"You are registering as the Site Host."
,
"not-host-tip"
:
"If you don't have an account, please contact the site host."
}
}
}
}
web/src/locales/zh.json
View file @
b596d049
...
@@ -4,5 +4,11 @@
...
@@ -4,5 +4,11 @@
"email"
:
"邮箱"
,
"email"
:
"邮箱"
,
"password"
:
"密码"
,
"password"
:
"密码"
,
"sign-in"
:
"登录"
"sign-in"
:
"登录"
},
"slogan"
:
"一个开源的、支持私有化部署的碎片化知识卡片管理工具。"
,
"auth"
:
{
"signup-as-host"
:
"注册为 Host"
,
"host-tip"
:
"你正在注册为 Host 用户账号。"
,
"not-host-tip"
:
"如果你没有账号,请联系站点 Host"
}
}
}
}
web/src/pages/
Signin
.tsx
→
web/src/pages/
Auth
.tsx
View file @
b596d049
...
@@ -3,10 +3,10 @@ import * as api from "../helpers/api";
...
@@ -3,10 +3,10 @@ import * as api from "../helpers/api";
import
{
validate
,
ValidatorConfig
}
from
"../helpers/validator"
;
import
{
validate
,
ValidatorConfig
}
from
"../helpers/validator"
;
import
useI18n
from
"../hooks/useI18n"
;
import
useI18n
from
"../hooks/useI18n"
;
import
useLoading
from
"../hooks/useLoading"
;
import
useLoading
from
"../hooks/useLoading"
;
import
{
locationService
,
userService
}
from
"../services"
;
import
{
globalService
,
locationService
,
userService
}
from
"../services"
;
import
toastHelper
from
"../components/Toast"
;
import
toastHelper
from
"../components/Toast"
;
import
GitHubBadge
from
"../components/GitHubBadge"
;
import
GitHubBadge
from
"../components/GitHubBadge"
;
import
"../less/
signin
.less"
;
import
"../less/
auth
.less"
;
interface
Props
{}
interface
Props
{}
...
@@ -17,8 +17,8 @@ const validateConfig: ValidatorConfig = {
...
@@ -17,8 +17,8 @@ const validateConfig: ValidatorConfig = {
noChinese
:
true
,
noChinese
:
true
,
};
};
const
Signin
:
React
.
FC
<
Props
>
=
()
=>
{
const
Auth
:
React
.
FC
<
Props
>
=
()
=>
{
const
{
t
}
=
useI18n
();
const
{
t
,
locale
}
=
useI18n
();
const
pageLoadingState
=
useLoading
(
true
);
const
pageLoadingState
=
useLoading
(
true
);
const
[
siteHost
,
setSiteHost
]
=
useState
<
User
>
();
const
[
siteHost
,
setSiteHost
]
=
useState
<
User
>
();
const
[
email
,
setEmail
]
=
useState
(
""
);
const
[
email
,
setEmail
]
=
useState
(
""
);
...
@@ -113,55 +113,68 @@ const Signin: React.FC<Props> = () => {
...
@@ -113,55 +113,68 @@ const Signin: React.FC<Props> = () => {
actionBtnLoadingState
.
setFinish
();
actionBtnLoadingState
.
setFinish
();
};
};
const
handleLocaleItemClick
=
(
locale
:
Locale
)
=>
{
globalService
.
setLocale
(
locale
);
};
return
(
return
(
<
div
className=
"page-wrapper
signin
"
>
<
div
className=
"page-wrapper
auth
"
>
<
div
className=
"page-container"
>
<
div
className=
"page-container"
>
<
div
className=
"page-header-container"
>
<
div
className=
"auth-form-wrapper"
>
<
div
className=
"title-container"
>
<
div
className=
"page-header-container"
>
<
p
className=
"title-text"
>
<
div
className=
"title-container"
>
<
span
className=
"icon-text"
>
✍️
</
span
>
Memos
<
p
className=
"title-text"
>
</
p
>
<
span
className=
"icon-text"
>
✍️
</
span
>
Memos
<
GitHubBadge
/>
</
p
>
<
GitHubBadge
/>
</
div
>
<
p
className=
"slogan-text"
>
{
t
(
"slogan"
)
}
</
p
>
</
div
>
</
div
>
<
p
className=
"slogan-text"
>
<
div
className=
{
`page-content-container ${actionBtnLoadingState.isLoading ? "requesting" : ""}`
}
>
An
<
i
>
open source
</
i
>
,
<
i
>
self-hosted
</
i
>
knowledge base that works with a SQLite db file.
<
div
className=
"form-item-container input-form-container"
>
</
p
>
<
span
className=
{
`normal-text ${email ? "not-null" : ""}`
}
>
{
t
(
"common.email"
)
}
</
span
>
</
div
>
<
input
type=
"email"
value=
{
email
}
onChange=
{
handleEmailInputChanged
}
/>
<
div
className=
{
`page-content-container ${actionBtnLoadingState.isLoading ? "requesting" : ""}`
}
>
</
div
>
<
div
className=
"form-item-container input-form-container"
>
<
div
className=
"form-item-container input-form-container"
>
<
span
className=
{
`normal-text ${email ? "not-null" : ""}`
}
>
{
t
(
"common.email"
)
}
</
span
>
<
span
className=
{
`normal-text ${password ? "not-null" : ""}`
}
>
{
t
(
"common.password"
)
}
</
span
>
<
input
type=
"email"
value=
{
email
}
onChange=
{
handleEmailInputChanged
}
/>
<
input
type=
"password"
value=
{
password
}
onChange=
{
handlePasswordInputChanged
}
/>
</
div
>
</
div
>
</
div
>
<
div
className=
"form-item-container input-form-container"
>
<
div
className=
"action-btns-container"
>
<
span
className=
{
`normal-text ${password ? "not-null" : ""}`
}
>
{
t
(
"common.password"
)
}
</
span
>
{
siteHost
||
pageLoadingState
.
isLoading
?
(
<
input
type=
"password"
value=
{
password
}
onChange=
{
handlePasswordInputChanged
}
/>
<
button
className=
{
`btn signin-btn ${actionBtnLoadingState.isLoading ? "requesting" : ""}`
}
onClick=
{
()
=>
handleSigninBtnsClick
()
}
>
{
t
(
"common.sign-in"
)
}
</
button
>
)
:
(
<
button
className=
{
`btn signin-btn ${actionBtnLoadingState.isLoading ? "requesting" : ""}`
}
onClick=
{
()
=>
handleSignUpAsHostBtnsClick
()
}
>
{
t
(
"auth.signup-as-host"
)
}
</
button
>
)
}
</
div
>
</
div
>
<
p
className=
{
`tip-text ${siteHost || pageLoadingState.isLoading ? "" : "host-tip"}`
}
>
{
siteHost
||
pageLoadingState
.
isLoading
?
t
(
"auth.not-host-tip"
)
:
t
(
"auth.host-tip"
)
}
</
p
>
</
div
>
</
div
>
<
div
className=
"action-btns-container"
>
<
div
className=
"footer-container"
>
{
siteHost
||
pageLoadingState
.
isLoading
?
(
<
div
className=
"language-container"
>
<
button
<
span
className=
{
`locale-item ${locale === "en" ? "active" : ""}`
}
onClick=
{
()
=>
handleLocaleItemClick
(
"en"
)
}
>
className=
{
`btn signin-btn ${actionBtnLoadingState.isLoading ? "requesting" : ""}`
}
English
onClick=
{
()
=>
handleSigninBtnsClick
()
}
</
span
>
>
<
span
className=
"split-line"
>
/
</
span
>
{
t
(
"common.sign-in"
)
}
<
span
className=
{
`locale-item ${locale === "zh" ? "active" : ""}`
}
onClick=
{
()
=>
handleLocaleItemClick
(
"zh"
)
}
>
</
button
>
中文
)
:
(
</
span
>
<
button
</
div
>
className=
{
`btn signin-btn ${actionBtnLoadingState.isLoading ? "requesting" : ""}`
}
onClick=
{
()
=>
handleSignUpAsHostBtnsClick
()
}
>
Sign up as Host
</
button
>
)
}
</
div
>
</
div
>
<
p
className=
{
`tip-text ${siteHost || pageLoadingState.isLoading ? "" : "host-tip"}`
}
>
{
siteHost
||
pageLoadingState
.
isLoading
?
"If you don't have an account, please
\n
contact the site host."
:
"You are registering as the Site Host."
}
</
p
>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
};
};
export
default
Signin
;
export
default
Auth
;
web/src/pages/Home.tsx
View file @
b596d049
...
@@ -23,7 +23,7 @@ function Home() {
...
@@ -23,7 +23,7 @@ function Home() {
.
finally
(
async
()
=>
{
.
finally
(
async
()
=>
{
const
{
host
,
owner
,
user
}
=
userService
.
getState
();
const
{
host
,
owner
,
user
}
=
userService
.
getState
();
if
(
!
host
)
{
if
(
!
host
)
{
locationService
.
replaceHistory
(
"/
signin
"
);
locationService
.
replaceHistory
(
"/
auth
"
);
return
;
return
;
}
}
...
@@ -61,7 +61,7 @@ function Home() {
...
@@ -61,7 +61,7 @@ function Home() {
<
span
className=
"icon"
>
🏠
</
span
>
Back to Home
<
span
className=
"icon"
>
🏠
</
span
>
Back to Home
</
button
>
</
button
>
)
:
(
)
:
(
<
button
className=
"btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/
signin
"
)
}
>
<
button
className=
"btn"
onClick=
{
()
=>
(
window
.
location
.
href
=
"/
auth
"
)
}
>
<
span
className=
"icon"
>
👉
</
span
>
Sign in
<
span
className=
"icon"
>
👉
</
span
>
Sign in
</
button
>
</
button
>
)
}
)
}
...
...
web/src/routers/appRouter.tsx
View file @
b596d049
import
Home
from
"../pages/Home"
;
import
Home
from
"../pages/Home"
;
import
Signin
from
"../pages/Signin
"
;
import
Auth
from
"../pages/Auth
"
;
const
appRouter
=
{
const
appRouter
=
{
"/
signin"
:
<
Signin
/>
,
"/
auth"
:
<
Auth
/>
,
"*"
:
<
Home
/>
,
"*"
:
<
Home
/>
,
};
};
...
...
web/src/store/modules/location.ts
View file @
b596d049
...
@@ -21,7 +21,7 @@ interface State {
...
@@ -21,7 +21,7 @@ interface State {
const
getValidPathname
=
(
pathname
:
string
):
string
=>
{
const
getValidPathname
=
(
pathname
:
string
):
string
=>
{
const
userPageUrlRegex
=
/^
\/
u
\/\d
+.*/
;
const
userPageUrlRegex
=
/^
\/
u
\/\d
+.*/
;
if
([
"/"
,
"/
signin
"
].
includes
(
pathname
)
||
userPageUrlRegex
.
test
(
pathname
))
{
if
([
"/"
,
"/
auth
"
].
includes
(
pathname
)
||
userPageUrlRegex
.
test
(
pathname
))
{
return
pathname
;
return
pathname
;
}
else
{
}
else
{
return
"/"
;
return
"/"
;
...
...
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