diff --git a/.gitignore b/.gitignore index 1f22b9c..5c5d33b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,116 +1,4 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* +/node_modules +/package-lock.json +/gh-pages +/.idea diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..2ada450 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "singleQuote": true, + "semi": true, + "trailingComma": "none", + "bracketSpacing": false, + "quoteProps": "consistent", + "arrowParens": "avoid", + "jsxBracketSameLine": false +} diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 67346e1..0000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# austin-admin - -#### Description -austin项目前端,依赖amis - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index f979eff..a911db2 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,19 @@ -# austin-admin +# amis admin 模板 -#### 介绍 -austin项目前端,依赖amis +基于 [amis](https://github.com/baidu/amis) 渲染器,快速搭建自己的管理系统。 -#### 软件架构 -软件架构说明 +## 快速开始 +其实这个项目直接双击 `index.html` 都能看大部分效果,不过为了更完整体验,请运行下面的命令: -#### 安装教程 +```bash -1. xxxx -2. xxxx -3. xxxx +# 安装依赖 +npm i +# 打开服务 +npm start +``` -#### 使用说明 +## 部署上线 -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +这个例子中的 amis 等依赖使用外部 cdn,为了稳定请在自己部署的时候将文件下载到本地。 \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..59ee0fa --- /dev/null +++ b/index.html @@ -0,0 +1,198 @@ + + + + + amis admin + + + + + + + + + + + +
+ + + diff --git a/nodemon.json b/nodemon.json new file mode 100644 index 0000000..367a505 --- /dev/null +++ b/nodemon.json @@ -0,0 +1,4 @@ +{ + "verbose": true, + "ignore": ["node_modules/*"] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d25caa2 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "amis-boilerplate", + "version": "1.0.0", + "description": "基于 amis 的项目模板", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js", + "gh-pages": "rm -rf gh-pages && fis3 release gh-pages -c", + "deploy-gh-pages": "git subtree push --prefix gh-pages origin gh-pages" + }, + "keywords": [ + "amis", + "boilerplate", + "admin", + "react" + ], + "author": "fex", + "license": "MIT", + "devDependencies": { + "body-parser": "^1.19.0", + "express": "^4.17.1", + "morgan": "^1.10.0", + "nodemon": "^2.0.7", + "reload": "^3.1.1" + } +} diff --git a/pages/console.json b/pages/console.json new file mode 100644 index 0000000..cb7a8a9 --- /dev/null +++ b/pages/console.json @@ -0,0 +1,5 @@ +{ + "type": "page", + "title": "Dashboard", + "body": "body..." +} diff --git a/pages/crud-advance.json b/pages/crud-advance.json new file mode 100644 index 0000000..cd94597 --- /dev/null +++ b/pages/crud-advance.json @@ -0,0 +1,274 @@ +{ + "type": "page", + "title": "复杂表单", + "subTitle": "展示表格编辑、联动等等", + "body": [ + { + "type": "form", + "mode": "horizontal", + "title": "", + "affixFooter": true, + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/form/save", + "actions": [ + { + "label": "保存", + "type": "submit", + "level": "success" + } + ], + "controls": [ + { + "type": "fieldSet", + "title": "基本配置", + "controls": [ + { + "type": "text", + "label": "任务名称", + "name": "title", + "size": "md", + "required": true + }, + + { + "type": "textarea", + "label": "任务描述", + "name": "description", + "size": "md" + }, + + { + "label": "任务频率", + "type": "radios", + "name": "repeat", + "inline": true, + "value": "none", + "required": true, + "options": [ + { + "label": "不重复", + "value": "none" + }, + + { + "label": "每天", + "value": "day" + }, + + { + "label": "每周", + "value": "week" + }, + + { + "label": "每月", + "value": "month" + } + ] + }, + + { + "label": "每天几点", + "type": "select", + "name": "time", + "multiple": true, + "required": true, + "extractValue": true, + "visibleOn": "this.repeat == \"day\"", + "inline": true, + "options": [ + {"value": 0, "label": "0:00"}, + {"value": 1, "label": "1:00"}, + {"value": 2, "label": "2:00"}, + {"value": 3, "label": "3:00"}, + {"value": 4, "label": "4:00"}, + {"value": 5, "label": "5:00"}, + {"value": 6, "label": "6:00"}, + {"value": 7, "label": "7:00"}, + {"value": 8, "label": "8:00"}, + {"value": 9, "label": "9:00"}, + {"value": 10, "label": "10:00"}, + {"value": 11, "label": "11:00"}, + {"value": 12, "label": "12:00"}, + {"value": 13, "label": "13:00"}, + {"value": 14, "label": "14:00"}, + {"value": 15, "label": "15:00"}, + {"value": 16, "label": "16:00"}, + {"value": 17, "label": "17:00"}, + {"value": 18, "label": "18:00"}, + {"value": 19, "label": "19:00"}, + {"value": 20, "label": "20:00"}, + {"value": 21, "label": "21:00"}, + {"value": 22, "label": "22:00"}, + {"value": 23, "label": "23:00"} + ] + }, + + { + "label": "每周几执行", + "type": "button-group", + "name": "weekdays", + "size": "md", + "visibleOn": "this.repeat == \"week\"", + "clearable": true, + "multiple": true, + "required": true, + "extractValue": true, + "maxLength": 7, + "options": [ + { + "label": "周一", + "value": "0" + }, + + { + "label": "周二", + "value": "1" + }, + + { + "label": "周三", + "value": "2" + }, + + { + "label": "周四", + "value": "3" + }, + + { + "label": "周五", + "value": "4" + }, + + { + "label": "周六", + "value": "5" + }, + + { + "label": "周日", + "value": "6" + } + ] + }, + + { + "label": "每月几号执行", + "type": "list", + "name": "monthday", + "size": "md", + "visibleOn": "this.repeat == \"month\"", + "required": true, + "maxLength": 31, + "clearable": true, + "multiple": true, + "extractValue": true, + "options": [ + {"value": 0, "label": "01"}, + {"value": 1, "label": "02"}, + {"value": 2, "label": "03"}, + {"value": 3, "label": "04"}, + {"value": 4, "label": "05"}, + {"value": 5, "label": "06"}, + {"value": 6, "label": "07"}, + {"value": 7, "label": "08"}, + {"value": 8, "label": "09"}, + {"value": 9, "label": "10"}, + {"value": 10, "label": "11"}, + {"value": 11, "label": "12"}, + {"value": 12, "label": "13"}, + {"value": 13, "label": "14"}, + {"value": 14, "label": "15"}, + {"value": 15, "label": "16"}, + {"value": 16, "label": "17"}, + {"value": 17, "label": "18"}, + {"value": 18, "label": "19"}, + {"value": 19, "label": "20"}, + {"value": 20, "label": "21"}, + {"value": 21, "label": "22"}, + {"value": 22, "label": "23"}, + {"value": 23, "label": "24"}, + {"value": 24, "label": "25"}, + {"value": 25, "label": "26"}, + {"value": 26, "label": "27"}, + {"value": 27, "label": "28"}, + {"value": 28, "label": "29"}, + {"value": 29, "label": "30"}, + {"value": 30, "label": "31"} + ] + } + ] + }, + + { + "type": "fieldSet", + "title": "其他信息", + "collapsable": true, + "controls": [ + { + "type": "combo", + "name": "admins", + "label": "用户列表", + "value": [""], + "description": "请输入用户信息,不要重复。", + "multiple": true, + "inline": true, + "controls": [ + { + "type": "text", + "name": "name", + "unique": true + }, + + { + "type": "select", + "name": "perm", + "value": "read", + "options": [ + { + "label": "可读", + "value": "read" + }, + + { + "label": "可写", + "value": "write" + } + ] + } + ] + }, + { + "label": "新增一行", + "type": "button", + "actionType": "add", + "target": "thetable", + "level": "info" + }, + { + "name": "thetable", + "type": "table", + "label": "任务参数", + "editable": true, + "addable": true, + "removable": true, + "columns": [ + { + "label": "参数名", + "name": "key", + "quickEdit": true + }, + + { + "label": "参数值", + "name": "value", + "quickEdit": true + } + ] + } + ] + } + ] + } + ] +} diff --git a/pages/crud-edit.json b/pages/crud-edit.json new file mode 100644 index 0000000..c5144b0 --- /dev/null +++ b/pages/crud-edit.json @@ -0,0 +1,64 @@ +{ + "type": "page", + "title": "修改 ${params.id}", + "remark": null, + "toolbar": [ + { + "type": "button", + "actionType": "link", + "link": "/crud/list", + "label": "返回列表" + } + ], + "body": [ + { + "type": "form", + "initApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample/${params.id}", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample/$id", + "redirect": "/crud/list", + "controls": [ + { + "type": "text", + "name": "engine", + "label": "Engine", + "required": true + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "browser", + "label": "Browser", + "required": true + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "platform", + "label": "Platform(s)", + "required": true + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "version", + "label": "Engine version" + }, + { + "type": "divider" + }, + { + "type": "select", + "name": "grade", + "label": "CSS grade", + "options": ["A", "B", "C", "D", "X"] + } + ] + } + ] +} diff --git a/pages/crud-list.json b/pages/crud-list.json new file mode 100644 index 0000000..765f088 --- /dev/null +++ b/pages/crud-list.json @@ -0,0 +1,149 @@ +{ + "type": "page", + "title": "列表.", + "remark": null, + "name": "page-demo", + "toolbar": [ + { + "type": "button", + "actionType": "link", + "link": "/crud/new", + "label": "新增", + "primary": true + } + ], + "body": [ + { + "type": "crud", + "name": "sample", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample", + "filter": { + "title": "", + "mode": "inline", + "wrapWithPanel": false, + "submitText": "", + "controls": [ + { + "type": "text", + "name": "keywords", + "placeholder": "通过关键字搜索", + "addOn": { + "label": "搜索", + "type": "submit", + "className": "btn-success" + }, + "clearable": true + } + ], + "className": "m-b-sm" + }, + "bulkActions": [ + { + "label": "批量修改", + "type": "button", + "actionType": "dialog", + "level": "primary", + "dialog": { + "title": "批量编辑", + "name": "sample-bulk-edit", + "body": { + "type": "form", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample/bulkUpdate2", + "controls": [ + { + "type": "text", + "name": "engine", + "label": "Engine" + } + ] + } + } + }, + { + "label": "批量删除", + "type": "button", + "level": "danger", + "actionType": "ajax", + "api": "delete:https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample/$ids", + "confirmText": "确定要批量删除?" + } + ], + "columns": [ + { + "name": "engine", + "label": "Rendering engine", + "sortable": true + }, + { + "name": "id", + "label": "ID", + "width": 20, + "sortable": true + }, + { + "name": "browser", + "label": "Browser", + "sortable": true + }, + { + "name": "platform", + "label": "Platform(s)", + "sortable": true + }, + { + "name": "version", + "label": "Engine version" + }, + { + "name": "grade", + "label": "CSS grade" + }, + { + "type": "operation", + "label": "操作", + "width": "", + "buttons": [ + { + "type": "button-group", + "buttons": [ + { + "type": "button", + "label": "查看", + "level": "primary", + "actionType": "link", + "link": "/crud/${id}" + }, + { + "type": "button", + "label": "修改", + "level": "info", + "actionType": "link", + "link": "/crud/${id}/edit" + }, + { + "type": "button", + "label": "删除", + "level": "danger", + "actionType": "ajax", + "confirmText": "您确认要删除?", + "api": "delete:https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample/$id" + } + ] + } + ], + "placeholder": "-", + "fixed": "right" + } + ], + "affixHeader": true, + "columnsTogglable": "auto", + "placeholder": "暂无数据", + "tableClassName": "table-db table-striped", + "headerClassName": "crud-table-header", + "footerClassName": "crud-table-footer", + "toolbarClassName": "crud-table-toolbar", + "combineNum": 0, + "bodyClassName": "panel-default" + } + ] +} diff --git a/pages/crud-new.json b/pages/crud-new.json new file mode 100644 index 0000000..49bf000 --- /dev/null +++ b/pages/crud-new.json @@ -0,0 +1,69 @@ +{ + "type": "page", + "title": "新增", + "remark": null, + "toolbar": [ + { + "type": "button", + "actionType": "link", + "link": "/crud/list", + "label": "返回列表" + } + ], + "body": [ + { + "title": "", + "type": "form", + "redirect": "/crud/list", + "name": "sample-edit-form", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample", + "controls": [ + { + "type": "text", + "name": "engine", + "label": "Engine", + "required": true, + "inline": false, + "description": "", + "descriptionClassName": "help-block", + "placeholder": "", + "addOn": null + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "browser", + "label": "Browser", + "required": true + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "platform", + "label": "Platform(s)", + "required": true + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "version", + "label": "Engine version" + }, + { + "type": "divider" + }, + { + "type": "text", + "name": "grade", + "label": "CSS grade" + } + ] + } + ] +} diff --git a/pages/crud-view.json b/pages/crud-view.json new file mode 100644 index 0000000..3469520 --- /dev/null +++ b/pages/crud-view.json @@ -0,0 +1,65 @@ +{ + "type": "page", + "title": "查看详情 ${params.id}", + "remark": null, + "toolbar": [ + { + "type": "button", + "actionType": "link", + "link": "/crud/list", + "label": "返回列表" + } + ], + "body": [ + { + "type": "form", + "initApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/sample/${params.id}", + "controls": [ + { + "type": "static", + "name": "engine", + "label": "Engine" + }, + { + "type": "divider" + }, + { + "type": "static", + "name": "browser", + "label": "Browser" + }, + { + "type": "divider" + }, + { + "type": "static", + "name": "platform", + "label": "Platform(s)" + }, + { + "type": "divider" + }, + { + "type": "static", + "name": "version", + "label": "Engine version" + }, + { + "type": "divider" + }, + { + "type": "static", + "name": "grade", + "label": "CSS grade" + }, + { + "type": "divider" + }, + { + "type": "html", + "html": "

添加其他 Html 片段 需要支持变量替换(todo).

" + } + ] + } + ] +} diff --git a/pages/editor.json b/pages/editor.json new file mode 100644 index 0000000..a6bb29c --- /dev/null +++ b/pages/editor.json @@ -0,0 +1,18 @@ +{ + "type": "page", + "title": "代码编辑器", + "subTitle": "使用的monaco-editor,用到了 worker, 如果控制台没有报错,说明一起正常。", + "body": [ + { + "type": "form", + "controls": [ + { + "type": "editor", + "name": "js", + "label": "Javascript", + "size": "md" + } + ] + } + ] +} diff --git a/pages/form-basic.json b/pages/form-basic.json new file mode 100644 index 0000000..7040b9c --- /dev/null +++ b/pages/form-basic.json @@ -0,0 +1,241 @@ +{ + "type": "page", + "title": "基础表单", + "subTitle": "展示一些常规的表单,包括验证、提示等等", + "body": [ + { + "type": "form", + "mode": "horizontal", + "title": "常规表单示例", + "affixFooter": true, + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/form/save", + "actions": [ + { + "label": "保存", + "type": "submit", + "level": "success" + } + ], + "controls": [ + { + "label": " 标题", + "type": "text", + "placeholder": "请输入标题", + "description": "请输入一个能吸引眼球的标题", + "name": "title", + "size": "md" + }, + + { + "label": "编号", + "required": true, + "type": "text", + "placeholder": "请输入编号", + "name": "b", + "size": "md", + "validations": { + "matchRegexp": "/^\\w{4}-\\w{4}-\\w{4}$/" + }, + "validationErrors": { + "matchRegexp": "您输入的内容格式不对,请按提示输入!" + }, + "hint": "输入范例:xxxx-xxxx-xxxx" + }, + + { + "label": "置顶", + "type": "switch", + "name": "c", + "inline": true, + "labelRemark": "开启后将置顶这条数据!" + }, + + { + "label": "活动时间", + "type": "date-range", + "name": "range", + "size": "md", + "remark": "这是一个字段时间范围" + }, + + { + "label": "日期范围", + "type": "group", + "controls": [ + { + "type": "date", + "size": "md", + "name": "start", + "mode": "inline", + "maxDate": "${end}" + }, + + { + "label": "到", + "type": "date", + "size": "md", + "name": "end", + "inputClassName": "m-l-sm", + "mode": "inline", + "minDate": "${start}", + "remark": "这是两个字段的时间范围" + } + ] + }, + + { + "label": "浏览器", + "type": "button-group", + "name": "browser", + "value": "chrome", + "options": [ + { + "label": "Chrome", + "value": "chrome" + }, + + { + "label": "火狐", + "value": "firefox" + }, + + { + "label": "IE", + "value": "ie" + } + ] + }, + + { + "type": "list", + "name": "taocan", + "label": "套餐选择", + "options": [ + { + "value": 1, + "body": "
套餐:C01
CPU:2核
内存:1GB
SSD盘:10GB
" + }, + { + "value": 2, + "body": "
套餐:C02
CPU:4核
内存:4GB
SSD盘:20GB
" + }, + { + "value": 3, + "disabled": true, + "body": "
套餐:C03
CPU:8核
内存:8GB
SSD盘:50GB
" + } + ] + }, + + { + "label": "最爱周几", + "type": "select", + "name": "select", + "size": "md", + "clearable": true, + "options": [ + { + "label": "周一", + "value": "0" + }, + + { + "label": "周二", + "value": "1" + }, + + { + "label": "周三", + "value": "2" + }, + + { + "label": "周四", + "value": "3" + }, + + { + "label": "周五", + "value": "4" + }, + + { + "label": "周六", + "value": "5" + }, + + { + "label": "周日", + "value": "6" + } + ] + }, + + { + "label": "休息日", + "type": "list", + "name": "freeday", + "value": ["5", "6"], + "multiple": true, + "extractValue": true, + "options": [ + { + "label": "周一", + "value": "0" + }, + + { + "label": "周二", + "value": "1" + }, + + { + "label": "周三", + "value": "2" + }, + + { + "label": "周四", + "value": "3" + }, + + { + "label": "周五", + "value": "4" + }, + + { + "label": "周六", + "value": "5" + }, + + { + "label": "周日", + "value": "6" + } + ] + }, + + { + "label": "人数", + "type": "number", + "name": "num", + "size": "md", + "value": 10 + }, + + { + "label": "比率", + "type": "range", + "name": "percent" + }, + + { + "label": "简介", + "type": "textarea", + "name": "textarea" + } + ] + } + ] +} diff --git a/pages/jsonp.js b/pages/jsonp.js new file mode 100644 index 0000000..9612fb8 --- /dev/null +++ b/pages/jsonp.js @@ -0,0 +1,12 @@ +(function() { + const response = { + data: { + type: "page", + title: "标题", + body: "this result is from jsonp" + }, + status: 0 + } + + window.jsonpCallback && window.jsonpCallback(response); +})(); diff --git a/pages/site.json b/pages/site.json new file mode 100644 index 0000000..f710212 --- /dev/null +++ b/pages/site.json @@ -0,0 +1,127 @@ +{ + "status": 0, + "msg": "", + "data": { + "pages": [ + { + "label": "Home", + "url": "/", + "redirect": "/index/1" + }, + { + "label": "示例", + "children": [ + { + "label": "页面A", + "url": "index", + "schema": { + "type": "page", + "title": "页面A", + "body": "页面A" + }, + "children": [ + { + "label": "页面A-1", + "url": "1", + "schema": { + "type": "page", + "title": "页面A-1", + "body": "页面A-1" + } + }, + { + "label": "页面A-2", + "url": "2", + "schema": { + "type": "page", + "title": "页面A-2", + "body": "页面A-2" + } + }, + { + "label": "页面A-3", + "url": "3", + "schema": { + "type": "page", + "title": "页面A-3", + "body": "页面A-3" + } + } + ] + }, + { + "label": "页面B", + "schema": { + "type": "page", + "title": "页面B", + "body": "页面B" + } + }, + { + "label": "页面C", + "schema": { + "type": "page", + "title": "页面C", + "body": "页面C" + } + }, + { + "label": "列表示例", + "url": "/crud", + "rewrite": "/crud/list", + "icon": "fa fa-cube", + "children": [ + { + "label": "列表", + "url": "/crud/list", + "icon": "fa fa-list", + "schemaApi": "get:/pages/crud-list.json" + }, + { + "label": "新增", + "url": "/crud/new", + "icon": "fa fa-plus", + "schemaApi": "get:/pages/crud-new.json" + }, + { + "label": "查看", + "url": "/crud/:id", + "schemaApi": "get:/pages/crud-view.json" + }, + { + "label": "修改", + "url": "/crud/:id/edit", + "schemaApi": "get:/pages/crud-edit.json" + } + ] + } + ] + }, + { + "label": "分组2", + "children": [ + { + "label": "用户管理", + "schema": { + "type": "page", + "title": "用户管理", + "body": "页面C" + } + }, + { + "label": "外部链接", + "link": "http://baidu.gitee.io/amis" + }, + { + "label": "部门管理", + "schemaApi": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/service/form?tpl=tpl3" + }, + { + "label": "jsonp 返回示例", + "schemaApi": "jsonp:/pages/jsonp.js?callback=jsonpCallback" + } + ] + } + ] + } +} diff --git a/pages/wizard.json b/pages/wizard.json new file mode 100644 index 0000000..11ed771 --- /dev/null +++ b/pages/wizard.json @@ -0,0 +1,105 @@ +{ + "type": "page", + "title": "表单向导", + "subTitle": "可以通过表单向导,将一个超长的表单页面拆分成多个步骤,一步一步指引用户完成。", + "body": [ + { + "type": "wizard", + "actionFinishLabel": "确认", + "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/saveWizard", + "steps": [ + { + "title": "填写活动信息", + "controls": [ + { + "type": "text", + "name": "title", + "label": "活动标题", + "required": true, + "size": "md" + }, + + { + "type": "date", + "name": "date", + "label": "举办时间", + "size": "md" + }, + + { + "type": "number", + "name": "num", + "label": "参与人数", + "value": 10, + "size": "md" + } + ] + }, + + { + "title": "填写赞助商信息", + "controls": [ + { + "type": "text", + "name": "company", + "label": "公司名称", + "required": true, + "size": "md" + }, + + { + "type": "text", + "name": "money", + "label": "赞助金额", + "addOn": { + "type": "text", + "label": "¥" + }, + "size": "md" + } + ] + }, + + { + "title": "确认", + "mode": "horizontal", + "horizontal": { + "leftFixed": "sm" + }, + "controls": [ + { + "type": "static", + "name": "company", + "label": "活动标题", + "labelClassName": "text-muted" + }, + { + "type": "static-date", + "name": "date", + "label": "举办时间", + "labelClassName": "text-muted" + }, + { + "type": "static", + "name": "num", + "label": "参与人数", + "labelClassName": "text-muted" + }, + { + "type": "static", + "name": "company", + "label": "公司名称", + "labelClassName": "text-muted" + }, + { + "type": "static", + "name": "money", + "label": "赞助金额", + "labelClassName": "text-muted" + } + ] + } + ] + } + ] +} diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000..c9ea77e Binary files /dev/null and b/public/logo.png differ diff --git a/server.js b/server.js new file mode 100644 index 0000000..1dbb830 --- /dev/null +++ b/server.js @@ -0,0 +1,40 @@ +const express = require('express'); +const http = require('http'); +const path = require('path'); +const reload = require('reload'); +const bodyParser = require('body-parser'); +const logger = require('morgan'); + +const app = express(); + +app.set('port', process.env.PORT || 3000); +app.use(logger('dev')); +app.use(bodyParser.json()); // Parses json, multi-part (file), url-encoded + +app.use('/public', express.static('public')); +app.use('/pages', express.static('pages')); + +app.get('/*', function (req, res) { + res.sendFile(path.join(__dirname, 'index.html')); +}); + +const server = http.createServer(app); + +// Reload code here +reload(app) + .then(function (reloadReturned) { + // reloadReturned is documented in the returns API in the README + + // Reload started, start web server + server.listen(app.get('port'), function () { + console.log( + 'Web server listening on port http://localhost:' + app.get('port') + ); + }); + }) + .catch(function (err) { + console.error( + 'Reload could not start, could not start server/sample app', + err + ); + });