├── .gitignore ├── .prettierrc ├── README.md ├── index.html ├── nodemon.json ├── package.json ├── pages ├── console.json ├── crud-advance.json ├── crud-edit.json ├── crud-list.json ├── crud-new.json ├── crud-view.json ├── editor.json ├── form-basic.json ├── jsonp.js ├── site.json └── wizard.json ├── public └── logo.png └── server.js /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /package-lock.json 3 | /gh-pages -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "singleQuote": true, 6 | "semi": true, 7 | "trailingComma": "none", 8 | "bracketSpacing": false, 9 | "quoteProps": "consistent", 10 | "arrowParens": "avoid", 11 | "jsxBracketSameLine": false 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # amis admin 模板 2 | 3 | 基于 [amis](https://github.com/baidu/amis) 渲染器,快速搭建自己的管理系统。 4 | 5 | ## 快速开始 6 | 7 | 其实这个项目直接双击 `index.html` 都能看大部分效果,不过为了更完整体验,请运行下面的命令: 8 | 9 | ```bash 10 | 11 | # 安装依赖 12 | npm i 13 | # 打开服务 14 | npm start 15 | ``` 16 | 17 | ## 部署上线 18 | 19 | 这个例子中的 amis 等依赖使用外部 cdn,为了稳定请在自己部署的时候将文件下载到本地。 -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | amis admin 6 | 7 | 11 | 12 | 17 | 18 | 22 | 23 | 24 | 26 | 37 | 38 | 39 |
40 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "ignore": ["node_modules/*"] 4 | } 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "amis-boilerplate", 3 | "version": "1.0.0", 4 | "description": "基于 amis 的项目模板", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js", 9 | "gh-pages": "rm -rf gh-pages && fis3 release gh-pages -c", 10 | "deploy-gh-pages": "git subtree push --prefix gh-pages origin gh-pages" 11 | }, 12 | "keywords": [ 13 | "amis", 14 | "boilerplate", 15 | "admin", 16 | "react" 17 | ], 18 | "author": "fex", 19 | "license": "MIT", 20 | "devDependencies": { 21 | "body-parser": "^1.19.0", 22 | "express": "^4.17.1", 23 | "morgan": "^1.10.0", 24 | "nodemon": "^2.0.7", 25 | "reload": "^3.1.1" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pages/console.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "Dashboard", 4 | "body": "body..." 5 | } 6 | -------------------------------------------------------------------------------- /pages/crud-advance.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "复杂表单", 4 | "subTitle": "展示表格编辑、联动等等", 5 | "body": [ 6 | { 7 | "type": "form", 8 | "mode": "horizontal", 9 | "title": "", 10 | "affixFooter": true, 11 | "api": "${API_HOST}/api/amis-mock/form/save", 12 | "actions": [ 13 | { 14 | "label": "保存", 15 | "type": "submit", 16 | "level": "success" 17 | } 18 | ], 19 | "controls": [ 20 | { 21 | "type": "fieldSet", 22 | "title": "基本配置", 23 | "controls": [ 24 | { 25 | "type": "text", 26 | "label": "任务名称", 27 | "name": "title", 28 | "size": "md", 29 | "required": true 30 | }, 31 | 32 | { 33 | "type": "textarea", 34 | "label": "任务描述", 35 | "name": "description", 36 | "size": "md" 37 | }, 38 | 39 | { 40 | "label": "任务频率", 41 | "type": "radios", 42 | "name": "repeat", 43 | "inline": true, 44 | "value": "none", 45 | "required": true, 46 | "options": [ 47 | { 48 | "label": "不重复", 49 | "value": "none" 50 | }, 51 | 52 | { 53 | "label": "每天", 54 | "value": "day" 55 | }, 56 | 57 | { 58 | "label": "每周", 59 | "value": "week" 60 | }, 61 | 62 | { 63 | "label": "每月", 64 | "value": "month" 65 | } 66 | ] 67 | }, 68 | 69 | { 70 | "label": "每天几点", 71 | "type": "select", 72 | "name": "time", 73 | "multiple": true, 74 | "required": true, 75 | "extractValue": true, 76 | "visibleOn": "this.repeat == \"day\"", 77 | "inline": true, 78 | "options": [ 79 | {"value": 0, "label": "0:00"}, 80 | {"value": 1, "label": "1:00"}, 81 | {"value": 2, "label": "2:00"}, 82 | {"value": 3, "label": "3:00"}, 83 | {"value": 4, "label": "4:00"}, 84 | {"value": 5, "label": "5:00"}, 85 | {"value": 6, "label": "6:00"}, 86 | {"value": 7, "label": "7:00"}, 87 | {"value": 8, "label": "8:00"}, 88 | {"value": 9, "label": "9:00"}, 89 | {"value": 10, "label": "10:00"}, 90 | {"value": 11, "label": "11:00"}, 91 | {"value": 12, "label": "12:00"}, 92 | {"value": 13, "label": "13:00"}, 93 | {"value": 14, "label": "14:00"}, 94 | {"value": 15, "label": "15:00"}, 95 | {"value": 16, "label": "16:00"}, 96 | {"value": 17, "label": "17:00"}, 97 | {"value": 18, "label": "18:00"}, 98 | {"value": 19, "label": "19:00"}, 99 | {"value": 20, "label": "20:00"}, 100 | {"value": 21, "label": "21:00"}, 101 | {"value": 22, "label": "22:00"}, 102 | {"value": 23, "label": "23:00"} 103 | ] 104 | }, 105 | 106 | { 107 | "label": "每周几执行", 108 | "type": "button-group", 109 | "name": "weekdays", 110 | "size": "md", 111 | "visibleOn": "this.repeat == \"week\"", 112 | "clearable": true, 113 | "multiple": true, 114 | "required": true, 115 | "extractValue": true, 116 | "maxLength": 7, 117 | "options": [ 118 | { 119 | "label": "周一", 120 | "value": "0" 121 | }, 122 | 123 | { 124 | "label": "周二", 125 | "value": "1" 126 | }, 127 | 128 | { 129 | "label": "周三", 130 | "value": "2" 131 | }, 132 | 133 | { 134 | "label": "周四", 135 | "value": "3" 136 | }, 137 | 138 | { 139 | "label": "周五", 140 | "value": "4" 141 | }, 142 | 143 | { 144 | "label": "周六", 145 | "value": "5" 146 | }, 147 | 148 | { 149 | "label": "周日", 150 | "value": "6" 151 | } 152 | ] 153 | }, 154 | 155 | { 156 | "label": "每月几号执行", 157 | "type": "list", 158 | "name": "monthday", 159 | "size": "md", 160 | "visibleOn": "this.repeat == \"month\"", 161 | "required": true, 162 | "maxLength": 31, 163 | "clearable": true, 164 | "multiple": true, 165 | "extractValue": true, 166 | "options": [ 167 | {"value": 0, "label": "01"}, 168 | {"value": 1, "label": "02"}, 169 | {"value": 2, "label": "03"}, 170 | {"value": 3, "label": "04"}, 171 | {"value": 4, "label": "05"}, 172 | {"value": 5, "label": "06"}, 173 | {"value": 6, "label": "07"}, 174 | {"value": 7, "label": "08"}, 175 | {"value": 8, "label": "09"}, 176 | {"value": 9, "label": "10"}, 177 | {"value": 10, "label": "11"}, 178 | {"value": 11, "label": "12"}, 179 | {"value": 12, "label": "13"}, 180 | {"value": 13, "label": "14"}, 181 | {"value": 14, "label": "15"}, 182 | {"value": 15, "label": "16"}, 183 | {"value": 16, "label": "17"}, 184 | {"value": 17, "label": "18"}, 185 | {"value": 18, "label": "19"}, 186 | {"value": 19, "label": "20"}, 187 | {"value": 20, "label": "21"}, 188 | {"value": 21, "label": "22"}, 189 | {"value": 22, "label": "23"}, 190 | {"value": 23, "label": "24"}, 191 | {"value": 24, "label": "25"}, 192 | {"value": 25, "label": "26"}, 193 | {"value": 26, "label": "27"}, 194 | {"value": 27, "label": "28"}, 195 | {"value": 28, "label": "29"}, 196 | {"value": 29, "label": "30"}, 197 | {"value": 30, "label": "31"} 198 | ] 199 | } 200 | ] 201 | }, 202 | 203 | { 204 | "type": "fieldSet", 205 | "title": "其他信息", 206 | "collapsable": true, 207 | "controls": [ 208 | { 209 | "type": "combo", 210 | "name": "admins", 211 | "label": "用户列表", 212 | "value": [""], 213 | "description": "请输入用户信息,不要重复。", 214 | "multiple": true, 215 | "inline": true, 216 | "controls": [ 217 | { 218 | "type": "text", 219 | "name": "name", 220 | "unique": true 221 | }, 222 | 223 | { 224 | "type": "select", 225 | "name": "perm", 226 | "value": "read", 227 | "options": [ 228 | { 229 | "label": "可读", 230 | "value": "read" 231 | }, 232 | 233 | { 234 | "label": "可写", 235 | "value": "write" 236 | } 237 | ] 238 | } 239 | ] 240 | }, 241 | { 242 | "label": "新增一行", 243 | "type": "button", 244 | "actionType": "add", 245 | "target": "thetable", 246 | "level": "info" 247 | }, 248 | { 249 | "name": "thetable", 250 | "type": "table", 251 | "label": "任务参数", 252 | "editable": true, 253 | "addable": true, 254 | "removable": true, 255 | "columns": [ 256 | { 257 | "label": "参数名", 258 | "name": "key", 259 | "quickEdit": true 260 | }, 261 | 262 | { 263 | "label": "参数值", 264 | "name": "value", 265 | "quickEdit": true 266 | } 267 | ] 268 | } 269 | ] 270 | } 271 | ] 272 | } 273 | ] 274 | } 275 | -------------------------------------------------------------------------------- /pages/crud-edit.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "修改 ${params.id}", 4 | "remark": null, 5 | "toolbar": [ 6 | { 7 | "type": "button", 8 | "actionType": "link", 9 | "link": "/crud/list", 10 | "label": "返回列表" 11 | } 12 | ], 13 | "body": [ 14 | { 15 | "type": "form", 16 | "initApi": "${API_HOST}/api/amis-mock/sample/${params.id}", 17 | "api": "${API_HOST}/api/amis-mock/sample/$id", 18 | "redirect": "/crud/list", 19 | "controls": [ 20 | { 21 | "type": "text", 22 | "name": "engine", 23 | "label": "Engine", 24 | "required": true 25 | }, 26 | { 27 | "type": "divider" 28 | }, 29 | { 30 | "type": "text", 31 | "name": "browser", 32 | "label": "Browser", 33 | "required": true 34 | }, 35 | { 36 | "type": "divider" 37 | }, 38 | { 39 | "type": "text", 40 | "name": "platform", 41 | "label": "Platform(s)", 42 | "required": true 43 | }, 44 | { 45 | "type": "divider" 46 | }, 47 | { 48 | "type": "text", 49 | "name": "version", 50 | "label": "Engine version" 51 | }, 52 | { 53 | "type": "divider" 54 | }, 55 | { 56 | "type": "select", 57 | "name": "grade", 58 | "label": "CSS grade", 59 | "options": ["A", "B", "C", "D", "X"] 60 | } 61 | ] 62 | } 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /pages/crud-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "列表", 4 | "remark": null, 5 | "name": "page-demo", 6 | "toolbar": [ 7 | { 8 | "type": "button", 9 | "actionType": "link", 10 | "link": "/crud/new", 11 | "label": "新增", 12 | "primary": true 13 | } 14 | ], 15 | "body": [ 16 | { 17 | "type": "crud", 18 | "name": "sample", 19 | "api": "${API_HOST}/api/amis-mock/sample?page=${page}&perPage=${perPage}&keywords=${keywords}", 20 | "filter": { 21 | "title": "", 22 | "mode": "inline", 23 | "wrapWithPanel": false, 24 | "submitText": "", 25 | "controls": [ 26 | { 27 | "type": "text", 28 | "name": "keywords", 29 | "placeholder": "通过关键字搜索", 30 | "addOn": { 31 | "label": "搜索", 32 | "type": "submit", 33 | "className": "btn-success" 34 | }, 35 | "clearable": true 36 | } 37 | ], 38 | "className": "m-b-sm" 39 | }, 40 | "bulkActions": [ 41 | { 42 | "label": "批量修改", 43 | "type": "button", 44 | "actionType": "dialog", 45 | "level": "primary", 46 | "dialog": { 47 | "title": "批量编辑", 48 | "name": "sample-bulk-edit", 49 | "body": { 50 | "type": "form", 51 | "api": "${API_HOST}/api/amis-mock/sample/bulkUpdate2", 52 | "controls": [ 53 | { 54 | "type": "text", 55 | "name": "engine", 56 | "label": "Engine" 57 | } 58 | ] 59 | } 60 | } 61 | }, 62 | { 63 | "label": "批量删除", 64 | "type": "button", 65 | "level": "danger", 66 | "actionType": "ajax", 67 | "api": "delete:${API_HOST}/api/amis-mock/sample/$ids", 68 | "confirmText": "确定要批量删除?" 69 | } 70 | ], 71 | "columns": [ 72 | { 73 | "name": "engine", 74 | "label": "Rendering engine", 75 | "sortable": true 76 | }, 77 | { 78 | "name": "id", 79 | "label": "ID", 80 | "width": 20, 81 | "sortable": true 82 | }, 83 | { 84 | "name": "browser", 85 | "label": "Browser", 86 | "sortable": true 87 | }, 88 | { 89 | "name": "platform", 90 | "label": "Platform(s)", 91 | "sortable": true 92 | }, 93 | { 94 | "name": "version", 95 | "label": "Engine version" 96 | }, 97 | { 98 | "name": "grade", 99 | "label": "CSS grade" 100 | }, 101 | { 102 | "type": "operation", 103 | "label": "操作", 104 | "width": "", 105 | "buttons": [ 106 | { 107 | "type": "button-group", 108 | "buttons": [ 109 | { 110 | "type": "button", 111 | "label": "查看", 112 | "level": "primary", 113 | "actionType": "link", 114 | "link": "/crud/${id}" 115 | }, 116 | { 117 | "type": "button", 118 | "label": "修改", 119 | "level": "info", 120 | "actionType": "link", 121 | "link": "/crud/${id}/edit" 122 | }, 123 | { 124 | "type": "button", 125 | "label": "删除", 126 | "level": "danger", 127 | "actionType": "ajax", 128 | "confirmText": "您确认要删除?", 129 | "api": "delete:${API_HOST}/api/amis-mock/sample/$id" 130 | } 131 | ] 132 | } 133 | ], 134 | "placeholder": "-", 135 | "fixed": "right" 136 | } 137 | ], 138 | "affixHeader": true, 139 | "columnsTogglable": "auto", 140 | "placeholder": "暂无数据", 141 | "tableClassName": "table-db table-striped", 142 | "headerClassName": "crud-table-header", 143 | "footerClassName": "crud-table-footer", 144 | "toolbarClassName": "crud-table-toolbar", 145 | "combineNum": 0, 146 | "bodyClassName": "panel-default" 147 | } 148 | ] 149 | } 150 | -------------------------------------------------------------------------------- /pages/crud-new.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "新增", 4 | "remark": null, 5 | "toolbar": [ 6 | { 7 | "type": "button", 8 | "actionType": "link", 9 | "link": "/crud/list", 10 | "label": "返回列表" 11 | } 12 | ], 13 | "body": [ 14 | { 15 | "title": "", 16 | "type": "form", 17 | "redirect": "/crud/list", 18 | "name": "sample-edit-form", 19 | "api": "${API_HOST}/api/amis-mock/sample", 20 | "controls": [ 21 | { 22 | "type": "text", 23 | "name": "engine", 24 | "label": "Engine", 25 | "required": true, 26 | "inline": false, 27 | "description": "", 28 | "descriptionClassName": "help-block", 29 | "placeholder": "", 30 | "addOn": null 31 | }, 32 | { 33 | "type": "divider" 34 | }, 35 | { 36 | "type": "text", 37 | "name": "browser", 38 | "label": "Browser", 39 | "required": true 40 | }, 41 | { 42 | "type": "divider" 43 | }, 44 | { 45 | "type": "text", 46 | "name": "platform", 47 | "label": "Platform(s)", 48 | "required": true 49 | }, 50 | { 51 | "type": "divider" 52 | }, 53 | { 54 | "type": "text", 55 | "name": "version", 56 | "label": "Engine version" 57 | }, 58 | { 59 | "type": "divider" 60 | }, 61 | { 62 | "type": "text", 63 | "name": "grade", 64 | "label": "CSS grade" 65 | } 66 | ] 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /pages/crud-view.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "查看详情 ${params.id}", 4 | "remark": null, 5 | "toolbar": [ 6 | { 7 | "type": "button", 8 | "actionType": "link", 9 | "link": "/crud/list", 10 | "label": "返回列表" 11 | } 12 | ], 13 | "body": [ 14 | { 15 | "type": "form", 16 | "initApi": "${API_HOST}/api/amis-mock/sample/${params.id}", 17 | "controls": [ 18 | { 19 | "type": "static", 20 | "name": "engine", 21 | "label": "Engine" 22 | }, 23 | { 24 | "type": "divider" 25 | }, 26 | { 27 | "type": "static", 28 | "name": "browser", 29 | "label": "Browser" 30 | }, 31 | { 32 | "type": "divider" 33 | }, 34 | { 35 | "type": "static", 36 | "name": "platform", 37 | "label": "Platform(s)" 38 | }, 39 | { 40 | "type": "divider" 41 | }, 42 | { 43 | "type": "static", 44 | "name": "version", 45 | "label": "Engine version" 46 | }, 47 | { 48 | "type": "divider" 49 | }, 50 | { 51 | "type": "static", 52 | "name": "grade", 53 | "label": "CSS grade" 54 | }, 55 | { 56 | "type": "divider" 57 | }, 58 | { 59 | "type": "html", 60 | "html": "

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

" 61 | } 62 | ] 63 | } 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /pages/editor.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "代码编辑器", 4 | "subTitle": "使用的monaco-editor,用到了 worker, 如果控制台没有报错,说明一起正常。", 5 | "body": [ 6 | { 7 | "type": "form", 8 | "controls": [ 9 | { 10 | "type": "editor", 11 | "name": "js", 12 | "label": "Javascript", 13 | "size": "md" 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /pages/form-basic.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "基础表单", 4 | "subTitle": "展示一些常规的表单,包括验证、提示等等", 5 | "body": [ 6 | { 7 | "type": "form", 8 | "mode": "horizontal", 9 | "title": "常规表单示例", 10 | "affixFooter": true, 11 | "api": "${API_HOST}/api/amis-mock/form/save", 12 | "actions": [ 13 | { 14 | "label": "保存", 15 | "type": "submit", 16 | "level": "success" 17 | } 18 | ], 19 | "controls": [ 20 | { 21 | "label": " 标题", 22 | "type": "text", 23 | "placeholder": "请输入标题", 24 | "description": "请输入一个能吸引眼球的标题", 25 | "name": "title", 26 | "size": "md" 27 | }, 28 | 29 | { 30 | "label": "编号", 31 | "required": true, 32 | "type": "text", 33 | "placeholder": "请输入编号", 34 | "name": "b", 35 | "size": "md", 36 | "validations": { 37 | "matchRegexp": "/^\\w{4}-\\w{4}-\\w{4}$/" 38 | }, 39 | "validationErrors": { 40 | "matchRegexp": "您输入的内容格式不对,请按提示输入!" 41 | }, 42 | "hint": "输入范例:xxxx-xxxx-xxxx" 43 | }, 44 | 45 | { 46 | "label": "置顶", 47 | "type": "switch", 48 | "name": "c", 49 | "inline": true, 50 | "labelRemark": "开启后将置顶这条数据!" 51 | }, 52 | 53 | { 54 | "label": "活动时间", 55 | "type": "date-range", 56 | "name": "range", 57 | "size": "md", 58 | "remark": "这是一个字段时间范围" 59 | }, 60 | 61 | { 62 | "label": "日期范围", 63 | "type": "group", 64 | "controls": [ 65 | { 66 | "type": "date", 67 | "size": "md", 68 | "name": "start", 69 | "mode": "inline", 70 | "maxDate": "${end}" 71 | }, 72 | 73 | { 74 | "label": "到", 75 | "type": "date", 76 | "size": "md", 77 | "name": "end", 78 | "inputClassName": "m-l-sm", 79 | "mode": "inline", 80 | "minDate": "${start}", 81 | "remark": "这是两个字段的时间范围" 82 | } 83 | ] 84 | }, 85 | 86 | { 87 | "label": "浏览器", 88 | "type": "button-group", 89 | "name": "browser", 90 | "value": "chrome", 91 | "options": [ 92 | { 93 | "label": "Chrome", 94 | "value": "chrome" 95 | }, 96 | 97 | { 98 | "label": "火狐", 99 | "value": "firefox" 100 | }, 101 | 102 | { 103 | "label": "IE", 104 | "value": "ie" 105 | } 106 | ] 107 | }, 108 | 109 | { 110 | "type": "list", 111 | "name": "taocan", 112 | "label": "套餐选择", 113 | "options": [ 114 | { 115 | "value": 1, 116 | "body": "
套餐:C01
CPU:2核
内存:1GB
SSD盘:10GB
" 117 | }, 118 | { 119 | "value": 2, 120 | "body": "
套餐:C02
CPU:4核
内存:4GB
SSD盘:20GB
" 121 | }, 122 | { 123 | "value": 3, 124 | "disabled": true, 125 | "body": "
套餐:C03
CPU:8核
内存:8GB
SSD盘:50GB
" 126 | } 127 | ] 128 | }, 129 | 130 | { 131 | "label": "最爱周几", 132 | "type": "select", 133 | "name": "select", 134 | "size": "md", 135 | "clearable": true, 136 | "options": [ 137 | { 138 | "label": "周一", 139 | "value": "0" 140 | }, 141 | 142 | { 143 | "label": "周二", 144 | "value": "1" 145 | }, 146 | 147 | { 148 | "label": "周三", 149 | "value": "2" 150 | }, 151 | 152 | { 153 | "label": "周四", 154 | "value": "3" 155 | }, 156 | 157 | { 158 | "label": "周五", 159 | "value": "4" 160 | }, 161 | 162 | { 163 | "label": "周六", 164 | "value": "5" 165 | }, 166 | 167 | { 168 | "label": "周日", 169 | "value": "6" 170 | } 171 | ] 172 | }, 173 | 174 | { 175 | "label": "休息日", 176 | "type": "list", 177 | "name": "freeday", 178 | "value": ["5", "6"], 179 | "multiple": true, 180 | "extractValue": true, 181 | "options": [ 182 | { 183 | "label": "周一", 184 | "value": "0" 185 | }, 186 | 187 | { 188 | "label": "周二", 189 | "value": "1" 190 | }, 191 | 192 | { 193 | "label": "周三", 194 | "value": "2" 195 | }, 196 | 197 | { 198 | "label": "周四", 199 | "value": "3" 200 | }, 201 | 202 | { 203 | "label": "周五", 204 | "value": "4" 205 | }, 206 | 207 | { 208 | "label": "周六", 209 | "value": "5" 210 | }, 211 | 212 | { 213 | "label": "周日", 214 | "value": "6" 215 | } 216 | ] 217 | }, 218 | 219 | { 220 | "label": "人数", 221 | "type": "number", 222 | "name": "num", 223 | "size": "md", 224 | "value": 10 225 | }, 226 | 227 | { 228 | "label": "比率", 229 | "type": "range", 230 | "name": "percent" 231 | }, 232 | 233 | { 234 | "label": "简介", 235 | "type": "textarea", 236 | "name": "textarea" 237 | } 238 | ] 239 | } 240 | ] 241 | } 242 | -------------------------------------------------------------------------------- /pages/jsonp.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | const response = { 3 | data: { 4 | type: "page", 5 | title: "标题", 6 | body: "this result is from jsonp" 7 | }, 8 | status: 0 9 | } 10 | 11 | window.jsonpCallback && window.jsonpCallback(response); 12 | })(); 13 | -------------------------------------------------------------------------------- /pages/site.json: -------------------------------------------------------------------------------- 1 | { 2 | "status": 0, 3 | "msg": "", 4 | "data": { 5 | "pages": [ 6 | { 7 | "label": "Home", 8 | "url": "/", 9 | "redirect": "/index/1" 10 | }, 11 | { 12 | "label": "示例", 13 | "children": [ 14 | { 15 | "label": "页面A", 16 | "url": "index", 17 | "schema": { 18 | "type": "page", 19 | "title": "页面A", 20 | "body": "页面A" 21 | }, 22 | "children": [ 23 | { 24 | "label": "页面A-1", 25 | "url": "1", 26 | "schema": { 27 | "type": "page", 28 | "title": "页面A-1", 29 | "body": "页面A-1" 30 | } 31 | }, 32 | { 33 | "label": "页面A-2", 34 | "url": "2", 35 | "schema": { 36 | "type": "page", 37 | "title": "页面A-2", 38 | "body": "页面A-2" 39 | } 40 | }, 41 | { 42 | "label": "页面A-3", 43 | "url": "3", 44 | "schema": { 45 | "type": "page", 46 | "title": "页面A-3", 47 | "body": "页面A-3" 48 | } 49 | } 50 | ] 51 | }, 52 | { 53 | "label": "页面B", 54 | "badge": 3, 55 | "badgeClassName": "bg-info", 56 | "schema": { 57 | "type": "page", 58 | "title": "页面B", 59 | "body": "页面B" 60 | } 61 | }, 62 | { 63 | "label": "页面C", 64 | "schema": { 65 | "type": "page", 66 | "title": "页面C", 67 | "body": "页面C" 68 | } 69 | }, 70 | { 71 | "label": "列表示例", 72 | "url": "/crud", 73 | "rewrite": "/crud/list", 74 | "icon": "fa fa-cube", 75 | "children": [ 76 | { 77 | "label": "列表", 78 | "url": "/crud/list", 79 | "icon": "fa fa-list", 80 | "schemaApi": "get:/pages/crud-list.json" 81 | }, 82 | { 83 | "label": "新增", 84 | "url": "/crud/new", 85 | "icon": "fa fa-plus", 86 | "schemaApi": "get:/pages/crud-new.json" 87 | }, 88 | { 89 | "label": "查看", 90 | "url": "/crud/:id", 91 | "schemaApi": "get:/pages/crud-view.json" 92 | }, 93 | { 94 | "label": "修改", 95 | "url": "/crud/:id/edit", 96 | "schemaApi": "get:/pages/crud-edit.json" 97 | } 98 | ] 99 | } 100 | ] 101 | }, 102 | { 103 | "label": "分组2", 104 | "children": [ 105 | { 106 | "label": "用户管理", 107 | "schema": { 108 | "type": "page", 109 | "title": "用户管理", 110 | "body": "页面C" 111 | } 112 | }, 113 | { 114 | "label": "外部链接", 115 | "link": "http://baidu.gitee.io/amis" 116 | }, 117 | { 118 | "label": "部门管理", 119 | "schemaApi": "${API_HOST}/api/amis-mock/mock2/service/form?tpl=tpl3" 120 | }, 121 | { 122 | "label": "jsonp 返回示例", 123 | "schemaApi": "jsonp:/pages/jsonp.js?callback=jsonpCallback" 124 | } 125 | ] 126 | } 127 | ] 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /pages/wizard.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "表单向导", 4 | "subTitle": "可以通过表单向导,将一个超长的表单页面拆分成多个步骤,一步一步指引用户完成。", 5 | "body": [ 6 | { 7 | "type": "wizard", 8 | "actionFinishLabel": "确认", 9 | "api": "${API_HOST}/api/amis-mock/saveWizard", 10 | "steps": [ 11 | { 12 | "title": "填写活动信息", 13 | "controls": [ 14 | { 15 | "type": "text", 16 | "name": "title", 17 | "label": "活动标题", 18 | "required": true, 19 | "size": "md" 20 | }, 21 | 22 | { 23 | "type": "date", 24 | "name": "date", 25 | "label": "举办时间", 26 | "size": "md" 27 | }, 28 | 29 | { 30 | "type": "number", 31 | "name": "num", 32 | "label": "参与人数", 33 | "value": 10, 34 | "size": "md" 35 | } 36 | ] 37 | }, 38 | 39 | { 40 | "title": "填写赞助商信息", 41 | "controls": [ 42 | { 43 | "type": "text", 44 | "name": "company", 45 | "label": "公司名称", 46 | "required": true, 47 | "size": "md" 48 | }, 49 | 50 | { 51 | "type": "text", 52 | "name": "money", 53 | "label": "赞助金额", 54 | "addOn": { 55 | "type": "text", 56 | "label": "¥" 57 | }, 58 | "size": "md" 59 | } 60 | ] 61 | }, 62 | 63 | { 64 | "title": "确认", 65 | "mode": "horizontal", 66 | "horizontal": { 67 | "leftFixed": "sm" 68 | }, 69 | "controls": [ 70 | { 71 | "type": "static", 72 | "name": "company", 73 | "label": "活动标题", 74 | "labelClassName": "text-muted" 75 | }, 76 | { 77 | "type": "static-date", 78 | "name": "date", 79 | "label": "举办时间", 80 | "labelClassName": "text-muted" 81 | }, 82 | { 83 | "type": "static", 84 | "name": "num", 85 | "label": "参与人数", 86 | "labelClassName": "text-muted" 87 | }, 88 | { 89 | "type": "static", 90 | "name": "company", 91 | "label": "公司名称", 92 | "labelClassName": "text-muted" 93 | }, 94 | { 95 | "type": "static", 96 | "name": "money", 97 | "label": "赞助金额", 98 | "labelClassName": "text-muted" 99 | } 100 | ] 101 | } 102 | ] 103 | } 104 | ] 105 | } 106 | -------------------------------------------------------------------------------- /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aisuda/amis-admin/36b359914427909f7393a1738d885a4153d3006c/public/logo.png -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const http = require('http'); 3 | const path = require('path'); 4 | const reload = require('reload'); 5 | const bodyParser = require('body-parser'); 6 | const logger = require('morgan'); 7 | 8 | const app = express(); 9 | 10 | app.set('port', process.env.PORT || 3000); 11 | app.use(logger('dev')); 12 | app.use(bodyParser.json()); // Parses json, multi-part (file), url-encoded 13 | 14 | app.use('/public', express.static('public')); 15 | app.use('/pages', express.static('pages')); 16 | 17 | app.get('/*', function (req, res) { 18 | res.sendFile(path.join(__dirname, 'index.html')); 19 | }); 20 | 21 | const server = http.createServer(app); 22 | 23 | // Reload code here 24 | reload(app) 25 | .then(function (reloadReturned) { 26 | // reloadReturned is documented in the returns API in the README 27 | 28 | // Reload started, start web server 29 | server.listen(app.get('port'), function () { 30 | console.log( 31 | 'Web server listening on port http://localhost:' + app.get('port') 32 | ); 33 | }); 34 | }) 35 | .catch(function (err) { 36 | console.error( 37 | 'Reload could not start, could not start server/sample app', 38 | err 39 | ); 40 | }); 41 | --------------------------------------------------------------------------------