feat(plugin-workflow): add concat calculator (#894)

(cherry picked from commit 7f3f1bc982379ec2d274ca79fb4d6c65664d3c2d)
This commit is contained in:
Junyi 2022-10-12 14:53:44 +08:00 committed by chenos
parent 47c1764ac3
commit 7ca8e562ce
3 changed files with 28 additions and 2 deletions

View File

@ -590,6 +590,7 @@ export default {
'Calculation result': '运算结果',
'True': '真',
'False': '假',
'concat': '连接',
'Condition': '条件判断',
'Mode': '模式',

View File

@ -18,6 +18,7 @@ function NullRender() {
interface Calculator {
name: string;
type: 'boolean' | 'number' | 'string' | 'date' | 'unknown' | 'null' | 'array';
group: string;
}
@ -25,72 +26,94 @@ export const calculators = new Registry<Calculator>();
calculators.register('equal', {
name: '=',
type: 'boolean',
group: 'boolean',
});
calculators.register('notEqual', {
name: '≠',
type: 'boolean',
group: 'boolean',
});
calculators.register('gt', {
name: '>',
type: 'boolean',
group: 'boolean',
});
calculators.register('gte', {
name: '≥',
type: 'boolean',
group: 'boolean',
});
calculators.register('lt', {
name: '<',
type: 'boolean',
group: 'boolean',
});
calculators.register('lte', {
name: '≤',
type: 'boolean',
group: 'boolean',
});
calculators.register('add', {
name: '+',
type: 'number',
group: 'number',
});
calculators.register('minus', {
name: '-',
type: 'number',
group: 'number',
});
calculators.register('multiple', {
name: '*',
type: 'number',
group: 'number',
});
calculators.register('divide', {
name: '/',
type: 'number',
group: 'number',
});
calculators.register('mod', {
name: '%',
type: 'number',
group: 'number',
});
calculators.register('includes', {
name: '{{t("contains")}}',
type: 'boolean',
group: 'string'
});
calculators.register('notIncludes', {
name: '{{t("does not contain")}}',
type: 'boolean',
group: 'string'
});
calculators.register('startsWith', {
name: '{{t("starts with")}}',
type: 'boolean',
group: 'string'
});
calculators.register('notStartsWith', {
name: '{{t("not starts with")}}',
type: 'boolean',
group: 'string'
});
calculators.register('endsWith', {
name: '{{t("ends with")}}',
type: 'boolean',
group: 'string'
});
calculators.register('notEndsWith', {
name: '{{t("not ends with")}}',
type: 'boolean',
group: 'string'
});
calculators.register('concat', {
name: '{{t("concat")}}',
type: 'string',
group: 'string'
});

View File

@ -203,10 +203,12 @@ calculators.register('notStartsWith', notStartsWith);
calculators.register('endsWith', endsWith);
calculators.register('notEndsWith', notEndsWith);
function before(a: string, b: string) {
return a < b;
function concat(a: string, b: string) {
return a.concat(b);
}
calculators.register('concat', concat);
calculators.register('now', () => new Date());
// TODO: add more common calculators