Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions mockServer/src/assets/json/appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1684,21 +1684,6 @@
"created_at": "2022-07-01T03:21:19.000Z",
"updated_at": "2022-07-01T03:21:19.000Z"
},
{
"id": 146,
"name": "npm",
"type": "function",
"content": {
"type": "JSFunction",
"value": "''"
},
"app": 1,
"category": "utils",
"created_by": null,
"updated_by": null,
"created_at": "2022-08-29T06:54:02.000Z",
"updated_at": "2023-01-05T01:00:52.000Z"
},
{
"id": 102,
"name": "Pager",
Expand Down
13 changes: 0 additions & 13 deletions mockServer/src/mock/get/app-center/apps/extension/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@
"created_at": "2022-07-01T03:21:19.000Z",
"updated_at": "2022-07-01T03:21:19.000Z"
},
{
"id": 146,
"name": "npm",
"type": "function",
"content": {
"type": "JSFunction",
"value": "''"
},
"app": 1,
"category": "utils",
"created_at": "2022-08-29T06:54:02.000Z",
"updated_at": "2023-01-05T01:00:52.000Z"
},
{
"id": 102,
"name": "Pager",
Expand Down
8 changes: 0 additions & 8 deletions mockServer/src/mock/get/app-center/v1/apps/schema/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2158,14 +2158,6 @@
"main": ""
}
},
{
"name": "npm",
"type": "function",
"content": {
"type": "JSFunction",
"value": "''"
}
},
{
"name": "Pager",
"type": "npm",
Expand Down
4 changes: 3 additions & 1 deletion packages/utils/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export function parseExpression(rawCode: any, context = {}) {
* @returns Function
*/
export function parseFunction(rawCode: any, context = {}) {
if (!rawCode || rawCode === "''" || rawCode === '""') return null
try {
return fun_ctor(`return (${rawCode})`).call(context).bind(context)
const result = fun_ctor(`return (${rawCode})`).call(context)
return typeof result === 'function' ? result.bind(context) : null
Comment on lines +44 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可能不做拦截更好,直接进入 try catch,有错误可以直接控制台上看到错误,方便快速定位错误。
如果是希望不打印错误,或者是向上抛出错误,可以考虑增加配置/增加实现

} catch (error) {
// eslint-disable-next-line no-console
console.error(`parseFunction error: ${JSON.stringify(error)}`)
Expand Down