提交 5b1795fc authored 作者: vipcxj's avatar vipcxj

backup

上级 62bf5217
......@@ -10,6 +10,8 @@
<w>roadhog</w>
<w>sizeme</w>
<w>splited</w>
<w>unnormed</w>
<w>unregister</w>
<w>yyyy</w>
</words>
</dictionary>
......
const proxy = {
"target": "http://192.168.1.121:1180",
"changeOrigin": true,
"pathRewrite": {
"^/api": "/houseServer/restful-services"
}
};
module.exports = {
"entry": "src/index.js",
"theme": {
......@@ -15,14 +23,11 @@ module.exports = {
"transform-runtime",
["import", { "libraryName": "antd", "style": true }]
],
"no-proxy": {
"/api": {
"target": "http://192.168.1.121:1180",
"changeOrigin": true,
"pathRewrite": {
"^/api": "/houseServer/restful-services"
}
}
"proxy": {
"/api/user/login2": proxy,
"/api/domain": proxy,
"/api/datasource": proxy,
"/api/modules": proxy,
}
},
"production": {
......@@ -32,4 +37,4 @@ module.exports = {
]
}
}
}
};
const moment = require('moment');
const { genModules } = require('./src/mock/modules');
const { getTasks } = require('./src/mock/tasks');
const toFilters = require('./mock/filter');
const modules = genModules();
const tasks = getTasks();
const users = [
{
userId: 1,
userName: 'cxj',
tokenId: '12345-65432-abcdef',
expire: -1,
},
];
let currentUser = users[0];
const domains = [
{
id: 1,
name: '虚拟基地01',
},
{
id: 2,
name: '虚拟基地02',
},
{
id: 3,
name: '虚拟基地03',
},
{
id: 4,
name: '虚拟基地04',
},
{
id: 5,
name: '虚拟基地05',
},
];
const getDomain = (id) => {
const domain = domains.filter(domain => domain.id === id);
return domain ? domain[0] : null;
};
const dealWithData = (req) => {
const sort = req.query.sort;
const order = req.query.order;
const filters = [];
for (const queryKey in req.query) {
if (queryKey.indexOf('f-') === 0) {
filters.push(toFilters(queryKey, req.query[queryKey]));
}
}
let data = tasks.filter((value) => {
return filters.map(filter => filter(value)).reduce((ret, cur) => ret && cur, true);
});
if (sort) {
data = data.sort((a, b) => {
const va = a[sort];
const vb = b[sort];
if (order === 'desc') {
if (moment.isMoment(va) || moment.isDate(va) || moment.isMoment(vb) || moment.isDate(vb)) {
if (moment(va).isAfter(moment(vb))) {
return 1;
} else if (moment(va).isSame(moment(vb))) {
return 0;
} else {
return -1;
}
} else {
if (va > vb) {
return 1;
} else if (va === vb) {
return 0;
} else {
return -1;
}
}
} else {
if (moment.isMoment(va) || moment.isDate(va) || moment.isMoment(vb) || moment.isDate(vb)) {
if (moment(va).isBefore(moment(vb))) {
return 1;
} else if (moment(va).isSame(moment(vb))) {
return 0;
} else {
return -1;
}
} else {
if (va < vb) {
return 1;
} else if (va === vb) {
return 0;
} else {
return -1;
}
}
}
})
}
return data;
};
let currentDomainId = null;
module.exports = {
'/api/user/login2': (req, res) => {
currentUser = users[0];
res.send(currentUser);
},
'/api/user/logout': (req, res) => {
res.status(204).end();
},
'/api/domain/all': domains,
'/api/domain/switch': (req, res) => {
const domainId = req.query.domainId;
const intDomainId = parseInt(domainId);
const domainIds = domains.map(domain => domain.id);
if (domainIds.indexOf(intDomainId) !== -1) {
if (currentDomainId) {
res.send(getDomain(currentDomainId));
} else {
res.status(204).end();
}
currentDomainId = intDomainId;
} else {
res.status(500).send({
errorCode: 0x00010010,
message: '无效的项目ID。',
});
}
},
'/api/domain/current': (req, res) => {
res.send(getDomain(currentDomainId));
},
'/api/module/all/info': (req, res) => {
const all = modules.all;
const publics = modules.public;
const findModule = (id) => all.filter(m => m.id === id).pop();
const fetchParent = (module) => {
if (module.parent) {
const parent = findModule(module.parent);
return parent ? [parent, ...fetchParent(parent)] : [];
} else {
return [];
}
};
const parents = new Set();
publics.map(m => {
const _p = fetchParent(m);
_p.map(p => {
parents.add(p);
});
});
res.send([
...publics,
...parents,
]);
},
'/api/bpm/task/all/count': (req, res) => {
res.send(`${dealWithData(req).length}`);
},
'/api/bpm/task/all/info': (req, res) => {
const pst = Number.parseInt(req.query.pst);
const psz = Number.parseInt(req.query.psz);
res.send(dealWithData(req).slice(pst, pst + psz));
},
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();
require('babel-register')({
presets: [
'es2015',
'es2016',
'stage-0'
]
});
require('../babel-register');
const createProxy = require('http-proxy-middleware');
const _ = require('lodash');
const assert = require('assert');
......@@ -45,7 +39,7 @@ function createMockHandler(value) {
}
module.exports = (router) => {
const proxy = roadhog.env.proxy;
const proxy = roadhog.env.development.proxy;
_.forEach(proxy, (value, key) => {
router.use(key, createProxy(key, value));
});
......
/* eslint-disable comma-dangle */
const babel = require('./my-babel-register');
babel.default(({
presets: [
'es2015',
'react'
]
}));
module.exports = {
unregister() {
babel.hookExtensions([]);
},
};
/* 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;
}
/* eslint-disable no-shadow */
import moment from 'moment';
import { genModules } from './src/mock/modules';
import { getTasks } from './src/mock/tasks';
import toFilters from './src/mock/filter';
const modules = genModules();
const tasks = getTasks();
const users = [
{
userId: 1,
userName: 'cxj',
tokenId: '12345-65432-abcdef',
expire: -1,
},
];
let currentUser = users[0];
const domains = [
{
id: 1,
name: '虚拟基地01',
},
{
id: 2,
name: '虚拟基地02',
},
{
id: 3,
name: '虚拟基地03',
},
{
id: 4,
name: '虚拟基地04',
},
{
id: 5,
name: '虚拟基地05',
},
];
const getDomain = (id) => {
const domain = domains.filter(domain => domain.id === id);
return domain ? domain[0] : null;
};
const dealWithData = (req) => {
const sort = req.query.sort;
const order = req.query.order;
const filters = [];
for (const queryKey in req.query) {
if (queryKey.indexOf('f-') === 0) {
filters.push(toFilters(queryKey, req.query[queryKey]));
}
}
let data = tasks.filter((value) => {
return filters.map(filter => filter(value)).reduce((ret, cur) => ret && cur, true);
});
if (sort) {
data = data.sort((a, b) => {
const va = a[sort];
const vb = b[sort];
if (order === 'desc') {
if (moment.isMoment(va) || moment.isDate(va) || moment.isMoment(vb) || moment.isDate(vb)) {
if (moment(va).isAfter(moment(vb))) {
return 1;
} else if (moment(va).isSame(moment(vb))) {
return 0;
} else {
return -1;
}
} else if (va > vb) {
return 1;
} else if (va === vb) {
return 0;
} else {
return -1;
}
} else if (moment.isMoment(va) || moment.isDate(va) || moment.isMoment(vb) || moment.isDate(vb)) {
if (moment(va).isBefore(moment(vb))) {
return 1;
} else if (moment(va).isSame(moment(vb))) {
return 0;
} else {
return -1;
}
} else if (va < vb) {
return 1;
} else if (va === vb) {
return 0;
} else {
return -1;
}
});
}
return data;
};
let currentDomainId = null;
module.exports = {
'/api/user/login2': (req, res) => {
currentUser = users[0];
res.send(currentUser);
},
'/api/user/logout': (req, res) => {
res.status(204).end();
},
'/api/domain/all': domains,
'/api/domain/switch': (req, res) => {
const domainId = req.query.domainId;
const intDomainId = parseInt(domainId, 10);
const domainIds = domains.map(domain => domain.id);
if (domainIds.indexOf(intDomainId) !== -1) {
if (currentDomainId) {
res.send(getDomain(currentDomainId));
} else {
res.status(204).end();
}
currentDomainId = intDomainId;
} else {
res.status(500).send({
errorCode: 0x00010010,
message: '无效的项目ID。',
});
}
},
'/api/domain/current': (req, res) => {
res.send(getDomain(currentDomainId));
},
'/api/module/all/info': (req, res) => {
console.log('/api/module/all/info');
const all = modules.all;
const publics = modules.public;
const findModule = id => all.filter(m => m.id === id).pop();
const fetchParent = (module) => {
if (module.parent) {
const parent = findModule(module.parent);
return parent ? [parent, ...fetchParent(parent)] : [];
} else {
return [];
}
};
const parents = new Set();
publics.forEach((m) => {
const p0 = fetchParent(m);
p0.forEach((p) => {
parents.add(p);
});
});
res.send([
...publics,
...parents,
]);
},
'/api/bpm/task/all/count': (req, res) => {
res.send(`${dealWithData(req).length}`);
},
'/api/bpm/task/all/info': (req, res) => {
const pst = Number.parseInt(req.query.pst, 10);
const psz = Number.parseInt(req.query.psz, 10);
res.send(dealWithData(req).slice(pst, pst + psz));
},
};
/* 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;
......@@ -40,6 +40,7 @@
"babel-plugin-transform-runtime": "^6.9.0",
"babel-preset-es2016": "^6.24.1",
"babel-preset-es2017": "^6.24.1",
"babel-register": "^6.24.1",
"chai": "^4.0.2",
"cross-env": "^5.0.1",
"enzyme": "^2.9.1",
......@@ -58,6 +59,6 @@
"path": "^0.12.7",
"react-test-renderer": "^15.6.1",
"redbox-react": "^1.3.2",
"roadhog": "^0.6.0"
"roadhog": "^1.0.0-beta.7"
}
}
import React, { Component } from 'react';
import { connect as dvaConnect } from 'dva';
import _, { startsWith } from 'lodash';
import { getApp } from '../../data/app';
const connect = (modelCreator, { app, mapStateToProps, mapDispatchToProps, mergeProps, options }) => (Comp) => {
......@@ -20,11 +21,20 @@ const connect = (modelCreator, { app, mapStateToProps, mapDispatchToProps, merge
const props = mapStateToProps ? mapStateToProps(state) : {};
props[name] = state[model.namespace];
props[namespaceVar || 'namespace'] = model.namespace;
if (state.loading) {
props.loading = state.loading;
props.loading.model = props.loading.models[model.namespace];
props.loading.effect = _(props.loading.effects)
.pickBy((v, k) => startsWith(k, `${model.namespace}/`))
.mapKeys((v, k) => k.slice(model.namespace.length + 1))
.value();
}
return props;
};
const mapDispatch = (dispatch) => {
const extras = mapDispatchToProps ? mapDispatchToProps(dispatch) : {};
return {
dispatch,
...extras,
[dispatchVar || 'dispatchLocal'](action) {
const { type, payload } = action;
......
......@@ -110,7 +110,7 @@ class DsTable extends React.Component {
dataSource: list,
columns,
filters: this.state.filters.map(filter => filter.filter),
loading: this.props.loading.effects[`${this.props.namespace}/fetchTasks`],
loading: this.props.loading.effect.fetchTasks,
pagination: {
current: this.state.current,
total: num,
......
import moment from 'moment';
import uuid from 'uuid/v4';
import _ from 'lodash';
import {} from '../../../services/modules';
import { countTasks, fetchTasks } from '../../../services/bpm';
import config from '../../../utils/config';
const prefix = uuid();
......@@ -30,20 +33,25 @@ const modelCreator = () => {
},
},
effects: {
*fetchTasks({ payload: { pst, psz, filters } }, { put }) {
console.log('fetchTasks');
const num = 100;
// *fetchData({ payload: { coordinate, pst, psz, params, filters} }, { put, call }) {
//
// }
*fetchTasks({ payload: { pst, psz, filters } }, { put, call }) {
const num = Number.parseInt(yield call(countTasks, filters), 10);
yield put({ type: 'queryCountSuccess', payload: num });
const tasks = yield call(fetchTasks, { pst, psz, filters });
yield put({
type: 'queryTasksSuccess',
payload: _.range(0, num).map(idx => ({
key: idx.toString(),
pName: `流程${idx}`,
nName: `任务${idx}`,
state: `状态${(idx / 3 | 0) + 1}`,
date: moment(),
deadline: moment(),
})),
payload: tasks.map((task) => {
return {
key: `${task.pId}-${task.nId}`,
pName: task.pName,
nName: task.nName,
state: task.state,
date: moment(task.date, config.defaultDateTimeFormat),
deadline: moment(task.deadline, config.defaultDateTimeFormat),
};
}),
});
},
},
......
......@@ -55,13 +55,6 @@ abbr, acronym {
border: 0;
}
a {
text-decoration: none;
color: #000000;
font-size: 15px;
/*字体*/
}
li {
list-style: none;
}
......
import moment from 'moment';
const findSep = (value, offset = 0) => {
const find = value.indexOf('|', offset);
if (find !== -1) {
let count = 0;
let from = find;
while (value[--from] === '#') ++count;
if (count % 2 === 1) {
return findSep(value, find + 1);
} else {
return find;
}
} else {
return -1;
}
};
const transform = (value) => {
const find = value.indexOf('#');
if (find !== -1) {
const left = value.slice(0, find);
const me = value[find + 1] ? value[find + 1] : '';
const right = value.slice(find + 2);
return `${left}${me}${transform(right)}`;
} else {
return value;
}
};
const split = (value) => {
const ret = [];
let offset = 0;
let posSep = -1;
do {
posSep = findSep(value, offset);
if (posSep !== -1) {
ret.push(transform(value.slice(offset, posSep)));
offset = posSep + 1;
}
} while (posSep !== -1);
ret.push(transform(value.slice(offset)));
return ret;
};
const is = (obj, type) => {
return (type === 'Null' && obj === null) ||
(type === 'Undefined' && obj === void 0) || // eslint-disable-line no-void
(type === 'Number' && isFinite(obj)) ||
Object.prototype.toString.call(obj).slice(8, -1) === type;
};
import { split } from '../utils/filter';
import { is } from '../utils/helper';
const parseExpr = (valueExpr) => {
let valueExpr0 = valueExpr.replace(/\s+/, '');
......@@ -186,7 +138,7 @@ const toFunction = (keysExpr, valueExpr) => {
};
};
const toFunctions = (keysExpr, valueExpr) => {
const toFilters = (keysExpr, valueExpr) => {
const keys = split(keysExpr);
const values = split(valueExpr);
if (keys.length !== values.length) {
......@@ -209,4 +161,4 @@ const toFunctions = (keysExpr, valueExpr) => {
};
};
export default toFunctions;
export default toFilters;
import { mapKeys, toPairs, isUndefined } from 'lodash';
import request, { normParams } from '../utils/request';
import { split } from '../utils/filter';
import { is } from '../utils/helper';
const parseFilters = filtersIn => (filtersIn || []).map(({ key, filter }) => [
`f-${split(key).map(value => value.replace(/#/g, '##').replace(/|/g, '#|')).join('|')}`,
filter,
]);
// const parseCoordinate = (coordinate) => {
// if (is(coordinate, 'String')) {
// return {
// query:
// }
// }
// }
export async function calcDatasource(coordinate, { pst, psz, filters = [], params = {} }) {
const queryParams = [
...toPairs({ pst, psz }),
...parseFilters(filters),
...normParams(mapKeys(params, (v, k) => `p-${k}`)),
].filter(isUndefined);
return request(`/api/datasource/${name}`, queryParams);
}
export async function countDatasource(name, { filters = [], params = {} }) {
const queryParams = [
...parseFilters(filters),
...normParams(mapKeys(params, (v, k) => `p-${k}`)),
].filter(isUndefined);
return request(`/api/datasource/${name}/count`, queryParams);
}
export async function getDatasourceMeta(name) {
return request(`/api/datasource/${name}`);
}
import request from '../utils/request';
export async function allModuleInfos() {
return request('/api/modules/info');
}
export async function getModuleConfigure(name) {
return request(`/api/modules/module/${name}/configure`);
}
/**
* Created by yaohx_169 on 2017/6/6.
*/
import { createError } from './error';
export const cookie = {
token: 'token',
......@@ -14,13 +13,6 @@ export const storage = {
domainName: 'domainName',
};
export const errors = {
unLogin: createError({
code: 1,
msg: '未登录',
}),
};
export const api = {
userLogin: '/user/login',
userLogout: '/user/logout',
......
......@@ -39,3 +39,10 @@ export function createError({ code, msg }) {
};
return error;
}
export const errors = {
unLogin: createError({
code: 1,
msg: '未登录',
}),
};
const findSep = (value, offset = 0) => {
const find = value.indexOf('|', offset);
if (find !== -1) {
let count = 0;
let from = find;
while (value[--from] === '#') ++count;
if (count % 2 === 1) {
return findSep(value, find + 1);
} else {
return find;
}
} else {
return -1;
}
};
const transform = (value) => {
const find = value.indexOf('#');
if (find !== -1) {
const left = value.slice(0, find);
const me = value[find + 1] ? value[find + 1] : '';
const right = value.slice(find + 2);
return `${left}${me}${transform(right)}`;
} else {
return value;
}
};
export const split = (value) => {
const ret = [];
let offset = 0;
let posSep = -1;
do {
posSep = findSep(value, offset);
if (posSep !== -1) {
ret.push(transform(value.slice(offset, posSep)));
offset = posSep + 1;
}
} while (posSep !== -1);
ret.push(transform(value.slice(offset)));
return ret;
};
/* eslint-disable */
if (typeof window === 'undefined') {
var window = global;
}
/**
* Created by yaohx_169 on 2017/6/7.
*/
......@@ -114,11 +119,11 @@
}
return c;
}
if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
if(j_lm && (typeof navigator !== 'undefined' && navigator.appName == "Microsoft Internet Explorer")) {
BigInteger.prototype.am = am2;
dbits = 30;
}
else if(j_lm && (navigator.appName != "Netscape")) {
else if(j_lm && (typeof navigator !== 'undefined' && navigator.appName != "Netscape")) {
BigInteger.prototype.am = am1;
dbits = 26;
}
......@@ -1909,7 +1914,7 @@
}));
},
nav = navigator,
nav = typeof navigator !== 'undefined' ? navigator : undefined,
o = {
ie: 0,
opera: 0,
......@@ -1931,7 +1936,7 @@
},
ua = agent || (navigator && navigator.userAgent),
loc = window && window.location,
loc = typeof window !== 'undefined' && window.location,
href = loc && loc.href,
m;
......@@ -2106,7 +2111,7 @@
* @name KJUR
* @namespace kjur's class library name space
*/
if (typeof KJUR == "undefined" || !KJUR) KJUR = {};
if (typeof KJUR == "undefined" || !KJUR) var KJUR = {};
/**
* kjur's ASN.1 class library name space
......@@ -3301,7 +3306,10 @@
};
// export globals
window.Hex = Hex;
if (typeof window !== 'undefined')
window.Hex = Hex;
else if (typeof global !== 'undefined')
global.Hex = Hex;
})();
// Base64 JavaScript decoder
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
......@@ -3387,7 +3395,10 @@
};
// export globals
window.Base64 = Base64;
if (typeof window !== 'undefined')
window.Base64 = Base64;
else if (typeof global !== 'undefined')
global.Base64 = Base64;
})();
// ASN.1 JavaScript decoder
// Copyright (c) 2008-2013 Lapo Luchini <lapo@lapo.it>
......@@ -3922,7 +3933,10 @@
};
// export globals
window.ASN1 = ASN1;
if (typeof window !== 'undefined')
window.ASN1 = ASN1;
else if (typeof global !== 'undefined')
global.ASN1 = ASN1;
})();
/**
* Retrieve the hexadecimal value (as a string) of the current ASN.1 element
......
import fetch from 'dva/fetch';
import _ from 'lodash';
import { getCookie, encrypt } from '../utils/helper';
import { cookie, errors } from '../utils/config';
import { cookie } from '../utils/config';
import { errors } from '../utils/error';
// eslint-disable-next-line max-len
function parseObject(response, { num2str = true, bool2str = true, nul2str = false, ud2str = false, nil2str = false } = {}) {
......@@ -87,6 +88,10 @@ function checkStatus(response) {
});
}
const defaultOptions = {
headers: { Accept: 'application/json' },
};
/**
* Requests a URL, returning a promise.
*
......@@ -105,22 +110,22 @@ export default function request(url, params = {}, options = {}, auth = true) {
}
token = encrypt(token);
}
let queryParams;
if (Array.isArray(params)) {
queryParams = [...params, ['token', token]];
} else {
queryParams = _(token ? { ...params, token } : params)
.toPairs();
}
let queryParams = token ? [...normParams(params), ['token', token]] : normParams(params);
queryParams = queryParams.map(([k, v]) => (_.isNil(v) ? k : `${k}=${encodeURIComponent(v)}`));
queryParams = queryParams.join('&');
let realUrl = url;
if (queryParams) {
realUrl = `${url}?${queryParams}`;
}
return fetch(realUrl, options)
return fetch(realUrl, _.defaults(options, defaultOptions))
.then(checkStatus)
.then(parseObject);
// .then(data => ({ data }));
// .catch(err => ({ err }));
}
export function normParams(unnormed) {
if (_.isPlainObject(unnormed)) {
return _(unnormed).toPairs().flatMap(([k, v]) => (_.isArray(v) ? v.map(vv => [k, vv]) : [[k, v]])).value();
} else {
return unnormed;
}
}
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import dva from 'dva';
import createLoading from 'dva-loading';
import { Button, Welcome } from '@storybook/react/demo';
import DsTable from '../src/components/table/dstable';
storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
import { login } from '../src/services/login';
import { switchDomain } from '../src/services/domain';
import { allModuleInfos, getModuleConfigure } from '../src/services/modules';
import { setCookie, setLocalStorge } from '../src/utils/helper';
import { cookie, storage } from '../src/utils/config';
const loginIt = async (userName, password, domainId) => {
const result = await login({ userName, password });
const { tokenId, userId } = result;
setCookie(cookie.token, tokenId);
setCookie(cookie.user, userId);
setLocalStorge(storage.userName, userName);
await switchDomain(domainId);
const moduleInfos = await allModuleInfos();
console.log(moduleInfos);
if (moduleInfos.length > 0) {
const module = await getModuleConfigure(moduleInfos[0].name);
console.log(module);
}
};
loginIt('cxj', '111111', 5).catch(err => console.log(err));
storiesOf('Button', module)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
const Wrapper = () => Comp => (props) => {
const app = dva({});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论