提交 af01272a 编写于 作者: 陈帅

refactor: remove unuse code

上级 408a3fee
......@@ -177,7 +177,6 @@ export default {
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
// ...darkTheme,
'primary-color': primaryColor,
},
define: {
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
......
......@@ -44,7 +44,8 @@ export interface DefaultSettings {
export default {
navTheme: 'dark',
primaryColor: '#1890FF',
// 拂晓蓝
primaryColor: 'daybreak',
layout: 'sidemenu',
contentWidth: 'Fluid',
fixedHeader: false,
......
@import '~antd/es/style/themes/default.less';
.copy-block {
position: fixed;
right: 80px;
bottom: 40px;
z-index: 99;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
font-size: 20px;
background: @input-bg;
border-radius: 40px;
box-shadow: @card-shadow;
cursor: pointer;
}
.copy-block-view {
position: relative;
.copy-block-code {
display: inline-block;
margin: 0 0.2em;
padding: 0.2em 0.4em 0.1em;
font-size: 85%;
border-radius: 3px;
}
}
import { Icon, Popover, Typography } from 'antd';
import React, { useRef } from 'react';
import { FormattedMessage } from 'umi-plugin-react/locale';
import { connect } from 'dva';
import { isAntDesignPro } from '@/utils/utils';
import styles from './index.less';
const firstUpperCase = (pathString: string): string =>
pathString
.replace('.', '')
.split(/\/|-/)
.map((s): string => s.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase()))
.filter((s): boolean => !!s)
.join('');
// when click block copy, send block url to ga
const onBlockCopy = (label: string) => {
if (!isAntDesignPro()) {
return;
}
const ga = window && window.ga;
if (ga) {
ga('send', 'event', {
eventCategory: 'block',
eventAction: 'copy',
eventLabel: label,
});
}
};
const BlockCodeView: React.SFC<{
url: string;
}> = ({ url }) => {
const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`;
return (
<div className={styles['copy-block-view']}>
<Typography.Paragraph
copyable={{
text: blockUrl,
onCopy: () => onBlockCopy(url),
}}
style={{
display: 'flex',
}}
>
<pre>
<code className={styles['copy-block-code']}>{blockUrl}</code>
</pre>
</Typography.Paragraph>
</div>
);
};
interface RoutingType {
location: {
pathname: string;
};
}
export default connect(({ routing }: { routing: RoutingType }) => ({
location: routing.location,
}))(({ location }: RoutingType) => {
const url = location.pathname;
const divDom = useRef<HTMLDivElement>(null);
return (
<Popover
title={<FormattedMessage id="app.preview.down.block" defaultMessage="下载此页面到本地项目" />}
placement="topLeft"
content={<BlockCodeView url={url} />}
trigger="click"
getPopupContainer={dom => (divDom.current ? divDom.current : dom)}
>
<div className={styles['copy-block']} ref={divDom}>
<Icon type="download" />
</div>
</Popover>
);
});
......@@ -126,9 +126,6 @@ const BasicLayout: React.FC<BasicLayoutProps> = props => {
dispatch({
type: 'user/fetchCurrent',
});
dispatch({
type: 'settings/getSetting',
});
}
}, []);
/**
......
......@@ -5,7 +5,6 @@ export interface SettingModelType {
namespace: 'settings';
state: DefaultSettings;
reducers: {
getSetting: Reducer<DefaultSettings>;
changeSetting: Reducer<DefaultSettings>;
};
}
......@@ -21,23 +20,6 @@ const SettingModel: SettingModelType = {
namespace: 'settings',
state: defaultSettings,
reducers: {
getSetting(state = defaultSettings) {
const setting: Partial<DefaultSettings> = {};
const urlParams = new URL(window.location.href);
Object.keys(state).forEach(key => {
if (urlParams.searchParams.has(key)) {
const value = urlParams.searchParams.get(key);
setting[key] = value;
}
});
const { colorWeak } = setting;
updateColorWeak(!!colorWeak);
return {
...state,
...setting,
};
},
changeSetting(state = defaultSettings, { payload }) {
const { colorWeak, contentWidth } = payload;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册