2 Star 5 Fork 3

hongxp/amis-react-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

amis react demo 示例项目

一、说明

  1. 参照 官方源代码官网示例代码 实现。

  2. 主要依赖如下:

  • amis ^6.0.0(包含amis-ui、amis-core)

  • axios ^1.4.0

  • react ^18.2.0

  • react-dom ^18.2.0

  • react-router-dom ^6.21.2(包含react-router)

  • vite ^5.0.11

  • @vitejs/plugin-react ^4.2.1

二、使用方法

1.安装依赖

pnpm install

需要稍等片刻

2.启动

pnpm dev

访问:http://localhost:8888

3.页面开发

(1)在/src/pages目录下新建文件夹

(2)然后在对应文件夹下创建jsx文件,命名导出或默认导出一个json对象,json对象的内容需参考Amis官方文档进行配置。

也可使用官方提供的可视化编辑器来生成。官方提供的编辑器的相关网页由github.io部署,访问速度较慢,甚至无法访问。可以下载Amis可视化编辑器的源码进行本地化部署,部署方法见文末“三、Amis可视化编辑器的本地化部署”。

(3)在src\Navigations.jsx的navigations常量中增加如下类似配置,以便生成菜单和路由。

      {
        label: '示例页面',
        icon: 'fa fa-th',
        badge: 3,
        badgeClassName: 'bg-info',
        children: [
          {
            label: '简单页面',
            path: '/examples/index',
            component: EasyPageSchema
          },
          {
            label: '表单页面',
            path: '/examples/form',
            component: FormPageSchema
          }
        ]
      }

(4)启动状态下浏览器页面会自动刷新,可即时查看效果

4.打包

pnpm build

三、Amis可视化编辑器的本地化部署

注:适用于5.6.2、6.0.0(最新版本)版本的源码,其他较低版本暂未验证。

1.源代码获取:

https://github.com/aisuda/amis-editor-demo

2.调试(开发)模式下运行

(1)安装依赖:npm install

备注:若使用pnpm安装依赖,很多包都找不到,要根据报错一个一个重新安装,比如:(还有一些没有一一列明)babel-loader、params-replace-loader、 ts-loader、 @babel/runtime等

(2)将src目录下index.html中的“https://unpkg.com/animate.css@4.1.1/animate.min.css” 修改为 “https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.min.css”

(3)将配置文件amis.config.js中的所有assetsPublicPath参数的值修改为“/”

(4)调试模式运行:npm run dev

(5)浏览器访问:localhost:80 ,查看是否正产运行

3.编译及部署

(1)编译: npm run build

(2)将demo-6.0.0文件夹下的打包内容部署到nginx

4.此外,还可以直接使用源代码中打包好的各个版本进行部署

以下以demo-5.6.2为例:

(1)找到源代码中的“demo-5.6.2”文件夹,全部拷贝出来。

(2)修改index.html中的“https://unpkg.com/animate.css@4.1.1/animate.min.css” 为 “https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.min.css”

(3)使用开发工具(vs-code)将工程中所有的“https://aisuda.github.io/amis-editor-demo/demo-5.6.2/” 进行全局替换,替换为“/”

(4)将所有文件拷贝到nginx的html目录进行发布。

注意:部署到nginx后,可以正常运行,但是schema.json是404【不用管,官方示例也是同样的问题】。

MIT License Copyright (c) 2024 hongxiangping Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个集成百度低代码前端框架Amis的React示例工程,在amis官方示例代码基础上进行了升级改造。可以使用Amis JSON 配置来生成页面,减少页面开发工作量,极大提升效率。 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/hongxpCode/amis-react-demo.git
git@gitee.com:hongxpCode/amis-react-demo.git
hongxpCode
amis-react-demo
amis-react-demo
master

搜索帮助