pre.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. !(function (window) {
  2. var env = {};
  3. window.env = env;
  4. checkPlatform(env);
  5. var isCN = checkIsChinese();
  6. initTitle(isCN);
  7. function initTitle(isCN) {
  8. document.title = isCN ? "杏聆荟" : "Flyinsono";
  9. }
  10. function checkPlatform(target) {
  11. // injectWinTest();
  12. var shell = window["FisShellApi"];
  13. if (shell) {
  14. target.platform = 'shell';
  15. shell.getPlatformName().then(function (res) {
  16. target.platform = res;
  17. });
  18. } else {
  19. target.platform = 'Web';
  20. }
  21. }
  22. /// inject `FisShellApi` for debug
  23. function injectWinTest() {
  24. window["FisShellApi"] = {
  25. writeLog: async (text) => {
  26. console.log(text);
  27. },
  28. getPlatformName: async () => "Win",
  29. setTitle: async (title) => {
  30. console.log(`Set title - ${title}`);
  31. },
  32. };
  33. }
  34. function checkIsChinese() {
  35. var lang = navigator.language.split('-')[0].toLocaleLowerCase();
  36. return lang === 'zh';
  37. }
  38. })(window);