index.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <link rel="icon" href="/favicon.ico" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>管乐迷</title>
  8. <style>
  9. .hide {
  10. display: none !important;
  11. }
  12. .el-notification {
  13. display: flex;
  14. width: 330px;
  15. padding: 14px 26px 14px 13px;
  16. border-radius: 8px;
  17. box-sizing: border-box;
  18. border: 1px solid #ebeef5;
  19. position: fixed;
  20. background-color: #fff;
  21. box-shadow:0 2px 12px 0 rgba(0, 0, 0, 0.1);
  22. transition: opacity 0.3s,transform 0.3s,left 0.3s,right 0.3s,top .4s,bottom 0.3s;
  23. overflow-wrap: anywhere;
  24. overflow: hidden;
  25. z-index: 9999;
  26. top: 16px;
  27. z-index: 2011;
  28. right: 16px;
  29. }
  30. .el-icon {
  31. --color: inherit;
  32. height: 1em;
  33. width: 1em;
  34. line-height: 1em;
  35. display: inline-flex;
  36. justify-content: center;
  37. align-items: center;
  38. position: relative;
  39. fill: currentColor;
  40. color: var(--color);
  41. font-size: inherit;
  42. }
  43. .el-notification .el-notification--info {
  44. color: #909399;
  45. }
  46. .el-notification .el-notification__icon {
  47. height: 24px;
  48. width: 24px;
  49. font-size: 24px;
  50. }
  51. .el-icon svg {
  52. height: 1em;
  53. width: 1em;
  54. }
  55. .el-notification__group {
  56. margin-left: 13px;
  57. margin-right: 8px;
  58. }
  59. .el-notification__title {
  60. font-weight: 700;
  61. font-size: 16px;
  62. line-height: 24px;
  63. color: #303133;
  64. margin: 0;
  65. }
  66. .el-notification__content {
  67. font-size: 14px;
  68. line-height: 24px;
  69. margin: 6px 0 0 0;
  70. color: #606266;
  71. text-align: justify;
  72. }
  73. .el-notification__content p {
  74. margin: 0;
  75. }
  76. .el-notification .el-notification__closeBtn {
  77. position: absolute;
  78. top: 18px;
  79. right: 15px;
  80. cursor: pointer;
  81. color: #909399;
  82. font-size: 16px;
  83. }
  84. </style>
  85. </head>
  86. <body>
  87. <div id="app"></div>
  88. <script type="module" src="/src/main.ts"></script>
  89. <div id="notification_1" class="el-notification right hide" role="alert" style="top: 16px; z-index: 2011;"><i class="el-icon el-notification__icon el-notification--info"><svg class="icon" width="200" height="200" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 110 896.064A448 448 0 01512 64zm67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344zM590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.992 12.992 0 01-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 017.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"></path></svg></i><div class="el-notification__group"><h2 class="el-notification__title">提示</h2><div class="el-notification__content"><p>为了保障更好的直播体验,建议使用chrome浏览器</p></div><i id="noClose" class="el-icon el-notification__closeBtn"><svg class="icon" width="200" height="200" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M764.288 214.592L512 466.88 259.712 214.592a31.936 31.936 0 00-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1045.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0045.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 10-45.12-45.184z"></path></svg></i></div></div>
  90. <script>
  91. var win = window;
  92. var nav = win.navigator;
  93. var doc = win.document;
  94. var ieAX = win.ActiveXObject;
  95. var ieMode = doc.documentMode;
  96. var REG_APPLE = /^Apple/;
  97. // var ieVer = _getIeVersion() || ieMode || 0;
  98. var isIe = ieAX || ieMode;
  99. // var chromiumType = _getChromiumType();
  100. /**
  101. * 检测 external 是否包含该字段
  102. * @param reg 正则
  103. * @param type 检测类型,0为键,1为值
  104. * @returns {boolean}
  105. * @private
  106. */
  107. function _testExternal(reg, type) {
  108. var external = win.external || {};
  109. for (var i in external) {
  110. if (reg.test(type ? external[i] : i)) {
  111. return true;
  112. }
  113. }
  114. return false;
  115. }
  116. /**
  117. * 获取 Chromium 内核浏览器类型
  118. * @link http://www.adtchrome.com/js/help.js
  119. * @link https://ext.chrome.360.cn/webstore
  120. * @link https://ext.se.360.cn
  121. * @return {String}
  122. * 360ee 360极速浏览器
  123. * 360se 360安全浏览器
  124. * sougou 搜狗浏览器
  125. * liebao 猎豹浏览器
  126. * chrome 谷歌浏览器
  127. * '' 无法判断
  128. * @version 1.0
  129. */
  130. function _getChromiumType() {
  131. if (isIe || typeof win.scrollMaxX !== 'undefined' || REG_APPLE.test(nav.vendor || '')) {
  132. return '';
  133. }
  134. var _track = 'track' in document.createElement('track');
  135. var webstoreKeysLength = win.chrome && win.chrome.webstore ? Object.keys(win.chrome.webstore).length : 0;
  136. console.log(webstoreKeysLength)
  137. // 搜狗浏览器
  138. if (_testExternal(/^sogou/i, 0)) {
  139. return 'sogou';
  140. }
  141. // 猎豹浏览器
  142. if (_testExternal(/^liebao/i, 0)) {
  143. return 'liebao';
  144. }
  145. // chrome 由于360极速浏览器 内核也是 chrome,所以先判断360极速浏览器
  146. if (win.clientInformation && win.clientInformation.permissions) {
  147. return 'chrome';
  148. }
  149. if (_track) {
  150. // 360极速浏览器
  151. // 360安全浏览器
  152. return webstoreKeysLength > 1 ? '360ee' : '360se';
  153. }
  154. return '';
  155. }
  156. // 获得ie浏览器版本
  157. function _getIeVersion() {
  158. var v = 3,
  159. p = document.createElement('p'),
  160. all = p.getElementsByTagName('i');
  161. while (
  162. p.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
  163. all[0]);
  164. return v > 4 ? v : 0;
  165. }
  166. function getBrowserInfo() {
  167. const userAgent = navigator.userAgent.toLocaleLowerCase();
  168. if (userAgent.match(/chrome/) != null) {
  169. if (userAgent.match(/wow64/) != null) {
  170. return false
  171. } else {
  172. return true
  173. }
  174. }
  175. }
  176. var isChrome = getBrowserInfo()
  177. var isCloseBrowser = sessionStorage.getItem('isCloseBrowser')
  178. console.log(isChrome, isCloseBrowser)
  179. // 如果不是360浏览器会提示
  180. if((!isChrome) && !isCloseBrowser) {
  181. console.log(document.getElementById('notification_1').className)
  182. document.getElementById('notification_1').className = 'el-notification right'
  183. // document.getElementById('notification_1').classList.remove('hide')
  184. sessionStorage.removeItem('isCloseBrowser')
  185. }
  186. document.getElementById('noClose').onclick = function() {
  187. // document.getElementById('notification_1').classList.add('hide')
  188. document.getElementById('notification_1').className = 'el-notification right hide'
  189. sessionStorage.setItem('isCloseBrowser', 1)
  190. }
  191. </script>
  192. </body>
  193. </html>