update 0.9.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: yehuozhili
|
||||
* @Date: 2021-07-07 14:51:17
|
||||
* @LastEditors: yehuozhili
|
||||
* @LastEditTime: 2021-08-12 14:37:38
|
||||
* @LastEditTime: 2021-08-27 14:45:47
|
||||
* @FilePath: \dooringx\packages\dooringx-example\src\layouts\index.tsx
|
||||
*/
|
||||
import { Button } from 'antd';
|
||||
@@ -14,9 +14,12 @@ import plugin from '../plugin';
|
||||
import 'antd/dist/antd.css';
|
||||
import '../global.less';
|
||||
import 'animate.css';
|
||||
|
||||
import { IntlProvider } from 'react-intl';
|
||||
import { locale } from 'dooringx-lib';
|
||||
import { localeKey } from '../../../dooringx-lib/dist/locale';
|
||||
export const config = new UserConfig(plugin);
|
||||
export const configContext = createContext<UserConfig>(config);
|
||||
|
||||
// 自定义右键
|
||||
const contextMenuState = config.getContextMenuState();
|
||||
const unmountContextMenu = contextMenuState.unmountContextMenu;
|
||||
@@ -70,6 +73,22 @@ const ContextMenu = () => {
|
||||
};
|
||||
contextMenuState.contextMenu = <ContextMenu></ContextMenu>;
|
||||
|
||||
export default function Layout({ children }: IRouteComponentProps) {
|
||||
return <configContext.Provider value={config}>{children}</configContext.Provider>;
|
||||
interface LocaleContextType {
|
||||
change: Function;
|
||||
current: localeKey;
|
||||
}
|
||||
export const LocaleContext = createContext<LocaleContextType>({
|
||||
change: () => {},
|
||||
current: 'zh-CN',
|
||||
});
|
||||
|
||||
export default function Layout({ children }: IRouteComponentProps) {
|
||||
const [l, setLocale] = useState<localeKey>('zh-CN');
|
||||
return (
|
||||
<LocaleContext.Provider value={{ change: setLocale, current: l }}>
|
||||
<IntlProvider messages={locale.localeMap[l]} locale={l} defaultLocale={l}>
|
||||
<configContext.Provider value={config}>{children}</configContext.Provider>
|
||||
</IntlProvider>
|
||||
</LocaleContext.Provider>
|
||||
);
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
* @Author: yehuozhili
|
||||
* @Date: 2021-05-15 12:49:28
|
||||
* @LastEditors: yehuozhili
|
||||
* @LastEditTime: 2021-08-19 16:52:35
|
||||
* @LastEditTime: 2021-08-27 16:24:39
|
||||
* @FilePath: \dooringx\packages\dooringx-example\src\pages\index.tsx
|
||||
*/
|
||||
import {
|
||||
@@ -16,10 +16,12 @@ import {
|
||||
} from 'dooringx-lib';
|
||||
import { InsertRowBelowOutlined } from '@ant-design/icons';
|
||||
import { useContext } from 'react';
|
||||
import { configContext } from '@/layouts';
|
||||
import { configContext, LocaleContext } from '@/layouts';
|
||||
import { useCallback } from 'react';
|
||||
import { PREVIEWSTATE } from '@/constant';
|
||||
import { Button, Popover } from 'antd';
|
||||
import { localeKey } from '../../../dooringx-lib/dist/locale';
|
||||
|
||||
export const HeaderHeight = '40px';
|
||||
const footerConfig = function () {
|
||||
return (
|
||||
@@ -33,6 +35,7 @@ const footerConfig = function () {
|
||||
|
||||
export default function IndexPage() {
|
||||
const config = useContext(configContext);
|
||||
const locale = useContext(LocaleContext);
|
||||
|
||||
const everyFn = () => {};
|
||||
|
||||
@@ -59,6 +62,15 @@ export default function IndexPage() {
|
||||
>
|
||||
普通预览
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
locale.change((pre: localeKey) => {
|
||||
return pre === 'zh-CN' ? 'en' : 'zh-CN';
|
||||
});
|
||||
}}
|
||||
>
|
||||
切换语言
|
||||
</Button>
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
|
Reference in New Issue
Block a user