Skip to content

Commit

Permalink
fix: add router to core-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ly525 committed Oct 11, 2020
1 parent 4c3679c commit 63a6b7b
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 7 deletions.
8 changes: 8 additions & 0 deletions back-end/h5-api/api/work/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
"policies": []
}
},
{
"method": "GET",
"path": "/works/editor",
"handler": "Work.renderCoreEditor",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/works",
Expand Down
15 changes: 9 additions & 6 deletions back-end/h5-api/api/work/controllers/Work.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: ly525
* @Date: 2019-12-04 19:55:24
* @LastEditors : ly525
* @LastEditTime : 2020-01-01 18:42:41
* @LastEditors: ly525
* @LastEditTime: 2020-10-11 20:02:09
* @FilePath: /luban-h5/back-end/h5-api/api/work/controllers/Work.js
* @Github: https://github.com/ly525/luban-h5
* @Description:
Expand All @@ -14,7 +14,7 @@ const _ = require('lodash');
// 浏览模式
const VIEW_MODE = {
PREVIEW: 'preview' // 预览
}
};

/**
* Read the documentation (https://strapi.io/documentation/3.0.0-beta.x/guides/controllers.html#core-controllers)
Expand All @@ -25,14 +25,17 @@ module.exports = {
// GET /previewOne
// strapi-hook-ejs: https://github.com/strapi/strapi/tree/master/packages/strapi-hook-ejs
previewOne: async (ctx) => {
const { view_mode } = ctx.request.query
const { view_mode } = ctx.request.query;
const work = await strapi.services.work.findOne(ctx.params);
// 非发布状态, 查看不到内容
// 非预览模式, 查看不到内容
const canRender = view_mode === VIEW_MODE.PREVIEW || work.is_publish
if (!canRender) work.pages = []
const canRender = view_mode === VIEW_MODE.PREVIEW || work.is_publish;
if (!canRender) work.pages = [];
return ctx.render('engine', { work });
},
renderCoreEditor: async (ctx) => {
return ctx.render('core-editor');
},
submitForm: async (ctx) => {
const work = await strapi.services.work.findOne(ctx.params);
const formData = ctx.request.body;
Expand Down
57 changes: 57 additions & 0 deletions back-end/h5-api/api/work/documentation/1.0.0/work.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,63 @@
"parameters": []
}
},
"/works/editor": {
"get": {
"deprecated": false,
"description": "",
"responses": {
"200": {
"description": "response",
"content": {
"application/json": {
"schema": {
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"summary": "",
"tags": [
"Work"
],
"parameters": []
}
},
"/works": {
"get": {
"deprecated": false,
Expand Down
15 changes: 15 additions & 0 deletions back-end/h5-api/views/core-editor.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<meta charset="UTF-8">
<title>鲁班H5 编辑器</title>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/@luban-h5/core-editor"></script>
</head>
<body>
<div id="app"> <core-editor :work-id="id" /></div>
<script>
const id = new URLSearchParams(window.location.search).get('id')
new Vue({ data: () => ({id }), el: '#app'});
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions front-end/h5/src/components/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Feedback from '@/components/common/feedback/index'
import AdjustLineV from 'core/support/adjust-line/vertical'

import store from 'core/store/index'
import router from 'core/router/index'
import i18n from '@/locales'
import '@/plugins/index'

Expand All @@ -24,6 +25,7 @@ const CoreEditor = {
name: 'CoreEditor',
store,
i18n,
router,
props: {
workId: {
type: [Number, String]
Expand Down
2 changes: 1 addition & 1 deletion front-end/h5/src/components/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@luban-h5/core-editor",
"private": false,
"version": "0.0.2",
"version": "0.0.4",
"description": "luban-h5 core-editor",
"main": "dist/core-editor.umd.min.js",
"author": "ly525",
Expand Down
5 changes: 5 additions & 0 deletions front-end/h5/src/components/core/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

export default new Router()

0 comments on commit 63a6b7b

Please sign in to comment.