From b63ba3d722ce587daecd44208bd2ce62335c130e Mon Sep 17 00:00:00 2001 From: pqcqaq <905739777@qq.com> Date: Tue, 16 Jul 2024 12:37:00 +0800 Subject: [PATCH] edit --- src/app.tsx | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index fc0baf7..70383f5 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,7 +4,7 @@ import { useState } from "react"; const functionBlockList = [ ` -const cpn = () => { + const cpn = () => { function handleClick() { console.log("Hi there!"); } @@ -227,12 +227,9 @@ ${func} render(cpn) `; -const editor = ( - func: string, - setShowEdit: React.Dispatch> -) => { +const editor = (setShowEdit: React.Dispatch>) => { return ( -
+
- +
+ {functionBlockList.map((func, index) => { + return ( +
+ { + functionBlockList[index] = code; + }} + /> +
+ ); + })} +
); }; @@ -258,8 +268,7 @@ export const DemoApp = () => { return (
- {showEdit && editor(functionBlockList.join("\n"), setShowEdit)} - {/* 主题切换页面和代码动态编辑页面 */} + {showEdit && editor(setShowEdit)} {!showEdit && ( <>
@@ -281,7 +290,6 @@ export const DemoApp = () => { > 浅色模式 - {/* 打开代码编辑框 */}