Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
najiu-frontend
najiu-admin-template
Commits
ae3f8329
Unverified
Commit
ae3f8329
authored
May 11, 2021
by
江麻妞
Committed by
GitHub
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: optimize i18n to add the initial locale to the locale pool during initialization (#577)
parent
2b76b884
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
setupI18n.ts
src/locales/setupI18n.ts
+5
-0
useLocale.ts
src/locales/useLocale.ts
+4
-0
No files found.
src/locales/setupI18n.ts
View file @
ae3f8329
...
...
@@ -3,6 +3,7 @@ import type { I18n, I18nOptions } from 'vue-i18n';
import
{
createI18n
}
from
'
vue-i18n
'
;
import
{
setLoadLocalePool
}
from
'
./useLocale
'
;
import
{
localeSetting
}
from
'
/@/settings/localeSetting
'
;
import
{
useLocaleStoreWithOut
}
from
'
/@/store/modules/locale
'
;
...
...
@@ -16,6 +17,10 @@ async function createI18nOptions(): Promise<I18nOptions> {
const
defaultLocal
=
await
import
(
`./lang/
${
locale
}
.ts`
);
const
message
=
defaultLocal
.
default
?.
message
??
{};
setLoadLocalePool
((
loadLocalePool
)
=>
{
loadLocalePool
.
push
(
locale
);
});
return
{
legacy
:
false
,
locale
,
...
...
src/locales/useLocale.ts
View file @
ae3f8329
...
...
@@ -17,6 +17,10 @@ interface LangModule {
const
loadLocalePool
:
LocaleType
[]
=
[];
export
function
setLoadLocalePool
(
cb
:
(
loadLocalePool
:
LocaleType
[])
=>
void
)
{
cb
(
loadLocalePool
);
}
function
setI18nLanguage
(
locale
:
LocaleType
)
{
const
localeStore
=
useLocaleStoreWithOut
();
...
...
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