mirror of
https://gitee.com/doramart/DoraCMS.git
synced 2024-12-02 04:07:42 +08:00
生产环境默认引用本地的后台插件路径
This commit is contained in:
parent
6b42c747e0
commit
2ceb5c1ee7
4
app/controller/api/admin.js
Normal file → Executable file
4
app/controller/api/admin.js
Normal file → Executable file
@ -2,7 +2,7 @@
|
||||
* @Author: doramart
|
||||
* @Date: 2019-06-27 17:16:32
|
||||
* @Last Modified by: doramart
|
||||
* @Last Modified time: 2020-02-03 13:23:29
|
||||
* @Last Modified time: 2020-02-04 16:08:53
|
||||
*/
|
||||
const Controller = require('egg').Controller;
|
||||
const jwt = require('jsonwebtoken')
|
||||
@ -12,6 +12,7 @@ const {
|
||||
adminUserRule
|
||||
} = require('@validate')
|
||||
|
||||
|
||||
class AdminController extends Controller {
|
||||
|
||||
|
||||
@ -138,6 +139,7 @@ class AdminController extends Controller {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = AdminController;
|
@ -1,144 +0,0 @@
|
||||
/*
|
||||
* @Author: doramart
|
||||
* @Date: 2019-08-16 16:06:21
|
||||
* @Last Modified by: doramart
|
||||
* @Last Modified time: 2019-11-02 22:15:40
|
||||
*/
|
||||
const Controller = require('egg').Controller;
|
||||
const awaitWriteStream = require('await-stream-ready').write
|
||||
const sendToWormhole = require('stream-wormhole')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
|
||||
let confirmPath = (path) => {
|
||||
return new Promise(function (resolve, reject) {
|
||||
let waitCheck = () => {
|
||||
setTimeout(() => {
|
||||
if (!fs.existsSync(path)) {
|
||||
if (checkPathNum == 3) {
|
||||
resolve(fs.existsSync(path));
|
||||
} else {
|
||||
checkPathNum++;
|
||||
waitCheck();
|
||||
}
|
||||
} else {
|
||||
resolve(fs.existsSync(path));
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
waitCheck();
|
||||
})
|
||||
}
|
||||
|
||||
let checkFilePath = async function (path) {
|
||||
checkPathNum = 0;
|
||||
return await confirmPath(path);
|
||||
};
|
||||
|
||||
|
||||
let updateLogoPath = async (ctx, model, targetFiles = []) => {
|
||||
|
||||
let targetItemList = await ctx.service[model].find({
|
||||
isPaging: '0'
|
||||
})
|
||||
for (const targetItem of targetItemList) {
|
||||
|
||||
for (const fileItem of targetFiles) {
|
||||
|
||||
if (targetItem[fileItem]) {
|
||||
var reg = new RegExp('/upload/', "g");
|
||||
let oldfile = targetItem[fileItem];
|
||||
let newFile = oldfile.replace(reg, '/static/upload/');
|
||||
let newObj = {};
|
||||
newObj[fileItem] = newFile;
|
||||
await ctx.service[model].update(ctx, targetItem._id, newObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UploadController extends Controller {
|
||||
|
||||
|
||||
// 上传单个文件
|
||||
async create() {
|
||||
const {
|
||||
ctx,
|
||||
service
|
||||
} = this
|
||||
|
||||
//存放目录
|
||||
let updatePath = `${this.app.config.upload_path}/upload/images/`;
|
||||
let updateVideoPath = `${this.app.config.upload_path}/upload/videos/`;
|
||||
let updateAudioPath = `${this.app.config.upload_path}/upload/audios/`;
|
||||
let updateOtherPath = `${this.app.config.upload_path}/upload/others/`;
|
||||
// 要通过 ctx.getFileStream 便捷的获取到用户上传的文件,需要满足两个条件:
|
||||
// 只支持上传一个文件。
|
||||
// 上传文件必须在所有其他的 fields 后面,否则在拿到文件流时可能还获取不到 fields。
|
||||
const stream = await ctx.getFileStream();
|
||||
let fileParams = stream.fields;
|
||||
let askFileType = fileParams.type || 'image'; // 默认上传图片
|
||||
// console.log('--askFileType--', askFileType);
|
||||
// 文件类型校验
|
||||
if (askFileType == 'image') {
|
||||
|
||||
} else if (askFileType == 'video') {
|
||||
updatePath = updateVideoPath;
|
||||
} else if (askFileType == 'audio') {
|
||||
updatePath = updateAudioPath;
|
||||
} else {
|
||||
updatePath = updateOtherPath;
|
||||
}
|
||||
if (!fs.existsSync(updatePath)) {
|
||||
fs.mkdirSync(updatePath);
|
||||
}
|
||||
// 所有表单字段都能通过 `stream.fields` 获取到
|
||||
const filename = path.basename(stream.filename) // 文件名称
|
||||
const extname = path.extname(stream.filename).toLowerCase() // 文件扩展名称
|
||||
if (!extname) {
|
||||
throw new Error(res.__('validate_error_params'));
|
||||
}
|
||||
// 生成文件名
|
||||
let ms = (new Date()).getTime().toString() + extname;
|
||||
const attachment = {};
|
||||
attachment.extname = extname || 'hello'
|
||||
attachment.filename = filename
|
||||
|
||||
const target = path.join(updatePath, `${ms}`)
|
||||
const writeStream = fs.createWriteStream(target)
|
||||
|
||||
// 文件处理,上传到云存储等等
|
||||
try {
|
||||
await awaitWriteStream(stream.pipe(writeStream))
|
||||
} catch (err) {
|
||||
// 必须将上传的文件流消费掉,要不然浏览器响应会卡死
|
||||
await sendToWormhole(stream)
|
||||
throw err
|
||||
}
|
||||
// 设置响应内容和响应状态码
|
||||
ctx.helper.renderSuccess(ctx, {
|
||||
data: {
|
||||
path: `${this.app.config.static.prefix}/upload/images/${ms}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async updateImgs() {
|
||||
|
||||
let ctx = this.ctx
|
||||
updateLogoPath(ctx, 'adminUser', ['logo']);
|
||||
updateLogoPath(ctx, 'adsItem', ['sImg']);
|
||||
updateLogoPath(ctx, 'content', ['sImg', 'comments', 'simpleComments']);
|
||||
updateLogoPath(ctx, 'user', ['logo']);
|
||||
|
||||
ctx.helper.renderSuccess(ctx);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = UploadController;
|
@ -2,7 +2,7 @@
|
||||
* @Author: doramart
|
||||
* @Date: 2019-06-20 18:55:40
|
||||
* @Last Modified by: doramart
|
||||
* @Last Modified time: 2020-02-03 13:19:53
|
||||
* @Last Modified time: 2020-02-04 12:24:12
|
||||
*/
|
||||
const Controller = require('egg').Controller;
|
||||
const {
|
||||
@ -489,7 +489,7 @@ class AdminUserController extends Controller {
|
||||
let pluginStr = `dora${pathItem.charAt(0).toUpperCase() + pathItem.slice(1)}`;
|
||||
|
||||
if (plugins.indexOf(pluginStr) >= 0 && this.app.config[pluginStr].adminUrl) {
|
||||
let adminUrlItem = this.app.config[pluginStr].adminUrl;
|
||||
let adminUrlItem = this.app.config.admin_root_path + this.app.config[pluginStr].adminUrl;
|
||||
if (adminUrlItem instanceof Array) {
|
||||
for (const routerItem of adminUrlItem) {
|
||||
renderMap.push({
|
||||
|
@ -29,7 +29,8 @@ module.exports = appInfo => {
|
||||
// 'helpCenter',
|
||||
// 'renderCms',
|
||||
// 'cmsTemplate',
|
||||
// 'plugin'
|
||||
// 'plugin',
|
||||
// 'uploadFile'
|
||||
],
|
||||
// DEV_CONFIG_MODULES_END
|
||||
mongoose: {
|
||||
@ -51,7 +52,7 @@ module.exports = appInfo => {
|
||||
},
|
||||
server_path: 'http://localhost:8080',
|
||||
server_api: 'http://localhost:8080/api',
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
@ -5,7 +5,7 @@ module.exports = appInfo => {
|
||||
|
||||
return {
|
||||
// 插件路径
|
||||
admin_root_path: 'https://cdn.html-js.cn/cms/plugins/static/admin',
|
||||
admin_root_path: '/static',
|
||||
// 数据库连接
|
||||
mongoose: {
|
||||
client: {
|
||||
@ -19,7 +19,7 @@ module.exports = appInfo => {
|
||||
// 静态目录
|
||||
static: {
|
||||
prefix: '/static',
|
||||
dir: [path.join(appInfo.baseDir, 'app/public'), '/home/doraData/uploadFiles/static'],
|
||||
dir: [path.join(appInfo.baseDir, 'app/public'), path.join(appInfo.baseDir, 'backstage/dist'), '/home/doraData/uploadFiles/static'],
|
||||
maxAge: 31536000,
|
||||
},
|
||||
// 日志路径
|
||||
|
@ -159,7 +159,7 @@ exports.doraUploadFile = {
|
||||
// doraUploadFilePluginEnd
|
||||
|
||||
// doraValidatePluginBegin
|
||||
exports.doraValidate = {
|
||||
exports.validate = {
|
||||
enable: true,
|
||||
package: 'egg-dora-validate',
|
||||
|
||||
|
@ -17,7 +17,7 @@ exports.doraAds = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_shakehands_fill', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/ads/js/app.js',
|
||||
adminUrl: '/ads/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'ads/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-ads",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "ads",
|
||||
"eggPlugin": {
|
||||
"name": "doraAds"
|
||||
|
@ -17,7 +17,7 @@ exports.doraAnnounce = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_inform_fill', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/announce/js/app.js',
|
||||
adminUrl: '/announce/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'systemAnnounce/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-announce",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "announce",
|
||||
"eggPlugin": {
|
||||
"name": "doraAnnounce"
|
||||
|
@ -17,7 +17,7 @@ exports.doraBackUpData = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_cspace', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/backUpData/js/app.js',
|
||||
adminUrl: '/backUpData/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'backupDataManage/getBakList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-backupdata",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "backUpData",
|
||||
"eggPlugin": {
|
||||
"name": "doraBackUpData"
|
||||
|
@ -413,11 +413,14 @@ let ContentController = {
|
||||
filesType = 'stage1';
|
||||
isSingerPage = true;
|
||||
let ableCateList = await this.getEnableCateList(ctx, isSingerPage);
|
||||
_.assign(queryObj, {
|
||||
categories: {
|
||||
$in: ableCateList
|
||||
}
|
||||
});
|
||||
if (ableCateList.indexOf(typeId) < 0) {
|
||||
_.assign(queryObj, {
|
||||
categories: {
|
||||
$in: ableCateList
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// 只查询可见分类的文章
|
||||
|
@ -17,7 +17,7 @@ exports.doraContent = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_doc_fill', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/content/js/app.js',
|
||||
adminUrl: '/content/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'content/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-content",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"description": "content",
|
||||
"eggPlugin": {
|
||||
"name": "doraContent"
|
||||
|
@ -17,7 +17,7 @@ exports.doraContentCategory = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_category', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/contentCategory/js/app.js',
|
||||
adminUrl: '/contentCategory/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'contentCategory/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-contentcategory",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "contentCategory",
|
||||
"eggPlugin": {
|
||||
"name": "doraContentCategory"
|
||||
|
@ -17,7 +17,7 @@ exports.doraContentMessage = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_service', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/contentMessage/js/app.js',
|
||||
adminUrl: '/contentMessage/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'contentMessage/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-contentmessage",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "contentMessage",
|
||||
"eggPlugin": {
|
||||
"name": "doraContentMessage"
|
||||
|
@ -17,7 +17,7 @@ exports.doraContentTags = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_tags', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/contentTags/js/app.js',
|
||||
adminUrl: '/contentTags/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'contentTag/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-contenttags",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "contentTag",
|
||||
"eggPlugin": {
|
||||
"name": "doraContentTags"
|
||||
|
@ -17,7 +17,7 @@ exports.doraContentTemp = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_compile', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/contentTemp/js/app.js',
|
||||
adminUrl: '/contentTemp/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'template/getTemplateForderList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-contenttemp",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"description": "contentTemplate",
|
||||
"eggPlugin": {
|
||||
"name": "doraContentTemp"
|
||||
|
@ -17,7 +17,7 @@ exports.doraHelpCenter = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_service', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/helpCenter/js/app.js',
|
||||
adminUrl: '/helpCenter/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'helpCenter/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-helpcenter",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"description": "helpCenter",
|
||||
"eggPlugin": {
|
||||
"name": "doraHelpCenter"
|
||||
|
@ -17,7 +17,7 @@ exports.doraRegUser = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_people_fill', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/regUser/js/app.js',
|
||||
adminUrl: '/regUser/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'regUser/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-reguser",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "regUser",
|
||||
"eggPlugin": {
|
||||
"name": "doraRegUser"
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-sitemessage",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "siteMessage",
|
||||
"eggPlugin": {
|
||||
"name": "doraSiteMessage"
|
||||
|
@ -17,7 +17,7 @@ exports.doraSystemNotify = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_system_notic', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/systemNotify/js/app.js',
|
||||
adminUrl: '/systemNotify/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'systemNotify/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-systemnotify",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "systemNotify",
|
||||
"eggPlugin": {
|
||||
"name": "doraSystemNotify"
|
||||
|
@ -17,7 +17,7 @@ exports.doraSystemOptionLog = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_logs', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/systemOptionLog/js/app.js',
|
||||
adminUrl: '/systemOptionLog/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'systemOptionLog/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-systemoptionlog",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"description": "systemOptionLog",
|
||||
"eggPlugin": {
|
||||
"name": "doraSystemOptionLog"
|
||||
|
@ -17,7 +17,7 @@ exports.doraTemplateConfig = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_skin', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/templateConfig/js/app.js',
|
||||
adminUrl: '/templateConfig/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'template/getMyTemplateList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-templateconfig",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "templateConfig",
|
||||
"eggPlugin": {
|
||||
"name": "doraTemplateConfig"
|
||||
|
@ -17,7 +17,7 @@ exports.doraVersionManage = {
|
||||
isindex: 0, // 是否需要前台访问,1:需要,0:不需要,入口地址:'/ext/devteam/index/index'
|
||||
version: pkgInfo.version, // 版本号
|
||||
iconName: 'icon_app', // 主菜单图标名称
|
||||
adminUrl: 'https://cdn.html-js.cn/cms/plugins/static/admin/versionManage/js/app.js',
|
||||
adminUrl: '/versionManage/js/app.js',
|
||||
adminApi: [{
|
||||
url: 'versionManage/getList',
|
||||
method: 'get',
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "egg-dora-versionmanage",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"description": "versionManage",
|
||||
"eggPlugin": {
|
||||
"name": "doraVersionManage"
|
||||
|
@ -57,6 +57,11 @@
|
||||
"autod": "autod",
|
||||
"pkgfiles": "egg-bin pkgfiles",
|
||||
"init": "node ./build/restore",
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"makePrdDoc": "apidoc -i lib/plugin -e node_modules -o app/public/apidoc/ && npm run modifyPrdDoc",
|
||||
"modifyPrdDoc": "node ./build/renderApiDoc --docv prd",
|
||||
"start": "egg-scripts start --daemon --title=doracms2",
|
||||
@ -95,4 +100,4 @@
|
||||
"@utils": "app/utils"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user