perf: 修改数据展示为动态获取

This commit is contained in:
奔跑的面条
2022-07-06 17:18:38 +08:00
parent 6a5fe679be
commit d00ba1fdaa
7 changed files with 60 additions and 27 deletions
+10
View File
@@ -1,3 +1,5 @@
import isObject from 'lodash/isObject'
export function isString(p: any): p is string {
return typeof p === 'string'
}
@@ -21,3 +23,11 @@ export function isNull(p: any): p is null {
export function isArray(p: any): p is [] {
return Array.isArray(p)
}
export const toNumber = (number: number | string, toFixedNumber = 2) => {
return isString(number) ? parseFloat(parseFloat(number).toFixed(2)) : number
}
export const toString = (str: any) => {
return isNumber(str) ? `${str}` : (isObject(str) ? JSON.stringify(str) : str)
}
+1 -1
View File
@@ -204,7 +204,7 @@ export const newFunctionHandle = (
if (!funcStr) return data
const fn = new Function('data', funcStr)
const fnRes = fn( cloneDeep(data))
const resHandle = toString && isString(fnRes) ? JSON.stringify(fnRes) : fnRes
const resHandle = toString && isString(fnRes) ? fnRes : JSON.stringify(fnRes)
// 成功回调
successCallBack && successCallBack(resHandle)
return resHandle