fix: 🐛 解决小程序环境没有 window, 而 rax 出码中却默认在 __$eval 中用到 window 的问题

-- 解决方法: 将这个 __$$eval 的错误处理的默认行为搞成配置化的, 支持从外面传入...
This commit is contained in:
Clarence-pan 2022-04-10 20:29:41 +08:00 committed by Clarence Pan
parent 2bb8efb6ee
commit ce531aeb45
35 changed files with 576 additions and 361 deletions

View File

@ -280,6 +280,8 @@ export class ProjectBuilder implements IProjectBuilder {
postProcessors: this.postProcessors, postProcessors: this.postProcessors,
contextData: { contextData: {
inStrictMode: this.inStrictMode, inStrictMode: this.inStrictMode,
tolerateEvalErrors: true,
evalErrorsHandler: '',
...this.extraContextData, ...this.extraContextData,
}, },
...options, ...options,

View File

@ -62,6 +62,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
const ir = next.ir as IContainerInfo; const ir = next.ir as IContainerInfo;
const rootScope = Scope.createRootScope(); const rootScope = Scope.createRootScope();
const { tolerateEvalErrors = true, evalErrorsHandler = '' } = next.contextData;
// Rax 构建到小程序的时候,不能给组件起起别名,得直接引用,故这里将所有的别名替换掉 // Rax 构建到小程序的时候,不能给组件起起别名,得直接引用,故这里将所有的别名替换掉
// 先收集下所有的 alias 的映射 // 先收集下所有的 alias 的映射
@ -86,7 +87,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
// 3. 通过 this.xxx 能拿到的东西太多了,而且自定义的 methods 可能会无意间破坏 Rax 框架或小程序框架在页面 this 上的东东 // 3. 通过 this.xxx 能拿到的东西太多了,而且自定义的 methods 可能会无意间破坏 Rax 框架或小程序框架在页面 this 上的东东
const customHandlers: HandlerSet<string> = { const customHandlers: HandlerSet<string> = {
expression(input: JSExpression, scope: IScope) { expression(input: JSExpression, scope: IScope) {
return transformJsExpr(generateExpression(input, scope), scope); return transformJsExpr(generateExpression(input, scope), scope, {
dontWrapEval: !tolerateEvalErrors,
});
}, },
function(input, scope: IScope) { function(input, scope: IScope) {
return transformThis2Context(input.value || 'null', scope); return transformThis2Context(input.value || 'null', scope);
@ -138,17 +141,14 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
type: ChunkType.STRING, type: ChunkType.STRING,
fileType: cfg.fileType, fileType: cfg.fileType,
name: COMMON_CHUNK_NAME.CustomContent, name: COMMON_CHUNK_NAME.CustomContent,
content: ` content: [
tolerateEvalErrors &&
`
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {
try { ${evalErrorsHandler}
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
} }
} }
@ -156,16 +156,57 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
const res = __$$eval(expr); const res = __$$eval(expr);
return Array.isArray(res) ? res : []; return Array.isArray(res) ? res : [];
} }
`,
`
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
return Object.assign({}, oldContext, ext); return Object.assign({}, oldContext, ext);
} }
`, `,
]
.filter(Boolean)
.join('\n'),
linkAfter: [COMMON_CHUNK_NAME.FileExport], linkAfter: [COMMON_CHUNK_NAME.FileExport],
}); });
return next; return next;
function generateRaxLoopCtrl(
nodeItem: NodeSchema,
scope: IScope,
config?: NodeGeneratorConfig,
next?: NodePlugin,
): CodePiece[] {
if (nodeItem.loop) {
const loopItemName = nodeItem.loopArgs?.[0] || 'item';
const loopIndexName = nodeItem.loopArgs?.[1] || 'index';
const subScope = scope.createSubScope([loopItemName, loopIndexName]);
const pieces: CodePiece[] = next ? next(nodeItem, subScope, config) : [];
const loopDataExpr = tolerateEvalErrors
? `__$$evalArray(() => (${transformThis2Context(
generateCompositeType(nodeItem.loop, scope, { handlers: config?.handlers }),
scope,
)}))`
: `(${transformThis2Context(
generateCompositeType(nodeItem.loop, scope, { handlers: config?.handlers }),
scope,
)})`;
pieces.unshift({
value: `${loopDataExpr}.map((${loopItemName}, ${loopIndexName}) => ((__$$context) => (`,
type: PIECE_TYPE.BEFORE,
});
pieces.push({
value: `))(__$$createChildContext(__$$context, { ${loopItemName}, ${loopIndexName} })))`,
type: PIECE_TYPE.AFTER,
});
return pieces;
}
return next ? next(nodeItem, scope, config) : [];
}
}; };
return plugin; return plugin;
@ -189,39 +230,6 @@ function isImportAliasDefineChunk(chunk: ICodeChunk): chunk is ICodeChunk & {
); );
} }
function generateRaxLoopCtrl(
nodeItem: NodeSchema,
scope: IScope,
config?: NodeGeneratorConfig,
next?: NodePlugin,
): CodePiece[] {
if (nodeItem.loop) {
const loopItemName = nodeItem.loopArgs?.[0] || 'item';
const loopIndexName = nodeItem.loopArgs?.[1] || 'index';
const subScope = scope.createSubScope([loopItemName, loopIndexName]);
const pieces: CodePiece[] = next ? next(nodeItem, subScope, config) : [];
const loopDataExpr = `__$$evalArray(() => (${transformThis2Context(
generateCompositeType(nodeItem.loop, scope, { handlers: config?.handlers }),
scope,
)}))`;
pieces.unshift({
value: `${loopDataExpr}.map((${loopItemName}, ${loopIndexName}) => ((__$$context) => (`,
type: PIECE_TYPE.BEFORE,
});
pieces.push({
value: `))(__$$createChildContext(__$$context, { ${loopItemName}, ${loopIndexName} })))`,
type: PIECE_TYPE.AFTER,
});
return pieces;
}
return next ? next(nodeItem, scope, config) : [];
}
function generateNodeAttrForRax( function generateNodeAttrForRax(
this: { cfg: PluginConfig }, this: { cfg: PluginConfig },
attrData: { attrName: string; attrValue: CompositeValue }, attrData: { attrName: string; attrValue: CompositeValue },

View File

@ -42,12 +42,14 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
...pre, ...pre,
}; };
const { tolerateEvalErrors = true, evalErrorsHandler = '' } = next.contextData;
// 这里会将内部的一些子上下文的访问(this.xxx)转换为 __$$context.xxx 的形式 // 这里会将内部的一些子上下文的访问(this.xxx)转换为 __$$context.xxx 的形式
// 与 Rax 所不同的是,这里不会将最顶层的 this 转换掉 // 与 Rax 所不同的是,这里不会将最顶层的 this 转换掉
const customHandlers: HandlerSet<string> = { const customHandlers: HandlerSet<string> = {
expression(input: JSExpression, scope: IScope) { expression(input: JSExpression, scope: IScope) {
return transformJsExpr(generateExpression(input, scope), scope, { return transformJsExpr(generateExpression(input, scope), scope, {
dontWrapEval: true, dontWrapEval: !tolerateEvalErrors,
dontTransformThis2ContextAtRootScope: true, dontTransformThis2ContextAtRootScope: true,
}); });
}, },
@ -111,7 +113,23 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
type: ChunkType.STRING, type: ChunkType.STRING,
fileType: cfg.fileType, fileType: cfg.fileType,
name: COMMON_CHUNK_NAME.CustomContent, name: COMMON_CHUNK_NAME.CustomContent,
content: ` content: [
tolerateEvalErrors &&
`
function __$$eval(expr) {
try {
return expr();
} catch (error) {
${evalErrorsHandler}
}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
`,
`
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,
@ -121,6 +139,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
return childContext; return childContext;
} }
`, `,
]
.filter(Boolean)
.join('\n'),
linkAfter: [COMMON_CHUNK_NAME.FileExport], linkAfter: [COMMON_CHUNK_NAME.FileExport],
}); });
return next; return next;

View File

@ -1,4 +1,4 @@
import { IProjectBuilder } from '../types'; import { IProjectBuilder, IProjectBuilderOptions } from '../types';
import { createProjectBuilder } from '../generator/ProjectBuilder'; import { createProjectBuilder } from '../generator/ProjectBuilder';
@ -22,15 +22,14 @@ import icejs from '../plugins/project/framework/icejs';
import { prettier } from '../postprocessor'; import { prettier } from '../postprocessor';
export type IceJsProjectBuilderOptions = { export interface IceJsProjectBuilderOptions extends IProjectBuilderOptions {}
inStrictMode?: boolean;
};
export default function createIceJsProjectBuilder( export default function createIceJsProjectBuilder(
options?: IceJsProjectBuilderOptions, options?: IceJsProjectBuilderOptions,
): IProjectBuilder { ): IProjectBuilder {
return createProjectBuilder({ return createProjectBuilder({
inStrictMode: options?.inStrictMode, inStrictMode: options?.inStrictMode,
extraContextData: { ...options },
template: icejs.template, template: icejs.template,
plugins: { plugins: {
components: [ components: [

View File

@ -1,4 +1,4 @@
import { IProjectBuilder } from '../types'; import { IProjectBuilder, IProjectBuilderOptions } from '../types';
import { createProjectBuilder } from '../generator/ProjectBuilder'; import { createProjectBuilder } from '../generator/ProjectBuilder';
@ -22,8 +22,14 @@ import raxApp from '../plugins/project/framework/rax';
import { prettier } from '../postprocessor'; import { prettier } from '../postprocessor';
import { RaxFrameworkOptions } from '../plugins/project/framework/rax/types/RaxFrameworkOptions'; import { RaxFrameworkOptions } from '../plugins/project/framework/rax/types/RaxFrameworkOptions';
export default function createRaxProjectBuilder(options?: RaxFrameworkOptions): IProjectBuilder { export interface RaxProjectBuilderOptions extends IProjectBuilderOptions, RaxFrameworkOptions {}
export default function createRaxProjectBuilder(
options?: RaxProjectBuilderOptions,
): IProjectBuilder {
return createProjectBuilder({ return createProjectBuilder({
inStrictMode: options?.inStrictMode,
extraContextData: { ...options },
template: raxApp.template, template: raxApp.template,
plugins: { plugins: {
components: [ components: [

View File

@ -63,10 +63,7 @@ export interface ICodeStruct extends IBaseCodeStruct {
} }
/** 上下文数据,用来在插件之间共享一些数据 */ /** 上下文数据,用来在插件之间共享一些数据 */
export interface IContextData { export interface IContextData extends IProjectBuilderOptions {
/** 是否处于严格模式 */
inStrictMode?: boolean;
/** 是否使用了 Ref 的 API (this.$/this.$$) */ /** 是否使用了 Ref 的 API (this.$/this.$$) */
useRefApi?: boolean; useRefApi?: boolean;
@ -139,6 +136,33 @@ export interface IProjectPlugins {
[slotName: string]: BuilderComponentPlugin[]; [slotName: string]: BuilderComponentPlugin[];
} }
export interface IProjectBuilderOptions {
/** 是否处于严格模式(默认: 否) */
inStrictMode?: boolean;
/**
* JSExpression
* true
* : 如果容忍异常 try-catch
* catch CustomEvent
*/
tolerateEvalErrors?: boolean;
/**
*
* 默认:
*
* window.dispatchEvent(new CustomEvent('lowcode-eval-error', { error, expr }))
*
*
*
* :
* - error: 异常信息
* - expr: 求值的表达式
*/
evalErrorsHandler?: string;
}
export interface IProjectBuilder { export interface IProjectBuilder {
generateProject: (schema: ProjectSchema | string) => Promise<ResultDir>; generateProject: (schema: ProjectSchema | string) => Promise<ResultDir>;
} }

View File

@ -129,13 +129,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -336,13 +336,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -138,13 +138,7 @@ export default Detail$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -138,13 +138,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -141,13 +141,7 @@ export default List$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -133,13 +133,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -135,13 +135,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -141,13 +141,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -135,13 +135,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -141,13 +141,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -144,13 +144,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -146,13 +146,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -158,13 +158,7 @@ export default Aaaa$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -149,13 +149,7 @@ export default Home$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -160,13 +160,7 @@ export default Example$$Page;
function __$$eval(expr) { function __$$eval(expr) {
try { try {
return expr(); return expr();
} catch (err) { } catch (error) {}
try {
if (window.handleEvalError) {
window.handleEvalError('Failed to evaluate: ', expr, err);
}
} catch (e) {}
}
} }
function __$$evalArray(expr) { function __$$evalArray(expr) {

View File

@ -131,7 +131,7 @@ class Test$$Page extends React.Component {
return ( return (
<div ref={this._refsManager.linkRef("outterView")} autoLoading={true}> <div ref={this._refsManager.linkRef("outterView")} autoLoading={true}>
<Form <Form
labelCol={this.state.colNum} labelCol={__$$eval(() => this.state.colNum)}
style={{}} style={{}}
ref={this._refsManager.linkRef("testForm")} ref={this._refsManager.linkRef("testForm")}
> >
@ -154,9 +154,9 @@ class Test$$Page extends React.Component {
<Button.Group> <Button.Group>
{["a", "b", "c"].map((item, index) => {["a", "b", "c"].map((item, index) =>
((__$$context) => ((__$$context) =>
!!(index >= 1) && ( !!__$$eval(() => index >= 1) && (
<Button type="primary" style={{ margin: "0 5px 0 5px" }}> <Button type="primary" style={{ margin: "0 5px 0 5px" }}>
{item} {__$$eval(() => item)}
</Button> </Button>
))(__$$createChildContext(__$$context, { item, index })) ))(__$$createChildContext(__$$context, { item, index }))
)} )}
@ -170,6 +170,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -87,6 +87,17 @@ class Aaaa$$Page extends React.Component {
export default Aaaa$$Page; export default Aaaa$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -43,12 +43,12 @@ class Test$$Page extends React.Component {
return ( return (
<div ref={this._refsManager.linkRef("outterView")} autoLoading={true}> <div ref={this._refsManager.linkRef("outterView")} autoLoading={true}>
<Form <Form
labelCol={this.state.colNum} labelCol={__$$eval(() => this.state.colNum)}
style={{}} style={{}}
ref={this._refsManager.linkRef("testForm")} ref={this._refsManager.linkRef("testForm")}
> >
<Form.Item <Form.Item
label={this.i18n("i18n-jwg27yo4")} label={__$$eval(() => this.i18n("i18n-jwg27yo4"))}
name="name" name="name"
initValue="李雷" initValue="李雷"
> >
@ -92,6 +92,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -45,7 +45,7 @@ class Test$$Page extends React.Component {
const { state } = __$$context; const { state } = __$$context;
return ( return (
<div> <div>
<Super title={this.state.title} /> <Super title={__$$eval(() => this.state.title)} />
<SuperSub /> <SuperSub />
<SuperOther /> <SuperOther />
<Button /> <Button />
@ -62,6 +62,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -190,7 +190,7 @@ class Test$$Page extends React.Component {
flex={true} flex={true}
> >
<AliSearchTable <AliSearchTable
dataSource={this.state.users.data} dataSource={__$$eval(() => this.state.users.data)}
rowKey="workid" rowKey="workid"
columns={[ columns={[
{ title: "花名", dataIndex: "cname" }, { title: "花名", dataIndex: "cname" },
@ -265,6 +265,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -152,7 +152,7 @@ class Test$$Page extends React.Component {
width: "400px", width: "400px",
display: "inline-block", display: "inline-block",
}} }}
options={this.state.gateways} options={__$$eval(() => this.state.gateways)}
mode="single" mode="single"
defaultValue={["auto-edd-uniproxy"]} defaultValue={["auto-edd-uniproxy"]}
labelInValue={true} labelInValue={true}
@ -220,7 +220,7 @@ class Test$$Page extends React.Component {
</Button> </Button>
<Modal <Modal
title="创建发布单" title="创建发布单"
visible={this.state.modalVisible} visible={__$$eval(() => this.state.modalVisible)}
footer="" footer=""
__events={{ __events={{
eventDataList: [ eventDataList: [
@ -317,7 +317,7 @@ class Test$$Page extends React.Component {
</Modal> </Modal>
<AliAutoSearchTableDefault <AliAutoSearchTableDefault
rowKey="key" rowKey="key"
dataSource={this.state.records} dataSource={__$$eval(() => this.state.records)}
columns={[ columns={[
{ {
title: "发布名称", title: "发布名称",
@ -342,7 +342,7 @@ class Test$$Page extends React.Component {
}, },
{ title: "发布时间", dataIndex: "publish_id" }, { title: "发布时间", dataIndex: "publish_id" },
]} ]}
actions={this.actions || []} actions={__$$eval(() => this.actions || [])}
getActions={function () { getActions={function () {
return this.getActions.apply( return this.getActions.apply(
this, this,
@ -362,6 +362,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -131,7 +131,7 @@ class Test$$Page extends React.Component {
return ( return (
<div ref={this._refsManager.linkRef("outterView")} autoLoading={true}> <div ref={this._refsManager.linkRef("outterView")} autoLoading={true}>
<Form <Form
labelCol={this.state.colNum} labelCol={__$$eval(() => this.state.colNum)}
style={{}} style={{}}
ref={this._refsManager.linkRef("testForm")} ref={this._refsManager.linkRef("testForm")}
> >
@ -156,7 +156,7 @@ class Test$$Page extends React.Component {
((__$$context) => ((__$$context) =>
!!false && ( !!false && (
<Button type="primary" style={{ margin: "0 5px 0 5px" }}> <Button type="primary" style={{ margin: "0 5px 0 5px" }}>
{item} {__$$eval(() => item)}
</Button> </Button>
))(__$$createChildContext(__$$context, { item, index })) ))(__$$createChildContext(__$$context, { item, index }))
)} )}
@ -170,6 +170,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -200,7 +200,7 @@ class Test$$Page extends React.Component {
> >
<Modal <Modal
title="是否修改" title="是否修改"
visible={this.state.isModifyDialogVisible} visible={__$$eval(() => this.state.isModifyDialogVisible)}
okText="确认" okText="确认"
okType="" okType=""
forceRender={false} forceRender={false}
@ -293,13 +293,13 @@ class Test$$Page extends React.Component {
flex={true} flex={true}
style={{ marginBottom: "24px" }} style={{ marginBottom: "24px" }}
> >
<Steps current={this.state.currentStep}> <Steps current={__$$eval(() => this.state.currentStep)}>
<Steps.Step title="版本申请" description="" /> <Steps.Step title="版本申请" description="" />
<Steps.Step title="机器配置" subTitle="" description="" /> <Steps.Step title="机器配置" subTitle="" description="" />
<Steps.Step title="项目审批" description="" /> <Steps.Step title="项目审批" description="" />
</Steps> </Steps>
</NextP> </NextP>
{!!(this.state.currentStep === 0) && ( {!!__$$eval(() => this.state.currentStep === 0) && (
<NextP <NextP
wrap={false} wrap={false}
type="body2" type="body2"
@ -347,7 +347,9 @@ class Test$$Page extends React.Component {
{ name: "onValuesChange", disabled: true }, { name: "onValuesChange", disabled: true },
], ],
}} }}
initialValues={this.state.customerProjectInfo} initialValues={__$$eval(
() => this.state.customerProjectInfo
)}
onValuesChange={function () { onValuesChange={function () {
this.onValuesChange.apply( this.onValuesChange.apply(
this, this,
@ -391,10 +393,11 @@ class Test$$Page extends React.Component {
{ label: "UI定制", value: "4", disabled: false }, { label: "UI定制", value: "4", disabled: false },
]} ]}
style={{ width: "600px" }} style={{ width: "600px" }}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -409,11 +412,12 @@ class Test$$Page extends React.Component {
> >
<Select <Select
style={{ width: "600px" }} style={{ width: "600px" }}
options={this.state.versionLinesArray} options={__$$eval(() => this.state.versionLinesArray)}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
placeholder="请选择版本线" placeholder="请选择版本线"
/> />
</Form.Item> </Form.Item>
@ -442,10 +446,11 @@ class Test$$Page extends React.Component {
<Input <Input
placeholder="公司简称-产品名称-版本类型" placeholder="公司简称-产品名称-版本类型"
style={{ width: "600px" }} style={{ width: "600px" }}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -462,10 +467,11 @@ class Test$$Page extends React.Component {
> >
<DatePicker <DatePicker
style={{ width: "600px" }} style={{ width: "600px" }}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -484,10 +490,11 @@ class Test$$Page extends React.Component {
value={3} value={3}
style={{ width: "600px" }} style={{ width: "600px" }}
placeholder="单位(台)使用该版本的机器数量+预计出货量,请如实填写" placeholder="单位(台)使用该版本的机器数量+预计出货量,请如实填写"
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
min={0} min={0}
size="middle" size="middle"
/> />
@ -543,7 +550,7 @@ class Test$$Page extends React.Component {
</Form> </Form>
</NextP> </NextP>
)} )}
{!!(this.state.currentStep === 1) && ( {!!__$$eval(() => this.state.currentStep === 1) && (
<NextP <NextP
wrap={false} wrap={false}
type="body2" type="body2"
@ -592,7 +599,9 @@ class Test$$Page extends React.Component {
{ name: "onValuesChange", disabled: true }, { name: "onValuesChange", disabled: true },
], ],
}} }}
initialValues={this.state.customerProjectInfo} initialValues={__$$eval(
() => this.state.customerProjectInfo
)}
onValuesChange={function () { onValuesChange={function () {
this.onValuesChange.apply( this.onValuesChange.apply(
this, this,
@ -614,11 +623,12 @@ class Test$$Page extends React.Component {
> >
<Select <Select
style={{ width: "600px" }} style={{ width: "600px" }}
options={this.state.projectModalsArray} options={__$$eval(() => this.state.projectModalsArray)}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
placeholder="请选择设备类型" placeholder="请选择设备类型"
/> />
</Form.Item> </Form.Item>
@ -638,10 +648,11 @@ class Test$$Page extends React.Component {
value={3} value={3}
style={{ width: "600px" }} style={{ width: "600px" }}
placeholder="例如1280" placeholder="例如1280"
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
min={0} min={0}
/> />
</Form.Item> </Form.Item>
@ -661,10 +672,11 @@ class Test$$Page extends React.Component {
value={3} value={3}
style={{ width: "600px" }} style={{ width: "600px" }}
placeholder="例如720" placeholder="例如720"
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
min={0} min={0}
/> />
</Form.Item> </Form.Item>
@ -684,10 +696,11 @@ class Test$$Page extends React.Component {
value={3} value={3}
style={{ width: "600px" }} style={{ width: "600px" }}
placeholder="请输入尺寸" placeholder="请输入尺寸"
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
min={0} min={0}
/> />
</Form.Item> </Form.Item>
@ -703,10 +716,11 @@ class Test$$Page extends React.Component {
value={3} value={3}
style={{ width: "600px" }} style={{ width: "600px" }}
placeholder="UI定制项目必填" placeholder="UI定制项目必填"
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
min={0} min={0}
/> />
</Form.Item> </Form.Item>
@ -727,10 +741,11 @@ class Test$$Page extends React.Component {
<Input <Input
placeholder="请输入芯片名称" placeholder="请输入芯片名称"
style={{ width: "600px" }} style={{ width: "600px" }}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -749,10 +764,11 @@ class Test$$Page extends React.Component {
value={3} value={3}
style={{ width: "600px" }} style={{ width: "600px" }}
placeholder="请输入芯片核数" placeholder="请输入芯片核数"
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
defaultValue="" defaultValue=""
min={0} min={0}
/> />
@ -767,11 +783,12 @@ class Test$$Page extends React.Component {
> >
<Select <Select
style={{ width: "600px" }} style={{ width: "600px" }}
options={this.state.instructionsArray} options={__$$eval(() => this.state.instructionsArray)}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
/> />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -788,11 +805,12 @@ class Test$$Page extends React.Component {
> >
<Select <Select
style={{ width: "600px" }} style={{ width: "600px" }}
options={this.state.osVersionsArray} options={__$$eval(() => this.state.osVersionsArray)}
disabled={ disabled={__$$eval(
this.state.customerProjectInfo.id > 0 && () =>
!this.state.isModifyStatus this.state.customerProjectInfo.id > 0 &&
} !this.state.isModifyStatus
)}
placeholder="请选择系统版本" placeholder="请选择系统版本"
/> />
</Form.Item> </Form.Item>
@ -829,11 +847,12 @@ class Test$$Page extends React.Component {
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ float: "right", marginLeft: "20px" }} style={{ float: "right", marginLeft: "20px" }}
loading={ loading={__$$eval(
this.state.LOADING_ADD_OR_UPDATE_CUSTOMER_PROJECT () =>
} this.state.LOADING_ADD_OR_UPDATE_CUSTOMER_PROJECT
)}
> >
{this.state.secondCommitText} {__$$eval(() => this.state.secondCommitText)}
</Button> </Button>
<Button <Button
type="primary" type="primary"
@ -862,7 +881,7 @@ class Test$$Page extends React.Component {
</Form> </Form>
</NextP> </NextP>
)} )}
{!!(this.state.currentStep === 2) && ( {!!__$$eval(() => this.state.currentStep === 2) && (
<NextP <NextP
wrap={false} wrap={false}
type="body2" type="body2"
@ -925,7 +944,7 @@ class Test$$Page extends React.Component {
style={{ width: "200px" }} style={{ width: "200px" }}
/> />
<Steps.Step <Steps.Step
title={this.state.thirdAuditText} title={__$$eval(() => this.state.thirdAuditText)}
subTitle="" subTitle=""
description="" description=""
style={{ width: "200px" }} style={{ width: "200px" }}
@ -982,9 +1001,11 @@ class Test$$Page extends React.Component {
); );
}.bind(this)} }.bind(this)}
> >
{this.state.thirdButtonText} {__$$eval(() => this.state.thirdButtonText)}
</Button> </Button>
{!!(this.state.customerProjectInfo.status > 2) && ( {!!__$$eval(
() => this.state.customerProjectInfo.status > 2
) && (
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
@ -1023,6 +1044,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -72,7 +72,7 @@ class Example$$Page extends React.Component {
return ( return (
<div> <div>
<Table <Table
dataSource={this.dataSourceMap["userList"]} dataSource={__$$eval(() => this.dataSourceMap["userList"])}
columns={[ columns={[
{ dataIndex: "name", title: "姓名" }, { dataIndex: "name", title: "姓名" },
{ dataIndex: "age", title: "年龄" }, { dataIndex: "age", title: "年龄" },
@ -85,6 +85,17 @@ class Example$$Page extends React.Component {
export default Example$$Page; export default Example$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -75,13 +75,13 @@ class Index$$Page extends React.Component {
return ( return (
<div> <div>
<div> <div>
{this.dataSourceMap.todos.data.map((item, index) => {__$$eval(() => this.dataSourceMap.todos.data).map((item, index) =>
((__$$context) => ( ((__$$context) => (
<div> <div>
<Switch <Switch
checkedChildren="开" checkedChildren="开"
unCheckedChildren="关" unCheckedChildren="关"
checked={item.done} checked={__$$eval(() => item.done)}
/> />
</div> </div>
))(__$$createChildContext(__$$context, { item, index })) ))(__$$createChildContext(__$$context, { item, index }))
@ -94,6 +94,17 @@ class Index$$Page extends React.Component {
export default Index$$Page; export default Index$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -192,7 +192,7 @@ class Test$$Page extends React.Component {
> >
<Modal <Modal
title="查看结果" title="查看结果"
visible={this.state.resultVisible} visible={__$$eval(() => this.state.resultVisible)}
footer={ footer={
<Button <Button
type="primary" type="primary"
@ -238,12 +238,13 @@ class Test$$Page extends React.Component {
width="720px" width="720px"
centered={true} centered={true}
> >
{this.state.results.map((item, index) => {__$$eval(() => this.state.results).map((item, index) =>
((__$$context) => ( ((__$$context) => (
<AliAutoDivDefault style={{ width: "100%" }}> <AliAutoDivDefault style={{ width: "100%" }}>
{!!( {!!__$$eval(
__$$context.state.results && () =>
__$$context.state.results.length > 0 __$$context.state.results &&
__$$context.state.results.length > 0
) && ( ) && (
<AliAutoDivDefault <AliAutoDivDefault
style={{ style={{
@ -277,16 +278,22 @@ class Test$$Page extends React.Component {
</AliAutoDivDefault> </AliAutoDivDefault>
)} )}
<Typography.Text> <Typography.Text>
{__$$context.formatResult(item)} {__$$eval(() => __$$context.formatResult(item))}
</Typography.Text> </Typography.Text>
{!!item.download_link && ( {!!__$$eval(() => item.download_link) && (
<Typography.Link href={item.download_link} target="_blank"> <Typography.Link
href={__$$eval(() => item.download_link)}
target="_blank"
>
{" "} {" "}
- 点击下载 - 点击下载
</Typography.Link> </Typography.Link>
)} )}
{!!item.release_notes && ( {!!__$$eval(() => item.release_notes) && (
<Typography.Link href={item.release_notes} target="_blank"> <Typography.Link
href={__$$eval(() => item.release_notes)}
target="_blank"
>
{" "} {" "}
- 跳转发布节点 - 跳转发布节点
</Typography.Link> </Typography.Link>
@ -365,7 +372,7 @@ class Test$$Page extends React.Component {
<Form.Item label="项目名称/渠道号" name="channel_id"> <Form.Item label="项目名称/渠道号" name="channel_id">
<Select <Select
style={{ width: "280px" }} style={{ width: "280px" }}
options={this.state.projects} options={__$$eval(() => this.state.projects)}
showArrow={true} showArrow={true}
tokenSeparators={[]} tokenSeparators={[]}
showSearch={true} showSearch={true}
@ -412,13 +419,14 @@ class Test$$Page extends React.Component {
flex={true} flex={true}
> >
<ConfigProvider locale="zh-CN"> <ConfigProvider locale="zh-CN">
{!!( {!!__$$eval(
!this.state.isSearch || () =>
(this.state.isSearch && this.state.pkgs.length > 0) !this.state.isSearch ||
(this.state.isSearch && this.state.pkgs.length > 0)
) && ( ) && (
<AliAutoSearchTableDefault <AliAutoSearchTableDefault
rowKey="key" rowKey="key"
dataSource={this.state.pkgs} dataSource={__$$eval(() => this.state.pkgs)}
columns={[ columns={[
{ {
title: "ID", title: "ID",
@ -433,14 +441,13 @@ class Test$$Page extends React.Component {
width: 142, width: 142,
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => ((__$$context) =>
text __$$eval(() => text.split(",")).map(
.split(",") (item, index) =>
.map((item, index) =>
((__$$context) => ( ((__$$context) => (
<Typography.Text <Typography.Text
style={{ display: "block" }} style={{ display: "block" }}
> >
{item} {__$$eval(() => item)}
</Typography.Text> </Typography.Text>
))( ))(
__$$createChildContext(__$$context, { __$$createChildContext(__$$context, {
@ -448,7 +455,7 @@ class Test$$Page extends React.Component {
index, index,
}) })
) )
))( ))(
__$$createChildContext(__$$context, { __$$createChildContext(__$$context, {
text, text,
record, record,
@ -463,26 +470,32 @@ class Test$$Page extends React.Component {
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => ( ((__$$context) => (
<Tooltip <Tooltip
title={(text || []).map((item, index) => title={__$$eval(() => text || []).map(
((__$$context) => ( (item, index) =>
<Typography.Text ((__$$context) => (
style={{ <Typography.Text
display: "block", style={{
color: "#FFFFFF", display: "block",
}} color: "#FFFFFF",
> }}
{item.channelId + " / " + item.version} >
</Typography.Text> {__$$eval(
))( () =>
__$$createChildContext(__$$context, { item.channelId +
item, " / " +
index, item.version
}) )}
) </Typography.Text>
))(
__$$createChildContext(__$$context, {
item,
index,
})
)
)} )}
> >
<Typography.Text> <Typography.Text>
{text[0].version} {__$$eval(() => text[0].version)}
</Typography.Text> </Typography.Text>
</Tooltip> </Tooltip>
))( ))(
@ -506,9 +519,9 @@ class Test$$Page extends React.Component {
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => [ ((__$$context) => [
<Typography.Text> <Typography.Text>
{__$$context.statusDesc[text]} {__$$eval(() => __$$context.statusDesc[text])}
</Typography.Text>, </Typography.Text>,
!!(text === 2) && ( !!__$$eval(() => text === 2) && (
<Icon <Icon
type="SyncOutlined" type="SyncOutlined"
size={16} size={16}
@ -552,12 +565,15 @@ class Test$$Page extends React.Component {
dataIndex: "jenkins_link", dataIndex: "jenkins_link",
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => [ ((__$$context) => [
!!text && ( !!__$$eval(() => text) && (
<Typography.Link href={text} target="_blank"> <Typography.Link
href={__$$eval(() => text)}
target="_blank"
>
查看 查看
</Typography.Link> </Typography.Link>
), ),
!!!text && ( !!__$$eval(() => !text) && (
<Typography.Text>暂无</Typography.Text> <Typography.Text>暂无</Typography.Text>
), ),
])( ])(
@ -575,7 +591,7 @@ class Test$$Page extends React.Component {
width: 120, width: 120,
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => [ ((__$$context) => [
!!text && ( !!__$$eval(() => text) && (
<Typography.Link <Typography.Link
href="http://rivermap.alibaba.net/dashboard/testExecute" href="http://rivermap.alibaba.net/dashboard/testExecute"
target="_blank" target="_blank"
@ -583,7 +599,7 @@ class Test$$Page extends React.Component {
查看 查看
</Typography.Link> </Typography.Link>
), ),
!!!text && ( !!__$$eval(() => !text) && (
<Typography.Text>暂无</Typography.Text> <Typography.Text>暂无</Typography.Text>
), ),
])( ])(
@ -668,7 +684,7 @@ class Test$$Page extends React.Component {
); );
}.bind(__$$context)} }.bind(__$$context)}
ghost={false} ghost={false}
href={text} href={__$$eval(() => text)}
> >
查看 查看
</Button> </Button>
@ -740,7 +756,7 @@ class Test$$Page extends React.Component {
]} ]}
actions={[]} actions={[]}
pagination={{ pagination={{
total: this.state.total, total: __$$eval(() => this.state.total),
defaultPageSize: 8, defaultPageSize: 8,
onPageChange: function () { onPageChange: function () {
return this.onPageChange.apply( return this.onPageChange.apply(
@ -766,9 +782,9 @@ class Test$$Page extends React.Component {
align="left" align="left"
flex={true} flex={true}
> >
{!!(this.state.pkgs.length < 1 && this.state.isSearch) && ( {!!__$$eval(
<Empty description="暂无数据" /> () => this.state.pkgs.length < 1 && this.state.isSearch
)} ) && <Empty description="暂无数据" />}
</NextP> </NextP>
</NextBlockCell> </NextBlockCell>
</NextBlock> </NextBlock>
@ -780,6 +796,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -218,7 +218,7 @@ class Test$$Page extends React.Component {
> >
<Modal <Modal
title="查看结果" title="查看结果"
visible={this.state.resultVisible} visible={__$$eval(() => this.state.resultVisible)}
footer={ footer={
<Button <Button
type="primary" type="primary"
@ -269,7 +269,9 @@ class Test$$Page extends React.Component {
maskClosable={true} maskClosable={true}
> >
<AliAutoDivDefault style={{ width: "100%" }}> <AliAutoDivDefault style={{ width: "100%" }}>
{!!(this.state.results && this.state.results.length > 0) && ( {!!__$$eval(
() => this.state.results && this.state.results.length > 0
) && (
<AliAutoDivDefault <AliAutoDivDefault
style={{ style={{
width: "100%", width: "100%",
@ -301,20 +303,26 @@ class Test$$Page extends React.Component {
</Button> </Button>
</AliAutoDivDefault> </AliAutoDivDefault>
)} )}
{this.state.results.map((item, index) => {__$$eval(() => this.state.results).map((item, index) =>
((__$$context) => ( ((__$$context) => (
<AliAutoDivDefault style={{ width: "100%", marginTop: "10px" }}> <AliAutoDivDefault style={{ width: "100%", marginTop: "10px" }}>
<Typography.Text> <Typography.Text>
{__$$context.formatResult(item)} {__$$eval(() => __$$context.formatResult(item))}
</Typography.Text> </Typography.Text>
{!!item.download_link && ( {!!__$$eval(() => item.download_link) && (
<Typography.Link href={item.download_link} target="_blank"> <Typography.Link
href={__$$eval(() => item.download_link)}
target="_blank"
>
{" "} {" "}
- 点击下载 - 点击下载
</Typography.Link> </Typography.Link>
)} )}
{!!item.release_notes && ( {!!__$$eval(() => item.release_notes) && (
<Typography.Link href={item.release_notes} target="_blank"> <Typography.Link
href={__$$eval(() => item.release_notes)}
target="_blank"
>
{" "} {" "}
- 跳转发布节点 - 跳转发布节点
</Typography.Link> </Typography.Link>
@ -378,7 +386,7 @@ class Test$$Page extends React.Component {
preserve={true} preserve={true}
scrollToFirstError={true} scrollToFirstError={true}
size="middle" size="middle"
values={this.state.searchValues} values={__$$eval(() => this.state.searchValues)}
> >
<Form.Item <Form.Item
label="项目名称/渠道号" label="项目名称/渠道号"
@ -388,7 +396,7 @@ class Test$$Page extends React.Component {
> >
<Select <Select
style={{ width: "320px" }} style={{ width: "320px" }}
options={this.state.projects} options={__$$eval(() => this.state.projects)}
showArrow={false} showArrow={false}
tokenSeparators={[]} tokenSeparators={[]}
showSearch={true} showSearch={true}
@ -454,14 +462,16 @@ class Test$$Page extends React.Component {
<Form.Item label="构建人" name="user_id"> <Form.Item label="构建人" name="user_id">
<Select <Select
style={{ width: "210px" }} style={{ width: "210px" }}
options={this.state.userOptions} options={__$$eval(() => this.state.userOptions)}
showSearch={true} showSearch={true}
defaultActiveFirstOption={false} defaultActiveFirstOption={false}
size="middle" size="middle"
bordered={true} bordered={true}
filterOption={true} filterOption={true}
optionFilterProp="label" optionFilterProp="label"
notFoundContent={this.userNotFoundContent} notFoundContent={__$$eval(
() => this.userNotFoundContent
)}
showArrow={false} showArrow={false}
placeholder="请输入构建人" placeholder="请输入构建人"
__events={{ __events={{
@ -568,13 +578,14 @@ class Test$$Page extends React.Component {
align="left" align="left"
flex={true} flex={true}
> >
{!!( {!!__$$eval(
!this.state.isSearch || () =>
(this.state.isSearch && this.state.pkgs.length > 0) !this.state.isSearch ||
(this.state.isSearch && this.state.pkgs.length > 0)
) && ( ) && (
<AliAutoSearchTableDefault <AliAutoSearchTableDefault
rowKey="key" rowKey="key"
dataSource={this.state.pkgs} dataSource={__$$eval(() => this.state.pkgs)}
columns={[ columns={[
{ title: "ID", dataIndex: "id", key: "name", width: 80 }, { title: "ID", dataIndex: "id", key: "name", width: 80 },
{ {
@ -584,20 +595,18 @@ class Test$$Page extends React.Component {
width: 142, width: 142,
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => ((__$$context) =>
text __$$eval(() => text.split(",")).map((item, index) =>
.split(",") ((__$$context) => (
.map((item, index) => <Typography.Text style={{ display: "block" }}>
((__$$context) => ( {__$$eval(() => item)}
<Typography.Text style={{ display: "block" }}> </Typography.Text>
{item}
</Typography.Text>
))(
__$$createChildContext(__$$context, {
item,
index,
})
)
))( ))(
__$$createChildContext(__$$context, {
item,
index,
})
)
))(
__$$createChildContext(__$$context, { __$$createChildContext(__$$context, {
text, text,
record, record,
@ -612,26 +621,30 @@ class Test$$Page extends React.Component {
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => ( ((__$$context) => (
<Tooltip <Tooltip
title={(text || []).map((item, index) => title={__$$eval(() => text || []).map(
((__$$context) => ( (item, index) =>
<Typography.Text ((__$$context) => (
style={{ <Typography.Text
display: "block", style={{
color: "#FFFFFF", display: "block",
}} color: "#FFFFFF",
> }}
{item.channelId + " / " + item.version} >
</Typography.Text> {__$$eval(
))( () =>
__$$createChildContext(__$$context, { item.channelId + " / " + item.version
item, )}
index, </Typography.Text>
}) ))(
) __$$createChildContext(__$$context, {
item,
index,
})
)
)} )}
> >
<Typography.Text> <Typography.Text>
{text[0].version} {__$$eval(() => text[0].version)}
</Typography.Text> </Typography.Text>
</Tooltip> </Tooltip>
))( ))(
@ -655,9 +668,9 @@ class Test$$Page extends React.Component {
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => [ ((__$$context) => [
<Typography.Text> <Typography.Text>
{__$$context.statusDesc[text]} {__$$eval(() => __$$context.statusDesc[text])}
</Typography.Text>, </Typography.Text>,
!!(text === 2) && ( !!__$$eval(() => text === 2) && (
<Icon <Icon
type="SyncOutlined" type="SyncOutlined"
size={16} size={16}
@ -701,12 +714,17 @@ class Test$$Page extends React.Component {
dataIndex: "jenkins_link", dataIndex: "jenkins_link",
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => [ ((__$$context) => [
!!text && ( !!__$$eval(() => text) && (
<Typography.Link href={text} target="_blank"> <Typography.Link
href={__$$eval(() => text)}
target="_blank"
>
查看 查看
</Typography.Link> </Typography.Link>
), ),
!!!text && <Typography.Text>暂无</Typography.Text>, !!__$$eval(() => !text) && (
<Typography.Text>暂无</Typography.Text>
),
])( ])(
__$$createChildContext(__$$context, { __$$createChildContext(__$$context, {
text, text,
@ -722,7 +740,7 @@ class Test$$Page extends React.Component {
width: 120, width: 120,
render: (text, record, index) => render: (text, record, index) =>
((__$$context) => [ ((__$$context) => [
!!text && ( !!__$$eval(() => text) && (
<Typography.Link <Typography.Link
href="http://rivermap.alibaba.net/dashboard/testExecute" href="http://rivermap.alibaba.net/dashboard/testExecute"
target="_blank" target="_blank"
@ -730,7 +748,9 @@ class Test$$Page extends React.Component {
查看 查看
</Typography.Link> </Typography.Link>
), ),
!!!text && <Typography.Text>暂无</Typography.Text>, !!__$$eval(() => !text) && (
<Typography.Text>暂无</Typography.Text>
),
])( ])(
__$$createChildContext(__$$context, { __$$createChildContext(__$$context, {
text, text,
@ -813,7 +833,7 @@ class Test$$Page extends React.Component {
); );
}.bind(__$$context)} }.bind(__$$context)}
ghost={false} ghost={false}
href={text} href={__$$eval(() => text)}
> >
查看 查看
</Button> </Button>
@ -885,7 +905,7 @@ class Test$$Page extends React.Component {
]} ]}
actions={[]} actions={[]}
pagination={{ pagination={{
total: this.state.total, total: __$$eval(() => this.state.total),
defaultPageSize: 10, defaultPageSize: 10,
onPageChange: function () { onPageChange: function () {
return this.onPageChange.apply( return this.onPageChange.apply(
@ -917,9 +937,9 @@ class Test$$Page extends React.Component {
align="left" align="left"
flex={true} flex={true}
> >
{!!(this.state.pkgs.length < 1 && this.state.isSearch) && ( {!!__$$eval(
<Empty description="暂无数据" /> () => this.state.pkgs.length < 1 && this.state.isSearch
)} ) && <Empty description="暂无数据" />}
</NextP> </NextP>
</NextBlockCell> </NextBlockCell>
</NextBlock> </NextBlock>
@ -931,6 +951,17 @@ class Test$$Page extends React.Component {
export default Test$$Page; export default Test$$Page;
function __$$eval(expr) {
try {
return expr();
} catch (error) {}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,

View File

@ -35,7 +35,7 @@ function exportProject(
) { ) {
const schemaJsonStr = fs.readFileSync(importPath, { encoding: 'utf8' }); const schemaJsonStr = fs.readFileSync(importPath, { encoding: 'utf8' });
const schema = { ...JSON.parse(schemaJsonStr), ...mergeSchema }; const schema = { ...JSON.parse(schemaJsonStr), ...mergeSchema };
const builder = CodeGenerator.solutions.icejs(); const builder = CodeGenerator.solutions.icejs({ tolerateEvalErrors: false });
return builder.generateProject(schema).then(async (result) => { return builder.generateProject(schema).then(async (result) => {
const publisher = createDiskPublisher(); const publisher = createDiskPublisher();

View File

@ -7,7 +7,7 @@ Object {
"content": " "content": "
const __$$context = this._context || this; const __$$context = this._context || this;
const { state } = __$$context; const { state } = __$$context;
return (this.state.otherThings).map((item, index) => ((__$$context) => (!!(__$$context.state.something) && (<Page><Text>Hello world!</Text></Page>)))(__$$createChildContext(__$$context, { item, index }))); return (__$$eval(() => (this.state.otherThings))).map((item, index) => ((__$$context) => (!!(__$$eval(() => (__$$context.state.something))) && (<Page><Text>Hello world!</Text></Page>)))(__$$createChildContext(__$$context, { item, index })));
", ",
"fileType": "jsx", "fileType": "jsx",
"linkAfter": Array [ "linkAfter": Array [
@ -19,6 +19,20 @@ Object {
}, },
Object { Object {
"content": " "content": "
function __$$eval(expr) {
try {
return expr();
} catch (error) {
}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,
@ -68,7 +82,7 @@ Object {
"content": " "content": "
const __$$context = this._context || this; const __$$context = this._context || this;
const { state } = __$$context; const { state } = __$$context;
return !!(this.state.something) && (<Page><Text>Hello world!</Text></Page>); return !!(__$$eval(() => (this.state.something))) && (<Page><Text>Hello world!</Text></Page>);
", ",
"fileType": "jsx", "fileType": "jsx",
"linkAfter": Array [ "linkAfter": Array [
@ -80,6 +94,20 @@ Object {
}, },
Object { Object {
"content": " "content": "
function __$$eval(expr) {
try {
return expr();
} catch (error) {
}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,
@ -137,6 +165,20 @@ Object {
}, },
Object { Object {
"content": " "content": "
function __$$eval(expr) {
try {
return expr();
} catch (error) {
}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,
@ -191,6 +233,20 @@ Object {
}, },
Object { Object {
"content": " "content": "
function __$$eval(expr) {
try {
return expr();
} catch (error) {
}
}
function __$$evalArray(expr) {
const res = __$$eval(expr);
return Array.isArray(res) ? res : [];
}
function __$$createChildContext(oldContext, ext) { function __$$createChildContext(oldContext, ext) {
const childContext = { const childContext = {
...oldContext, ...oldContext,