style: rax-render

This commit is contained in:
wuji.xwt 2020-09-11 17:13:59 +08:00
parent a8ffb0d773
commit 00a10e8b65
9 changed files with 22 additions and 19 deletions

View File

@ -2,6 +2,7 @@
node_modules node_modules
build build
dist dist
demo
es es
lib lib
.* .*

View File

@ -0,0 +1,9 @@
module.exports = {
extends: 'eslint-config-ali/typescript/react',
rules: {
'no-proto': 1,
'no-new-func': 1,
'no-shadow': 1,
'@typescript-eslint/no-unused-vars': 1,
}
}

View File

@ -43,6 +43,7 @@ export default class BaseEngine extends Component {
messages: PropTypes.object, messages: PropTypes.object,
__appHelper: PropTypes.object, __appHelper: PropTypes.object,
__components: PropTypes.object, __components: PropTypes.object,
// eslint-disable-next-line react/no-unused-prop-types
__componentsMap: PropTypes.object, __componentsMap: PropTypes.object,
__ctx: PropTypes.object, __ctx: PropTypes.object,
__schema: PropTypes.object, __schema: PropTypes.object,
@ -293,7 +294,6 @@ export default class BaseEngine extends Component {
__schema: schema, __schema: schema,
__appHelper: appHelper, __appHelper: appHelper,
__components: components, __components: components,
// __componentsMap: componentsMap,
} }
: {}; : {};
if (engine && engine.props.designMode) { if (engine && engine.props.designMode) {
@ -334,9 +334,8 @@ export default class BaseEngine extends Component {
} }
props.__id = schema.id; props.__id = schema.id;
let Child = null;
if (!isFileSchema(schema) && schema.children) { if (!isFileSchema(schema) && schema.children) {
Child = this.__createVirtualDom( this.__createVirtualDom(
isJSExpression(schema.children) ? parseExpression(schema.children, self) : schema.children, isJSExpression(schema.children) ? parseExpression(schema.children, self) : schema.children,
self, self,
{ {
@ -460,7 +459,7 @@ export default class BaseEngine extends Component {
return checkProps(function () { return checkProps(function () {
const args = {}; const args = {};
if (Array.isArray(params) && params.length) { if (Array.isArray(params) && params.length) {
params.map((item, idx) => { params.forEach((item, idx) => {
if (typeof item === 'string') { if (typeof item === 'string') {
args[item] = arguments[idx]; args[item] = arguments[idx];
} else if (item && typeof item === 'object') { } else if (item && typeof item === 'object') {

View File

@ -61,7 +61,7 @@ export default class CompEngine extends BaseEngine {
debug(`comp.componentWillUnmount - ${this.props.__schema.fileName}`); debug(`comp.componentWillUnmount - ${this.props.__schema.fileName}`);
} }
async componentDidCatch(e) { async componentDidCatch() {
super.componentDidCatch(...arguments); super.componentDidCatch(...arguments);
debug(`comp.componentDidCatch - ${this.props.__schema.fileName}`); debug(`comp.componentDidCatch - ${this.props.__schema.fileName}`);
} }

View File

@ -79,7 +79,7 @@ export default class PageEngine extends BaseEngine {
debug(`page.render - ${__schema.fileName}`); debug(`page.render - ${__schema.fileName}`);
const { const {
id, className, style, autoLoading, defaultHeight = 300, loading, id, className, style,
} = this.__parseData(__schema.props); } = this.__parseData(__schema.props);
const { Page } = __components; const { Page } = __components;
@ -89,9 +89,6 @@ export default class PageEngine extends BaseEngine {
<AppContext.Consumer> <AppContext.Consumer>
{(context) => { {(context) => {
this.context = context; this.context = context;
{
/* this.__generateCtx(currCtx); */
}
this.__render(); this.__render();
return ( return (
<AppContext.Provider <AppContext.Provider

View File

@ -40,7 +40,7 @@ export default class TempEngine extends BaseEngine {
debug(`temp.componentDidMount - ${this.props.__schema.fileName}`); debug(`temp.componentDidMount - ${this.props.__schema.fileName}`);
} }
componentDidUpdate(prevProps, prevState, snapshot) { componentDidUpdate() {
debug(`temp.componentDidUpdate - ${this.props.__schema.fileName}`); debug(`temp.componentDidUpdate - ${this.props.__schema.fileName}`);
} }

View File

@ -4,10 +4,6 @@ import { createElement, Component } from 'rax';
export default function (Comp) { export default function (Comp) {
return class CompWrapper extends Component { return class CompWrapper extends Component {
constructor(props, context) {
super(props, context);
}
render() { render() {
return createElement(Comp, { return createElement(Comp, {
...this.props, ...this.props,

View File

@ -159,7 +159,7 @@ export default class DataHelper {
const afterRequest = this.appHelper && this.appHelper.utils && this.appHelper.utils.afterRequest; const afterRequest = this.appHelper && this.appHelper.utils && this.appHelper.utils.afterRequest;
const csrfInput = document.getElementById('_csrf_token'); const csrfInput = document.getElementById('_csrf_token');
const _tb_token_ = csrfInput && csrfInput.value; const _tb_token_ = csrfInput && csrfInput.value;
asyncDataList.map(req => { asyncDataList.forEach(req => {
const { id, type, options } = req; const { id, type, options } = req;
if (!id || !type) return; if (!id || !type) return;
if (type === 'doServer') { if (type === 'doServer') {
@ -272,6 +272,7 @@ export default class DataHelper {
} }
fetchOne(type, options) { fetchOne(type, options) {
// eslint-disable-next-line prefer-const
let { uri, method = 'GET', headers, params, ...otherProps } = options; let { uri, method = 'GET', headers, params, ...otherProps } = options;
otherProps = otherProps || {}; otherProps = otherProps || {};
switch (type) { switch (type) {

View File

@ -50,8 +50,6 @@ const EXPRESSION_TYPE = {
JSSLOT: 'JSSlot', JSSLOT: 'JSSlot',
}; };
const EXPRESSION_REG = /^\{\{(\{.*\}|.*?)\}\}$/; const EXPRESSION_REG = /^\{\{(\{.*\}|.*?)\}\}$/;
const hasSymbol = typeof Symbol === 'function' && Symbol.for;
const REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
const debug = Debug('utils:index'); const debug = Debug('utils:index');
const ENV = { const ENV = {
@ -180,6 +178,7 @@ export function fillObj(receiver = {}, ...suppliers) {
// 中划线转驼峰 // 中划线转驼峰
export function toHump(name) { export function toHump(name) {
// eslint-disable-next-line no-useless-escape
return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase()); return name.replace(/\-(\w)/g, (all, letter) => letter.toUpperCase());
} }
// 驼峰转中划线 // 驼峰转中划线
@ -525,7 +524,7 @@ export function addCssTag(id, content) {
// 注册快捷 // 注册快捷
export function registShortCuts(config, appHelper) { export function registShortCuts(config, appHelper) {
const keyboardFilter = (keymaster.filter = (event) => { keymaster.filter = (event) => {
const eTarget = event.target || event.srcElement; const eTarget = event.target || event.srcElement;
const { tagName } = eTarget; const { tagName } = eTarget;
const isInput = !!(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA'); const isInput = !!(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA');
@ -541,7 +540,8 @@ export function registShortCuts(config, appHelper) {
return false; return false;
} }
return true; return true;
}); };
const keyboardFilter = keymaster.filter;
const ideMessage = appHelper.utils && appHelper.utils.ideMessage; const ideMessage = appHelper.utils && appHelper.utils.ideMessage;