Gerald 7 лет назад
Родитель
Сommit
49f567150f
3 измененных файлов с 29 добавлено и 94 удалено
  1. 2 2
      src/background/index.js
  2. 17 20
      src/background/utils/db.js
  3. 10 72
      src/options/views/tab-settings/vm-export.vue

+ 2 - 2
src/background/index.js

@@ -141,8 +141,8 @@ const commands = {
     // Value will be updated to store later.
     // Value will be updated to store later.
     return updateValueStore(id, update);
     return updateValueStore(id, update);
   },
   },
-  ExportZip({ ids, values }) {
-    return getExportData(ids, values);
+  ExportZip({ values }) {
+    return getExportData(values);
   },
   },
   GetScriptCode(id) {
   GetScriptCode(id) {
     return getScriptCode(id);
     return getScriptCode(id);

+ 17 - 20
src/background/utils/db.js

@@ -443,26 +443,23 @@ export function updateScriptInfo(id, data) {
   return storage.script.dump(script);
   return storage.script.dump(script);
 }
 }
 
 
-export function getExportData(ids, withValues) {
-  const availableIds = ids.filter(id => {
-    const script = store.scriptMap[id];
-    return script && !script.config.removed;
-  });
-  return Promise.all([
-    Promise.all(availableIds.map(id => getScript({ id }))),
-    storage.code.getMulti(availableIds),
-  ])
-  .then(([scripts, codeMap]) => {
-    const data = {};
-    data.items = scripts.map(script => ({ script, code: codeMap[script.props.id] }));
-    if (withValues) {
-      return storage.value.getMulti(ids)
-      .then(values => {
-        data.values = values;
-        return data;
-      });
-    }
-    return data;
+export function getExportData(withValues) {
+  return getScripts()
+  .then(scripts => {
+    const ids = scripts.map(({ props: { id } }) => id);
+    return storage.code.getMulti(ids)
+    .then(codeMap => {
+      const data = {};
+      data.items = scripts.map(script => ({ script, code: codeMap[script.props.id] }));
+      if (withValues) {
+        return storage.value.getMulti(ids)
+        .then(values => {
+          data.values = values;
+          return data;
+        });
+      }
+      return data;
+    });
   });
   });
 }
 }
 
 

+ 10 - 72
src/options/views/tab-settings/vm-export.vue

@@ -1,22 +1,13 @@
 <template>
 <template>
   <section>
   <section>
     <h3 v-text="i18n('labelDataExport')"></h3>
     <h3 v-text="i18n('labelDataExport')"></h3>
-    <div class="export-list">
-      <div
-        v-for="(item, index) in items"
-        :key="index"
-        class="ellipsis"
-        :class="{active: item.active}"
-        @click="item.active = !item.active"
-        v-text="getName(item)"
-      />
-    </div>
-    <button v-text="i18n('buttonAllNone')" @click="toggleSelection()"></button>
     <button v-text="i18n('buttonExportData')" @click="exportData" :disabled="exporting"></button>
     <button v-text="i18n('buttonExportData')" @click="exportData" :disabled="exporting"></button>
-    <label class="ml-1">
-      <setting-check name="exportValues" />
-      <span v-text="i18n('labelExportScriptData')"></span>
-    </label>
+    <div class="mt-1">
+      <label>
+        <setting-check name="exportValues" />
+        <span v-text="i18n('labelExportScriptData')"></span>
+      </label>
+    </div>
     <modal
     <modal
       v-if="store.ffDownload"
       v-if="store.ffDownload"
       transition="in-out"
       transition="in-out"
@@ -55,40 +46,14 @@ export default {
   },
   },
   data() {
   data() {
     return {
     return {
-      isFirefox,
       store,
       store,
       exporting: false,
       exporting: false,
-      items: [],
     };
     };
   },
   },
-  watch: {
-    'store.scripts': 'initItems',
-  },
-  computed: {
-    selectedIds() {
-      return this.items.filter(item => item.active).map(item => item.script.props.id);
-    },
-  },
-  created() {
-    this.initItems();
-  },
   methods: {
   methods: {
-    initItems() {
-      this.items = (store.scripts || [])
-      .filter(({ config: { removed } }) => !removed)
-      .map(script => ({
-        script,
-        active: true,
-      }));
-    },
-    toggleSelection() {
-      if (!store.scripts.length) return;
-      const active = this.selectedIds.length < store.scripts.length;
-      this.items.forEach(item => { item.active = active; });
-    },
     exportData() {
     exportData() {
       this.exporting = true;
       this.exporting = true;
-      Promise.resolve(exportData(this.selectedIds))
+      Promise.resolve(exportData())
       .then(download)
       .then(download)
       .catch(err => {
       .catch(err => {
         console.error(err);
         console.error(err);
@@ -163,15 +128,14 @@ function download(blob) {
   }
   }
 }
 }
 
 
-function exportData(selectedIds) {
+function exportData() {
   const withValues = options.get('exportValues');
   const withValues = options.get('exportValues');
-  return (selectedIds.length ? sendMessage({
+  return sendMessage({
     cmd: 'ExportZip',
     cmd: 'ExportZip',
     data: {
     data: {
       values: withValues,
       values: withValues,
-      ids: selectedIds,
     },
     },
-  }) : Promise.resolve())
+  })
   .then(data => {
   .then(data => {
     const names = {};
     const names = {};
     const vm = {
     const vm = {
@@ -221,32 +185,6 @@ function exportData(selectedIds) {
 </script>
 </script>
 
 
 <style>
 <style>
-.export-list {
-  display: block;
-  min-height: 4rem;
-  max-height: 20rem;
-  overflow-y: auto;
-  padding: .3rem;
-  white-space: normal;
-  border: 1px solid #ddd;
-  > .ellipsis {
-    display: inline-block;
-    width: 13rem;
-    max-width: 100%;
-    line-height: 1.5;
-    margin-right: .2rem;
-    margin-bottom: .1rem;
-    padding: 0 .3rem;
-    border: 1px solid #bbb;
-    border-radius: 3px;
-    cursor: pointer;
-    &.active {
-      border-color: #2c82c9;
-      background: #3498db;
-      color: white;
-    }
-  }
-}
 .export-modal {
 .export-modal {
   width: 13rem;
   width: 13rem;
 }
 }