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
ae1d9adf
Unverified
Commit
ae1d9adf
authored
May 20, 2023
by
boojack
Committed by
GitHub
May 20, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: initial system locale (#1684)
parent
b4057109
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
39 deletions
+18
-39
auth.go
server/auth.go
+0
-18
Memo.tsx
web/src/components/Memo.tsx
+1
-4
RelationListView.tsx
web/src/components/MemoEditor/RelationListView.tsx
+1
-1
ResourceListView.tsx
web/src/components/MemoEditor/ResourceListView.tsx
+1
-1
SystemSection.tsx
web/src/components/Settings/SystemSection.tsx
+2
-2
UsageHeatMap.tsx
web/src/components/UsageHeatMap.tsx
+10
-11
global.ts
web/src/store/module/global.ts
+3
-2
No files found.
server/auth.go
View file @
ae1d9adf
...
@@ -101,24 +101,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group, secret string) {
...
@@ -101,24 +101,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group, secret string) {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Incorrect login credentials, please try again"
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Incorrect login credentials, please try again"
)
}
}
if
user
==
nil
{
if
user
==
nil
{
allowSignUpSetting
,
err
:=
s
.
Store
.
FindSystemSetting
(
ctx
,
&
api
.
SystemSettingFind
{
Name
:
api
.
SystemSettingAllowSignUpName
,
})
if
err
!=
nil
&&
common
.
ErrorCode
(
err
)
!=
common
.
NotFound
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find system setting"
)
.
SetInternal
(
err
)
}
allowSignUpSettingValue
:=
false
if
allowSignUpSetting
!=
nil
{
err
=
json
.
Unmarshal
([]
byte
(
allowSignUpSetting
.
Value
),
&
allowSignUpSettingValue
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal system setting allow signup"
)
.
SetInternal
(
err
)
}
}
if
!
allowSignUpSettingValue
{
return
echo
.
NewHTTPError
(
http
.
StatusUnauthorized
,
"signup is disabled"
)
.
SetInternal
(
err
)
}
userCreate
:=
&
api
.
UserCreate
{
userCreate
:=
&
api
.
UserCreate
{
Username
:
userInfo
.
Identifier
,
Username
:
userInfo
.
Identifier
,
// The new signup user should be normal user by default.
// The new signup user should be normal user by default.
...
...
web/src/components/Memo.tsx
View file @
ae1d9adf
...
@@ -210,10 +210,7 @@ const Memo: React.FC<Props> = (props: Props) => {
...
@@ -210,10 +210,7 @@ const Memo: React.FC<Props> = (props: Props) => {
return
(
return
(
<>
<>
<
div
<
div
className=
{
`memo-wrapper ${"memos-" + memo.id} ${memo.pinned && !readonly ? "pinned" : ""}`
}
ref=
{
memoContainerRef
}
>
className=
{
`memo-wrapper ${"memos-" + memo.id} ${relatedMemoList.length > 0 && "pinned"} ${memo.pinned ? "pinned" : ""}`
}
ref=
{
memoContainerRef
}
>
<
div
className=
"memo-top-wrapper"
>
<
div
className=
"memo-top-wrapper"
>
<
div
className=
"status-text-container"
>
<
div
className=
"status-text-container"
>
<
Link
className=
"time-text"
to=
{
`/m/${memo.id}`
}
onClick=
{
handleMemoCreatedTimeClick
}
>
<
Link
className=
"time-text"
to=
{
`/m/${memo.id}`
}
onClick=
{
handleMemoCreatedTimeClick
}
>
...
...
web/src/components/MemoEditor/RelationListView.tsx
View file @
ae1d9adf
...
@@ -41,7 +41,7 @@ const RelationListView = () => {
...
@@ -41,7 +41,7 @@ const RelationListView = () => {
return
(
return
(
<
div
<
div
key=
{
memoRelation
.
relatedMemoId
}
key=
{
memoRelation
.
relatedMemoId
}
className=
"w-auto max-w-[50%] overflow-hidden flex flex-row justify-start items-center bg-gray-100
hover:bg-gray-20
0 rounded text-sm p-1 px-2 text-gray-500 cursor-pointer"
className=
"w-auto max-w-[50%] overflow-hidden flex flex-row justify-start items-center bg-gray-100
dark:bg-zinc-800 hover:opacity-8
0 rounded text-sm p-1 px-2 text-gray-500 cursor-pointer"
>
>
<
Icon
.
Link
className=
"w-4 h-auto shrink-0"
/>
<
Icon
.
Link
className=
"w-4 h-auto shrink-0"
/>
<
span
className=
"mx-1 max-w-full text-ellipsis font-mono whitespace-nowrap overflow-hidden"
>
<
span
className=
"mx-1 max-w-full text-ellipsis font-mono whitespace-nowrap overflow-hidden"
>
...
...
web/src/components/MemoEditor/ResourceListView.tsx
View file @
ae1d9adf
...
@@ -18,7 +18,7 @@ const ResourceListView = () => {
...
@@ -18,7 +18,7 @@ const ResourceListView = () => {
return
(
return
(
<
div
<
div
key=
{
resource
.
id
}
key=
{
resource
.
id
}
className=
"max-w-full flex flex-row justify-start items-center flex-nowrap bg-gray-100
px-2 py-1 rounded cursor-pointer text-gray-500 hover:bg-gray-200 dark:opacity-6
0"
className=
"max-w-full flex flex-row justify-start items-center flex-nowrap bg-gray-100
dark:bg-zinc-800 hover:opacity-80 px-2 py-1 rounded cursor-pointer text-gray-50
0"
>
>
<
ResourceIcon
resourceType=
{
resource
.
type
}
className=
"w-4 h-auto mr-1"
/>
<
ResourceIcon
resourceType=
{
resource
.
type
}
className=
"w-4 h-auto mr-1"
/>
<
span
className=
"text-sm max-w-xs truncate font-mono"
>
{
resource
.
filename
}
</
span
>
<
span
className=
"text-sm max-w-xs truncate font-mono"
>
{
resource
.
filename
}
</
span
>
...
...
web/src/components/Settings/SystemSection.tsx
View file @
ae1d9adf
...
@@ -232,7 +232,7 @@ const SystemSection = () => {
...
@@ -232,7 +232,7 @@ const SystemSection = () => {
</
div
>
</
div
>
<
div
className=
"form-label"
>
<
div
className=
"form-label"
>
<
div
className=
"flex flex-row items-center"
>
<
div
className=
"flex flex-row items-center"
>
<
span
className=
"
normal-text
mr-1"
>
{
t
(
"setting.system-section.max-upload-size"
)
}
</
span
>
<
span
className=
"
text-sm
mr-1"
>
{
t
(
"setting.system-section.max-upload-size"
)
}
</
span
>
<
HelpButton
icon=
"info"
hint=
{
t
(
"setting.system-section.max-upload-size-hint"
)
}
/>
<
HelpButton
icon=
"info"
hint=
{
t
(
"setting.system-section.max-upload-size-hint"
)
}
/>
</
div
>
</
div
>
<
Input
<
Input
...
@@ -248,7 +248,7 @@ const SystemSection = () => {
...
@@ -248,7 +248,7 @@ const SystemSection = () => {
<
Divider
className=
"!mt-3 !my-4"
/>
<
Divider
className=
"!mt-3 !my-4"
/>
<
div
className=
"form-label"
>
<
div
className=
"form-label"
>
<
div
className=
"flex flex-row items-center"
>
<
div
className=
"flex flex-row items-center"
>
<
span
className=
"
normal-text
mr-1"
>
{
t
(
"setting.system-section.openai-api-key"
)
}
</
span
>
<
span
className=
"
text-sm
mr-1"
>
{
t
(
"setting.system-section.openai-api-key"
)
}
</
span
>
<
HelpButton
hint=
{
t
(
"setting.system-section.openai-api-key-description"
)
}
url=
"https://platform.openai.com/account/api-keys"
/>
<
HelpButton
hint=
{
t
(
"setting.system-section.openai-api-key-description"
)
}
url=
"https://platform.openai.com/account/api-keys"
/>
</
div
>
</
div
>
<
Button
onClick=
{
handleSaveOpenAIConfig
}
>
{
t
(
"common.save"
)
}
</
Button
>
<
Button
onClick=
{
handleSaveOpenAIConfig
}
>
{
t
(
"common.save"
)
}
</
Button
>
...
...
web/src/components/UsageHeatMap.tsx
View file @
ae1d9adf
...
@@ -44,16 +44,19 @@ const UsageHeatMap = () => {
...
@@ -44,16 +44,19 @@ const UsageHeatMap = () => {
const
[
allStat
,
setAllStat
]
=
useState
<
DailyUsageStat
[]
>
(
getInitialUsageStat
(
usedDaysAmount
,
beginDayTimestamp
));
const
[
allStat
,
setAllStat
]
=
useState
<
DailyUsageStat
[]
>
(
getInitialUsageStat
(
usedDaysAmount
,
beginDayTimestamp
));
const
[
currentStat
,
setCurrentStat
]
=
useState
<
DailyUsageStat
|
null
>
(
null
);
const
[
currentStat
,
setCurrentStat
]
=
useState
<
DailyUsageStat
|
null
>
(
null
);
const
containerElRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
containerElRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
currentUserId
=
userStore
.
getCurrentUserId
();
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
userStore
.
state
.
user
)
{
userStore
.
getUserById
(
currentUserId
).
then
((
user
)
=>
{
return
;
if
(
!
user
)
{
}
return
;
setCreatedDays
(
Math
.
ceil
((
Date
.
now
()
-
getTimeStampByDate
(
userStore
.
state
.
user
.
createdTs
))
/
1000
/
3600
/
24
));
}
},
[
userStore
.
state
.
user
]);
setCreatedDays
(
Math
.
ceil
((
Date
.
now
()
-
getTimeStampByDate
(
user
.
createdTs
))
/
1000
/
3600
/
24
));
});
},
[
currentUserId
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
getMemoStats
(
userStore
.
getCurrentUserId
()
)
getMemoStats
(
currentUserId
)
.
then
(({
data
:
{
data
}
})
=>
{
.
then
(({
data
:
{
data
}
})
=>
{
setMemoAmount
(
data
.
length
);
setMemoAmount
(
data
.
length
);
const
newStat
:
DailyUsageStat
[]
=
getInitialUsageStat
(
usedDaysAmount
,
beginDayTimestamp
);
const
newStat
:
DailyUsageStat
[]
=
getInitialUsageStat
(
usedDaysAmount
,
beginDayTimestamp
);
...
@@ -72,11 +75,7 @@ const UsageHeatMap = () => {
...
@@ -72,11 +75,7 @@ const UsageHeatMap = () => {
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
error
(
error
);
console
.
error
(
error
);
});
});
},
[
memos
.
length
,
currentUserId
]);
return
()
=>
{
handleUsageStatItemMouseLeave
();
};
},
[
memos
.
length
]);
const
handleUsageStatItemMouseEnter
=
useCallback
((
event
:
React
.
MouseEvent
,
item
:
DailyUsageStat
)
=>
{
const
handleUsageStatItemMouseEnter
=
useCallback
((
event
:
React
.
MouseEvent
,
item
:
DailyUsageStat
)
=>
{
const
tempDiv
=
document
.
createElement
(
"div"
);
const
tempDiv
=
document
.
createElement
(
"div"
);
...
...
web/src/store/module/global.ts
View file @
ae1d9adf
...
@@ -49,8 +49,9 @@ export const initialGlobalState = async () => {
...
@@ -49,8 +49,9 @@ export const initialGlobalState = async () => {
externalUrl
:
""
,
externalUrl
:
""
,
},
},
};
};
defaultGlobalState
.
locale
=
storageLocale
||
findNearestLanguageMatch
(
i18n
.
language
);
defaultGlobalState
.
locale
=
defaultGlobalState
.
appearance
=
customizedProfile
.
appearance
;
storageLocale
||
defaultGlobalState
.
systemStatus
.
customizedProfile
.
locale
||
findNearestLanguageMatch
(
i18n
.
language
);
defaultGlobalState
.
appearance
=
defaultGlobalState
.
systemStatus
.
customizedProfile
.
appearance
;
}
}
store
.
dispatch
(
setGlobalState
(
defaultGlobalState
));
store
.
dispatch
(
setGlobalState
(
defaultGlobalState
));
};
};
...
...
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