From df75f138160f2ae24712966c0713503793da3e01 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Fri, 28 Nov 2025 18:54:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0AI=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/Creator.tsx | 90 ++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/client/src/pages/Creator.tsx b/client/src/pages/Creator.tsx index 185fd49..cbf1e6a 100644 --- a/client/src/pages/Creator.tsx +++ b/client/src/pages/Creator.tsx @@ -1,5 +1,32 @@ import React from 'react' import {amisRender, commonInfo, horizontalFormOptions} from '../util/amis.tsx' +import {type Schema, uuid} from 'amis' + +const aiToolbar = (component: Schema): Schema[] => { + const id = uuid() + return [ + { + ...component, + componentId: id, + }, + { + className: 'text-right', + type: 'button-toolbar', + buttons: [ + { + type: 'action', + label: 'AI 生成', + icon: 'fa fa-brain', + }, + { + type: 'action', + label: 'AI 润色', + icon: 'fa fa-edit', + }, + ], + }, + ] +} function Creator() { return ( @@ -16,7 +43,7 @@ function Creator() { wrapWithPanel: false, canAccessSuperData: false, body: [ - { + ...aiToolbar({ type: 'textarea', name: 'outline', label: '故事概述', @@ -24,8 +51,8 @@ function Creator() { required: true, trimContents: true, showCounter: true, - }, - { + }), + ...aiToolbar({ type: 'textarea', name: 'world', label: '世界观', @@ -33,7 +60,7 @@ function Creator() { required: true, trimContents: true, showCounter: true, - }, + }), { type: 'input-tag', name: 'tags', @@ -58,18 +85,14 @@ function Creator() { leftFixed: 'sm', }, items: [ - { - type: 'uuid', - name: 'id', - }, - { + ...aiToolbar({ type: 'input-text', name: 'name', label: '名称', clearable: true, required: true, trimContents: true, - }, + }), { type: 'select', name: 'sex', @@ -95,7 +118,7 @@ function Creator() { precision: 0, required: true, }, - { + ...aiToolbar({ type: 'textarea', name: 'appearance', label: '外形', @@ -103,8 +126,9 @@ function Creator() { required: true, trimContents: true, showCounter: true, - }, - { + }), + ...aiToolbar({ + componentId: 'd8eecb59-153d-4f5e-97b7-a52f4dc2dc58', type: 'textarea', name: 'disposition', label: '性格', @@ -112,31 +136,31 @@ function Creator() { required: true, trimContents: true, showCounter: true, - }, - { + }), + ...aiToolbar({ type: 'textarea', name: 'clothes', label: '衣着', clearable: true, trimContents: true, showCounter: true, - }, - { + }), + ...aiToolbar({ type: 'textarea', name: 'experience', label: '经历', clearable: true, trimContents: true, showCounter: true, - }, - { + }), + ...aiToolbar({ type: 'textarea', name: 'family', label: '家庭', clearable: true, trimContents: true, showCounter: true, - }, + }), { type: 'input-kvs', name: 'extra2', @@ -152,21 +176,19 @@ function Creator() { leftFixed: 'sm', }, }, - valueItems: [ - { - type: 'textarea', - name: 'value', - label: '属性内容', - clearable: true, - required: true, - trimContents: true, - showCounter: true, - mode: 'horizontal', - horizontal: { - leftFixed: 'sm', - }, + valueItems: aiToolbar({ + type: 'textarea', + name: 'value', + label: '属性内容', + clearable: true, + required: true, + trimContents: true, + showCounter: true, + mode: 'horizontal', + horizontal: { + leftFixed: 'sm', }, - ], + }), }, ], },