diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/button-ar.png b/YuMi/Tools/CocoaHttpServer/Web/images/button-ar.png new file mode 100644 index 00000000..71b93c6b Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/button-ar.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/button-en.png b/YuMi/Tools/CocoaHttpServer/Web/images/button-en.png new file mode 100644 index 00000000..879aab47 Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/button-en.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/button-id.png b/YuMi/Tools/CocoaHttpServer/Web/images/button-id.png new file mode 100644 index 00000000..5a2a965b Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/button-id.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/button-tr.png b/YuMi/Tools/CocoaHttpServer/Web/images/button-tr.png new file mode 100644 index 00000000..cd33a38c Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/button-tr.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/header-ar.png b/YuMi/Tools/CocoaHttpServer/Web/images/header-ar.png new file mode 100644 index 00000000..48bdea29 Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/header-ar.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/header-en.png b/YuMi/Tools/CocoaHttpServer/Web/images/header-en.png new file mode 100644 index 00000000..e53ecb04 Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/header-en.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/header-id.png b/YuMi/Tools/CocoaHttpServer/Web/images/header-id.png new file mode 100644 index 00000000..659e319e Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/header-id.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/images/header-tr.png b/YuMi/Tools/CocoaHttpServer/Web/images/header-tr.png new file mode 100644 index 00000000..cfde88a0 Binary files /dev/null and b/YuMi/Tools/CocoaHttpServer/Web/images/header-tr.png differ diff --git a/YuMi/Tools/CocoaHttpServer/Web/js/getLanguage.js b/YuMi/Tools/CocoaHttpServer/Web/js/getLanguage.js new file mode 100644 index 00000000..eea23041 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/js/getLanguage.js @@ -0,0 +1,164 @@ +const checkVersion = () => { + var u = navigator.userAgent, app = navigator.appVersion; + return { + trident: u.indexOf('Trident') > -1, //IE内核 + presto: u.indexOf('Presto') > -1, //opera内核 + webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 + gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核 + mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 + ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 + android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端 + iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器 + iPad: u.indexOf('iPad') > -1, //是否iPad + webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部 + weixin: u.indexOf('MicroMessenger') > -1, //是否微信 + qq: u.match(/\sQQ/i) == " qq", //是否QQ + app: u.match('pekoApp') == 'pekoApp' //是否在app内 + }; +} + +// 根据域名适配环境 +function EnvCheck() { + if (window.location.href) { + var _url = window.location.href; + var res = _url.match(/uat/); + var res1 = _url.match(/120.79.211.243/); + var res2 = _url.match(/192.168./) + var res3 = _url.match(/127.0/) + var res4 = _url.match(/beta/) + if (res || res1 || res2 || res3 || res4) { + return 'test'; + } else { + return 'live'; + } + } +} + +// 封装 获取公共参数的方法(客户端提供) +// written by zxfxiong +const methodsFromClient = { + // 注意:ios 提供的方法属异步操作 + "uid": { + android: () => window.androidJsObj.getUid(), + ios: function () { + window.webkit.messageHandlers.getUid.postMessage(null); + // let allcookies = document.cookie; + // let $uid = allcookies.match(/\d+/); + // console.log($uid[0]); + } + }, + "ticket": { + android: () => window.androidJsObj.getTicket(), + ios: function () { + window.webkit.messageHandlers.getTicket.postMessage(null); + } + }, + "roomUid": { + android: () => window.androidJsObj.getRoomUid(), + ios: function () { + window.webkit.messageHandlers.getRoomUid.postMessage(null); + } + }, + "deviceId": { + android: () => window.androidJsObj.getDeviceId(), + ios: function () { + window.webkit.messageHandlers.getDeviceId.postMessage(null); + } + }, + "deviceInfo": { + android: () => window.androidJsObj.getDeviceInfo(), + ios: function () { + window.webkit.messageHandlers.getDeviceInfo.postMessage(null); + } + }, + "encryptPwd": { + android: (data) => window.androidJsObj.encryptPwd(data), + ios: function (data) { + window.webkit.messageHandlers.encryptPwd.postMessage(data); + } + } + +} +// 封装 在ios环境中 配置公共参数的回调函数 +// 配合 methodsFromClient[infoName].ios 方法 +// written by zxfxiong +function getMessage(key, value) { + pubInfo[key] = value; +} +// 全局获取并配置公共参数 +const pubInfo = {}; +function getInfoFromClient() { + const browser = checkVersion(); + if (browser.app) { + console.log('从客户端获取了用户信息(设备信息),此信息来源:common2.js'); + if (browser.android) { + pubInfo.uid = methodsFromClient.uid.android(); + pubInfo.ticket = methodsFromClient.ticket.android(); + pubInfo.deviceId = methodsFromClient.deviceId.android(); + pubInfo.deviceInfo = methodsFromClient.deviceInfo.android(); + } else { + methodsFromClient.uid.ios(); + methodsFromClient.ticket.ios(); + methodsFromClient.deviceId.ios(); + methodsFromClient.deviceInfo.ios(); + } + + } else { + // 非app环境调试参数 + pubInfo.uid = 0; + pubInfo.ticket = ""; + pubInfo.deviceId = "0"; + pubInfo.deviceInfo = { + 'Accept-Language':'en', + app: 'peko', + appVersion: '0.0.0', + os: '0.0.0', + osVersion: '0.0.0', + channel: 'browser', + client: 'h5' + }; + } +}; + +// 设定语言 fuzzy模糊查询客户端返回的语言 +const languageMap = [ + { name: '简体中文', code: 'zh', fuzzy: ['zh', 'zh-Hans', 'zh-'] }, + { name: '繁体中文', code: 'zh', fuzzy: ['zh', 'zh-Hant', 'zh-'] }, + { name: '英语', code: 'en', fuzzy: ['en'] }, + { name: '阿拉伯语', code: 'ar', fuzzy: ['ar', 'ar-'] }, + { name: '印尼语', code: 'id', fuzzy: ['id', 'in', 'id-', 'in-'] }, + { name: '土耳其语', code: 'tr', fuzzy: ['tr', 'tr-'] }, +]; +// 判断当前语言环境 +function getLanguageCode(language) { + if (language) { + // language = language.toLowerCase(); + for (const item of languageMap) { + for (const list of item.fuzzy) { + if (language.indexOf(list) != -1) { + window.sessionStorage.setItem('language', item.code); + } + } + } + } else { + window.sessionStorage.setItem('language', 'zh'); + } +} +// 判断国际化参数路径 +function fuzzyMatchUpdateQueryStringParameterFun() { + const browser = checkVersion(); + if (browser.app) { + if (browser.android) { + console.log('and deviceInfo', JSON.parse(pubInfo.deviceInfo)); + getLanguageCode(JSON.parse(pubInfo.deviceInfo)["Accept-Language"]); + + } else { + setTimeout(function () { + console.log('ios deviceInfo', pubInfo.deviceInfo); + getLanguageCode(pubInfo.deviceInfo["Accept-Language"]); + }, 40) + } + } else { + getLanguageCode(); + } +} diff --git a/YuMi/Tools/CocoaHttpServer/Web/js/langHandler.js b/YuMi/Tools/CocoaHttpServer/Web/js/langHandler.js new file mode 100644 index 00000000..2cdeafc4 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/js/langHandler.js @@ -0,0 +1,49 @@ +/** + * 初始化当前语言 + */ +function initLocalLang () { + const lang = sessionStorage.getItem('language') + console.log('getSessionLang',lang); + if (lang === 'zh' || window.location.href.match('=zh')) { + console.log("langHandler" + '繁体') + window.lang = langZh + window.lang.code = 'zh' + window.lang.defaults = false + } else if (lang === 'ar' || window.location.href.match('=ar')) { + // 阿拉伯 + console.log("langHandler" + '阿拉伯') + window.lang = langAr + window.lang.code = 'ar' + window.lang.defaults = false + } else if (lang === 'en' || window.location.href.match('=en')) { + // 英语 + console.log("langHandler" + '英语') + window.lang = langEn + window.lang.code = 'en' + window.lang.defaults = false + } else if (lang === 'id' || window.location.href.match('=id')) { + // 印度尼西亚 + console.log("langHandler" + '印尼') + window.lang = langId + window.lang.code = 'Id' + window.lang.defaults = false + }else if (lang === 'tr' || window.location.href.match('=tr')) { + // 土耳其 + console.log("langHandler" + '土耳其') + window.lang = langTr + window.lang.code = 'Tr' + window.lang.defaults = false + } else { + console.log("langHandler" + '默认') + window.lang = langZh + window.lang.code = null + window.lang.defaults = true + } + + window.lang.replace = (Lang, defaultText) => { + if (Lang) { + return Lang + } + return defaultText + } +} \ No newline at end of file diff --git a/YuMi/Tools/CocoaHttpServer/Web/local/ar.js b/YuMi/Tools/CocoaHttpServer/Web/local/ar.js new file mode 100644 index 00000000..394741d1 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/local/ar.js @@ -0,0 +1,10 @@ +// 阿拉伯 +langAr = { + demoModule: { + // ===============index============ + song_title:'بنقرة واحدة تحميل الأغاني', + song_list: 'قائمة الأغاني', + headerImg:'images/header-ar.png', + btnImg:'images/button-ar.png', + } +} \ No newline at end of file diff --git a/YuMi/Tools/CocoaHttpServer/Web/local/en.js b/YuMi/Tools/CocoaHttpServer/Web/local/en.js new file mode 100644 index 00000000..fbd919f5 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/local/en.js @@ -0,0 +1,10 @@ +// 英文 +langEn = { + demoModule: { + // ===============index============ + song_title:'One-click upload of songs', + song_list: 'Song list', + headerImg:'images/header-en.png', + btnImg:'images/button-en.png', + } +} \ No newline at end of file diff --git a/YuMi/Tools/CocoaHttpServer/Web/local/id.js b/YuMi/Tools/CocoaHttpServer/Web/local/id.js new file mode 100644 index 00000000..741f18e7 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/local/id.js @@ -0,0 +1,10 @@ +// 印尼语 +langId = { + demoModule: { + // ===============index============ + song_title:'Unggah lagu dengan satu klik', + song_list: 'Daftar lagu', + headerImg:'images/header-id.png', + btnImg:'images/button-id.png', + } +} \ No newline at end of file diff --git a/YuMi/Tools/CocoaHttpServer/Web/local/tr.js b/YuMi/Tools/CocoaHttpServer/Web/local/tr.js new file mode 100644 index 00000000..16209e61 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/local/tr.js @@ -0,0 +1,10 @@ +// 土耳其语 +langTr = { + demoModule: { + // ===============index============ + song_title:'Tek tıklamayla şarkı yükleyin', + song_list: 'şarkı listesi', + headerImg:'images/header-tr.png', + btnImg:'images/button-tr.png', + } +} \ No newline at end of file diff --git a/YuMi/Tools/CocoaHttpServer/Web/local/zh.js b/YuMi/Tools/CocoaHttpServer/Web/local/zh.js new file mode 100644 index 00000000..ba957076 --- /dev/null +++ b/YuMi/Tools/CocoaHttpServer/Web/local/zh.js @@ -0,0 +1,10 @@ +// 繁体中文 +langZh = { + demoModule: { + // ===============index============ + song_title:'一鍵上傳歌曲', + song_list: '歌曲列表', + headerImg:'images/header.png', + btnImg:'images/button.png', + } +} \ No newline at end of file