File tree 2 files changed +10
-2
lines changed
pages/app/functions/mods/FunctionPanel/CreateModal
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ export const COLOR_MODE = {
81
81
dark : "dark" ,
82
82
} ;
83
83
84
+ export const DEFAULT_CODE = `import cloud from '@lafjs/cloud'
85
+
86
+ export default async function (ctx: FunctionContext) {
87
+ console.log('Hello World')
88
+ return { data: 'hi, laf' }
89
+ }
90
+ ` ;
91
+
84
92
export enum APP_SETTING_KEY {
85
93
INFO = "info" ,
86
94
ENV = "env" ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import { debounce } from "lodash";
24
24
25
25
import { MoreTemplateIcon , TextIcon } from "@/components/CommonIcon" ;
26
26
import InputTag from "@/components/InputTag" ;
27
- import { SUPPORTED_METHODS } from "@/constants" ;
27
+ import { DEFAULT_CODE , SUPPORTED_METHODS } from "@/constants" ;
28
28
29
29
import { useCreateFunctionMutation , useUpdateFunctionMutation } from "../../../service" ;
30
30
import useFunctionStore from "../../../store" ;
@@ -58,7 +58,7 @@ const CreateModal = (props: {
58
58
description : functionItem ?. desc || "" ,
59
59
websocket : ! ! functionItem ?. websocket ,
60
60
methods : functionItem ?. methods || [ "GET" , "POST" ] ,
61
- code : functionItem ?. source ?. code || aiCode || "" ,
61
+ code : functionItem ?. source ?. code || aiCode || DEFAULT_CODE || "" ,
62
62
tags : functionItem ?. tags || [ ] ,
63
63
} ;
64
64
You can’t perform that action at this time.
0 commit comments