mtl-js-sdk
Version:
ynf-fw-mtl-api
59 lines (54 loc) • 1.69 kB
JavaScript
/*
* @Author: wangyingliang@yonyou.com
* @Date: 2023-09-06 11:17:55
* @LastEditors: wangyingliang wangyingliang@yonyou.com
* @LastEditTime: 2025-01-07 10:55:21
* @FilePath: /mtl-api-project/src/nindex.js
* @Description: 流水线入口文件.
* Copyright (c) 2023 by Yonyou, All Rights Reserved.
*/
function getPlatform() {
let userAgent = window.navigator.userAgent;
let platform = null;
if (userAgent.indexOf("miniProgram") !== -1 || userAgent.indexOf("wxwork") !== -1 || userAgent.indexOf("wechatdevtools") !== -1) {
platform = "wx";
} else if (userAgent.indexOf("APIAndroid") !== -1) {
if (userAgent.indexOf("QYZone") !== -1) {
platform = "upesnAndroid";
} else {
platform = "APIIos";
}
} else if (userAgent.indexOf("APIIOS") !== -1) {
if (userAgent.indexOf("QYZone") !== -1) {
platform = "upesnIos";
} else {
platform = "APIIos";
}
} else if (userAgent.indexOf("QYZone") !== -1) {
platform = "upesn";
} else if (userAgent.indexOf("APIHarmonyOS") !== -1) {
platform = "APIHarmonyOS"
} else if (/dingtalk/i.test(userAgent)) {
platform = "dingtalk";
} else if (userAgent.indexOf("Feishu") !== -1) {
// 飞书平台
platform = "tt";
} else {
platform = "h5";
}
return platform;
}
function onloadUrl(url, platform) {
var script = document.createElement("script");
script.type = "text/javascript";
script.defer = "defer"
script.id = `mtl%${platform}`;
script.src = url;
script.onerror = function () {
console.log('load mtl error ')
}
document.head && document.head.appendChild(script);
}
const platform = getPlatform()
const path = `/ynf-fw-mtl-api/ucf-wh/${platform}/mtl.${platform}.js`
onloadUrl(path, platform)