"添加前端模板和运行代码模块"
This commit is contained in:
39
qiming-run_code_rmcp/fixtures/test_js_params.js
Normal file
39
qiming-run_code_rmcp/fixtures/test_js_params.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// JavaScript测试文件,演示参数传递
|
||||
|
||||
// 打印一些调试信息
|
||||
console.log("JavaScript脚本开始执行...");
|
||||
|
||||
// 定义一个加法函数
|
||||
function add(a, b) {
|
||||
console.log(`正在计算: ${a} + ${b}`);
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// 处理一些数据
|
||||
const numbers = [1, 2, 3, 4, 5];
|
||||
console.log(`处理数字列表: ${numbers}`);
|
||||
|
||||
/**
|
||||
* 处理函数,接收参数并返回结果
|
||||
* 注意:这个函数必须存在,并且会被框架调用来获取结果
|
||||
*/
|
||||
function handler(input) {
|
||||
console.log(`接收到的参数: ${JSON.stringify(input)}`);
|
||||
|
||||
// 从参数中获取值,提供默认值
|
||||
const a = input.a || 0;
|
||||
const b = input.b || 0;
|
||||
const name = input.name || "用户";
|
||||
|
||||
// 计算结果
|
||||
const result = add(a, b);
|
||||
console.log(`计算完成: ${a} + ${b} = ${result}`);
|
||||
|
||||
// 返回结果
|
||||
return {
|
||||
sum: result,
|
||||
numbers: numbers,
|
||||
greeting: `你好,${name}!`,
|
||||
message: `成功计算 ${a} + ${b} 的结果`
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user