ant-codeAI 通过截图生成代码

一、✨简介

最近开源项目screenshot-to-code火爆,在screenshot-to-code基础上将后端代码改为node,开源地址ant-codeAI,提供截图生成代码的功能,使用GPT-4 Vision生成,在原有(React,Tailwind CSS)等代码基础上,新增react/ant design的代码输出,后续会逐步迭代自己的创意,不止于截图生成代码。

二、🚀 本地试用

可以先下载下来本地运行尝试,将尽快找服务器部署到线上,(有没有免费的部署环境帮推荐一个🤦‍♂️)。腾讯云有部署如需要尝试可以私聊。

shell 复制代码
cd client
yarn dev


cd service
npm run start:dev

三、🛠 设置

  • OpenAI API Key
  • OpenAI Base URL:代理地址,默认:api.openai.com/v1
  • Mock AI Response:模拟 AI返回的数据,不直接请求openAI,请求OpenAI 接口会消耗费用。

四、🔥 使用场景

试用通过图片生成的代码细节准确度不高。可以用于快速验证方案、对细节不敏感的项目、在生成的代码基础上自行补全细节。

  • 中后台项目
  • 快速验证方案,对还原度要求不高的项目
  • 生成代码后二次开发

五、⌨️ 输出代码

html 复制代码
<html>
<head>
  <title>Registration Form</title>
  <link rel="stylesheet" href="https://unpkg.com/antd@5.12.1/dist/antd.min.css">
</head>
<body>
  <div id="root"></div>

  <script src="https://unpkg.com/react/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/dayjs@1.11.10/dayjs.min.js"></script>
  <script src="https://unpkg.com/@babel/standalone/babel.js"></script>
  <script src="https://unpkg.com/antd@5.12.1/dist/antd.min.js"></script>

  <script type="text/babel">
    const { Form, Input, Cascader, Checkbox, Button,  Select} = antd;

    const residenceOptions = [
      {
        value: 'zhejiang',
        label: 'Zhejiang',
        children: [
          {
            value: 'hangzhou',
            label: 'Hangzhou',
            children: [
              {
                value: 'westlake',
                label: 'West Lake',
              },
            ],
          },
        ],
      },
      // ...other province options
    ];

    function RegistrationForm() {
      return (
        <Form
          labelCol={{ span: 8 }}
          wrapperCol={{ span: 16 }}
          layout="horizontal"
        >
          <Form.Item label="Nickname" required tooltip="This is a required field">
            <Input placeholder="" />
          </Form.Item>
          <Form.Item label="Habitual Residence" required>
            <Cascader
              options={residenceOptions}
              defaultValue={['zhejiang', 'hangzhou', 'westlake']}
              placeholder="Please select your habitual residence"
            />
          </Form.Item>
          <Form.Item label="Phone Number" required>
            <Input addonBefore={<Select defaultValue="+86" style={{ width: 70 }}>
              {/* Add other country codes as needed */}
            </Select>} style={{ width: '100%' }} />
          </Form.Item>
          <Form.Item label="Donation" required>
            <Input placeholder="" />
          </Form.Item>
          <Form.Item label="Website" required>
            <Input placeholder="website" />
          </Form.Item>
          <Form.Item label="Intro" required>
            <Input.TextArea showCount maxLength={100} />
          </Form.Item>
          <Form.Item label="Gender" required>
            <Select placeholder="select your gender">
              {/* Add gender options as needed */}
            </Select>
          </Form.Item>
          <Form.Item label="Captcha" extra="We must make sure that your are a human.">
            <Input />
          </Form.Item>
          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
            <Checkbox>I have read the agreement</Checkbox>
          </Form.Item>
          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
            <Button type="primary">Register</Button>
          </Form.Item>
        </Form>
      );
    }

    ReactDOM.render(<RegistrationForm />, document.getElementById('root'));
  </script>
</body>
</html>

六、🙋‍♂️ 开源地址

ant-codeAI

相关推荐
ze_juejin21 小时前
Angular 中设置宿主元素(Host)样式的方法
前端
用户904438163246021 小时前
《零代码基础也能 AI 创作?GPT+DALL・E 实战教程,10 分钟上手》
前端·github
WillaWang21 小时前
aria | "Accessible Rich Internet Applications"
前端
reoreo21 小时前
如何使用 i18next 实现多种语言的国际化(从新建 vite ts 项目开始)
前端·javascript
云动雨颤21 小时前
Typecho 博客统计脚本怎么装?同步 / 异步 + Head/Body 选择指南
前端·html
golang学习记21 小时前
用好 Cursor Composer:把 AI 多文件编辑能力真正转化为生产力
人工智能
用户40993225021221 小时前
快速入门Vue3的v-指令:数据和DOM的“翻译官”到底有多少本事?
前端·ai编程·trae
Asort21 小时前
JavaScript设计模式(二十三)——访问者模式:优雅地扩展对象结构
前端·javascript·设计模式
背包客研究21 小时前
小模型是AI Agent的未来
人工智能·搜索引擎
oscar99921 小时前
1.1 神经网络基本组成
人工智能·深度学习·神经网络