seer-dynamic-component
Advanced tools
Comparing version 1.7.2 to 1.7.3
153
lib/utils.js
@@ -22,2 +22,4 @@ import "core-js/modules/es6.object.keys.js"; | ||
import "core-js/modules/es6.regexp.match.js"; | ||
import "core-js/modules/es6.string.starts-with.js"; | ||
import "core-js/modules/es6.string.ends-with.js"; | ||
import "core-js/modules/es6.string.includes.js"; | ||
@@ -182,11 +184,22 @@ import "core-js/modules/es7.array.includes.js"; | ||
}; | ||
export var getLangOrign = function getLangOrign() { | ||
export var getLangOrign = function getLangOrign(oriWorkbenchParams) { | ||
var origin; | ||
var isFromWoken = false; | ||
var workbenchParams = oriWorkbenchParams || '_YMSHOST_'; | ||
try { | ||
if (window._YMSHOST_) { | ||
origin = window._YMSHOST_; | ||
} else if (window.parent && window.parent._YMSHOST_) { | ||
origin = window.parent._YMSHOST_; | ||
} else if (window.opener && window.opener._YMSHOST_) { | ||
origin = window.opener._YMSHOST_; | ||
if (window[workbenchParams]) { | ||
origin = window[workbenchParams]; | ||
isFromWoken = true; | ||
} else if (window.parent && window.parent[workbenchParams]) { | ||
origin = window.parent[workbenchParams]; | ||
isFromWoken = true; | ||
} else if (window.opener && window.opener[workbenchParams]) { | ||
origin = window.opener[workbenchParams]; | ||
isFromWoken = true; | ||
} else if (window.opener && window.opener.parent && window.opener.parent[workbenchParams]) { | ||
origin = window.opener.parent[workbenchParams]; | ||
isFromWoken = true; | ||
} else if (window.parent.opener && window.parent.opener && window.parent.opener[workbenchParams]) { | ||
origin = window.parent.opener[workbenchParams]; | ||
isFromWoken = true; | ||
} | ||
@@ -196,6 +209,13 @@ } catch (error) { | ||
} | ||
if (!origin) { | ||
origin = xssFilter(window.location.origin); | ||
if (!oriWorkbenchParams) { | ||
if (!origin) { | ||
origin = xssFilter(window.location.origin); | ||
} | ||
return { | ||
origin: origin, | ||
isFromWoken: isFromWoken | ||
}; | ||
} else { | ||
return origin; | ||
} | ||
return origin; | ||
}; | ||
@@ -241,2 +261,14 @@ export var inDiwork = function inDiwork(opener) { | ||
}; | ||
export var getUrlWithHost = function getUrlWithHost(url) { | ||
if (!url) return ''; | ||
if (url.startsWith("http") || url.startsWith("https")) return url; | ||
if (window._YYReport && window._YYReport.urlProps && window._YYReport.urlProps.serverUrl) { | ||
if (window._YYReport.urlProps.serverUrl.endsWith('/') && url.startsWith('/')) { | ||
url = url.replace("/", ""); | ||
} | ||
return "".concat(window._YYReport.urlProps.serverUrl).concat(url); | ||
} else { | ||
return url; | ||
} | ||
}; | ||
@@ -246,3 +278,3 @@ //获取当前平台的多语资源 | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) { | ||
var groupCode, tenantid, langApi, lang, packJs, callback, includeFw, diworkContext, userInfo; | ||
var groupCode, tenantid, langApi, lang, packJs, callback, includeFw, seerConfig, diworkContextFunction, diworkContext, userInfo, locale, langInfo, langInit, initResponse, initPackLangJson, jsonLocale; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
@@ -254,4 +286,5 @@ while (1) switch (_context2.prev = _context2.next) { | ||
window.seerConfig = window.seerConfig || {}; | ||
if (!(window.seerConfig && window.seerConfig.groupCodeList && window.seerConfig.groupCodeList.includes(groupCode))) { | ||
_context2.next = 5; | ||
seerConfig = window.seerConfig; | ||
if (!(seerConfig.groupCodeList && seerConfig.groupCodeList.includes(groupCode))) { | ||
_context2.next = 6; | ||
break; | ||
@@ -261,36 +294,37 @@ } | ||
return _context2.abrupt("return", true); | ||
case 5: | ||
case 6: | ||
lang = lang || window.lang; | ||
if (lang) { | ||
_context2.next = 10; | ||
_context2.next = 11; | ||
break; | ||
} | ||
window.seerConfig.loadLangError = 1; | ||
seerConfig.loadLangError = 1; | ||
callback && callback(); | ||
return _context2.abrupt("return", false); | ||
case 10: | ||
case 11: | ||
if (typeof includeFw === 'undefined') { | ||
includeFw = true; | ||
} | ||
diworkContext = window.diworkContext ? window.diworkContext() : null; | ||
diworkContextFunction = getLangOrign('diworkContext'); | ||
diworkContext = diworkContextFunction ? diworkContextFunction() : null; | ||
if (!diworkContext) { | ||
_context2.next = 20; | ||
_context2.next = 22; | ||
break; | ||
} | ||
if (diworkContext.ext.multilingualFlag) { | ||
_context2.next = 17; | ||
_context2.next = 19; | ||
break; | ||
} | ||
window.seerConfig.loadLangError = 1; | ||
seerConfig.loadLangError = 1; | ||
callback && callback(); | ||
return _context2.abrupt("return", false); | ||
case 17: | ||
case 19: | ||
if (!tenantid) { | ||
tenantid = diworkContext.tenantid; | ||
} | ||
_context2.next = 27; | ||
_context2.next = 29; | ||
break; | ||
case 20: | ||
case 22: | ||
if (!(seerConfig && seerConfig.userInfo)) { | ||
_context2.next = 27; | ||
_context2.next = 29; | ||
break; | ||
@@ -300,31 +334,43 @@ } | ||
if (userInfo.enableMultilingual) { | ||
_context2.next = 26; | ||
_context2.next = 28; | ||
break; | ||
} | ||
window.seerConfig.loadLangError = 1; | ||
seerConfig.loadLangError = 1; | ||
callback && callback(); | ||
return _context2.abrupt("return", false); | ||
case 26: | ||
case 28: | ||
if (!tenantid) { | ||
tenantid = userInfo.tenantPk || '0'; //可以直接从url中取 | ||
} | ||
case 27: | ||
//let locale = getLocale("locale"); | ||
// if(!inDiwork() && groupCode && locale) { | ||
// let langInit = {}; | ||
// try { | ||
// let initResponse = await request('GET', `/iuap-data-common/ucf-wh/intelliv/static/js/lang/${groupCode}/${locale}.json`); | ||
// if(initResponse.body && initResponse.statusCode === 200){ | ||
// let initPackLangJson = JSON.parse(initResponse.body) || {}; | ||
// let jsonLocale = locale.toLowerCase().replace(/_/, ''); | ||
// langInit[jsonLocale] = initPackLangJson; | ||
// } | ||
// } catch(error) { | ||
// console.error('获取多语错误'); | ||
// } | ||
// lang.init(langInit); | ||
// callback && callback(); | ||
// } else { | ||
langApi = langApi || getLangOrign() + "/iuap-apcom-i18n"; | ||
case 29: | ||
locale = getLocale("locale"); | ||
langInfo = getLangOrign(); | ||
if (!(!(langInfo !== null && langInfo !== void 0 && langInfo.isFromWoken) && !inDiwork() && groupCode && locale)) { | ||
_context2.next = 47; | ||
break; | ||
} | ||
langInit = {}; | ||
_context2.prev = 33; | ||
_context2.next = 36; | ||
return request('GET', getUrlWithHost("/iuap-data-common/ucf-wh/intelliv/static/js/lang/".concat(groupCode, "/").concat(locale, ".json"))); | ||
case 36: | ||
initResponse = _context2.sent; | ||
if (initResponse.body && initResponse.statusCode === 200) { | ||
initPackLangJson = JSON.parse(initResponse.body) || {}; | ||
jsonLocale = locale.toLowerCase().replace(/_/, ''); | ||
langInit[jsonLocale] = initPackLangJson; | ||
} | ||
_context2.next = 43; | ||
break; | ||
case 40: | ||
_context2.prev = 40; | ||
_context2.t0 = _context2["catch"](33); | ||
console.error('获取多语错误'); | ||
case 43: | ||
lang.init(langInit); | ||
callback && callback(); | ||
_context2.next = 50; | ||
break; | ||
case 47: | ||
langApi = langApi || langInfo.origin + "/iuap-apcom-i18n"; | ||
lang.init(packJs || {}); | ||
@@ -334,15 +380,14 @@ lang.jsonpUuid(tenantid, groupCode, langApi, function (data) { | ||
}, 'YS', includeFw); | ||
//} | ||
case 50: | ||
//把已经加载过的多语模块存入全局变量中 | ||
window.seerConfig = window.seerConfig || {}; | ||
window.seerConfig.groupCodeList = window.seerConfig.groupCodeList || []; | ||
if (!window.seerConfig.groupCodeList.includes(groupCode)) { | ||
window.seerConfig.groupCodeList.push(groupCode); | ||
seerConfig.groupCodeList = seerConfig.groupCodeList || []; | ||
if (!seerConfig.groupCodeList.includes(groupCode)) { | ||
seerConfig.groupCodeList.push(groupCode); | ||
} | ||
return _context2.abrupt("return", true); | ||
case 34: | ||
case 53: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
}, _callee2); | ||
}, _callee2, null, [[33, 40]]); | ||
})); | ||
@@ -349,0 +394,0 @@ return function getLangData(_x2) { |
{ | ||
"name": "seer-dynamic-component", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25294
601