nocobase/packages/core/client/src/common/getVariableValue.ts
Katherine 86b6603b1d
feat: support variables in secondary confirmation title and content (#6787)
* feat: support variables in secondary confirmation title and content

* fix: bug

* fix: build error

* fix: e2e

* fix: test

* fix: test

* fix: test

* fix: test

* fix: bug

* fix: e2e test

* fix: e2e test

* fix: e2e test

* fix: e2e test

* fix: e2e test
2025-04-30 18:29:42 +08:00

24 lines
774 B
TypeScript

/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { evaluators } from '@nocobase/evaluators/client';
import { replaceVariables } from '../schema-settings/LinkageRules/bindLinkageRulesToFiled';
export const getVariableValue = async (text: string, scopes) => {
if (!text) {
return text;
}
const { evaluate } = evaluators.get('string');
const { exp, scope: expScope } = await replaceVariables(text, scopes);
const result = evaluate(exp, { now: () => new Date().toString(), ...expScope });
return result;
};