提交 c7bffe52 编写于 作者: 陈帅

Merge branch 'master' into v4

...@@ -10,7 +10,7 @@ module.exports = { ...@@ -10,7 +10,7 @@ module.exports = {
jasmine: true, jasmine: true,
}, },
globals: { globals: {
APP_TYPE: true, ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
page: true, page: true,
}, },
rules: { rules: {
...@@ -27,6 +27,7 @@ module.exports = { ...@@ -27,6 +27,7 @@ module.exports = {
devDependencies: ['**/tests/**.js', '/mock/**/**.js', '**/**.test.js'], devDependencies: ['**/tests/**.js', '/mock/**/**.js', '**/**.test.js'],
}, },
], ],
'import/no-cycle': 0,
'jsx-a11y/no-noninteractive-element-interactions': 0, 'jsx-a11y/no-noninteractive-element-interactions': 0,
'jsx-a11y/click-events-have-key-events': 0, 'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-static-element-interactions': 0, 'jsx-a11y/no-static-element-interactions': 0,
......
**/*.md
**/*.svg **/*.svg
package.json package.json
.umi .umi
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"singleQuote": true, "singleQuote": true,
"trailingComma": "all", "trailingComma": "all",
"printWidth": 100, "printWidth": 100,
"proseWrap": "never",
"overrides": [ "overrides": [
{ {
"files": ".prettierrc", "files": ".prettierrc",
......
...@@ -6,7 +6,8 @@ import defaultSettings from './defaultSettings'; ...@@ -6,7 +6,8 @@ import defaultSettings from './defaultSettings';
import webpackPlugin from './plugin.config'; import webpackPlugin from './plugin.config';
const { pwa, primaryColor } = defaultSettings; const { pwa, primaryColor } = defaultSettings;
const { APP_TYPE, TEST } = process.env; // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST } = process.env;
const plugins: IPlugin[] = [ const plugins: IPlugin[] = [
[ [
...@@ -57,8 +58,8 @@ const plugins: IPlugin[] = [ ...@@ -57,8 +58,8 @@ const plugins: IPlugin[] = [
]; ];
// 针对 preview.pro.ant.design 的 GA 统计代码 // 针对 preview.pro.ant.design 的 GA 统计代码
// 业务上不需要这个 // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (APP_TYPE === 'site') { if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
plugins.push([ plugins.push([
'umi-plugin-ga', 'umi-plugin-ga',
{ {
...@@ -71,12 +72,14 @@ export default { ...@@ -71,12 +72,14 @@ export default {
// add for transfer to umi // add for transfer to umi
plugins, plugins,
define: { define: {
APP_TYPE: APP_TYPE || '', ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
}, },
treeShaking: true, treeShaking: true,
targets: { targets: {
ie: 11, ie: 11,
}, },
devtool: ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION ? 'source-map' : false,
// 路由配置 // 路由配置
routes: [ routes: [
{ {
......
...@@ -24,8 +24,11 @@ function getModulePackageName(module) { ...@@ -24,8 +24,11 @@ function getModulePackageName(module) {
} }
export default config => { export default config => {
// pro 和 开发环境再添加这个插件 // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') { if (
process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ||
process.env.NODE_ENV !== 'production'
) {
// 将所有 less 合并为一个供 themePlugin使用 // 将所有 less 合并为一个供 themePlugin使用
const outFile = path.join(__dirname, '../.temp/ant-design-pro.less'); const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
const stylesDir = path.join(__dirname, '../src/'); const stylesDir = path.join(__dirname, '../src/');
......
module.exports = { module.exports = {
testURL: 'http://localhost:8000', testURL: 'http://localhost:8000',
preset: 'jest-puppeteer', preset: 'jest-puppeteer',
extraSetupFiles: ['./tests/setupTests.js'],
globals: { globals: {
APP_TYPE: false, ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
}, },
}; };
...@@ -14,7 +14,7 @@ function parseKey(key) { ...@@ -14,7 +14,7 @@ function parseKey(key) {
method = spliced[0].toLowerCase(); method = spliced[0].toLowerCase();
path = spliced[1]; // eslint-disable-line path = spliced[1]; // eslint-disable-line
} }
const routerBasePath = process.env.NODE_ENV === 'dev' ? `${path}` : `/.netlify/functions${path}`; const routerBasePath = `${path}`;
return { return {
method, method,
path: routerBasePath, path: routerBasePath,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
[[redirects]] [[redirects]]
from = "/api/*" from = "/api/*"
to = "https://us-central1-antd-pro.cloudfunctions.net/api/api/:splat" to = "/.netlify/functions/api/:splat"
status = 200 status = 200
force = true force = true
[redirects.headers] [redirects.headers]
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
"lint:style": "stylelint 'src/**/*.less' --syntax less", "lint:style": "stylelint 'src/**/*.less' --syntax less",
"lint:ts": "tslint -p . -c tslint.yml", "lint:ts": "tslint -p . -c tslint.yml",
"prettier": "node ./scripts/prettier.js", "prettier": "node ./scripts/prettier.js",
"start": "cross-env APP_TYPE=site umi dev", "site": "umi build && npm run functions:build",
"start": "cross-env ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION=site umi dev",
"start:no-mock": "cross-env MOCK=none umi dev", "start:no-mock": "cross-env MOCK=none umi dev",
"test": "umi test", "test": "umi test",
"test:all": "node ./tests/run-tests.js", "test:all": "node ./tests/run-tests.js",
...@@ -111,29 +112,27 @@ ...@@ -111,29 +112,27 @@
"gh-pages": "^2.0.1", "gh-pages": "^2.0.1",
"husky": "^1.3.1", "husky": "^1.3.1",
"jest-puppeteer": "^4.1.0", "jest-puppeteer": "^4.1.0",
"jsdom-global": "^3.0.2",
"less": "^3.9.0", "less": "^3.9.0",
"lint-staged": "^8.1.1", "lint-staged": "^8.1.1",
"merge-umi-mock-data": "^1.0.4", "merge-umi-mock-data": "^1.0.4",
"mockjs": "^1.0.1-beta3", "mockjs": "^1.0.1-beta3",
"netlify-lambda": "^1.4.3", "netlify-lambda": "^1.4.3",
"prettier": "^1.16.4", "prettier": "^1.17.0",
"serverless-http": "^1.9.1", "serverless-http": "^2.0.1",
"slash2": "^2.0.0", "slash2": "^2.0.0",
"stylelint": "^9.10.1", "stylelint": "^9.10.1",
"stylelint-config-css-modules": "^1.3.0", "stylelint-config-css-modules": "^1.3.0",
"stylelint-config-prettier": "^5.0.0", "stylelint-config-prettier": "^5.0.0",
"stylelint-config-rational-order": "^0.0.4", "stylelint-config-rational-order": "^0.1.0",
"stylelint-config-standard": "^18.2.0", "stylelint-config-standard": "^18.2.0",
"stylelint-declaration-block-no-ignored-properties": "^1.1.0", "stylelint-declaration-block-no-ignored-properties": "^2.1.0",
"stylelint-order": "^2.0.0", "stylelint-order": "^2.0.0",
"tslint": "^5.12.1", "tslint": "^5.12.1",
"tslint-config-prettier": "^1.17.0", "tslint-config-prettier": "^1.17.0",
"tslint-eslint-rules": "^5.4.0", "tslint-eslint-rules": "^5.4.0",
"tslint-react": "^3.6.0", "tslint-react": "^3.6.0",
"umi-plugin-ga": "^1.1.3", "umi-plugin-ga": "^1.1.3"
"umi-plugin-pro-block": "^1.3.0",
"umi-plugin-react": "^1.7.2",
"umi-types": "^0.2.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"puppeteer": "^1.12.1" "puppeteer": "^1.12.1"
......
...@@ -7,11 +7,13 @@ const getPrettierFiles = () => { ...@@ -7,11 +7,13 @@ const getPrettierFiles = () => {
const configFiles = glob.sync('config/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] }); const configFiles = glob.sync('config/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] });
const scriptFiles = glob.sync('scripts/**/*.js'); const scriptFiles = glob.sync('scripts/**/*.js');
const lessFiles = glob.sync('src/**/*.less*', { ignore: ['**/node_modules/**', 'build/**'] }); const lessFiles = glob.sync('src/**/*.less*', { ignore: ['**/node_modules/**', 'build/**'] });
const mdFiles = glob.sync('src/**/*.md*', { ignore: ['**/node_modules/**', 'build/**'] });
files = files.concat(jsFiles); files = files.concat(jsFiles);
files = files.concat(tsFiles); files = files.concat(tsFiles);
files = files.concat(configFiles); files = files.concat(configFiles);
files = files.concat(scriptFiles); files = files.concat(scriptFiles);
files = files.concat(lessFiles); files = files.concat(lessFiles);
files = files.concat(mdFiles);
if (!files.length) { if (!files.length) {
return; return;
} }
......
...@@ -3,8 +3,6 @@ import { notification, Button, message } from 'antd'; ...@@ -3,8 +3,6 @@ import { notification, Button, message } from 'antd';
import { formatMessage } from 'umi-plugin-react/locale'; import { formatMessage } from 'umi-plugin-react/locale';
import defaultSettings from '../config/defaultSettings'; import defaultSettings from '../config/defaultSettings';
(window as any).React = React;
const { pwa } = defaultSettings; const { pwa } = defaultSettings;
// if pwa is true // if pwa is true
if (pwa) { if (pwa) {
...@@ -59,4 +57,9 @@ if (pwa) { ...@@ -59,4 +57,9 @@ if (pwa) {
onClose: async () => {}, onClose: async () => {},
}); });
}); });
} else if ('serviceWorker' in navigator) {
// eslint-disable-next-line compat/compat
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
} }
...@@ -32,7 +32,7 @@ const links = [ ...@@ -32,7 +32,7 @@ const links = [
const copyright = ( const copyright = (
<Fragment> <Fragment>
Copyright <Icon type="copyright" /> 2018 蚂蚁金服体验技术部出品 Copyright <Icon type="copyright" /> 2019 蚂蚁金服体验技术部出品
</Fragment> </Fragment>
); );
......
...@@ -14,7 +14,8 @@ let lessNodesAppended: boolean; ...@@ -14,7 +14,8 @@ let lessNodesAppended: boolean;
const updateTheme: (primaryColor?: string) => void = primaryColor => { const updateTheme: (primaryColor?: string) => void = primaryColor => {
// Don't compile less in production! // Don't compile less in production!
if (APP_TYPE !== 'site') { // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION !== 'site') {
return; return;
} }
// Determine if the component is remounted // Determine if the component is remounted
......
...@@ -13,7 +13,8 @@ export function getAuthority(str?: string): any { ...@@ -13,7 +13,8 @@ export function getAuthority(str?: string): any {
if (typeof authority === 'string') { if (typeof authority === 'string') {
return [authority]; return [authority];
} }
if (!authority && APP_TYPE === 'site') { // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
if (!authority && ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
return ['admin']; return ['admin'];
} }
return authority; return authority;
......
import 'jsdom-global/register';
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册