Procházet zdrojové kódy

fix: check userAgent at runtime

Gerald před 8 roky
rodič
revize
54609f0043

+ 0 - 2
scripts/webpack.base.conf.js

@@ -9,8 +9,6 @@ const definePlugin = new webpack.DefinePlugin({
     NODE_ENV: JSON.stringify(process.env.NODE_ENV),
     // DEBUG: IS_DEV ? 'true' : 'false', // whether to log message errors
     DEBUG: 'false',
-    // CLIENT may be `chrome`, `firefox`, `edge`
-    CLIENT: JSON.stringify(process.env.CLIENT || 'chrome'),
   },
 });
 

+ 4 - 0
src/common/ua.js

@@ -0,0 +1,4 @@
+const { userAgent } = navigator;
+
+export const isFirefox = /firefox\//i.test(userAgent);
+export const isChrome = /chrome\//i.test(userAgent);

+ 2 - 1
src/options/views/tab-settings/vm-export.vue

@@ -20,6 +20,7 @@
 <script>
 import { sendMessage, getLocaleString } from 'src/common';
 import options from 'src/common/options';
+import { isFirefox } from 'src/common/ua';
 import { store } from '../../utils';
 import SettingCheck from '../setting-check';
 
@@ -111,7 +112,7 @@ function download(url, cb) {
 function downloadBlob(blob) {
   // Known issue: does not work on Firefox
   // https://bugzilla.mozilla.org/show_bug.cgi?id=1331176
-  if (process.env.CLIENT === 'firefox') {
+  if (isFirefox) {
     const reader = new FileReader();
     reader.onload = () => {
       download(reader.result);