Commit 00bd838a authored by tjy's avatar tjy
parents 4097fe38 88bbcb19
{"userRegister":{"useType":{"memberType":[{"id":1,"typeName":"企业会员"},{"id":2,"typeName":"个人会员"},{"id":3,"typeName":"渠道企业会员"},{"id":4,"typeName":"渠道个人会员"}],"businessType":[{"id":1,"typeName":"new11"},{"id":2,"typeName":"王者农药"}]},"useDetail":[{"groupName":"企业组","elements":[{"id":2,"fieldName":"company","fieldCNName":"企业","fieldType":null,"fieldLength":10,"fieldEmpty":0,"fieldOrder":1,"fieldRemark":"test","checkRules":[]}]},{"groupName":"企业信息","elements":[{"id":3,"fieldName":"company_name","fieldCNName":"公司名称","fieldType":null,"fieldLength":128,"fieldEmpty":1,"fieldOrder":1,"fieldRemark":"","checkRules":[]},{"id":4,"fieldName":"company_type","fieldCNName":"公司类型","fieldType":null,"fieldLength":128,"fieldEmpty":0,"fieldOrder":2,"fieldRemark":"","checkRules":[]}]},{"groupName":"444","elements":[{"id":1,"fieldName":"444","fieldCNName":"44","fieldType":null,"fieldLength":44,"fieldEmpty":1,"fieldOrder":44,"fieldRemark":null,"checkRules":[]}]}]},"global":{"logo":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/logo.png","countryList":[{"name":"简体中文-ZH","key":"cn","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/china.png"},{"name":"English-EN","key":"en","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/us.png"},{"name":"日本語-JP","key":"jp","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/japen.png"},{"name":"한국어-KO","key":"ko","icon":"http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/koren.png"}]}}
{
"userRegister": {
"useType": {
"memberType": [
{
"id": 1,
"typeName": "企业会员"
},
{
"id": 2,
"typeName": "个人会员"
},
{
"id": 3,
"typeName": "渠道企业会员"
},
{
"id": 4,
"typeName": "渠道个人会员"
}
],
"businessType": [
{
"id": 1,
"typeName": "new11"
},
{
"id": 2,
"typeName": "王者农药"
}
]
},
"useDetail": [
{
"groupName": "企业组",
"elements": [
{
"id": 2,
"fieldName": "company",
"fieldCNName": "企业",
"fieldType": null,
"fieldLength": 10,
"fieldEmpty": 0,
"fieldOrder": 1,
"fieldRemark": "test",
"checkRules": []
}
]
},
{
"groupName": "企业信息",
"elements": [
{
"id": 3,
"fieldName": "company_name",
"fieldCNName": "公司名称",
"fieldType": null,
"fieldLength": 128,
"fieldEmpty": 1,
"fieldOrder": 1,
"fieldRemark": "",
"checkRules": []
},
{
"id": 4,
"fieldName": "company_type",
"fieldCNName": "公司类型",
"fieldType": null,
"fieldLength": 128,
"fieldEmpty": 0,
"fieldOrder": 2,
"fieldRemark": "",
"checkRules": []
}
]
},
{
"groupName": "444",
"elements": [
{
"id": 1,
"fieldName": "444",
"fieldCNName": "44",
"fieldType": null,
"fieldLength": 44,
"fieldEmpty": 1,
"fieldOrder": 44,
"fieldRemark": null,
"checkRules": []
}
]
}
]
},
"global": {
"logo": "http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/logo.png",
"countryList": [
{
"name": "简体中文-ZH",
"key": "zh-CN",
"icon": "http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/china.png"
},
{
"name": "English-EN",
"key": "en-US",
"icon": "http://lingxi-frontend-test.oss-cn-hangzhou.aliyuncs.com/images/us.png"
}
]
}
}
\ No newline at end of file
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { Dropdown, Space, Menu } from 'antd'
import { setLocale, getLocale } from 'umi'
import ChinaImg from '../../../mockStatic/china.png'
import gou from '../../../mockStatic/gou.png'
import { CaretDownOutlined } from '@ant-design/icons'
......@@ -15,33 +16,51 @@ interface countryItem {
const SelectLang: React.FC = () => {
// 此处暂时无接口, 对接接口后需用枚举类型做补充
const [select, setSelect] = useState<countryItem>({
key: 'cn',
name: '简体中文-ZH',
icon: ChinaImg
})
const [currentLangKey, setCurrentLangKey] = useState<string>('zh-CN')
useEffect(() => {
console.log(getLocale(), "getLocale()")
setCurrentLangKey(getLocale())
}, [])
const setLang = (langItem: countryItem) => {
setLocale(langItem.key, true)
}
const menuHeaderDropdown = (
<Menu selectedKeys={[]}>
{
GlobalConfig.global.countryList.map(v => <Menu.Item key={v.key} onClick={() => setSelect(v)}>
GlobalConfig.global.countryList.map(v => <Menu.Item key={v.key} onClick={() => setLang(v)}>
<Space>
{select.key === v.key ? <img src={gou} style={{width: 20, height: 20}}/> : <div style={{width: 20, height: 20}}></div> }
<img src={v.icon} style={{width: 24, height: 17}}/>
{currentLangKey === v.key ? <img src={gou} style={{ width: 20, height: 20 }} /> : <div style={{ width: 20, height: 20 }}></div>}
<img src={v.icon} style={{ width: 24, height: 17 }} />
<span>{v.name}</span>
</Space>
</Menu.Item>)
}
</Menu>
);
return (
<Dropdown overlay={menuHeaderDropdown} placement='bottomRight' className="selectLangBox">
<Space style={{cursor: 'pointer'}} size={5}>
<img src={select.icon} style={{width: 24, height: 17}}/>
<span>{select.name}</span>
const renderCurrentLang = () => {
let currentLang: countryItem
GlobalConfig.global.countryList.map(item => {
if (item.key === currentLangKey) {
currentLang = item
}
})
return (
<Space style={{ cursor: 'pointer' }} size={5}>
<img src={currentLang?.icon} style={{ width: 24, height: 17 }} />
<span>{currentLang?.name}</span>
<CaretDownOutlined />
</Space>
)
}
return (
<Dropdown overlay={menuHeaderDropdown} placement='bottomRight' className="selectLangBox">
{renderCurrentLang()}
</Dropdown>
)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment