From b92bcbb127f87b9db56b42d10db7eeceecd9c09e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 23 May 2019 14:36:50 +0800 Subject: [PATCH] new copy code style --- scripts/fetch-blocks.js | 5 +++-- src/components/CopyBlock/index.less | 14 +------------- src/components/CopyBlock/index.tsx | 19 ++++++++++--------- src/locales/en-US/menu.ts | 3 +++ src/locales/pt-BR/menu.ts | 4 ++++ src/locales/zh-CN/menu.ts | 3 +++ src/locales/zh-TW/menu.ts | 3 +++ 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/scripts/fetch-blocks.js b/scripts/fetch-blocks.js index e55d80b4..f2c5af28 100644 --- a/scripts/fetch-blocks.js +++ b/scripts/fetch-blocks.js @@ -26,7 +26,7 @@ const findAllInstallRouter = router => { if (item.path !== '/user' || item.path !== '/') { routers.push({ ...item, - routes: '', + routes: !!item.routes, }); } } @@ -92,9 +92,10 @@ const installBlock = async () => { if (gitFiles.find(file => file.path === gitPath)) { console.log('install ' + chalk.green(item.name) + ' to: ' + chalk.yellow(item.path)); gitFiles = gitFiles.filter(file => file.path !== gitPath); + const skipModifyRouter = item.routes ? '--skip-modify-routes' : ''; const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${gitPath} --npm-client=cnpm --path=${ item.path - }`; + } ${skipModifyRouter}`; try { await execCmd(cmd); console.log(`install ${chalk.hex('#1890ff')(item.name)} success`); diff --git a/src/components/CopyBlock/index.less b/src/components/CopyBlock/index.less index 32846160..83d899a1 100644 --- a/src/components/CopyBlock/index.less +++ b/src/components/CopyBlock/index.less @@ -2,6 +2,7 @@ position: fixed; right: 80px; bottom: 40px; + z-index: 99; display: flex; flex-direction: column; align-items: center; @@ -18,24 +19,11 @@ .copy-block-view { position: relative; - :global { - .ant-typography-copy { - position: absolute; - right: 5px; - bottom: 0; - } - } .copy-block-code { display: inline-block; margin: 0 0.2em; padding: 0.2em 0.4em 0.1em; - color: #fff; font-size: 85%; - background: rgba(0, 0, 0, 0.06); border-radius: 3px; } - .copy-block-text { - margin: 0; - font-size: 12px; - } } diff --git a/src/components/CopyBlock/index.tsx b/src/components/CopyBlock/index.tsx index c0fda636..f1a1156a 100644 --- a/src/components/CopyBlock/index.tsx +++ b/src/components/CopyBlock/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Icon, Typography, Tooltip } from 'antd'; +import { Icon, Typography, Popover } from 'antd'; import styles from './index.less'; const firstUpperCase = (pathString: string) => { return pathString @@ -12,15 +12,11 @@ const firstUpperCase = (pathString: string) => { const BlockCodeView: React.SFC<{ url: string; }> = ({ url }) => { - console.log(url); - const blockUrl = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${firstUpperCase( - url, - )} --npm-client=cnpm --path=${url}`; + const blockUrl = `npx umi block add ant-design-pro/${firstUpperCase(url)} --path=${url}`; return (
-

下载到项目中:

-
{blockUrl}
+ {blockUrl}
); @@ -28,10 +24,15 @@ const BlockCodeView: React.SFC<{ export default ({ url }: { url: string }) => { return ( - } trigger="click"> + } + trigger="click" + >
-
+ ); }; diff --git a/src/locales/en-US/menu.ts b/src/locales/en-US/menu.ts index fae9170f..8e0026fe 100644 --- a/src/locales/en-US/menu.ts +++ b/src/locales/en-US/menu.ts @@ -9,6 +9,9 @@ export default { 'menu.dashboard.analysis': 'Analysis', 'menu.dashboard.monitor': 'Monitor', 'menu.dashboard.workplace': 'Workplace', + 'menu.exception.403': '403', + 'menu.exception.404': '404', + 'menu.exception.500': '500', 'menu.form': 'Form', 'menu.form.basic-form': 'Basic Form', 'menu.form.step-form': 'Step Form', diff --git a/src/locales/pt-BR/menu.ts b/src/locales/pt-BR/menu.ts index 6e641938..3666b6b6 100644 --- a/src/locales/pt-BR/menu.ts +++ b/src/locales/pt-BR/menu.ts @@ -1,6 +1,7 @@ export default { 'menu.welcome': 'Welcome', 'menu.more-blocks': 'More Blocks', + 'menu.home': 'Início', 'menu.login': 'Login', 'menu.register': 'Registro', @@ -9,6 +10,9 @@ export default { 'menu.dashboard.analysis': 'Análise', 'menu.dashboard.monitor': 'Monitor', 'menu.dashboard.workplace': 'Ambiente de Trabalho', + 'menu.exception.403': '403', + 'menu.exception.404': '404', + 'menu.exception.500': '500', 'menu.form': 'Formulário', 'menu.form.basic-form': 'Formulário Básico', 'menu.form.step-form': 'Formulário Assistido', diff --git a/src/locales/zh-CN/menu.ts b/src/locales/zh-CN/menu.ts index fd93cf33..f851fe96 100644 --- a/src/locales/zh-CN/menu.ts +++ b/src/locales/zh-CN/menu.ts @@ -9,6 +9,9 @@ export default { 'menu.dashboard.analysis': '分析页', 'menu.dashboard.monitor': '监控页', 'menu.dashboard.workplace': '工作台', + 'menu.exception.403': '403', + 'menu.exception.404': '404', + 'menu.exception.500': '500', 'menu.form': '表单页', 'menu.form.basic-form': '基础表单', 'menu.form.step-form': '分步表单', diff --git a/src/locales/zh-TW/menu.ts b/src/locales/zh-TW/menu.ts index 6bc2964b..b0160286 100644 --- a/src/locales/zh-TW/menu.ts +++ b/src/locales/zh-TW/menu.ts @@ -4,6 +4,9 @@ export default { 'menu.home': '首頁', 'menu.login': '登錄', + 'menu.exception.403': '403', + 'menu.exception.404': '404', + 'menu.exception.500': '500', 'menu.register': '註冊', 'menu.register.resultt': '註冊結果', 'menu.dashboard': 'Dashboard', -- GitLab