Authored by Targaryen

cdn-config

... ... @@ -10,7 +10,8 @@ const path = require('path');
const fs = require('fs');
const rd = require('rd');
const ws = require('../../lib/ws');
const qn = require('../../lib/qiniu');
const CDNCONFIG = require('../../config/cdn_config');
const qn = require('../../lib/qiniu')(CDNCONFIG.feature); // 活动上传
const FILE_SAVE_ROOT_PATH = './uploads'; // 上传到本地服务器的根目录
const SUPER_FILE_CHECK_PASS = 'yohowebtech.superfile'; // 存在此文件,直接上传到七牛
... ... @@ -171,7 +172,7 @@ class FileApi {
}).skip(skip).limit(limit).exec();
_.forEach(result, perLog => {
perLog.link = FileApi.DOMAIN + perLog.actPath + '/index.html';
perLog.link = _.get(CDNCONFIG, 'feature.origin') + perLog.actPath + '/index.html';
});
return result;
... ... @@ -179,6 +180,4 @@ class FileApi {
}
FileApi.DOMAIN = 'https://feature.yoho.cn'; // 活动域名
module.exports = FileApi;
... ...
... ... @@ -5,7 +5,8 @@ const moment = require('moment');
const Router = require('koa-router');
const router = new Router();
const FileApi = require('../../ci/file');
const qn = require('../../../lib/qiniu');
const CDNCONFIG = require('../../../config/cdn_config');
const qn = require('../../../lib/qiniu')(CDNCONFIG.feature);
/**
* 处理列表数据
... ... @@ -17,7 +18,7 @@ const _handleListItems = items => {
let dateTime = _.parseInt(perFile.putTime.toString().substring(0, 13));
perFile.putTimeFormat = moment(dateTime).format('YYYY-MM-DD HH:mm');
perFile.link = FileApi.DOMAIN + '/' + perFile.key;
perFile.link = _.get(CDNCONFIG, 'feature.origin') + '/' + perFile.key;
});
return items;
... ... @@ -35,7 +36,7 @@ const file = {
* 文件管理页面
*/
page: async(ctx) => {
await ctx.render('/action/file_page', {domain: FileApi.DOMAIN});
await ctx.render('/action/file_page', {domain: _.get(CDNCONFIG, 'feature.origin')});
},
/**
... ...
/**
* CDN 配置
*/
const CDNCONFIG = {
feature: {
origin: 'https://feature.yoho.cn',
bucket: 'yohogirlzine'
}
}
module.exports = CDNCONFIG;
\ No newline at end of file
... ...
... ... @@ -17,8 +17,17 @@ const config = {
bucket: 'yohocdn'
};
const _default = (params) => {
let finalConfig = config;
const _default = Promise.promisifyAll(qn.create(config));
if (params) {
_.assign(finalConfig, params);
}
return Promise.promisifyAll(
qn.create(finalConfig)
);
}
_default.key = function(key) {
let _conifg = _.clone(config);
... ...