feat(plugin-workflow): add concat calculator (#894)
(cherry picked from commit 7f3f1bc982379ec2d274ca79fb4d6c65664d3c2d)
This commit is contained in:
parent
47c1764ac3
commit
7ca8e562ce
@ -590,6 +590,7 @@ export default {
|
|||||||
'Calculation result': '运算结果',
|
'Calculation result': '运算结果',
|
||||||
'True': '真',
|
'True': '真',
|
||||||
'False': '假',
|
'False': '假',
|
||||||
|
'concat': '连接',
|
||||||
|
|
||||||
'Condition': '条件判断',
|
'Condition': '条件判断',
|
||||||
'Mode': '模式',
|
'Mode': '模式',
|
||||||
|
@ -18,6 +18,7 @@ function NullRender() {
|
|||||||
|
|
||||||
interface Calculator {
|
interface Calculator {
|
||||||
name: string;
|
name: string;
|
||||||
|
type: 'boolean' | 'number' | 'string' | 'date' | 'unknown' | 'null' | 'array';
|
||||||
group: string;
|
group: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,72 +26,94 @@ export const calculators = new Registry<Calculator>();
|
|||||||
|
|
||||||
calculators.register('equal', {
|
calculators.register('equal', {
|
||||||
name: '=',
|
name: '=',
|
||||||
|
type: 'boolean',
|
||||||
group: 'boolean',
|
group: 'boolean',
|
||||||
});
|
});
|
||||||
calculators.register('notEqual', {
|
calculators.register('notEqual', {
|
||||||
name: '≠',
|
name: '≠',
|
||||||
|
type: 'boolean',
|
||||||
group: 'boolean',
|
group: 'boolean',
|
||||||
});
|
});
|
||||||
calculators.register('gt', {
|
calculators.register('gt', {
|
||||||
name: '>',
|
name: '>',
|
||||||
|
type: 'boolean',
|
||||||
group: 'boolean',
|
group: 'boolean',
|
||||||
});
|
});
|
||||||
calculators.register('gte', {
|
calculators.register('gte', {
|
||||||
name: '≥',
|
name: '≥',
|
||||||
|
type: 'boolean',
|
||||||
group: 'boolean',
|
group: 'boolean',
|
||||||
});
|
});
|
||||||
calculators.register('lt', {
|
calculators.register('lt', {
|
||||||
name: '<',
|
name: '<',
|
||||||
|
type: 'boolean',
|
||||||
group: 'boolean',
|
group: 'boolean',
|
||||||
});
|
});
|
||||||
calculators.register('lte', {
|
calculators.register('lte', {
|
||||||
name: '≤',
|
name: '≤',
|
||||||
|
type: 'boolean',
|
||||||
group: 'boolean',
|
group: 'boolean',
|
||||||
});
|
});
|
||||||
|
|
||||||
calculators.register('add', {
|
calculators.register('add', {
|
||||||
name: '+',
|
name: '+',
|
||||||
|
type: 'number',
|
||||||
group: 'number',
|
group: 'number',
|
||||||
});
|
});
|
||||||
calculators.register('minus', {
|
calculators.register('minus', {
|
||||||
name: '-',
|
name: '-',
|
||||||
|
type: 'number',
|
||||||
group: 'number',
|
group: 'number',
|
||||||
});
|
});
|
||||||
calculators.register('multiple', {
|
calculators.register('multiple', {
|
||||||
name: '*',
|
name: '*',
|
||||||
|
type: 'number',
|
||||||
group: 'number',
|
group: 'number',
|
||||||
});
|
});
|
||||||
calculators.register('divide', {
|
calculators.register('divide', {
|
||||||
name: '/',
|
name: '/',
|
||||||
|
type: 'number',
|
||||||
group: 'number',
|
group: 'number',
|
||||||
});
|
});
|
||||||
calculators.register('mod', {
|
calculators.register('mod', {
|
||||||
name: '%',
|
name: '%',
|
||||||
|
type: 'number',
|
||||||
group: 'number',
|
group: 'number',
|
||||||
});
|
});
|
||||||
|
|
||||||
calculators.register('includes', {
|
calculators.register('includes', {
|
||||||
name: '{{t("contains")}}',
|
name: '{{t("contains")}}',
|
||||||
|
type: 'boolean',
|
||||||
group: 'string'
|
group: 'string'
|
||||||
});
|
});
|
||||||
calculators.register('notIncludes', {
|
calculators.register('notIncludes', {
|
||||||
name: '{{t("does not contain")}}',
|
name: '{{t("does not contain")}}',
|
||||||
|
type: 'boolean',
|
||||||
group: 'string'
|
group: 'string'
|
||||||
});
|
});
|
||||||
calculators.register('startsWith', {
|
calculators.register('startsWith', {
|
||||||
name: '{{t("starts with")}}',
|
name: '{{t("starts with")}}',
|
||||||
|
type: 'boolean',
|
||||||
group: 'string'
|
group: 'string'
|
||||||
});
|
});
|
||||||
calculators.register('notStartsWith', {
|
calculators.register('notStartsWith', {
|
||||||
name: '{{t("not starts with")}}',
|
name: '{{t("not starts with")}}',
|
||||||
|
type: 'boolean',
|
||||||
group: 'string'
|
group: 'string'
|
||||||
});
|
});
|
||||||
calculators.register('endsWith', {
|
calculators.register('endsWith', {
|
||||||
name: '{{t("ends with")}}',
|
name: '{{t("ends with")}}',
|
||||||
|
type: 'boolean',
|
||||||
group: 'string'
|
group: 'string'
|
||||||
});
|
});
|
||||||
calculators.register('notEndsWith', {
|
calculators.register('notEndsWith', {
|
||||||
name: '{{t("not ends with")}}',
|
name: '{{t("not ends with")}}',
|
||||||
|
type: 'boolean',
|
||||||
|
group: 'string'
|
||||||
|
});
|
||||||
|
calculators.register('concat', {
|
||||||
|
name: '{{t("concat")}}',
|
||||||
|
type: 'string',
|
||||||
group: 'string'
|
group: 'string'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -203,10 +203,12 @@ calculators.register('notStartsWith', notStartsWith);
|
|||||||
calculators.register('endsWith', endsWith);
|
calculators.register('endsWith', endsWith);
|
||||||
calculators.register('notEndsWith', notEndsWith);
|
calculators.register('notEndsWith', notEndsWith);
|
||||||
|
|
||||||
function before(a: string, b: string) {
|
function concat(a: string, b: string) {
|
||||||
return a < b;
|
return a.concat(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculators.register('concat', concat);
|
||||||
|
|
||||||
calculators.register('now', () => new Date());
|
calculators.register('now', () => new Date());
|
||||||
|
|
||||||
// TODO: add more common calculators
|
// TODO: add more common calculators
|
||||||
|
Loading…
Reference in New Issue
Block a user