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
3ff4d197
Commit
3ff4d197
authored
Oct 08, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update initial global loader
parent
31997936
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
35 deletions
+18
-35
manifest.json
web/public/manifest.json
+2
-2
en.json
web/src/locales/en.json
+2
-2
index.tsx
web/src/router/index.tsx
+9
-19
global.ts
web/src/store/module/global.ts
+5
-12
No files found.
web/public/manifest.json
View file @
3ff4d197
{
"short_name"
:
"
M
emos"
,
"name"
:
"
M
emos"
,
"short_name"
:
"
m
emos"
,
"name"
:
"
m
emos"
,
"description"
:
"usememos/memos"
,
"icons"
:
[
{
...
...
web/src/locales/en.json
View file @
3ff4d197
...
...
@@ -320,8 +320,8 @@
"days"
:
"days"
},
"about"
:
{
"about-memos"
:
"About
M
emos"
,
"memos-description"
:
"
M
emos is a web-based note-taking application that you can use to write, organize, and share notes."
,
"about-memos"
:
"About
m
emos"
,
"memos-description"
:
"
m
emos is a web-based note-taking application that you can use to write, organize, and share notes."
,
"no-server-description"
:
"No description configured for this server."
,
"powered-by"
:
"Powered by"
,
"other-projects"
:
"Other Projects"
...
...
web/src/router/index.tsx
View file @
3ff4d197
...
...
@@ -18,21 +18,14 @@ const Resources = lazy(() => import("@/pages/Resources"));
const
Setting
=
lazy
(()
=>
import
(
"@/pages/Setting"
));
const
NotFound
=
lazy
(()
=>
import
(
"@/pages/NotFound"
));
const
initialGlobalStateLoader
=
(()
=>
{
let
done
=
false
;
return
async
()
=>
{
if
(
done
)
{
return
;
}
done
=
true
;
try
{
await
initialGlobalState
();
}
catch
(
error
)
{
// do nth
}
};
})();
const
initialGlobalStateLoader
=
async
()
=>
{
try
{
await
initialGlobalState
();
}
catch
(
error
)
{
// do nth
}
return
null
;
};
const
initialUserStateLoader
=
async
(
redirectWhenNotFound
=
true
)
=>
{
let
user
=
undefined
;
...
...
@@ -52,10 +45,7 @@ const router = createBrowserRouter([
{
path
:
"/"
,
element
:
<
App
/>,
loader
:
async
()
=>
{
await
initialGlobalStateLoader
();
return
null
;
},
loader
:
()
=>
initialGlobalStateLoader
(),
children
:
[
{
path
:
"/auth"
,
...
...
web/src/store/module/global.ts
View file @
3ff4d197
...
...
@@ -7,9 +7,10 @@ import store, { useAppSelector } from "../";
import
{
setAppearance
,
setGlobalState
,
setLocale
}
from
"../reducer/global"
;
export
const
initialGlobalState
=
async
()
=>
{
const
{
locale
:
storageLocale
,
appearance
:
storageAppearance
}
=
storage
.
get
([
"locale"
,
"appearance"
]);
const
defaultGlobalState
=
{
locale
:
"en"
as
Locale
,
appearance
:
"system"
as
Appearance
,
locale
:
(
storageLocale
||
"en"
)
as
Locale
,
appearance
:
(
storageAppearance
||
"system"
)
as
Appearance
,
systemStatus
:
{
allowSignUp
:
false
,
disablePasswordLogin
:
false
,
...
...
@@ -30,14 +31,6 @@ export const initialGlobalState = async () => {
}
as
SystemStatus
,
};
const
{
locale
:
storageLocale
,
appearance
:
storageAppearance
}
=
storage
.
get
([
"locale"
,
"appearance"
]);
if
(
storageLocale
)
{
defaultGlobalState
.
locale
=
storageLocale
;
}
if
(
storageAppearance
)
{
defaultGlobalState
.
appearance
=
storageAppearance
;
}
const
{
data
}
=
await
api
.
getSystemStatus
();
if
(
data
)
{
const
customizedProfile
=
data
.
customizedProfile
;
...
...
@@ -53,8 +46,8 @@ export const initialGlobalState = async () => {
},
};
defaultGlobalState
.
locale
=
storageL
ocale
||
defaultGlobalState
.
systemStatus
.
customizedProfile
.
locale
||
findNearestLanguageMatch
(
i18n
.
language
);
defaultGlobalState
.
appearance
=
defaultGlobalState
.
systemStatus
.
customizedProfile
.
appearance
;
defaultGlobalState
.
l
ocale
||
defaultGlobalState
.
systemStatus
.
customizedProfile
.
locale
||
findNearestLanguageMatch
(
i18n
.
language
);
defaultGlobalState
.
appearance
=
defaultGlobalState
.
appearance
||
defaultGlobalState
.
systemStatus
.
customizedProfile
.
appearance
;
}
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