Skip to content

Commit 0b903e8

Browse files
authored
fix(web): fix create function default code (#1544)
1 parent 8c68089 commit 0b903e8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

web/src/constants/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ export const COLOR_MODE = {
8181
dark: "dark",
8282
};
8383

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+
8492
export enum APP_SETTING_KEY {
8593
INFO = "info",
8694
ENV = "env",

web/src/pages/app/functions/mods/FunctionPanel/CreateModal/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { debounce } from "lodash";
2424

2525
import { MoreTemplateIcon, TextIcon } from "@/components/CommonIcon";
2626
import InputTag from "@/components/InputTag";
27-
import { SUPPORTED_METHODS } from "@/constants";
27+
import { DEFAULT_CODE, SUPPORTED_METHODS } from "@/constants";
2828

2929
import { useCreateFunctionMutation, useUpdateFunctionMutation } from "../../../service";
3030
import useFunctionStore from "../../../store";
@@ -58,7 +58,7 @@ const CreateModal = (props: {
5858
description: functionItem?.desc || "",
5959
websocket: !!functionItem?.websocket,
6060
methods: functionItem?.methods || ["GET", "POST"],
61-
code: functionItem?.source?.code || aiCode || "",
61+
code: functionItem?.source?.code || aiCode || DEFAULT_CODE || "",
6262
tags: functionItem?.tags || [],
6363
};
6464

0 commit comments

Comments
 (0)