From 9b82625ef7ff6845563e6154453dd379eff3002f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 23 May 2019 03:45:43 +0800 Subject: [PATCH] new style --- src/components/CopyBlock/index.less | 28 +++++-- src/components/CopyBlock/index.tsx | 12 +-- src/layouts/BasicLayout.tsx | 5 +- src/services/api.js | 126 ---------------------------- src/utils/utils.ts | 12 +++ 5 files changed, 41 insertions(+), 142 deletions(-) delete mode 100644 src/services/api.js diff --git a/src/components/CopyBlock/index.less b/src/components/CopyBlock/index.less index 48e6c7e2..68327401 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 68590253..c0fda636 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 4aaf0076..2cb64e02 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 5358a8e1..00000000 --- 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 8ab8c89b..480064c3 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'; +} -- GitLab