提交 2e8374a7 authored 作者: vipcxj's avatar vipcxj

Merge remote-tracking branch 'scaffold/master'

# Conflicts: # .roadhogrc.js # package.json # src/models/domain.js # src/models/main/index.js # src/router.js # src/routes/domain/index.js # src/routes/main/header.js 更新到最新的脚手架
{
"presets": ["./tools/babel-preset"]
}
{ {
"parser": "babel-eslint", "parser": "babel-eslint",
"extends": "airbnb", "extends": ["airbnb", "plugin:lodash-fp/recommended"],
"rules": { "rules": {
"generator-star-spacing": [0], "generator-star-spacing": [0],
"consistent-return": [0], "consistent-return": [0],
...@@ -25,11 +25,27 @@ ...@@ -25,11 +25,27 @@
"require-yield": [1], "require-yield": [1],
"no-plusplus": "off", "no-plusplus": "off",
"no-mixed-operators": "off", "no-mixed-operators": "off",
"max-len": [0, 120] "max-len": [0, 120],
"object-curly-newline": "off",
"padded-blocks": "off",
"function-paren-newline": "off",
"jsx-a11y/anchor-is-valid": "off",
"no-multi-assign": "off",
"no-await-in-loop": "off",
"prefer-destructuring": "off",
"lines-between-class-members": "off",
"no-multiple-empty-lines": "off",
"react/require-default-props": "off",
"react/no-array-index-key": "off",
"react/destructuring-assignment": "off",
"react/jsx-one-expression-per-line": "off",
"lodash-fp/use-fp": "off",
"lodash-fp/no-unused-result": "off"
}, },
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"experimentalObjectRestSpread": true "experimentalObjectRestSpread": true
} }
} },
"plugins": ["lodash-fp"]
} }
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
/.cache-loader
# dependencies # dependencies
/node_modules /node_modules
...@@ -10,5 +12,8 @@ ...@@ -10,5 +12,8 @@
.DS_Store .DS_Store
npm-debug.log* npm-debug.log*
/.idea
/storybook-static /storybook-static
jsCodeStructure.html
/webpack/**
!/webpack/.gitkeep
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
const proxy = {
"target": "http://192.168.1.22:8080",
"changeOrigin": true,
"pathRewrite": {
"^/api": "/app/api"
}
};
const resource_proxy = {
"target": "http://192.168.1.22:8080",
"changeOrigin": true,
"pathRewrite": {
"^/resource": "/app/resource"
}
};
module.exports = {
"entry": "src/index.js",
"theme": {
"layout-header-height": "48px",
"layout-header-background": "#fff",
"layout-footer-background": "#fff",
"layout-sider-background": '#404040',
'menu-dark-bg': '#404040',
"layout-header-padding": "0",
},
"env": {
"development": {
"extraBabelPlugins": [
"dva-hmr",
"transform-runtime",
["import", { "libraryName": "antd", "style": true }]
],
"proxy": {
"/api": proxy,
"/resource": resource_proxy,
}
},
"production": {
publicPath: "/app/console/",
define: {
contextPath: "/app/console",
apiContextPath: "/app"
},
"extraBabelPlugins": [
"transform-runtime",
["import", { "libraryName": "antd", "style": true }]
]
}
}
};
const oldRequire = require.extensions['.js'];
const babelRegister = require('./babel-register');
const babelRequire = require.extensions['.js'];
require.extensions = (m, filename) => {
oldRequire(m, filename);
delete require.cache[filename];
return babelRequire(m, filename);
};
module.exports = require('./mock');
babelRegister.unregister();
{ {
"presets": [ "presets": ["../tools/babel-preset"]
"es2015",
"es2016",
"es2017",
"stage-0",
"react"
],
"plugins": [
"dva-hmr",
"transform-runtime",
["import", { "libraryName": "antd", "style": true }]
]
} }
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */ /* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions */
import 'babel-polyfill'; import '@babel/polyfill';
import { configure } from '@storybook/react'; import { configure } from '@storybook/react';
function loadStories() { import('../stories').then((stories) => {
require('../stories'); configure(() => stories, module);
} });
configure(loadStories, module);
require('../babel-register');
const createProxy = require('http-proxy-middleware'); const createProxy = require('http-proxy-middleware');
const _ = require('lodash'); const forEach = require('lodash/forEach');
const assert = require('assert'); require('../babel-register');
const proxy = require('../proxy');
const roadhog = require('../.roadhogrc'); const mock = require('../mock');
const mock = require('../.roadhogrc.mock'); const applyMock = require('../tools/applyMock');
function parseKey(key) {
let method = 'get';
let path = key;
if (key.indexOf(' ') > -1) {
const splited = key.split(' ');
method = splited[0].toLowerCase();
path = splited[1];
}
return { method, path };
}
function makeProxy(method, path, target) {
const filter = (pathname, req) => {
return path.test(pathname) && req.method === method.toUpperCase();
};
return createProxy(filter, { target });
}
function createMockHandler(value) {
return function mockHandler(...args) {
const res = args[1];
if (typeof value === 'function') {
value(...args);
} else {
res.json(value);
}
};
}
module.exports = (router) => { module.exports = (app) => {
const proxy = roadhog.env.development.proxy; forEach(proxy, (value, key) => {
_.forEach(proxy, (value, key) => { app.use(key, createProxy(key, value));
router.use(key, createProxy(key, value));
}); });
_.forEach(mock, (value, key) => { applyMock(app, mock);
const parsedkey = parseKey(key);
assert(
typeof value === 'function' ||
typeof value === 'object' ||
typeof value === 'string',
`mock value of ${key} should be function or object or string, but got ${typeof value}`
);
if (typeof value === 'string') {
let path = parsedkey.path;
if (/\(.+\)/.test(parsedkey.path)) {
path = new RegExp(`^${parsedkey.path}$`);
}
router.use(
path,
makeProxy(parsedkey.method, path, value)
);
} else {
router[parsedkey.method](
parsedkey.path,
createMockHandler(value)
);
}
})
}; };
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js'); let config;
const path = require('path');
module.exports = (baseConfig, env) => { if (process.env.NODE_ENV === 'production') {
const config = genDefaultConfig(baseConfig, env); config = require('../webpack.prod');
} else {
// Extend it as you need. config = require('../webpack.dev');
}
// For example, add typescript loader: module.exports = (baseConfig, env) => {
config.module.rules.push({ baseConfig.resolve.extensions = config.resolve.extensions;
test: /\.less$/, baseConfig.module.rules = config.module.rules;
include: path.resolve(__dirname, '../src'), return baseConfig;
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
modules: true,
},
},
require.resolve('less-loader')
],
}, {
test: /\.less$/,
exclude: path.resolve(__dirname, '../src'),
use: [
require.resolve('style-loader'),
require.resolve('css-loader'),
require.resolve('less-loader')
],
});
return config;
}; };
/* eslint-disable comma-dangle */ /* eslint-disable comma-dangle */
const babel = require('@babel/register/lib/node');
const path = require('path');
const babel = require('./my-babel-register'); babel.default({
babel.default(({
presets: [ presets: [
'es2015', ['./tools/babel-preset', {
'react' modules: 'commonjs',
}],
],
babelrc: false,
only: [
path.resolve(__dirname, 'src/**/*'),
path.resolve(__dirname, 'stories/**/*'),
path.resolve(__dirname, 'mock/**/*'),
] ]
})); });
// require('@babel/runtime');
module.exports = { module.exports = {
unregister() { unregister() {
babel.hookExtensions([]); babel.default({
extensions: [],
});
}, },
}; };
/* eslint-disable */
exports.__esModule = true;
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
exports.save = save;
exports.load = load;
exports.get = get;
var _path = require("path");
var _path2 = _interopRequireDefault(_path);
var _fs = require("fs");
var _fs2 = _interopRequireDefault(_fs);
var _mkdirp = require("mkdirp");
var _homeOrTmp = require("home-or-tmp");
var _homeOrTmp2 = _interopRequireDefault(_homeOrTmp);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var FILENAME = process.env.BABEL_CACHE_PATH || _path2.default.join(_homeOrTmp2.default, ".babel.json");
var data = {};
function save() {
var serialised = "{}";
try {
serialised = (0, _stringify2.default)(data, null, " ");
} catch (err) {
if (err.message === "Invalid string length") {
err.message = "Cache too large so it's been cleared.";
console.error(err.stack);
} else {
throw err;
}
}
(0, _mkdirp.sync)(_path2.default.dirname(FILENAME));
_fs2.default.writeFileSync(FILENAME, serialised);
}
function load() {
if (process.env.BABEL_DISABLE_CACHE) return;
process.on("exit", save);
process.nextTick(save);
if (!_fs2.default.existsSync(FILENAME)) return;
try {
data = JSON.parse(_fs2.default.readFileSync(FILENAME));
} catch (err) {
return;
}
}
function get() {
return data;
}
const makeSureEndsWithSlash = (path) => {
if (!path || !path.endsWith('/')) {
return `${path || ''}/`;
} else {
return path;
}
};
const makeSureStartsWithSlash = (path) => {
if (!path || !path.startsWith('/')) {
return `/${path || ''}`;
} else {
return path;
}
};
const tripEndSlash = (path) => {
if (path && path.endsWith('/')) {
return path.slice(0, path.length - 1);
} else {
return path;
}
};
const contextPathDev = '';
const contextPathProd = 'bm/console';
const apiContextPathDev = '';
const apiContextPathProd = 'bm';
module.exports = {
dev: {
publicPath: makeSureEndsWithSlash(makeSureStartsWithSlash(contextPathDev)),
basename: tripEndSlash(makeSureStartsWithSlash(contextPathDev)),
contextPath: tripEndSlash(makeSureStartsWithSlash(contextPathDev)),
apiContextPath: tripEndSlash(makeSureStartsWithSlash(apiContextPathDev)),
},
prod: {
publicPath: makeSureEndsWithSlash(makeSureStartsWithSlash(contextPathProd)),
basename: tripEndSlash(makeSureStartsWithSlash(contextPathProd)),
contextPath: tripEndSlash(makeSureStartsWithSlash(contextPathProd)),
apiContextPath: tripEndSlash(makeSureStartsWithSlash(apiContextPathProd)),
},
};
/* eslint-disable no-shadow */ /* eslint-disable no-shadow */
import moment from 'moment'; import moment from 'moment';
import { genModules } from './src/mock/modules'; import { genModules } from '../src/mock/modules';
import { getTasks } from './src/mock/tasks'; import { getTasks } from '../src/mock/tasks';
import toFilters from './src/mock/filter'; import toFilters from '../src/mock/filter';
const modules = genModules(); const modules = genModules();
const tasks = getTasks(); const tasks = getTasks();
const users = [
{
userId: 1,
userName: 'cxj',
tokenId: '12345-65432-abcdef',
expire: -1,
},
];
let currentUser = users[0];
const domains = [ const domains = [
{ {
id: 1, id: 1,
...@@ -47,8 +36,7 @@ const getDomain = (id) => { ...@@ -47,8 +36,7 @@ const getDomain = (id) => {
}; };
const dealWithData = (req) => { const dealWithData = (req) => {
const sort = req.query.sort; const { sort, order } = req.query;
const order = req.query.order;
const filters = []; const filters = [];
for (const queryKey in req.query) { for (const queryKey in req.query) {
if (queryKey.indexOf('f-') === 0) { if (queryKey.indexOf('f-') === 0) {
...@@ -114,7 +102,7 @@ module.exports = { ...@@ -114,7 +102,7 @@ module.exports = {
}, },
'/api/domain/all': wrapResponse(domains), '/api/domain/all': wrapResponse(domains),
'/api/domain/switch': (req, res) => { '/api/domain/switch': (req, res) => {
const domainId = req.query.domainId; const { domainId } = req.query;
const intDomainId = parseInt(domainId, 10); const intDomainId = parseInt(domainId, 10);
const domainIds = domains.map(domain => domain.id); const domainIds = domains.map(domain => domain.id);
if (domainIds.indexOf(intDomainId) !== -1) { if (domainIds.indexOf(intDomainId) !== -1) {
...@@ -136,7 +124,7 @@ module.exports = { ...@@ -136,7 +124,7 @@ module.exports = {
}, },
'/api/module/all/info': (req, res) => { '/api/module/all/info': (req, res) => {
console.log('/api/module/all/info'); console.log('/api/module/all/info');
const all = modules.all; const { all } = modules;
const publics = modules.public; const publics = modules.public;
const findModule = id => all.filter(m => m.id === id).pop(); const findModule = id => all.filter(m => m.id === id).pop();
const fetchParent = (module) => { const fetchParent = (module) => {
......
/* eslint-disable */
exports.__esModule = true;
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
exports.default = function () {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (opts.only != null) only = _babelCore.util.arrayify(opts.only, _babelCore.util.regexify);
if (opts.ignore != null) ignore = _babelCore.util.arrayify(opts.ignore, _babelCore.util.regexify);
if (opts.extensions) hookExtensions(_babelCore.util.arrayify(opts.extensions));
if (opts.cache === false) cache = null;
delete opts.extensions;
delete opts.ignore;
delete opts.cache;
delete opts.only;
(0, _extend2.default)(transformOpts, opts);
};
var _cloneDeep = require("lodash/cloneDeep");
var _cloneDeep2 = _interopRequireDefault(_cloneDeep);
var _sourceMapSupport = require("source-map-support");
var _sourceMapSupport2 = _interopRequireDefault(_sourceMapSupport);
var _cache = require("./cache");
var registerCache = _interopRequireWildcard(_cache);
var _extend = require("lodash/extend");
var _extend2 = _interopRequireDefault(_extend);
var _babelCore = require("babel-core");
var babel = _interopRequireWildcard(_babelCore);
var _fs = require("fs");
var _fs2 = _interopRequireDefault(_fs);
var _path = require("path");
var _path2 = _interopRequireDefault(_path);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_sourceMapSupport2.default.install({
handleUncaughtExceptions: false,
environment: "node",
retrieveSourceMap: function retrieveSourceMap(source) {
var map = maps && maps[source];
if (map) {
return {
url: null,
map: map
};
} else {
return null;
}
}
});
registerCache.load();
var cache = registerCache.get();
var transformOpts = {};
var ignore = void 0;
var only = void 0;
var oldHandlers = {};
var maps = {};
var cwd = process.cwd();
function getRelativePath(filename) {
return _path2.default.relative(cwd, filename);
}
function mtime(filename) {
return +_fs2.default.statSync(filename).mtime;
}
function compile(filename) {
var result = void 0;
var opts = new _babelCore.OptionManager().init((0, _extend2.default)({ sourceRoot: _path2.default.dirname(filename) }, (0, _cloneDeep2.default)(transformOpts), { filename: filename }));
var cacheKey = (0, _stringify2.default)(opts) + ":" + babel.version;
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
if (env) cacheKey += ":" + env;
if (cache) {
var cached = cache[cacheKey];
if (cached && cached.mtime === mtime(filename)) {
result = cached;
}
}
if (!result) {
result = babel.transformFileSync(filename, (0, _extend2.default)(opts, {
babelrc: false,
sourceMaps: "both",
ast: false
}));
}
if (cache) {
cache[cacheKey] = result;
result.mtime = mtime(filename);
}
maps[filename] = result.map;
return result.code;
}
function shouldIgnore(filename) {
if (!ignore && !only) {
return getRelativePath(filename).split(_path2.default.sep).indexOf("node_modules") >= 0;
} else {
return _babelCore.util.shouldIgnore(filename, ignore || [], only);
}
}
function loader(m, filename) {
m._compile(compile(filename), filename);
}
function registerExtension(ext) {
var old = oldHandlers[ext] || oldHandlers[".js"] || require.extensions[".js"];
require.extensions[ext] = function (m, filename) {
if (shouldIgnore(filename)) {
old(m, filename);
} else {
loader(m, filename, old);
}
};
}
function hookExtensions(_exts) {
(0, _keys2.default)(oldHandlers).forEach(function (ext) {
var old = oldHandlers[ext];
if (old === undefined) {
delete require.extensions[ext];
} else {
require.extensions[ext] = old;
}
});
oldHandlers = {};
_exts.forEach(function (ext) {
oldHandlers[ext] = require.extensions[ext];
registerExtension(ext);
});
}
exports.hookExtensions = hookExtensions;
exports.exts = _babelCore.util.canCompile.EXTENSIONS;
hookExtensions(exports.exts);
module.exports = exports;
This source diff could not be displayed because it is too large. You can view the blob instead.
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论