Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Accounts Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Accounts Web
Commits
8e8fb944
Commit
8e8fb944
authored
Apr 06, 2017
by
2breakegg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change language
parent
bcd4546f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
src/models/common.js
src/models/common.js
+5
-0
src/routes/Index.js
src/routes/Index.js
+30
-2
No files found.
src/models/common.js
View file @
8e8fb944
...
...
@@ -13,6 +13,11 @@ export default {
...
state
,
...
action
.
payload
,
};
},
changeLanguage
(
state
,
{
payload
:
id
})
{
localStorage
.
setItem
(
'
locale
'
,
id
.
id
);
history
.
go
(
0
);
return
state
;
},
},
effects
:
{},
subscriptions
:
{
...
...
src/routes/Index.js
View file @
8e8fb944
import
{
Layout
,
Menu
}
from
'
antd
'
;
import
{
Layout
,
Menu
,
Dropdown
,
Icon
}
from
'
antd
'
;
import
{
connect
}
from
'
dva
'
;
import
{
Link
}
from
'
dva/router
'
;
import
React
from
'
react
'
;
...
...
@@ -123,6 +123,21 @@ const particleConfig = {
};
function
Index
({
children
,
messages
,
dispatch
})
{
const
language
=
localStorage
.
getItem
(
'
locale
'
)
||
navigator
.
language
||
(
navigator
.
languages
&&
navigator
.
languages
[
0
])
||
navigator
.
userLanguage
||
navigator
.
browserLanguage
||
'
zh-CN
'
;
const
menu
=
(
<
Menu
style
=
{{
transform
:
'
translateX(-16px)
'
}}
>
<
Menu
.
Item
key
=
"
0
"
>
<
a
onClick
=
{()
=>
{
dispatch
({
type
:
'
common/changeLanguage
'
,
payload
:
{
id
:
'
en-US
'
}
})}}
className
=
'
changelanguage
'
>
&
nbsp
;
English
<
/a
>
<
/Menu.Item
>
<
Menu
.
Item
key
=
"
1
"
>
<
a
onClick
=
{()
=>
{
dispatch
({
type
:
'
common/changeLanguage
'
,
payload
:
{
id
:
'
zh-EN
'
}
})}}
className
=
'
changelanguage
'
>
&
nbsp
;
中文
<
/a
>
<
/Menu.Item
>
<
/Menu
>
);
return
(
<
div
style
=
{{
height
:
'
100%
'
}}
>
<
DocumentTitle
title
=
{
messages
.
title
||
'
Moe Cube
'
}
/
>
...
...
@@ -155,9 +170,22 @@ function Index({ children, messages, dispatch }) {
<
div
onClick
=
{()
=>
{
dispatch
({
type
:
'
auth/signOut
'
})
}}
>
<
Format
id
=
"
sign-out
"
/>
<
/div
>
<
/Menu.Item>
)
:
(
''
)
<
/Menu.Item>
)
:
(
''
)
}
<
Menu
.
Item
key
=
"
2
"
>
<
Dropdown
overlay
=
{
menu
}
trigger
=
{[
'
click
'
]}
>
{
language
===
'
en-US
'
?
(
<
a
className
=
"
ant-dropdown-link changelanguage
"
href
=
"
#
"
>
&
nbsp
;
English
<
Icon
type
=
"
down
"
className
=
"
flag
"
/>
<
/a>
)
:
(
<a className="ant-dropdown-link changelanguage" href="#"
>
&
nbsp
;
中文
<
Icon
type
=
"
down
"
className
=
"
flag
"
/>
<
/a>
)
}
<
/Dropdown
>
<
/Menu.Item
>
<
/Menu
>
<
/Header
>
<
Particles
...
...
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