Просмотр исходного кода

fix: close options page on button clicked

fix violentmonkey/violentmonkey#105
Gerald 8 лет назад
Родитель
Сommit
3f63e3706a
2 измененных файлов с 4 добавлено и 4 удалено
  1. 1 1
      src/background/app.js
  2. 3 3
      src/options/views/confirm.vue

+ 1 - 1
src/background/app.js

@@ -182,7 +182,7 @@ const commands = {
     .then(tab => ({ id: tab.id }));
   },
   TabClose(data, src) {
-    const tabId = data && (data.id || (src.tab && src.tab.id));
+    const tabId = (data && data.id) || (src.tab && src.tab.id);
     if (tabId) browser.tabs.remove(tabId);
   },
   GetAllOptions: getAllOptions,

+ 3 - 3
src/options/views/confirm.vue

@@ -167,7 +167,8 @@ export default {
       });
     },
     close() {
-      window.close();
+      // window.close();
+      sendMessage({ cmd: 'TabClose' });
     },
     getFile(url, { isBlob, useCache } = {}) {
       const cacheKey = isBlob ? `blob+${url}` : `text+${url}`;
@@ -222,8 +223,7 @@ export default {
       })
       .then(res => {
         this.message = `${res.message}[${this.getTimeString()}]`;
-        if (res.code < 0) return;
-        if (this.closeAfterInstall) this.close();
+        if (this.settings.closeAfterInstall) this.close();
         else if (this.isLocal && options.get('trackLocalFile')) this.trackLocalFile();
       });
     },