diff --git a/examples/main.py b/examples/main.py index 0c37a1d..47b00ec 100644 --- a/examples/main.py +++ b/examples/main.py @@ -47,12 +47,12 @@ async def home(): def create_app(): - fast_app = FastAPI(debug=True) + fast_app = FastAPI(debug=False) register_tortoise(fast_app, config=TORTOISE_ORM, generate_schemas=True) fast_app.mount('/admin', admin_app) - admin_app.debug = True + admin_app.debug = False admin_app.init( user_model='User', admin_secret='test', @@ -157,4 +157,4 @@ def create_app(): app = create_app() if __name__ == '__main__': - uvicorn.run('main:app', port=8000, debug=True, reload=True, lifespan='on') + uvicorn.run('main:app', port=8000, debug=False, reload=False, lifespan='on') diff --git a/front/BASH.md b/front/BASH.md deleted file mode 100644 index cf175d3..0000000 --- a/front/BASH.md +++ /dev/null @@ -1,7 +0,0 @@ -``` -npm run build - - -rm -rf public/admin && cp -rf ~/git/wxs77577/rest-admin/dist public/admin -git add -A && git commit -am "update admin ui" && git push -``` \ No newline at end of file diff --git a/front/README-zh.md b/front/README-zh.md deleted file mode 100644 index e15aff2..0000000 --- a/front/README-zh.md +++ /dev/null @@ -1,377 +0,0 @@ -# REST-ADMIN - -### 如果觉得有用,请在爱发电上赞助我: https://afdian.net/@johnny ,让我可以分出更多精力来完善它。 - -> 一个基于 Vue.js 和 Boostrap 4 的后台 UI. - -REST-ADMIN 试图让你在构建后台管理界面的时候更轻松点,所有你需要做的仅仅是提供一个后台服务的 RESTFul API 而已。 - -## 在线 DEMO - -#### http://rest-admin.genyii.com/ - -> 用户名:密码 `admin:admin` - -## 截图 - -| - | - | -| ----------------------------------------------------------------------------- | ------------------------------------------------------------------- | -| ![](./screenshots/1.png) 登录 | ![](./screenshots/2.png) 用户列表 | -| ![](./screenshots/3.png) 博客列表 | ![](./screenshots/4.png) 博客编辑表单 | -| ![](./screenshots/tfs-qrcode.png) 全栈之巅微信群
加微信拉群: johnny77577 | ![](./screenshots/tfs-logo.png) 免费视频教程-《全栈之巅》微信小程序 | - -## 功能 - -- 基于最新的 Bootstrap 和 VueJs,这意味着你可以方便地切换各种基于 bootstrap 框架的 CSS 皮肤 -- 纯前端的 VueJs 项目,可以无缝对接任何类型的后端 RESTful API -- 强大的 **Data Table**,自带排序、分页、搜索、显示图片等等功能 -- 强大的 **Data Form Builder**,可以显示/编辑各种类型的值:文本、图片、布尔值等等 -- 支持基于资源的各项 CRUD 操作 -- 基于英语的 i18n 支持 -- **高度可配置的**站点信息。如:网站名称、LOGO、**后台菜单**以及底部信息。 -- 可用于实际项目。已经应用于公司的两个项目中 - -## 快速开始 - -```bash -git clone git@github.com:wxs77577/rest-admin.git -cd rest-admin -code . # 用VSCODE打开项目 -npm i # 或者 cnpm i - -# 和本地测试API一起启动 -npm run test-api # 启动测试API -npm run serve # 启动REST-ADMIN客户端 -``` - -> 测试 API 的后台登录用户名及密码为 `admin` 和 `admin` - -### 发布 - -```bash -API_URI=http://localhost:5555/admin/api/ npm run build -``` - -然后只需要把`/dist/admin/`文件夹复制到对应的地方就好了 - -> 测试 API 基于`express` - -## 字段定义 - -> 用于表格和表单中 -> 默认主键字段为`_id`,你可以在`/src/config.json`中随意更改它。 - -范例: - -```javascript -{ - "_id": { "label": "ID" }, - "title": { "label": "标题" }, - "type": { "label": "类型", "type": "select", "options": [ - { "text": "Vue", "value": "vue" }, - { "text": "React", "value": "react" }, - { "text": "Angular", "value": "angular" }, - ]}, - "body": { "type": "html", "group": "详情" }, - "steps": { "type": "array", "group": "阶段", "fields": { - "name": { "label": "名称" }, - "date": { "label": "日期" } - }}, - - "_actions": { // 定义表格视图中的一些额外选项 - "buttons": { // 要隐藏“操作”栏中的某个按钮请把它设置为false - "delete": false, - "edit": false - }, - "toolbar": { // 定义表格视图顶部的按钮 - "extra": [ // 添加额外按钮 - //所有``支持的属性 - { "to": "/form?uri=vouchers/generate", "label": "Generate Vouchers" } - ] - } - } -} -``` - -### 字段属性 - -- `label` 显示的名称 -- `cols` 占用栅格列宽度, 总数为 12。(参考 Bootstrap) -- `input_cols` 输入控件的宽度 -- `group` 在创建、更新表单中的 TAB 分组名称 -- `type` 字段类型。不同字段类型拥有不同的附加属性 - - `select` 来自 [b-select](https://bootstrap-vue.js.org/docs/components/form-select) `bootstrap-vue` 的原生 HTML `` tag from [b-select](https://bootstrap-vue.js.org/docs/components/form-select) of `bootstrap-vue` - - `options` e.g. `[{ "text": "Label", "value": "1" }]` - - `select2` [vue-select](https://github.com/sagalbot/vue-select), like `select2` in jQuery - - `options` e.g. `[{ "text": "Label", "value": "1" }]` - - `tree` [vue-treeselect](https://vue-treeselect.js.org/) - - `options` **use `text` and `value` instead `label` and `id`** e.g. `[{ "text": "Label", "value": "1", "children": [ { "text": "Item1", "value": "2" } ] }]` - - `date` [vue2-datepicker](https://github.com/mengxiong10/vue2-datepicker) supports **date range** - - `switch` A iOS-liked switch component - - `html` An WYSIWYG html editor from [vue-html5-editor](https://github.com/PeakTai/vue-html5-editor) - - `array` Array values - - `fields` child fields defination - - `is_table` display as a table ? - - `radiolist` - - `options` e.g. `[{ "text": "Label", "value": "1" }]` - - `checkboxlist` - - `options` e.g. `[{ "text": "Label", "value": "1" }]` - - `checkbox` - - `file` File uploader - - `limit` define file limit options of **size** in byets, e.g. `{ size: 1000000 }` - - `image` Image file uploader with preview. - - `limit` define file limit options of **width** **height** and **size** in byets, e.g. `{ "width": 320, "height": 180, size: 1000000 }` - - `audio` like `image` - - `limit` define file limit options of **size** in byets, e.g. `{ size: 1000000 }` - - `video` like `image` - - `limit` define file limit options of **size** in byets, e.g. `{ size: 1000000 }` - - `textarea` - - `number` - - `text` -- `required` -- Any other properties accepted in https://bootstrap-vue.js.org/docs/components/form-input, please notice that every kind of field component has it's own properties. - -## APIs - -> Tips: check `/api/index.js` :p - -Example Base Api Url: http://localhost:8088/admin/api - -#### GET `/site` (url: http://localhost:8088/admin/api/site) - -Get config data of site - -- Returns - ```javascript - { - "name": "Site Name", - "logo": "http://.../logo.png", - "locale": "en-US", //or zh-CN - "locale_switcher": false, //hide locale switcher - "menu": [ - { - "name": "Home", - "url": "/", - "icon": "fa fa-home" - // for home page - }, - { - "name": "Content", - "title": true - // display as a delimiter - }, - { - "name": "Posts", - "url": "/rest/posts", - "icon": "fa fa-list" - // url format of resource list: /rest/:resourceName - }, - { - "name": "Config", - "url": "/form?uri=site/settings", - "icon": "fa fa-cogs" - // a custom form. - }, - { - "name": "Logout", - "url": "/login", - "icon": "fa fa-lock" - // for logout - } - ] - } - ``` - -#### POST `/login` - -For admin user login - -- POST DATA - ```javascript - { - "username": "admin", - "password": "admin" - } - ``` -- Returns - ```javascript - { - "user": { - "username": "admin", - ... - }, - "token": "1o2u3h4oi2u3h4jkashdflsda" - } - ``` - or with validation errors - > must response `422` http status. - ```javascript - { - "name": "HttpException", - "message": [{ "field": "password", "message": "Incorrect password." }] - } - ``` - -#### GET `/:resource` - -Fetch all records of a resource. -`:resource` means any resource name. e.g. `/users`, `/posts`... - -- Returns **IMPORTANT** - ```javascript - { - "total": 80, - "perPage": 10, - "page": 1, - "data": [ - {...}, - {...}, - {...}, - ] - } - ``` - -#### GET `/:resource/grid` - -Fetch grid view config of a resource. -`:resource` means any resource name. e.g. `/users/grid`, `/posts/grid`... - -- Returns **IMPORTANT** - ```javascript - { - "searchModel": {}, - "searchFields": { - render a searching form - ...see Fields Definition... - }, - "fields": { - render a table view - ...see Fields Definition... - } - } - ``` - -#### GET `/:resource/form` - -Fetch editing form config of a resource. -`:resource` means any resource name. e.g. `/users/form`, `/posts/form`... - -- Returns **IMPORTANT** - ```javascript - { - "model": {}, - "fields": { - render a editing form - ...see Fields Definition... - } - } - ``` - -#### POST `/:resource` - -create a resource - -- POST DATA - ```javascript - { - "_id": "12341234", - "title": "The New Title", - ... - } - ``` -- Returns - ```javascript - { - "_id": "12341234", - "title": "The New Title", - ... - } - ``` - -#### PUT `/:resource/:id` - -update a resource - -- POST DATA (Request Payload) - ```javascript - { - "_id": "12341234", - "title": "The New Title", - ... - } - ``` -- Returns - ```javascript - { - "_id": "12341234", - "title": "The New Title", - ... - } - ``` - -#### DELETE `/:resource/:id` - -delete a resource - -- Returns - ```javascript - { - "success": true - } - ``` - -#### DELETE `/:resource` - -delete all - -- Returns - ```javascript - { - "success": true - } - ``` - -#### Custom Form ? - -> To render a custom form, you need to define a `menu` item in `/site` api, or add an `extra` button of toolbar in `/:resource/grid`. - -There are two apis for a custom form: - -1. Get form definition - -- GET `/site/settings` -- Returns - ``` - { - "title": "Form Title", - "fields": { - ...see Fields Definition... - } - } - ``` - -2. Handle submission - -- POST `/site/settings` -- Returns - ```javascript - { - "success": true, - "message": "Well done!", //[optional] will show after form submited. - "redirect": "/" //[optional] auto redirect after form submited, default is back to the last page. - } - ``` - -## i18n - -> Check [vu-i18n](https://github.com/kazupon/vue-i18n/) for detailed documentation. - -REST-ADMIN gives built-in support for `en-US` and `zh-CN`, you can change translation files in `/src/i18n/*.json`. - -## Thanks to - -- Vue.js and Bootstrap v4 based [bootstrap-vue](https://github.com/bootstrap-vue/bootstrap-vue) -- Nice UI from [Core UI](https://coreui.io/) -- i18n component from [vue-i18n](https://github.com/kazupon/vue-i18n/) diff --git a/front/screenshots/1.png b/front/screenshots/1.png deleted file mode 100644 index c92f527..0000000 Binary files a/front/screenshots/1.png and /dev/null differ diff --git a/front/screenshots/2.png b/front/screenshots/2.png deleted file mode 100644 index d0d2969..0000000 Binary files a/front/screenshots/2.png and /dev/null differ diff --git a/front/screenshots/3.png b/front/screenshots/3.png deleted file mode 100644 index 8c6062d..0000000 Binary files a/front/screenshots/3.png and /dev/null differ diff --git a/front/screenshots/4.png b/front/screenshots/4.png deleted file mode 100644 index 7cae83c..0000000 Binary files a/front/screenshots/4.png and /dev/null differ diff --git a/front/screenshots/5.png b/front/screenshots/5.png deleted file mode 100644 index d8a3413..0000000 Binary files a/front/screenshots/5.png and /dev/null differ diff --git a/front/screenshots/6.png b/front/screenshots/6.png deleted file mode 100644 index 0f08271..0000000 Binary files a/front/screenshots/6.png and /dev/null differ diff --git a/front/screenshots/home.png b/front/screenshots/home.png deleted file mode 100644 index dedc399..0000000 Binary files a/front/screenshots/home.png and /dev/null differ diff --git a/front/screenshots/tfs-logo.png b/front/screenshots/tfs-logo.png deleted file mode 100644 index 224ebb2..0000000 Binary files a/front/screenshots/tfs-logo.png and /dev/null differ diff --git a/front/screenshots/tfs-qrcode.png b/front/screenshots/tfs-qrcode.png deleted file mode 100644 index 8e830c0..0000000 Binary files a/front/screenshots/tfs-qrcode.png and /dev/null differ diff --git a/front/src/components/Footer.vue b/front/src/components/Footer.vue index d029f3c..c7125ff 100644 --- a/front/src/components/Footer.vue +++ b/front/src/components/Footer.vue @@ -20,9 +20,10 @@ diff --git a/front/src/components/FormField.vue b/front/src/components/FormField.vue index 3b8f8a2..eee4f93 100644 --- a/front/src/components/FormField.vue +++ b/front/src/components/FormField.vue @@ -73,15 +73,27 @@ - + + + + + + + + + +
+ + + + + +
- +
@@ -19,7 +19,7 @@
- +