38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.composeFileUrl = exports.getCosBackend = exports.registerCosBackend = void 0;
|
|
const tslib_1 = require("tslib");
|
|
const assert_1 = require("oak-domain/lib/utils/assert");
|
|
const ctyun_backend_1 = tslib_1.__importDefault(require("./ctyun.backend"));
|
|
const wechat_backend_1 = tslib_1.__importDefault(require("./wechat.backend"));
|
|
const qiniu_backend_1 = tslib_1.__importDefault(require("./qiniu.backend"));
|
|
const CosBackendDict = {
|
|
'ctyun': new ctyun_backend_1.default(),
|
|
'wechat': new wechat_backend_1.default(),
|
|
'qiniu': new qiniu_backend_1.default(),
|
|
};
|
|
/**
|
|
* 注入一个其它OSS上实现的uploader类
|
|
* @param clazz
|
|
*/
|
|
function registerCosBackend(clazz) {
|
|
const instance = new clazz();
|
|
CosBackendDict[instance.name] = instance;
|
|
}
|
|
exports.registerCosBackend = registerCosBackend;
|
|
function getCosBackend(origin) {
|
|
(0, assert_1.assert)(CosBackendDict.hasOwnProperty(origin));
|
|
return CosBackendDict[origin];
|
|
}
|
|
exports.getCosBackend = getCosBackend;
|
|
function composeFileUrl(application, extraFile, style) {
|
|
const { origin } = extraFile;
|
|
if (origin === 'unknown') {
|
|
// 扯淡的代码 by Xc 20240521
|
|
return extraFile.extra1;
|
|
}
|
|
const cos = CosBackendDict[origin];
|
|
return cos.composeFileUrl(application, extraFile, style);
|
|
}
|
|
exports.composeFileUrl = composeFileUrl;
|