From c6c91515f776b0d51d015d2c6e2be47db44da4ae Mon Sep 17 00:00:00 2001 From: yulixing Date: Tue, 25 Jun 2019 11:46:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E4=BD=93=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/express.js | 7 +++++-- src/controllers/games/mp_share.js | 26 ++++++++++++++++++++++++++ src/models/mp_share/Template.js | 24 ++++++++++++++++++++++++ src/utils/painter/index.js | 1 - 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/models/mp_share/Template.js diff --git a/src/bin/express.js b/src/bin/express.js index 77331e9..51b4699 100644 --- a/src/bin/express.js +++ b/src/bin/express.js @@ -11,6 +11,7 @@ import helmet from 'helmet'; import FileStreamRotator from 'file-stream-rotator'; import morgan from 'morgan'; import fs from 'fs'; +import path from 'path'; import logger from './../utils/logger'; import expressUtils from './../utils/express-utils'; import config from './../../config/config'; @@ -97,12 +98,14 @@ app.get('/robots.txt', function(req, res) { }); // TODO: 待删 字体测试用 -app.use('/get_font', async (req, res, next) => { +app.get('/get_font', async (req, res, next) => { const query = req.query; const font_name = query.font_name; const ext = query.ext; + const fontPath = path.join(__dirname, `../fonts/${font_name}.${ext}`) + console.log(path) - res.download(`fonts/${font_name}.${ext}`); + res.download(fontPath); }); // -- We don't want to serve sessions for static resources diff --git a/src/controllers/games/mp_share.js b/src/controllers/games/mp_share.js index fc35153..6389438 100644 --- a/src/controllers/games/mp_share.js +++ b/src/controllers/games/mp_share.js @@ -8,6 +8,7 @@ import config from '../../../config/config'; const router = new Router(); +// 生成预览图 router.post('/get_pic', async (req, res, next) => { const body = req.body; const opt = body.opt; @@ -47,4 +48,29 @@ router.post('/get_pic', async (req, res, next) => { } }); + +// 保存模板 +router.post('/save_tpl', async (req, res, next) => { + +}) + + +// 修改模板 + + + +// 删除模板 + + + +// 查询单个模板 + + + + +// 获取模板列表 + + + + export default router; diff --git a/src/models/mp_share/Template.js b/src/models/mp_share/Template.js new file mode 100644 index 0000000..6022851 --- /dev/null +++ b/src/models/mp_share/Template.js @@ -0,0 +1,24 @@ +'use strict'; +import mongoose from 'mongoose'; + +const Schema = mongoose.Schema; +const ObjectId = Schema.Types.ObjectId; +/** + * 操作日志 + */ +const OpLog = new mongoose.Schema({ + // 游戏id + tpl_name: {type: String}, + tpl_id: {type: String}, + prev_url: {type: String}, + base_style: {type: Object}, + views: [{type: Object}], + comment: {type: String}, + createdBy: {type: String} +}, { + collection: 'template', + timestamps: true, +}); + +export default mongoose.model('Template', Template); + diff --git a/src/utils/painter/index.js b/src/utils/painter/index.js index 723bcfa..5eb3256 100644 --- a/src/utils/painter/index.js +++ b/src/utils/painter/index.js @@ -101,7 +101,6 @@ function _drawBg(ctx, info) { ctx.fillStyle = bg ctx.fillRect(0, 0, w, h) } - // TODO: 渐变填充 ctx.restore() }