diff --git a/src/components/CopyBlock/index.less b/src/components/CopyBlock/index.less index 48e6c7e28ac6b2a4235e150ee1a7b034d59707c6..683274010d4bd7aad8605c72dfd380c2a155c807 100644 --- a/src/components/CopyBlock/index.less +++ b/src/components/CopyBlock/index.less @@ -6,20 +6,36 @@ flex-direction: column; align-items: center; justify-content: center; - width: 80px; - height: 80px; + width: 40px; + height: 40px; font-size: 20px; background: #fff; border-radius: 40px; box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.2), 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12); cursor: pointer; +} +.copy-block-view { + position: relative; + :global { + .ant-typography-copy { + position: absolute; + right: 5px; + bottom: 0px; + } + } + .copy-block-code { + color: #fff; + margin: 0 0.2em; + padding: 0.2em 0.4em 0.1em; + font-size: 85%; + background: rgba(0, 0, 0, 0.06); + border-radius: 3px; + display: inline-block; + } .copy-block-text { font-size: 12px; + margin: 0; } } -.copy-block-code { - color: #fff; - background: #000; -} diff --git a/src/components/CopyBlock/index.tsx b/src/components/CopyBlock/index.tsx index 68590253ce01fbb72e25597a9e6413825ecf2721..c0fda636baefa8152ed62c8f3382408260b3bbe9 100644 --- a/src/components/CopyBlock/index.tsx +++ b/src/components/CopyBlock/index.tsx @@ -17,9 +17,10 @@ const BlockCodeView: React.SFC<{ url, )} --npm-client=cnpm --path=${url}`; return ( -
+
+

下载到项目中:

- {blockUrl} +
{blockUrl}
); @@ -29,12 +30,7 @@ export default ({ url }: { url: string }) => { return ( } trigger="click">
- -
- 下载到 -
- 项目中 -
+
); diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 4aaf0076b109f1e01fbd73edf093f02fa1cdc819..2cb64e0235b90242b9bb9ffd8285954b00756881 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -14,6 +14,7 @@ import { SettingDrawer, } from '@ant-design/pro-layout'; import Link from 'umi/link'; +import { isAntDesignProOrDev } from '@/utils/utils'; export interface BasicLayoutProps extends BasicLayoutComponentsProps, ConnectProps { breadcrumbNameMap: { [path: string]: MenuDataItem }; @@ -81,7 +82,7 @@ const BasicLayout: React.FC = props => { > {children} - {ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' && ( + {isAntDesignProOrDev() && ( @@ -92,7 +93,7 @@ const BasicLayout: React.FC = props => { } /> )} - + {isAntDesignProOrDev() && } ); }; diff --git a/src/services/api.js b/src/services/api.js deleted file mode 100644 index 5358a8e186a0adae677c5db8b7d8e815a2cd53ed..0000000000000000000000000000000000000000 --- a/src/services/api.js +++ /dev/null @@ -1,126 +0,0 @@ -import { stringify } from 'qs'; -import request from '@/utils/request'; - -export async function queryProjectNotice() { - return request('/api/project/notice'); -} - -export async function queryActivities() { - return request('/api/activities'); -} - -export async function queryRule(params) { - return request(`/api/rule?${stringify(params)}`); -} - -export async function removeRule(params) { - return request('/api/rule', { - method: 'POST', - data: { - ...params, - method: 'delete', - }, - }); -} - -export async function addRule(params) { - return request('/api/rule', { - method: 'POST', - data: { - ...params, - method: 'post', - }, - }); -} - -export async function updateRule(params = {}) { - return request(`/api/rule?${stringify(params.query)}`, { - method: 'POST', - data: { - ...params.body, - method: 'update', - }, - }); -} - -export async function fakeSubmitForm(params) { - return request('/api/forms', { - method: 'POST', - data: params, - }); -} - -export async function fakeChartData() { - return request('/api/fake_chart_data'); -} - -export async function queryTags() { - return request('/api/tags'); -} - -export async function queryBasicProfile(id) { - return request(`/api/profile/basic?id=${id}`); -} - -export async function queryAdvancedProfile() { - return request('/api/profile/advanced'); -} - -export async function queryFakeList(params) { - return request(`/api/fake_list?${stringify(params)}`); -} - -export async function removeFakeList(params) { - const { count = 5, ...restParams } = params; - return request(`/api/fake_list?count=${count}`, { - method: 'POST', - data: { - ...restParams, - method: 'delete', - }, - }); -} - -export async function addFakeList(params) { - const { count = 5, ...restParams } = params; - return request(`/api/fake_list?count=${count}`, { - method: 'POST', - data: { - ...restParams, - method: 'post', - }, - }); -} - -export async function updateFakeList(params) { - const { count = 5, ...restParams } = params; - return request(`/api/fake_list?count=${count}`, { - method: 'POST', - data: { - ...restParams, - method: 'update', - }, - }); -} - -export async function fakeAccountLogin(params) { - return request('/api/login/account', { - method: 'POST', - data: params, - }); -} - -export async function fakeRegister(params) { - return request('/api/register', { - method: 'POST', - data: params, - }); -} - -export async function queryNotices(params = {}) { - return request(`/api/notices?${stringify(params)}`); -} - -export async function getFakeCaptcha(mobile) { - return request(`/api/captcha?mobile=${mobile}`); -} diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 8ab8c89bac0bd68b9a00305ebecbef95766b36d3..480064c3318b66263e3e874ec5de1e48338b3e68 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -4,3 +4,15 @@ const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|( export function isUrl(path: string) { return reg.test(path); } + +// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 +export function isAntDesignProOrDev() { + const { NODE_ENV } = process.env; + if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { + return true; + } + if (NODE_ENV === 'development') { + return true; + } + return window.location.hostname === 'preview.pro.ant.design'; +}