Bläddra i källkod

动态加载ico

gcj 3 år sedan
förälder
incheckning
ba927d5a2b
3 ändrade filer med 26 tillägg och 15 borttagningar
  1. BIN
      public/favicon.ico
  2. 21 15
      public/index.html
  3. 5 0
      src/settings.js

BIN
public/favicon.ico


+ 21 - 15
public/index.html

@@ -1,17 +1,23 @@
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html>
 <html>
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
-    <title><%= webpackConfig.name %></title>
-  </head>
-  <body>
-    <noscript>
-      <strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
-    </noscript>
-    <div id="app"></div>
-    <!-- built files will be auto injected -->
-  </body>
-</html>
+
+<head>
+  <meta charset="utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+  <!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico"> -->
+  <title>
+    <%= webpackConfig.name %>
+  </title>
+</head>
+
+<body>
+  <noscript>
+    <strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it
+        to continue.</strong>
+  </noscript>
+  <div id="app"></div>
+  <!-- built files will be auto injected -->
+</body>
+
+</html>

+ 5 - 0
src/settings.js

@@ -5,6 +5,11 @@ let config = Cookies.get('GCLS_Config')
 if (config) {
 if (config) {
   let configObj = JSON.parse(config);
   let configObj = JSON.parse(config);
   title = configObj.title
   title = configObj.title
+  var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
+  link.type = 'image/x-icon';
+  link.rel = 'shortcut icon';
+  link.href = configObj.title_icon_url;
+  document.getElementsByTagName('head')[0].appendChild(link);
 }
 }
 console.log(title);
 console.log(title);
 module.exports = {
 module.exports = {