瀏覽代碼

fix: check userAgent at runtime

Gerald 8 年之前
父節點
當前提交
54609f0043
共有 3 個文件被更改,包括 6 次插入3 次删除
  1. 0 2
      scripts/webpack.base.conf.js
  2. 4 0
      src/common/ua.js
  3. 2 1
      src/options/views/tab-settings/vm-export.vue

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

@@ -9,8 +9,6 @@ const definePlugin = new webpack.DefinePlugin({
     NODE_ENV: JSON.stringify(process.env.NODE_ENV),
     NODE_ENV: JSON.stringify(process.env.NODE_ENV),
     // DEBUG: IS_DEV ? 'true' : 'false', // whether to log message errors
     // DEBUG: IS_DEV ? 'true' : 'false', // whether to log message errors
     DEBUG: 'false',
     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>
 <script>
 import { sendMessage, getLocaleString } from 'src/common';
 import { sendMessage, getLocaleString } from 'src/common';
 import options from 'src/common/options';
 import options from 'src/common/options';
+import { isFirefox } from 'src/common/ua';
 import { store } from '../../utils';
 import { store } from '../../utils';
 import SettingCheck from '../setting-check';
 import SettingCheck from '../setting-check';
 
 
@@ -111,7 +112,7 @@ function download(url, cb) {
 function downloadBlob(blob) {
 function downloadBlob(blob) {
   // Known issue: does not work on Firefox
   // Known issue: does not work on Firefox
   // https://bugzilla.mozilla.org/show_bug.cgi?id=1331176
   // https://bugzilla.mozilla.org/show_bug.cgi?id=1331176
-  if (process.env.CLIENT === 'firefox') {
+  if (isFirefox) {
     const reader = new FileReader();
     const reader = new FileReader();
     reader.onload = () => {
     reader.onload = () => {
       download(reader.result);
       download(reader.result);