pre.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. !(function (window) {
  2. var env = {};
  3. window.env = env;
  4. checkPlatform(env);
  5. var isCN = checkIsChinese();
  6. initTitle(isCN);
  7. initSplash(isCN);
  8. function initTitle(isCN) {
  9. document.title = isCN ? "杏聆荟" : "Flyinsono";
  10. }
  11. function initSplash(isCN) {
  12. var splash = document.getElementsByClassName('splash')[0];
  13. if (!splash) return;
  14. splash.classList.add(isCN ? 'splash_cn' : 'splash_en');
  15. }
  16. function checkPlatform(target) {
  17. // injectWinTest();
  18. var shell = window["FisShellApi"];
  19. if (shell) {
  20. target.platform = 'shell';
  21. shell.getPlatformName().then(function (res) {
  22. target.platform = res;
  23. });
  24. } else {
  25. target.platform = 'Web';
  26. }
  27. }
  28. /// inject `FisShellApi` for debug
  29. function injectWinTest() {
  30. window["FisShellApi"] = {
  31. writeLog: async (text) => {
  32. console.log(text);
  33. },
  34. getPlatformName: async () => "Win",
  35. setTitle: async (title) => {
  36. console.log(`Set title - ${title}`);
  37. },
  38. };
  39. }
  40. function checkIsChinese() {
  41. var lang = navigator.language.split('-')[0].toLocaleLowerCase();
  42. // var storeLocale = localStorage['flutter.store_app_locale'];
  43. // if (storeLocale != null && storeLocale.length) {
  44. // try {
  45. // var arr = JSON.parse(storeLocale);
  46. // if (arr && arr.length === 2) {
  47. // lang = arr[0].toLocaleLowerCase();
  48. // }
  49. // } catch (error) { }
  50. // }
  51. return lang === 'zh';
  52. }
  53. })(window);