Commit 63a6b7b245548e77ec9e000c5d0b0001466598ae

Authored by ly525
1 parent 4c3679c4

fix: add router to core-editor

back-end/h5-api/api/work/config/routes.json
... ... @@ -18,6 +18,14 @@
18 18 },
19 19 {
20 20 "method": "GET",
  21 + "path": "/works/editor",
  22 + "handler": "Work.renderCoreEditor",
  23 + "config": {
  24 + "policies": []
  25 + }
  26 + },
  27 + {
  28 + "method": "GET",
21 29 "path": "/works",
22 30 "handler": "Work.find",
23 31 "config": {
... ...
back-end/h5-api/api/work/controllers/Work.js
1 1 /*
2 2 * @Author: ly525
3 3 * @Date: 2019-12-04 19:55:24
4   - * @LastEditors : ly525
5   - * @LastEditTime : 2020-01-01 18:42:41
  4 + * @LastEditors: ly525
  5 + * @LastEditTime: 2020-10-11 20:02:09
6 6 * @FilePath: /luban-h5/back-end/h5-api/api/work/controllers/Work.js
7 7 * @Github: https://github.com/ly525/luban-h5
8 8 * @Description:
... ... @@ -14,7 +14,7 @@ const _ = require('lodash');
14 14 // 浏览模式
15 15 const VIEW_MODE = {
16 16 PREVIEW: 'preview' // 预览
17   -}
  17 +};
18 18  
19 19 /**
20 20 * Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/guides/controllers.html#core-controllers)
... ... @@ -25,14 +25,17 @@ module.exports = {
25 25 // GET /previewOne
26 26 // strapi-hook-ejs: https://github.com/strapi/strapi/tree/master/packages/strapi-hook-ejs
27 27 previewOne: async (ctx) => {
28   - const { view_mode } = ctx.request.query
  28 + const { view_mode } = ctx.request.query;
29 29 const work = await strapi.services.work.findOne(ctx.params);
30 30 // 非发布状态, 查看不到内容
31 31 // 非预览模式, 查看不到内容
32   - const canRender = view_mode === VIEW_MODE.PREVIEW || work.is_publish
33   - if (!canRender) work.pages = []
  32 + const canRender = view_mode === VIEW_MODE.PREVIEW || work.is_publish;
  33 + if (!canRender) work.pages = [];
34 34 return ctx.render('engine', { work });
35 35 },
  36 + renderCoreEditor: async (ctx) => {
  37 + return ctx.render('core-editor');
  38 + },
36 39 submitForm: async (ctx) => {
37 40 const work = await strapi.services.work.findOne(ctx.params);
38 41 const formData = ctx.request.body;
... ...
back-end/h5-api/api/work/documentation/1.0.0/work.json
... ... @@ -114,6 +114,63 @@
114 114 "parameters": []
115 115 }
116 116 },
  117 + "/works/editor": {
  118 + "get": {
  119 + "deprecated": false,
  120 + "description": "",
  121 + "responses": {
  122 + "200": {
  123 + "description": "response",
  124 + "content": {
  125 + "application/json": {
  126 + "schema": {
  127 + "properties": {
  128 + "foo": {
  129 + "type": "string"
  130 + }
  131 + }
  132 + }
  133 + }
  134 + }
  135 + },
  136 + "403": {
  137 + "description": "Forbidden",
  138 + "content": {
  139 + "application/json": {
  140 + "schema": {
  141 + "$ref": "#/components/schemas/Error"
  142 + }
  143 + }
  144 + }
  145 + },
  146 + "404": {
  147 + "description": "Not found",
  148 + "content": {
  149 + "application/json": {
  150 + "schema": {
  151 + "$ref": "#/components/schemas/Error"
  152 + }
  153 + }
  154 + }
  155 + },
  156 + "default": {
  157 + "description": "unexpected error",
  158 + "content": {
  159 + "application/json": {
  160 + "schema": {
  161 + "$ref": "#/components/schemas/Error"
  162 + }
  163 + }
  164 + }
  165 + }
  166 + },
  167 + "summary": "",
  168 + "tags": [
  169 + "Work"
  170 + ],
  171 + "parameters": []
  172 + }
  173 + },
117 174 "/works": {
118 175 "get": {
119 176 "deprecated": false,
... ...
back-end/h5-api/views/core-editor.ejs 0 → 100644
  1 +<html>
  2 + <head>
  3 + <meta charset="UTF-8">
  4 + <title>鲁班H5 编辑器</title>
  5 + <script src="https://unpkg.com/vue"></script>
  6 + <script src="https://unpkg.com/@luban-h5/core-editor"></script>
  7 + </head>
  8 + <body>
  9 + <div id="app"> <core-editor :work-id="id" /></div>
  10 + <script>
  11 + const id = new URLSearchParams(window.location.search).get('id')
  12 + new Vue({ data: () => ({id }), el: '#app'});
  13 + </script>
  14 + </body>
  15 +</html>
0 16 \ No newline at end of file
... ...
front-end/h5/src/components/core/index.js
... ... @@ -16,6 +16,7 @@ import Feedback from &#39;@/components/common/feedback/index&#39;
16 16 import AdjustLineV from 'core/support/adjust-line/vertical'
17 17  
18 18 import store from 'core/store/index'
  19 +import router from 'core/router/index'
19 20 import i18n from '@/locales'
20 21 import '@/plugins/index'
21 22  
... ... @@ -24,6 +25,7 @@ const CoreEditor = {
24 25 name: 'CoreEditor',
25 26 store,
26 27 i18n,
  28 + router,
27 29 props: {
28 30 workId: {
29 31 type: [Number, String]
... ...
front-end/h5/src/components/core/package.json
1 1 {
2 2 "name": "@luban-h5/core-editor",
3 3 "private": false,
4   - "version": "0.0.2",
  4 + "version": "0.0.4",
5 5 "description": "luban-h5 core-editor",
6 6 "main": "dist/core-editor.umd.min.js",
7 7 "author": "ly525",
... ...
front-end/h5/src/components/core/router/index.js 0 → 100644
  1 +import Vue from 'vue'
  2 +import Router from 'vue-router'
  3 +Vue.use(Router)
  4 +
  5 +export default new Router()
... ...